Skip to content

Commit ebb7771

Browse files
committed
Add setting change handling to app so more settings can be changed without a restart
1 parent 1204d7e commit ebb7771

File tree

4 files changed

+34
-23
lines changed

4 files changed

+34
-23
lines changed

src/JuliusSweetland.OptiKey.Core/UI/ViewModels/Management/FeaturesViewModel.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -385,12 +385,9 @@ public bool ChangesRequireRestart
385385
get
386386
{
387387

388-
return (Settings.Default.Debug != Debug)
388+
return Settings.Default.Debug != Debug
389389
|| Settings.Default.CommuniKatePagesetLocation != CommuniKatePagesetLocation
390-
|| Settings.Default.LookToScrollIsDefault != LookToScrollIsDefault
391-
|| (Settings.Default.LookToScrollOverlayBoundsThickness
392-
+ Settings.Default.LookToScrollOverlayDeadzoneThickness == 0
393-
&& LookToScrollOverlayBoundsThickness + LookToScrollOverlayDeadzoneThickness > 0);
390+
|| Settings.Default.LookToScrollIsDefault != LookToScrollIsDefault;
394391
}
395392
}
396393

src/JuliusSweetland.OptiKey.Core/UI/ViewModels/Management/VisualsViewModel.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ public string GazeIndicatorStyle
493493
public int GazeIndicatorSize
494494
{
495495
get { return gazeIndicatorSize; }
496-
set { SetProperty(ref gazeIndicatorSize, value); }
496+
set { Settings.Default.GazeIndicatorSize = value; SetProperty(ref gazeIndicatorSize, value); }
497497
}
498498

499499
private bool magnifierCenterOnScreen;
@@ -586,10 +586,7 @@ public bool ChangesRequireRestart
586586
{
587587
return Settings.Default.ConversationOnlyMode != ConversationOnlyMode
588588
|| Settings.Default.ConversationConfirmEnable != ConversationConfirmEnable
589-
|| Settings.Default.ConversationConfirmOnlyMode != ConversationConfirmOnlyMode
590-
|| Settings.Default.EnableResizeWithMouse != EnableResizeWithMouse
591-
|| (Settings.Default.GazeIndicatorStyle == GazeIndicatorStyles.None
592-
&& (GazeIndicatorStyles)Enum.Parse(typeof(GazeIndicatorStyles), GazeIndicatorStyle) != GazeIndicatorStyles.None);
589+
|| Settings.Default.ConversationConfirmOnlyMode != ConversationConfirmOnlyMode;
593590
}
594591
}
595592

@@ -719,7 +716,6 @@ public void ApplyChanges()
719716

720717
windowManipulationService.SetOpacity(Settings.Default.MainWindowOpacity);
721718
Settings.Default.EnableResizeWithMouse = EnableResizeWithMouse;
722-
windowManipulationService.SetResizeState();
723719
}
724720

725721
#endregion

src/JuliusSweetland.OptiKey.Core/UI/Windows/MainWindow.xaml.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,6 @@ public MainWindow(
4646
{
4747
InitializeComponent();
4848

49-
if (Settings.Default.EnableResizeWithMouse
50-
&& (Settings.Default.MainWindowState == WindowStates.Floating
51-
|| Settings.Default.MainWindowState == WindowStates.Docked))
52-
{
53-
this.ResizeMode = ResizeMode.CanResizeWithGrip;
54-
}
5549
this.audioService = audioService;
5650
this.dictionaryService = dictionaryService;
5751
this.inputService = inputService;

src/JuliusSweetland.OptiKey.Pro/App.xaml.cs

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -196,15 +196,39 @@ private void App_OnStartup(object sender, StartupEventArgs e)
196196
//Show the main window
197197
mainWindow.Show();
198198

199-
if (Settings.Default.LookToScrollOverlayBoundsThickness > 0
200-
|| Settings.Default.LookToScrollOverlayDeadzoneThickness > 0)
199+
LookToScrollOverlayWindow lookToScrollOverlayWindow = null;
200+
OverlayWindow overlayWindow = null;
201+
202+
void TrySetLookToScrollOverlayWindow()
203+
{
204+
if (Settings.Default.LookToScrollOverlayBoundsThickness > 0
205+
|| Settings.Default.LookToScrollOverlayDeadzoneThickness > 0)
206+
{
207+
lookToScrollOverlayWindow = lookToScrollOverlayWindow ?? new LookToScrollOverlayWindow(mainViewModel);
208+
}
209+
}
210+
void TrySetOverlayWindow()
211+
{
212+
if (Settings.Default.GazeIndicatorStyle != GazeIndicatorStyles.None)
213+
overlayWindow = overlayWindow ?? new OverlayWindow(mainViewModel);
214+
}
215+
void TrySetResizeMode()
201216
{
202-
// Create the overlay window, but don't show it yet. It'll make itself visible when the conditions are right.
203-
new LookToScrollOverlayWindow(mainViewModel);
217+
mainWindow.ResizeMode = Settings.Default.EnableResizeWithMouse
218+
&& (Settings.Default.MainWindowState == WindowStates.Floating
219+
|| Settings.Default.MainWindowState == WindowStates.Docked)
220+
? ResizeMode.CanResizeWithGrip : ResizeMode.NoResize;
204221
}
205222

206-
if (Settings.Default.GazeIndicatorStyle != GazeIndicatorStyles.None)
207-
new OverlayWindow(mainViewModel);
223+
// Create the overlay window, but don't show it yet. It'll make itself visible when the conditions are right.
224+
TrySetLookToScrollOverlayWindow();
225+
TrySetOverlayWindow();
226+
TrySetResizeMode();
227+
228+
Settings.Default.OnPropertyChanges(s => s.LookToScrollOverlayBoundsThickness).Subscribe(value => { TrySetLookToScrollOverlayWindow(); });
229+
Settings.Default.OnPropertyChanges(s => s.LookToScrollOverlayDeadzoneThickness).Subscribe(value => { TrySetLookToScrollOverlayWindow(); });
230+
Settings.Default.OnPropertyChanges(s => s.GazeIndicatorStyle).Subscribe(value => { TrySetOverlayWindow(); });
231+
Settings.Default.OnPropertyChanges(s => s.EnableResizeWithMouse).Subscribe(value => { TrySetResizeMode(); });
208232

209233
//Display splash screen and check for updates (and display message) after the window has been sized and positioned for the 1st time
210234
EventHandler sizeAndPositionInitialised = null;

0 commit comments

Comments
 (0)