Skip to content

Commit

Permalink
Rubberduck.UI\Settings
Browse files Browse the repository at this point in the history
  • Loading branch information
IvenBach committed Nov 23, 2017
1 parent 19af169 commit 2fe14f6
Showing 1 changed file with 22 additions and 26 deletions.
48 changes: 22 additions & 26 deletions RetailCoder.VBE/UI/Settings/GeneralSettingsViewModel.cs
Expand Up @@ -33,7 +33,7 @@ public GeneralSettingsViewModel(Configuration config, IOperatingSystem operating
LogLevels = new ObservableCollection<MinimumLogLevel>(LogLevelHelper.LogLevels.Select(l => new MinimumLogLevel(l.Ordinal, l.Name)));
TransferSettingsToView(config.UserSettings.GeneralSettings, config.UserSettings.HotkeySettings);

_showLogFolderCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), _ => ShowLogFolder());
ShowLogFolderCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), _ => ShowLogFolder());
ExportButtonCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), _ => ExportSettings());
ImportButtonCommand = new DelegateCommand(LogManager.GetCurrentClassLogger(), _ => ImportSettings());
}
Expand All @@ -43,7 +43,7 @@ public GeneralSettingsViewModel(Configuration config, IOperatingSystem operating
private DisplayLanguageSetting _selectedLanguage;
public DisplayLanguageSetting SelectedLanguage
{
get { return _selectedLanguage; }
get => _selectedLanguage;
set
{
if (!Equals(_selectedLanguage, value))
Expand All @@ -57,7 +57,7 @@ public DisplayLanguageSetting SelectedLanguage
private ObservableCollection<HotkeySetting> _hotkeys;
public ObservableCollection<HotkeySetting> Hotkeys
{
get { return _hotkeys; }
get => _hotkeys;
set
{
if (_hotkeys != value)
Expand All @@ -71,7 +71,7 @@ public ObservableCollection<HotkeySetting> Hotkeys
private bool _autoSaveEnabled;
public bool AutoSaveEnabled
{
get { return _autoSaveEnabled; }
get => _autoSaveEnabled;
set
{
if (_autoSaveEnabled != value)
Expand All @@ -85,7 +85,7 @@ public bool AutoSaveEnabled
private bool _showSplashAtStartup;
public bool ShowSplashAtStartup
{
get { return _showSplashAtStartup; }
get => _showSplashAtStartup;
set
{
if (_showSplashAtStartup != value)
Expand All @@ -99,7 +99,7 @@ public bool ShowSplashAtStartup
private bool _checkVersionAtStartup;
public bool CheckVersionAtStartup
{
get { return _checkVersionAtStartup; }
get => _checkVersionAtStartup;
set
{
if (_checkVersionAtStartup != value)
Expand All @@ -113,7 +113,7 @@ public bool CheckVersionAtStartup
private int _autoSavePeriod;
public int AutoSavePeriod
{
get { return _autoSavePeriod; }
get => _autoSavePeriod;
set
{
if (_autoSavePeriod != value)
Expand All @@ -127,7 +127,7 @@ public int AutoSavePeriod
private DelimiterOptions _delimiter;
public DelimiterOptions Delimiter
{
get { return _delimiter; }
get => _delimiter;
set
{
if (_delimiter != value)
Expand All @@ -142,7 +142,7 @@ public DelimiterOptions Delimiter
private MinimumLogLevel _selectedLogLevel;
public MinimumLogLevel SelectedLogLevel
{
get { return _selectedLogLevel; }
get => _selectedLogLevel;
set
{
if (!Equals(_selectedLogLevel, value))
Expand All @@ -156,7 +156,7 @@ public MinimumLogLevel SelectedLogLevel
private bool _sourceControlEnabled;
public bool SourceControlEnabled
{
get { return _sourceControlEnabled; }
get => _sourceControlEnabled;
set
{
if (_sourceControlEnabled != value)
Expand All @@ -167,11 +167,7 @@ public bool SourceControlEnabled
}
}

private readonly CommandBase _showLogFolderCommand;
public CommandBase ShowLogFolderCommand
{
get { return _showLogFolderCommand; }
}
public CommandBase ShowLogFolderCommand { get; }

private void ShowLogFolder()
{
Expand All @@ -194,29 +190,29 @@ private Rubberduck.Settings.GeneralSettings GetCurrentGeneralSettings()
return new Rubberduck.Settings.GeneralSettings
{
Language = SelectedLanguage,
ShowSplash = ShowSplashAtStartup,
CheckVersion = CheckVersionAtStartup,
SmartIndenterPrompted = _indenterPrompted,
AutoSaveEnabled = AutoSaveEnabled,
CanShowSplash = ShowSplashAtStartup,
CanCheckVersion = CheckVersionAtStartup,
IsSmartIndenterPrompted = _indenterPrompted,
IsAutoSaveEnabled = AutoSaveEnabled,
AutoSavePeriod = AutoSavePeriod,
//Delimiter = (char)Delimiter,
MinimumLogLevel = SelectedLogLevel.Ordinal,
SourceControlEnabled = SourceControlEnabled
IsSourceControlEnabled = SourceControlEnabled
};
}

private void TransferSettingsToView(IGeneralSettings general, IHotkeySettings hottkey)
{
SelectedLanguage = Languages.First(l => l.Code == general.Language.Code);
Hotkeys = new ObservableCollection<HotkeySetting>(hottkey.Settings);
ShowSplashAtStartup = general.ShowSplash;
CheckVersionAtStartup = general.CheckVersion;
_indenterPrompted = general.SmartIndenterPrompted;
AutoSaveEnabled = general.AutoSaveEnabled;
ShowSplashAtStartup = general.CanShowSplash;
CheckVersionAtStartup = general.CanCheckVersion;
_indenterPrompted = general.IsSmartIndenterPrompted;
AutoSaveEnabled = general.IsAutoSaveEnabled;
AutoSavePeriod = general.AutoSavePeriod;
//Delimiter = (DelimiterOptions)general.Delimiter;
SelectedLogLevel = LogLevels.First(l => l.Ordinal == general.MinimumLogLevel);
SourceControlEnabled = general.SourceControlEnabled;
SourceControlEnabled = general.IsSourceControlEnabled;
}

private void ImportSettings()
Expand All @@ -234,7 +230,7 @@ private void ImportSettings()
var hkService = new XmlPersistanceService<HotkeySettings> { FilePath = dialog.FileName };
var hotkey = hkService.Load(new HotkeySettings());
//Always assume Smart Indenter registry import has been prompted if importing.
general.SmartIndenterPrompted = true;
general.IsSmartIndenterPrompted = true;
TransferSettingsToView(general, hotkey);
}
}
Expand Down

0 comments on commit 2fe14f6

Please sign in to comment.