From bec58268bc040eea660bbadecb98f0c7d1455c80 Mon Sep 17 00:00:00 2001 From: Clicia Scarlet Date: Wed, 27 May 2015 00:41:40 +0700 Subject: [PATCH] Code more readable --- .../ViewModels/MainWindowViewModel.cs | 25 ++++++++----------- .../Views/ExitDialog.xaml | 6 ++--- .../Views/MainWindow.xaml | 19 ++++++-------- 3 files changed, 19 insertions(+), 31 deletions(-) diff --git a/Grabacr07.KanColleViewer/ViewModels/MainWindowViewModel.cs b/Grabacr07.KanColleViewer/ViewModels/MainWindowViewModel.cs index 44e6f7254..c7646cff2 100644 --- a/Grabacr07.KanColleViewer/ViewModels/MainWindowViewModel.cs +++ b/Grabacr07.KanColleViewer/ViewModels/MainWindowViewModel.cs @@ -29,7 +29,7 @@ public class MainWindowViewModel : WindowViewModel private ICommand _RefreshNavigator; public ICommand RefreshNavigator { - get { return _RefreshNavigator; } + get { return this._RefreshNavigator; } } #endregion @@ -55,7 +55,7 @@ public Mode Mode StatusService.Current.Set(Properties.Resources.StatusBar_Ready); ThemeService.Current.ChangeAccent(Accent.Blue); if (KanColleClient.Current.Homeport != null) - KanColleClient.Current.Homeport.Logger.EnableLogging = Settings.EnableLogging; + KanColleClient.Current.Homeport.Logger.EnableLogging = this.Settings.EnableLogging; break; case Mode.InSortie: ThemeService.Current.ChangeAccent(Accent.Orange); @@ -183,12 +183,12 @@ public MainWindowViewModel() this.UpdateCloseConfirm(); this.CompositeDisposable.Add(new PropertyChangedEventListener(Setting.Current) { - { "CloseConfirm", (sender, args) => UpdateCloseConfirm() }, - { "CloseConfirmOnlyInSortie", (sender, args) => UpdateCloseConfirm() }, + { "CloseConfirm", (sender, args) => this.UpdateCloseConfirm() }, + { "CloseConfirmOnlyInSortie", (sender, args) => this.UpdateCloseConfirm() }, }); - _RefreshNavigator = new RelayCommand(Navigator.ReNavigate); + this._RefreshNavigator = new RelayCommand(this.Navigator.ReNavigate); this.UpdateMode(); } @@ -222,7 +222,7 @@ private void UpdateMode() ? Mode.InSortie : Mode.Started : Mode.NotStarted; - UpdateCloseConfirm(); + this.UpdateCloseConfirm(); } private void UpdateCloseConfirm() @@ -234,20 +234,15 @@ private void UpdateCloseConfirm() } } - public void Closing() + public void Close() { - if (!this.CanClose) - { - var message = new TransitionMessage(this, "Show/ExitDialog"); - this.Messenger.Raise(message); - } + this.Messenger.Raise(new TransitionMessage(this, "Show/ExitDialog")); } - public void Close() + public void ForceClose() { this.CanClose = true; - var message = new TransitionMessage(this, "Close"); - this.Messenger.Raise(message); + this.Messenger.Raise(new WindowActionMessage(WindowAction.Close, "Window/Close")); } } } diff --git a/Grabacr07.KanColleViewer/Views/ExitDialog.xaml b/Grabacr07.KanColleViewer/Views/ExitDialog.xaml index a9647db9e..c44b05097 100644 --- a/Grabacr07.KanColleViewer/Views/ExitDialog.xaml +++ b/Grabacr07.KanColleViewer/Views/ExitDialog.xaml @@ -18,11 +18,9 @@ d:DataContext="{d:DesignInstance viewModels:MainWindowViewModel}" Style="{DynamicResource MetroDialogStyleKey}" Background="{DynamicResource ThemeBrushKey}" - Foreground="{DynamicResource ActiveForegroundBrushKey}" Title="{Binding Resources.ExitDialogTitle, Source={x:Static models:ResourceService.Current}, Mode=OneWay}" WindowStartupLocation="CenterScreen" - SizeToContent="Height" - Name="WindowNameTobeClose"> + SizeToContent="Height"> @@ -45,7 +43,7 @@ MinWidth="100" Padding="20,5" Margin="12,0,0,0" - MethodName="Close" /> + MethodName="ForceClose" /> - - - + + + - - - - - - - - +