Skip to content

Commit

Permalink
Merge pull request #198 from DHancock/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
DHancock authored Sep 20, 2023
2 parents f99d759 + 544e9e3 commit 96724a1
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 27 deletions.
6 changes: 0 additions & 6 deletions SudokuSolver/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,6 @@

<x:Double x:Key="cell_size">50</x:Double>

<!-- work around for https://github.com/microsoft/microsoft-ui-xaml/issues/8756 -->
<Style TargetType="MenuFlyoutPresenter" BasedOn="{StaticResource DefaultMenuFlyoutPresenterStyle}">
<Setter Property="Background" Value="{ThemeResource FlyoutPresenterBackground}"/>
<Setter Property="BorderBrush" Value="{ThemeResource FlyoutBorderThemeBrush}"/>
</Style>

</ResourceDictionary>
</Application.Resources>
</Application>
6 changes: 3 additions & 3 deletions SudokuSolver/Installer/inno_script.iss
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion SudokuSolver/SudokuSolver.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<PackageReference Include="Microsoft.Windows.CsWin32" Version="0.3.18-beta">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.4.230822000" />
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.4.230913002" />
<!-- the build tools are only required for packaged builds to run...
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.22621.755" />
-->
Expand Down
35 changes: 21 additions & 14 deletions SudokuSolver/ViewModels/PuzzleViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public void UpdateCellForKeyDown(int index, int newValue)
UpdateView();
undoHelper.Push(model);
IsModified = true;
RaiseCanExecuteChanged();
UpdateMenuItemsDisabledState();
}
else
{
Expand Down Expand Up @@ -124,7 +124,7 @@ public void Open(Stream stream)
{
UpdateView();
undoHelper.Push(model);
RaiseCanExecuteChanged();
UpdateMenuItemsDisabledState();
}
}

Expand All @@ -148,7 +148,7 @@ public void New()
UpdateView();
undoHelper.Push(model);
IsModified = false;
RaiseCanExecuteChanged();
UpdateMenuItemsDisabledState();
}

public bool ShowPossibles
Expand Down Expand Up @@ -224,7 +224,7 @@ public void ExecuteUndo(object? param)
model = undoHelper.PopUndo();
UpdateView();
IsModified = true;
RaiseCanExecuteChanged();
UpdateMenuItemsDisabledState();
}
}

Expand All @@ -238,7 +238,7 @@ public void ExecuteRedo(object? param)
model = undoHelper.PopRedo();
UpdateView();
IsModified = true;
RaiseCanExecuteChanged();
UpdateMenuItemsDisabledState();
}
}

Expand All @@ -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;
Expand Down
11 changes: 8 additions & 3 deletions SudokuSolver/Views/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,13 @@
<KeyboardAccelerator Key="V" Modifiers="Control"/>
</MenuFlyoutItem.KeyboardAccelerators>
</MenuFlyoutItem>
<MenuFlyoutItem Text="Delete" Command="{x:Bind Puzzle.ViewModel.DeleteCommand}" AccessKey="D">
<!-- no keyboard accelerator because it's already implemented by a focused cell -->

<!-- remove work in progress, bug fix release required -->

<!--<MenuFlyoutItem Text="Delete" Command="{x:Bind Puzzle.ViewModel.DeleteCommand}" AccessKey="D">
-->
<!-- no keyboard accelerator because it's already implemented by a focused cell -->
<!--
</MenuFlyoutItem>
<MenuFlyoutSeparator />
Expand All @@ -119,7 +124,7 @@
<MenuFlyoutItem.KeyboardAccelerators>
<KeyboardAccelerator Key="M" Modifiers="Control"/>
</MenuFlyoutItem.KeyboardAccelerators>
</MenuFlyoutItem>
</MenuFlyoutItem>-->
</MenuBarItem>

<MenuBarItem Title="View" AccessKey="V">
Expand Down

0 comments on commit 96724a1

Please sign in to comment.