Skip to content

Commit

Permalink
Fixed window closing process.
Browse files Browse the repository at this point in the history
  • Loading branch information
t-miyake committed Oct 1, 2017
1 parent bcc8252 commit c30d6bc
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 18 deletions.
18 changes: 5 additions & 13 deletions PocketFanController/ConfigWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Windows;

namespace PocketFanController
{
Expand All @@ -22,6 +10,10 @@ public partial class ConfigWindow : Window
public ConfigWindow()
{
InitializeComponent();
var vm = new ConfigWindowViewModel();
DataContext = vm;
if (vm.CloseAction == null)
vm.CloseAction = Close;
}
}
}
9 changes: 6 additions & 3 deletions PocketFanController/ConfigWindowViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Windows;
using System;
using System.Windows;
using System.Windows.Input;

namespace PocketFanController
Expand All @@ -12,6 +13,8 @@ public class ConfigWindowViewModel : ViewModelBase
public ICommand CancelButton { get; }
public ICommand ApplyButton { get; }

public Action CloseAction { get; set; }

public int Margin
{
get => Model.ManualMargin;
Expand Down Expand Up @@ -64,7 +67,7 @@ public ConfigWindowViewModel()
{
Model.SaveManualConfig(Margin, BorderOfSlow, BorderOfFast, BorderOfFastest);
SetManual();
Application.Current.MainWindow.Close();
CloseAction();
});

ApplyButton = new RelayCommand(() =>
Expand All @@ -76,7 +79,7 @@ public ConfigWindowViewModel()

CancelButton = new RelayCommand(() =>
{
Application.Current.MainWindow.Close();
CloseAction();
});

Model.GetManualConfigs();
Expand Down
4 changes: 2 additions & 2 deletions PocketFanController/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
// すべての値を指定するか、次を使用してビルド番号とリビジョン番号を既定に設定できます
// 既定値にすることができます:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.5.1.0")]
[assembly: AssemblyFileVersion("0.5.1.0")]
[assembly: AssemblyVersion("0.5.2.0")]
[assembly: AssemblyFileVersion("0.5.2.0")]
[assembly: NeutralResourcesLanguage("en")]

0 comments on commit c30d6bc

Please sign in to comment.