Skip to content

Commit

Permalink
Code more readable
Browse files Browse the repository at this point in the history
  • Loading branch information
yuyuvn committed May 26, 2015
1 parent 7c6441d commit bec5826
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 31 deletions.
25 changes: 10 additions & 15 deletions Grabacr07.KanColleViewer/ViewModels/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class MainWindowViewModel : WindowViewModel
private ICommand _RefreshNavigator;
public ICommand RefreshNavigator
{
get { return _RefreshNavigator; }
get { return this._RefreshNavigator; }
}

#endregion
Expand All @@ -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);
Expand Down Expand Up @@ -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();
}

Expand Down Expand Up @@ -222,7 +222,7 @@ private void UpdateMode()
? Mode.InSortie
: Mode.Started
: Mode.NotStarted;
UpdateCloseConfirm();
this.UpdateCloseConfirm();
}

private void UpdateCloseConfirm()
Expand All @@ -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"));
}
}
}
6 changes: 2 additions & 4 deletions Grabacr07.KanColleViewer/Views/ExitDialog.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -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">
<Grid>
<Grid.RowDefinitions>
<RowDefinition />
Expand All @@ -45,7 +43,7 @@
MinWidth="100"
Padding="20,5"
Margin="12,0,0,0"
MethodName="Close" />
MethodName="ForceClose" />
<metro2:CallMethodButton Content="Cancel"
MinWidth="100"
Padding="20,5"
Expand Down
19 changes: 7 additions & 12 deletions Grabacr07.KanColleViewer/Views/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,27 +58,22 @@
MessageKey="Window/Activate">
<livet:WindowInteractionMessageAction />
</livet:InteractionMessageTrigger>
<i:EventTrigger EventName="Closing">
<livet:LivetCallMethodAction MethodTarget="{Binding}" MethodName="Closing"/>
</i:EventTrigger>
<livet:InteractionMessageTrigger Messenger="{Binding Messenger, Mode=OneWay}"
MessageKey="Window/Close">
<livet:WindowInteractionMessageAction />
</livet:InteractionMessageTrigger>
<livet:InteractionMessageTrigger Messenger="{Binding Messenger, Mode=OneWay}"
MessageKey="Show/ExitDialog">
<livet:TransitionInteractionMessageAction Mode="NewOrActive"
WindowType="views:ExitDialog"
IsOwned="True" />
</livet:InteractionMessageTrigger>
<livet:InteractionMessageTrigger Messenger="{Binding Messenger, Mode=OneWay}"
MessageKey="Close">
<livet:WindowInteractionMessageAction>
<livet:DirectInteractionMessage>
<livet:WindowActionMessage />
</livet:DirectInteractionMessage>
</livet:WindowInteractionMessageAction>
</livet:InteractionMessageTrigger>
</i:Interaction.Triggers>

<i:Interaction.Behaviors>
<livet:WindowCloseCancelBehavior CanClose="{Binding CanClose, Mode=OneWay}" />
<livet:WindowCloseCancelBehavior CanClose="{Binding CanClose, Mode=OneWay}"
CloseCanceledCallbackMethodTarget="{Binding}"
CloseCanceledCallbackMethodName="Close"/>
</i:Interaction.Behaviors>
<Grid>
<Grid.RowDefinitions>
Expand Down

0 comments on commit bec5826

Please sign in to comment.