Skip to content

Commit

Permalink
Merge pull request #71 from DHancock/current
Browse files Browse the repository at this point in the history
Current
  • Loading branch information
DHancock authored Dec 22, 2020
2 parents 2163d09 + 017f478 commit 591f6fd
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 12 deletions.
4 changes: 2 additions & 2 deletions SudokuSolver/ViewModels/PuzzleViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,10 @@ private void CellChanged_EventHandler(object? sender, PropertyChangedEventArgs e
}


public void SaveFile(Stream stream) => Model.Save(stream);
public void Save(Stream stream) => Model.Save(stream);


public void OpenFile(Stream stream)
public void Open(Stream stream)
{
try
{
Expand Down
11 changes: 11 additions & 0 deletions SudokuSolver/Views/ErrorDialog.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using MahApps.Metro.Controls;
using MahApps.Metro.Controls.Dialogs;
using System.Windows.Input;

namespace Sudoku.Views
{
Expand All @@ -9,11 +10,21 @@ public static async void Show(MetroWindow parent, string heading, string details
{
MetroDialogSettings dialogSettings = new MetroDialogSettings()
{
// A bug in MahApps stops access keys from working in this dialog. The
// Esc and Enter keys both work though so not really too much of a problem...
AffirmativeButtonText = "Close",
ColorScheme = MetroDialogColorScheme.Accented,
};

// Another bug in MahApps is that the dialog isn't as modal as it should be.
// The parent window's command bindings will still be active while the dialog
// is open i.e. typing Control+P opens the print dialog.
CommandBindingCollection backup = new CommandBindingCollection(parent.CommandBindings);
parent.CommandBindings.Clear();

await parent.ShowMessageAsync(heading, details, MessageDialogStyle.Affirmative, dialogSettings);

parent.CommandBindings.AddRange(backup);
}
}
}
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}" Checked="DarkThemeCheckedHandler" Unchecked="DarkThemeUncheckedHandler"/>
<MenuItem Header="_Dark theme" IsCheckable="True" IsChecked="{Binding DarkThemed, Mode=OneWayToSource}" Checked="DarkThemeCheckedHandler" Unchecked="DarkThemeUncheckedHandler"/>
</MenuItem>
</Menu>

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

private void InitializeTheme()
{
PuzzleViewModel vm = (PuzzleViewModel)DataContext;

if (!WindowsThemeHelper.AppsUseLightTheme())
{
vm.DarkThemed = true;
ThemeManager.Current.ChangeThemeBaseColor(Application.Current, ThemeManager.BaseColorDark);
}
SetTheme(dark: true);

vm.AccentTitleBar = WindowsThemeHelper.ShowAccentColorOnTitleBarsAndWindowBorders();
((PuzzleViewModel)DataContext).AccentTitleBar = WindowsThemeHelper.ShowAccentColorOnTitleBarsAndWindowBorders();
}

private void ExitClickHandler(object sender, RoutedEventArgs e) => Close();
Expand Down Expand Up @@ -94,7 +89,7 @@ private void OpenFile(string fullPath)
try
{
using FileStream fs = File.OpenRead(fullPath);
((PuzzleViewModel)DataContext).OpenFile(fs);
((PuzzleViewModel)DataContext).Open(fs);
Title = $"{cDefaultWindowTitle} - {Path.GetFileNameWithoutExtension(fullPath)}";
}
catch (Exception ex)
Expand Down Expand Up @@ -122,7 +117,7 @@ private void SaveExecutedHandler(object sender, ExecutedRoutedEventArgs e)
try
{
using Stream stream = dialog.OpenFile();
((PuzzleViewModel)DataContext).SaveFile(stream);
((PuzzleViewModel)DataContext).Save(stream);
}
catch (Exception ex)
{
Expand Down

0 comments on commit 591f6fd

Please sign in to comment.