public FancyZonesViewModel() { try { Settings = SettingsUtils.GetSettings <FancyZonesSettings>(ModuleName); } catch { Settings = new FancyZonesSettings(); SettingsUtils.SaveSettings(Settings.ToJsonString(), ModuleName); } LaunchEditorEventHandler = new ButtonClickCommand(LaunchEditor); _shiftDrag = Settings.Properties.FancyzonesShiftDrag.Value; _mouseSwitch = Settings.Properties.FancyzonesMouseSwitch.Value; _overrideSnapHotkeys = Settings.Properties.FancyzonesOverrideSnapHotkeys.Value; _moveWindowsAcrossMonitors = Settings.Properties.FancyzonesMoveWindowsAcrossMonitors.Value; _displayChangemoveWindows = Settings.Properties.FancyzonesDisplayChangeMoveWindows.Value; _zoneSetChangeMoveWindows = Settings.Properties.FancyzonesZoneSetChangeMoveWindows.Value; _appLastZoneMoveWindows = Settings.Properties.FancyzonesAppLastZoneMoveWindows.Value; _openWindowOnActiveMonitor = Settings.Properties.FancyzonesOpenWindowOnActiveMonitor.Value; _restoreSize = Settings.Properties.FancyzonesRestoreSize.Value; _useCursorPosEditorStartupScreen = Settings.Properties.UseCursorposEditorStartupscreen.Value; _showOnAllMonitors = Settings.Properties.FancyzonesShowOnAllMonitors.Value; _makeDraggedWindowTransparent = Settings.Properties.FancyzonesMakeDraggedWindowTransparent.Value; _highlightOpacity = Settings.Properties.FancyzonesHighlightOpacity.Value; _excludedApps = Settings.Properties.FancyzonesExcludedApps.Value; EditorHotkey = Settings.Properties.FancyzonesEditorHotkey.Value; string inactiveColor = Settings.Properties.FancyzonesInActiveColor.Value; _zoneInActiveColor = inactiveColor != string.Empty ? inactiveColor.ToColor() : "#F5FCFF".ToColor(); string borderColor = Settings.Properties.FancyzonesBorderColor.Value; _zoneBorderColor = borderColor != string.Empty ? borderColor.ToColor() : "#FFFFFF".ToColor(); string highlightColor = Settings.Properties.FancyzonesZoneHighlightColor.Value; _zoneHighlightColor = highlightColor != string.Empty ? highlightColor.ToColor() : "#0078D7".ToColor(); GeneralSettings generalSettings; try { generalSettings = SettingsUtils.GetSettings <GeneralSettings>(string.Empty); } catch { generalSettings = new GeneralSettings(); SettingsUtils.SaveSettings(generalSettings.ToJsonString(), string.Empty); } _isEnabled = generalSettings.Enabled.FancyZones; }
public void OriginalFilesModificationTest(string version, string fileName) { var settingPathMock = new Mock <ISettingsPath>(); var fileMock = BackCompatTestProperties.GetModuleIOProvider(version, FancyZonesSettings.ModuleName, fileName); var mockSettingsUtils = new SettingsUtils(fileMock.Object, settingPathMock.Object); FancyZonesSettings originalSettings = mockSettingsUtils.GetSettingsOrDefault <FancyZonesSettings>(FancyZonesSettings.ModuleName); var mockGeneralIOProvider = BackCompatTestProperties.GetGeneralSettingsIOProvider(version); var mockGeneralSettingsUtils = new SettingsUtils(mockGeneralIOProvider.Object, settingPathMock.Object); GeneralSettings originalGeneralSettings = mockGeneralSettingsUtils.GetSettingsOrDefault <GeneralSettings>(); var generalSettingsRepository = new BackCompatTestProperties.MockSettingsRepository <GeneralSettings>(mockGeneralSettingsUtils); var fancyZonesRepository = new BackCompatTestProperties.MockSettingsRepository <FancyZonesSettings>(mockSettingsUtils); // Initialise View Model with test Config files FancyZonesViewModel viewModel = new FancyZonesViewModel(mockSettingsUtils, generalSettingsRepository, fancyZonesRepository, ColorPickerIsEnabledByDefault_IPC); // Verify that the old settings persisted Assert.AreEqual(originalGeneralSettings.Enabled.FancyZones, viewModel.IsEnabled); Assert.AreEqual(originalSettings.Properties.FancyzonesAppLastZoneMoveWindows.Value, viewModel.AppLastZoneMoveWindows); Assert.AreEqual(originalSettings.Properties.FancyzonesBorderColor.Value, viewModel.ZoneBorderColor); Assert.AreEqual(originalSettings.Properties.FancyzonesDisplayChangeMoveWindows.Value, viewModel.DisplayChangeMoveWindows); Assert.AreEqual(originalSettings.Properties.FancyzonesEditorHotkey.Value.ToString(), viewModel.EditorHotkey.ToString()); Assert.AreEqual(originalSettings.Properties.FancyzonesWindowSwitching.Value, viewModel.WindowSwitching); Assert.AreEqual(originalSettings.Properties.FancyzonesNextTabHotkey.Value.ToString(), viewModel.NextTabHotkey.ToString()); Assert.AreEqual(originalSettings.Properties.FancyzonesPrevTabHotkey.Value.ToString(), viewModel.PrevTabHotkey.ToString()); Assert.AreEqual(originalSettings.Properties.FancyzonesExcludedApps.Value, viewModel.ExcludedApps); Assert.AreEqual(originalSettings.Properties.FancyzonesHighlightOpacity.Value, viewModel.HighlightOpacity); Assert.AreEqual(originalSettings.Properties.FancyzonesInActiveColor.Value, viewModel.ZoneInActiveColor); Assert.AreEqual(originalSettings.Properties.FancyzonesMakeDraggedWindowTransparent.Value, viewModel.MakeDraggedWindowsTransparent); Assert.AreEqual(originalSettings.Properties.FancyzonesMouseSwitch.Value, viewModel.MouseSwitch); Assert.AreEqual(originalSettings.Properties.FancyzonesMoveWindowsAcrossMonitors.Value, viewModel.MoveWindowsAcrossMonitors); Assert.AreEqual(originalSettings.Properties.FancyzonesMoveWindowsBasedOnPosition.Value, viewModel.MoveWindowsBasedOnPosition); Assert.AreEqual(originalSettings.Properties.FancyzonesOpenWindowOnActiveMonitor.Value, viewModel.OpenWindowOnActiveMonitor); Assert.AreEqual(originalSettings.Properties.FancyzonesOverrideSnapHotkeys.Value, viewModel.OverrideSnapHotkeys); Assert.AreEqual(originalSettings.Properties.FancyzonesRestoreSize.Value, viewModel.RestoreSize); Assert.AreEqual(originalSettings.Properties.FancyzonesShiftDrag.Value, viewModel.ShiftDrag); Assert.AreEqual(originalSettings.Properties.FancyzonesShowOnAllMonitors.Value, viewModel.ShowOnAllMonitors); Assert.AreEqual(originalSettings.Properties.FancyzonesSpanZonesAcrossMonitors.Value, viewModel.SpanZonesAcrossMonitors); Assert.AreEqual(originalSettings.Properties.FancyzonesZoneHighlightColor.Value, viewModel.ZoneHighlightColor); Assert.AreEqual(originalSettings.Properties.FancyzonesZoneSetChangeMoveWindows.Value, viewModel.ZoneSetChangeMoveWindows); Assert.AreEqual(originalSettings.Properties.UseCursorposEditorStartupscreen.Value, viewModel.UseCursorPosEditorStartupScreen); Assert.AreEqual(originalSettings.Properties.FancyzonesAllowPopupWindowSnap.Value, viewModel.AllowPopupWindowSnap); Assert.AreEqual(originalSettings.Properties.FancyzonesAllowChildWindowSnap.Value, viewModel.AllowChildWindowSnap); Assert.AreEqual(originalSettings.Properties.FancyzonesDisableRoundCornersOnSnap.Value, viewModel.DisableRoundCornersOnWindowSnap); // Verify that the stub file was used var expectedCallCount = 2; // once via the view model, and once by the test (GetSettings<T>) BackCompatTestProperties.VerifyModuleIOProviderWasRead(fileMock, FancyZonesSettings.ModuleName, expectedCallCount); BackCompatTestProperties.VerifyGeneralSettingsIOProviderWasRead(mockGeneralIOProvider, expectedCallCount); }
public FancyZonesViewModel() { try { Settings = SettingsUtils.GetSettings <FancyZonesSettings>(ModuleName); } catch { Settings = new FancyZonesSettings(); SettingsUtils.SaveSettings(Settings.ToJsonString(), ModuleName); } this.LaunchEditorEventHandler = new ButtonClickCommand(LaunchEditor); this._shiftDrag = Settings.Properties.FancyzonesShiftDrag.Value; this._overrideSnapHotkeys = Settings.Properties.FancyzonesOverrideSnapHotkeys.Value; this._flashZones = Settings.Properties.FancyzonesZoneSetChangeFlashZones.Value; this._displayChangemoveWindows = Settings.Properties.FancyzonesDisplayChangeMoveWindows.Value; this._zoneSetChangeMoveWindows = Settings.Properties.FancyzonesZoneSetChangeMoveWindows.Value; this._virtualDesktopChangeMoveWindows = Settings.Properties.FancyzonesVirtualDesktopChangeMoveWindows.Value; this._appLastZoneMoveWindows = Settings.Properties.FancyzonesAppLastZoneMoveWindows.Value; this._useCursorPosEditorStartupScreen = Settings.Properties.UseCursorposEditorStartupscreen.Value; this._showOnAllMonitors = Settings.Properties.FancyzonesShowOnAllMonitors.Value; this._highlightOpacity = Settings.Properties.FancyzonesHighlightOpacity.Value; this._excludedApps = Settings.Properties.FancyzonesExcludedApps.Value; this._editorHotkey = Settings.Properties.FancyzonesEditorHotkey.Value; string inactiveColor = Settings.Properties.FancyzonesInActiveColor.Value; this._zoneInActiveColor = inactiveColor != string.Empty ? inactiveColor.ToColor() : "#F5FCFF".ToColor(); string borderColor = Settings.Properties.FancyzonesBorderColor.Value; this._zoneBorderColor = borderColor != string.Empty ? borderColor.ToColor() : "#FFFFFF".ToColor(); string highlightColor = Settings.Properties.FancyzonesZoneHighlightColor.Value; this._zoneHighlightColor = highlightColor != string.Empty ? highlightColor.ToColor() : "#0078D7".ToColor(); GeneralSettings generalSettings; try { generalSettings = SettingsUtils.GetSettings <GeneralSettings>(string.Empty); } catch { generalSettings = new GeneralSettings(); SettingsUtils.SaveSettings(generalSettings.ToJsonString(), string.Empty); } this._isEnabled = generalSettings.Enabled.FancyZones; }
public FancyZonesViewModel(Func <string, int> ipcMSGCallBackFunc, string configFileSubfolder = "") { settingsConfigFileFolder = configFileSubfolder; try { Settings = SettingsUtils.GetSettings <FancyZonesSettings>(GetSettingsSubPath()); } catch { Settings = new FancyZonesSettings(); SettingsUtils.SaveSettings(Settings.ToJsonString(), GetSettingsSubPath()); } LaunchEditorEventHandler = new ButtonClickCommand(LaunchEditor); _shiftDrag = Settings.Properties.FancyzonesShiftDrag.Value; _mouseSwitch = Settings.Properties.FancyzonesMouseSwitch.Value; _overrideSnapHotkeys = Settings.Properties.FancyzonesOverrideSnapHotkeys.Value; _moveWindowsAcrossMonitors = Settings.Properties.FancyzonesMoveWindowsAcrossMonitors.Value; _moveWindowsBasedOnPosition = Settings.Properties.FancyzonesMoveWindowsBasedOnPosition.Value; _displayChangemoveWindows = Settings.Properties.FancyzonesDisplayChangeMoveWindows.Value; _zoneSetChangeMoveWindows = Settings.Properties.FancyzonesZoneSetChangeMoveWindows.Value; _appLastZoneMoveWindows = Settings.Properties.FancyzonesAppLastZoneMoveWindows.Value; _openWindowOnActiveMonitor = Settings.Properties.FancyzonesOpenWindowOnActiveMonitor.Value; _restoreSize = Settings.Properties.FancyzonesRestoreSize.Value; _useCursorPosEditorStartupScreen = Settings.Properties.UseCursorposEditorStartupscreen.Value; _showOnAllMonitors = Settings.Properties.FancyzonesShowOnAllMonitors.Value; _makeDraggedWindowTransparent = Settings.Properties.FancyzonesMakeDraggedWindowTransparent.Value; _highlightOpacity = Settings.Properties.FancyzonesHighlightOpacity.Value; _excludedApps = Settings.Properties.FancyzonesExcludedApps.Value; EditorHotkey = Settings.Properties.FancyzonesEditorHotkey.Value; // set the callback functions value to hangle outgoing IPC message. SendConfigMSG = ipcMSGCallBackFunc; string inactiveColor = Settings.Properties.FancyzonesInActiveColor.Value; _zoneInActiveColor = inactiveColor != string.Empty ? inactiveColor : "#F5FCFF"; string borderColor = Settings.Properties.FancyzonesBorderColor.Value; _zoneBorderColor = borderColor != string.Empty ? borderColor : "#FFFFFF"; string highlightColor = Settings.Properties.FancyzonesZoneHighlightColor.Value; _zoneHighlightColor = highlightColor != string.Empty ? highlightColor : "#0078D7"; GeneralSettings generalSettings; try { generalSettings = SettingsUtils.GetSettings <GeneralSettings>(string.Empty); } catch { generalSettings = new GeneralSettings(); SettingsUtils.SaveSettings(generalSettings.ToJsonString(), string.Empty); } _isEnabled = generalSettings.Enabled.FancyZones; }