Skip to content

Commit

Permalink
Merge pull request #72 from DHancock/current
Browse files Browse the repository at this point in the history
Current
  • Loading branch information
DHancock authored Dec 23, 2020
2 parents 591f6fd + 7cfb31b commit 8536d6c
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 11 deletions.
2 changes: 1 addition & 1 deletion SudokuSolver/Common/CellBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public bool Equals(CellBase? other)
if (HasValue)
{
if (other.HasValue)
return Value == other.Value;
return (Value == other.Value) && (Origin == other.Origin);

return false;
}
Expand Down
8 changes: 4 additions & 4 deletions SudokuSolver/SudokuSolver.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@
<OutputType>WinExe</OutputType>
<TargetFramework>net5.0-windows</TargetFramework>
<UseWPF>true</UseWPF>
<Version>0.3.0</Version>
<Version>1.0.0</Version>
<Authors>David Hancock</Authors>
<Company>[email protected]</Company>
<Copyright>David Hancock 2020</Copyright>
<PackageId>SudokuSolver</PackageId>
<RepositoryUrl>https://github.com/DHancock/SudokuSolver</RepositoryUrl>
<RepositoryType></RepositoryType>
<NeutralLanguage>En</NeutralLanguage>
<PackageReleaseNotes>pre-release version</PackageReleaseNotes>
<PackageReleaseNotes></PackageReleaseNotes>
<Product>SudokuSolver</Product>
<AssemblyName>SudokuSolver</AssemblyName>
<RootNamespace>Sudoku</RootNamespace>
<ApplicationIcon>app.ico</ApplicationIcon>
<AssemblyVersion>0.3.0.0</AssemblyVersion>
<FileVersion>0.3.0.0</FileVersion>
<AssemblyVersion>1.0.0.0</AssemblyVersion>
<FileVersion>1.0.0.0</FileVersion>
<Nullable>enable</Nullable>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<ApplicationManifest>app.manifest</ApplicationManifest>
Expand Down
15 changes: 15 additions & 0 deletions SudokuSolver/ViewModels/PuzzleViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,21 @@ public PuzzleViewModel()
}


public PuzzleViewModel(PuzzleViewModel source)
{
Model = new PuzzleModel(source.Model);
Cells = new CellList(CellChanged_EventHandler);
ClearCommand = new RelayCommand(ClearCommandHandler, o => Cells.NotEmpty);

foreach (Models.Cell cell in Model.Cells)
Cells.UpdateCell(cell);

DarkThemed = source.DarkThemed;
ShowPossibles = source.ShowPossibles;
AccentTitleBar = source.AccentTitleBar;
}


// an empty implementation used to indicate no action is required
// when the user changes a cell. As the code supports nullable using
// this avoids the need to return a null function delegate.
Expand Down
2 changes: 1 addition & 1 deletion SudokuSolver/Views/Cell.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
<TextBlock x:Name="PossibleValue3" Text="4" Canvas.Top="16" Canvas.Left="4"/>
<TextBlock x:Name="PossibleValue4" Text="5" Canvas.Top="16" Canvas.Left="22"/>
<TextBlock x:Name="PossibleValue5" Text="6" Canvas.Top="16" Canvas.Left="39"/>
<TextBlock x:Name="PossibleValue6" Text="7" Canvas.Top="34" Canvas.Left="5"/>
<TextBlock x:Name="PossibleValue6" Text="7" Canvas.Top="34" Canvas.Left="4"/>
<TextBlock x:Name="PossibleValue7" Text="8" Canvas.Top="34" Canvas.Left="22"/>
<TextBlock x:Name="PossibleValue8" Text="9" Canvas.Top="34" Canvas.Left="39"/>
</Canvas>
Expand Down
2 changes: 1 addition & 1 deletion SudokuSolver/Views/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
<MenuItem Header="_Options">
<MenuItem Header="_Show possibles" IsCheckable="True" IsChecked="{Binding ShowPossibles}"/>
<Separator />
<MenuItem Header="_Dark theme" IsCheckable="True" IsChecked="{Binding DarkThemed, Mode=OneWayToSource}" Checked="DarkThemeCheckedHandler" Unchecked="DarkThemeUncheckedHandler"/>
<MenuItem Header="_Dark theme" IsCheckable="True" IsChecked="{Binding DarkThemed, Mode=OneWay}" Checked="DarkThemeCheckedHandler" Unchecked="DarkThemeUncheckedHandler"/>
</MenuItem>
</Menu>

Expand Down
15 changes: 11 additions & 4 deletions SudokuSolver/Views/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ private void ProcessCommandLine(string[] args)

private void InitializeTheme()
{
if (!WindowsThemeHelper.AppsUseLightTheme())
if (WindowsThemeHelper.GetWindowsBaseColor() == ThemeManager.BaseColorDark)
SetTheme(dark: true);

((PuzzleViewModel)DataContext).AccentTitleBar = WindowsThemeHelper.ShowAccentColorOnTitleBarsAndWindowBorders();
Expand All @@ -75,10 +75,17 @@ private void PrintExecutedHandler(object sender, ExecutedRoutedEventArgs e)
PuzzleView puzzleView = new PuzzleView
{
Padding = new Thickness(Math.Min(printDialog.PrintableAreaHeight, printDialog.PrintableAreaWidth) * (cMarginsPercentage / 100D)),
Background = this.Background,
Foreground = this.Foreground,
DataContext = this.DataContext
};

if (((PuzzleViewModel)DataContext).DarkThemed)
{
PuzzleViewModel clone = new PuzzleViewModel((PuzzleViewModel)DataContext);
clone.DarkThemed = false;
puzzleView.DataContext = clone;
ThemeManager.Current.ChangeThemeBaseColor(puzzleView, ThemeManager.BaseColorLight);
}
else
puzzleView.DataContext = DataContext;

printDialog.PrintVisual(puzzleView, "Sudoku puzzle");
}
Expand Down

0 comments on commit 8536d6c

Please sign in to comment.