-
Notifications
You must be signed in to change notification settings - Fork 295
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c992238
commit e8e5cb8
Showing
12 changed files
with
264 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
<UserControl x:Class="Rubberduck.UI.Settings.AutoCompleteSettings" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:core="clr-namespace:System;assembly=mscorlib" | ||
xmlns:settings="clr-namespace:Rubberduck.UI.Settings" | ||
xmlns:converters="clr-namespace:Rubberduck.UI.Settings.Converters" | ||
xmlns:controls="clr-namespace:Rubberduck.UI.Controls" | ||
mc:Ignorable="d" | ||
d:DataContext="{d:DesignInstance {x:Type settings:AutoCompleteSettingsViewModel}, IsDesignTimeCreatable=False}" | ||
d:DesignWidth="500" | ||
d:DesignHeight="350"> | ||
<UserControl.Resources> | ||
<Style x:Key="PrettifyRow" TargetType="{x:Type DataGridRow}"> | ||
<Style.Resources> | ||
<Style TargetType="{x:Type Border}"> | ||
<Setter Property="CornerRadius" Value="2"/> | ||
</Style> | ||
</Style.Resources> | ||
<Setter Property="BorderThickness" Value="0,.5,0,0" /> | ||
<Setter Property="BorderBrush" Value="DarkGray" /> | ||
<Setter Property="Height" Value="26" /> | ||
<Setter Property="TextBlock.FontWeight" Value="Normal" /> | ||
<Style.Triggers> | ||
<Trigger Property="IsSelected" Value="True"> | ||
<Setter Property="BorderThickness" Value="1.5" /> | ||
</Trigger> | ||
<MultiTrigger> | ||
<MultiTrigger.Conditions> | ||
<Condition Property="IsSelected" Value="True" /> | ||
<Condition Property="Selector.IsSelectionActive" Value="True" /> | ||
</MultiTrigger.Conditions> | ||
<Setter Property="BorderBrush" Value="#adc6e5"/> | ||
<Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}" /> | ||
</MultiTrigger> | ||
<MultiTrigger> | ||
<MultiTrigger.Conditions> | ||
<Condition Property="IsSelected" Value="True" /> | ||
<Condition Property="Selector.IsSelectionActive" Value="False" /> | ||
</MultiTrigger.Conditions> | ||
<Setter Property="BorderBrush" Value="LightGray"/> | ||
<Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.InactiveSelectionHighlightBrushKey}}" /> | ||
</MultiTrigger> | ||
</Style.Triggers> | ||
</Style> | ||
|
||
</UserControl.Resources> | ||
<Grid> | ||
<ScrollViewer> | ||
<StackPanel Margin="5,5,5,0" ScrollViewer.VerticalScrollBarVisibility="Auto"> | ||
<Label Background="DarkGray" | ||
HorizontalContentAlignment="Stretch" | ||
Margin="0,5,0,5"> | ||
<Label.Style> | ||
<Style> | ||
<Style.Resources> | ||
<Style TargetType="{x:Type Border}"> | ||
<Setter Property="CornerRadius" Value="5"/> | ||
</Style> | ||
</Style.Resources> | ||
</Style> | ||
</Label.Style> | ||
<DockPanel Background="DarkGray" FlowDirection="LeftToRight"> | ||
<StackPanel Orientation="Horizontal" DockPanel.Dock="Left"> | ||
<Label Foreground="White" | ||
FontWeight="SemiBold" | ||
Content="{Resx ResxName=Rubberduck.Resources.Settings.AutoCompletePage, Key=PageHeader}"> | ||
</Label> | ||
</StackPanel> | ||
<StackPanel Orientation="Horizontal" DockPanel.Dock="Right" HorizontalAlignment="Right"> | ||
<controls:LinkButton | ||
Margin="2" | ||
Command="{Binding ImportButtonCommand}" | ||
Content="{Resx ResxName=Rubberduck.Resources.Settings.SettingsUI, Key=ImportPageSettingsButton}"/> | ||
<controls:LinkButton | ||
Margin="2" | ||
Command="{Binding ExportButtonCommand}" | ||
Content="{Resx ResxName=Rubberduck.Resources.Settings.SettingsUI, Key=ExportPageSettingsButton}"/> | ||
</StackPanel> | ||
</DockPanel> | ||
</Label> | ||
<Border BorderBrush="DarkGray" BorderThickness="1" CornerRadius="2"> | ||
<DataGrid Name="AutoCompleteSettingsGrid" | ||
ItemsSource="{Binding Settings}" | ||
AutoGenerateColumns="False" | ||
CanUserReorderColumns="False" | ||
IsReadOnly="False" | ||
SelectionMode="Single" | ||
CanUserAddRows="False" | ||
CanUserSortColumns="False" | ||
HorizontalGridLinesBrush="Transparent" | ||
VerticalGridLinesBrush="Transparent" | ||
HeadersVisibility="None" | ||
ScrollViewer.HorizontalScrollBarVisibility="Disabled" | ||
ItemContainerStyle="{StaticResource PrettifyRow}" | ||
ColumnHeaderHeight="22" | ||
BorderThickness="0" | ||
Height="200"> | ||
<DataGrid.CellStyle> | ||
<Style TargetType="{x:Type DataGridCell}"> | ||
<Setter Property="BorderThickness" Value="0" /> | ||
<Setter Property="VerticalAlignment" Value="Center" /> | ||
<Setter Property="Background" Value="Transparent" /> | ||
</Style> | ||
</DataGrid.CellStyle> | ||
<DataGrid.Columns> | ||
<DataGridTextColumn Width="Auto" Binding="{Binding Description}" IsReadOnly="True" /> | ||
<DataGridCheckBoxColumn Width="*" Binding="{Binding IsEnabled}" /> | ||
</DataGrid.Columns> | ||
</DataGrid> | ||
</Border> | ||
</StackPanel> | ||
</ScrollViewer> | ||
</Grid> | ||
</UserControl> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Windows; | ||
using System.Windows.Controls; | ||
using System.Windows.Data; | ||
using System.Windows.Documents; | ||
using System.Windows.Input; | ||
using System.Windows.Media; | ||
using System.Windows.Media.Imaging; | ||
using System.Windows.Navigation; | ||
using System.Windows.Shapes; | ||
|
||
namespace Rubberduck.UI.Settings | ||
{ | ||
/// <summary> | ||
/// Interaction logic for AutoCompleteSettings.xaml | ||
/// </summary> | ||
public partial class AutoCompleteSettings : UserControl, ISettingsView | ||
{ | ||
public AutoCompleteSettings() | ||
{ | ||
InitializeComponent(); | ||
} | ||
|
||
public AutoCompleteSettings(ISettingsViewModel vm) : this() | ||
{ | ||
DataContext = vm; | ||
} | ||
|
||
public ISettingsViewModel ViewModel => DataContext as ISettingsViewModel; | ||
} | ||
} |
86 changes: 86 additions & 0 deletions
86
Rubberduck.Core/UI/Settings/AutoCompleteSettingsViewModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
using NLog; | ||
using Rubberduck.Resources; | ||
using Rubberduck.Settings; | ||
using Rubberduck.SettingsProvider; | ||
using Rubberduck.UI.Command; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Windows.Data; | ||
|
||
namespace Rubberduck.UI.Settings | ||
{ | ||
public class AutoCompleteSettingsViewModel : SettingsViewModelBase, ISettingsViewModel | ||
{ | ||
public AutoCompleteSettingsViewModel(Configuration config) | ||
{ | ||
Settings = new ListCollectionView( | ||
config.UserSettings.AutoCompleteSettings.AutoCompletes.ToList()); | ||
|
||
ExportButtonCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), _ => ExportSettings()); | ||
ImportButtonCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), _ => ImportSettings()); | ||
} | ||
|
||
private ListCollectionView _settings; | ||
public ListCollectionView Settings | ||
{ | ||
get { return _settings; } | ||
set | ||
{ | ||
if (_settings != value) | ||
{ | ||
_settings = value; | ||
OnPropertyChanged(); | ||
} | ||
} | ||
} | ||
|
||
public void SetToDefaults(Configuration config) | ||
{ | ||
TransferSettingsToView(config.UserSettings.AutoCompleteSettings); | ||
} | ||
|
||
public void UpdateConfig(Configuration config) | ||
{ | ||
config.UserSettings.AutoCompleteSettings.AutoCompletes = new HashSet<AutoCompleteSetting>(_settings.OfType<AutoCompleteSetting>()); | ||
} | ||
|
||
private void TransferSettingsToView(Rubberduck.Settings.AutoCompleteSettings toLoad) | ||
{ | ||
Settings = new ListCollectionView(toLoad.AutoCompletes.ToList()); | ||
} | ||
|
||
private void ImportSettings() | ||
{ | ||
using (var dialog = new OpenFileDialog | ||
{ | ||
Filter = RubberduckUI.DialogMask_XmlFilesOnly, | ||
Title = RubberduckUI.DialogCaption_LoadInspectionSettings | ||
}) | ||
{ | ||
dialog.ShowDialog(); | ||
if (string.IsNullOrEmpty(dialog.FileName)) return; | ||
var service = new XmlPersistanceService<Rubberduck.Settings.AutoCompleteSettings> { FilePath = dialog.FileName }; | ||
var loaded = service.Load(new Rubberduck.Settings.AutoCompleteSettings()); | ||
TransferSettingsToView(loaded); | ||
} | ||
} | ||
|
||
private void ExportSettings() | ||
{ | ||
using (var dialog = new SaveFileDialog | ||
{ | ||
Filter = RubberduckUI.DialogMask_XmlFilesOnly, | ||
Title = RubberduckUI.DialogCaption_SaveInspectionSettings | ||
}) | ||
{ | ||
dialog.ShowDialog(); | ||
if (string.IsNullOrEmpty(dialog.FileName)) return; | ||
var service = new XmlPersistanceService<Rubberduck.Settings.AutoCompleteSettings> { FilePath = dialog.FileName }; | ||
service.Save(new Rubberduck.Settings.AutoCompleteSettings | ||
{ | ||
AutoCompletes = new HashSet<AutoCompleteSetting>(this.Settings.SourceCollection.OfType<AutoCompleteSetting>()), | ||
}); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters