diff --git a/SudokuSolver/App.xaml b/SudokuSolver/App.xaml index 92231d1..590545a 100644 --- a/SudokuSolver/App.xaml +++ b/SudokuSolver/App.xaml @@ -11,12 +11,6 @@ 50 - - - diff --git a/SudokuSolver/Installer/inno_script.iss b/SudokuSolver/Installer/inno_script.iss index f882f0b..0797030 100644 --- a/SudokuSolver/Installer/inno_script.iss +++ b/SudokuSolver/Installer/inno_script.iss @@ -335,10 +335,10 @@ begin if not FileExists(ExeFilePath) then ExtractTemporaryFile('CheckWinAppSdk.exe'); - // WinAppSdk 1.4.0 is 4000.964.11.0 - // Check for any 1.4.n version where n >= 0 + // WinAppSdk 1.4.1 is 4000.986.611.0 + // Check for any 1.4.n version where n >= 1 - if not Exec(ExeFilePath, '4000.964.11.0' + ' ' + GetPlatformParamStr, '', SW_HIDE, ewWaitUntilTerminated, ResultCode) then + if not Exec(ExeFilePath, '4000.986.611.0' + ' ' + GetPlatformParamStr, '', SW_HIDE, ewWaitUntilTerminated, ResultCode) then Log('Exec CheckWinAppSdk.exe failed: ' + SysErrorMessage(ResultCode)); Result := ResultCode = 0; diff --git a/SudokuSolver/SudokuSolver.csproj b/SudokuSolver/SudokuSolver.csproj index c163f59..0cf5ee9 100644 --- a/SudokuSolver/SudokuSolver.csproj +++ b/SudokuSolver/SudokuSolver.csproj @@ -23,7 +23,7 @@ all - + diff --git a/SudokuSolver/ViewModels/PuzzleViewModel.cs b/SudokuSolver/ViewModels/PuzzleViewModel.cs index 85751b4..acaec0c 100644 --- a/SudokuSolver/ViewModels/PuzzleViewModel.cs +++ b/SudokuSolver/ViewModels/PuzzleViewModel.cs @@ -92,7 +92,7 @@ public void UpdateCellForKeyDown(int index, int newValue) UpdateView(); undoHelper.Push(model); IsModified = true; - RaiseCanExecuteChanged(); + UpdateMenuItemsDisabledState(); } else { @@ -124,7 +124,7 @@ public void Open(Stream stream) { UpdateView(); undoHelper.Push(model); - RaiseCanExecuteChanged(); + UpdateMenuItemsDisabledState(); } } @@ -148,7 +148,7 @@ public void New() UpdateView(); undoHelper.Push(model); IsModified = false; - RaiseCanExecuteChanged(); + UpdateMenuItemsDisabledState(); } public bool ShowPossibles @@ -224,7 +224,7 @@ public void ExecuteUndo(object? param) model = undoHelper.PopUndo(); UpdateView(); IsModified = true; - RaiseCanExecuteChanged(); + UpdateMenuItemsDisabledState(); } } @@ -238,7 +238,7 @@ public void ExecuteRedo(object? param) model = undoHelper.PopRedo(); UpdateView(); IsModified = true; - RaiseCanExecuteChanged(); + UpdateMenuItemsDisabledState(); } } @@ -249,18 +249,25 @@ public void Puzzle_SelectedIndexChanged(object sender, Views.Cell.SelectionChang else if (selectedIndex == e.Index) selectedIndex = -1; - RaiseCanExecuteChanged(); + UpdateMenuItemsDisabledState(); } - private void RaiseCanExecuteChanged() + private void UpdateMenuItemsDisabledState() { - UndoCommand.RaiseCanExecuteChanged(); - RedoCommand.RaiseCanExecuteChanged(); - CutCommand.RaiseCanExecuteChanged(); - CopyCommand.RaiseCanExecuteChanged(); - DeleteCommand.RaiseCanExecuteChanged(); - PasteCommand.RaiseCanExecuteChanged(); - MarkAsGivenCommand.RaiseCanExecuteChanged(); + // an unfortunate work around for https://github.com/microsoft/microsoft-ui-xaml/issues/8894 + // The menu flyout item will loose it's foreground color if disabled from within the ICommands execute + // method when the system theme is light and the app's theme is dark. Fire and forget, so always need to + // call the CanExecute method first when executing to check it's still valid to execute. + Task.Run(() => + { + UndoCommand.RaiseCanExecuteChanged(); + RedoCommand.RaiseCanExecuteChanged(); + CutCommand.RaiseCanExecuteChanged(); + CopyCommand.RaiseCanExecuteChanged(); + DeleteCommand.RaiseCanExecuteChanged(); + PasteCommand.RaiseCanExecuteChanged(); + MarkAsGivenCommand.RaiseCanExecuteChanged(); + }); } private bool CanCutCopyDelete(object? param = null) => (selectedIndex >= 0) && Cells[selectedIndex].HasValue; diff --git a/SudokuSolver/Views/MainWindow.xaml b/SudokuSolver/Views/MainWindow.xaml index b0a56c4..6c73830 100644 --- a/SudokuSolver/Views/MainWindow.xaml +++ b/SudokuSolver/Views/MainWindow.xaml @@ -101,8 +101,13 @@ - - + + + + + +