diff options
Diffstat (limited to 'src/WixToolset.WixBA/RootView.xaml.cs')
-rw-r--r-- | src/WixToolset.WixBA/RootView.xaml.cs | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/src/WixToolset.WixBA/RootView.xaml.cs b/src/WixToolset.WixBA/RootView.xaml.cs new file mode 100644 index 00000000..1d4301f2 --- /dev/null +++ b/src/WixToolset.WixBA/RootView.xaml.cs | |||
@@ -0,0 +1,51 @@ | |||
1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. | ||
2 | |||
3 | namespace WixToolset.UX | ||
4 | { | ||
5 | using System.ComponentModel; | ||
6 | using System.Windows; | ||
7 | using System.Windows.Interop; | ||
8 | |||
9 | /// <summary> | ||
10 | /// Interaction logic for View.xaml | ||
11 | /// </summary> | ||
12 | public partial class RootView : Window | ||
13 | { | ||
14 | /// <summary> | ||
15 | /// Creates the view populated with it's model. | ||
16 | /// </summary> | ||
17 | /// <param name="viewModel">Model for the view.</param> | ||
18 | public RootView(RootViewModel viewModel) | ||
19 | { | ||
20 | this.DataContext = viewModel; | ||
21 | |||
22 | this.Loaded += (sender, e) => WixBA.Model.Engine.CloseSplashScreen(); | ||
23 | this.Closed += (sender, e) => this.Dispatcher.InvokeShutdown(); // shutdown dispatcher when the window is closed. | ||
24 | |||
25 | this.InitializeComponent(); | ||
26 | |||
27 | viewModel.Dispatcher = this.Dispatcher; | ||
28 | viewModel.ViewWindowHandle = new WindowInteropHelper(this).EnsureHandle(); | ||
29 | } | ||
30 | |||
31 | /// <summary> | ||
32 | /// Event is fired when the window is closing. | ||
33 | /// </summary> | ||
34 | /// <param name="sender"></param> | ||
35 | /// <param name="e"></param> | ||
36 | private void Window_Closing(object sender, CancelEventArgs e) | ||
37 | { | ||
38 | RootViewModel rvm = this.DataContext as RootViewModel; | ||
39 | if ((null != rvm) && (InstallationState.Applying == rvm.InstallState)) | ||
40 | { | ||
41 | rvm.CancelButton_Click(); | ||
42 | if (rvm.Canceled) | ||
43 | { | ||
44 | // Defer closing until the engine has canceled processing. | ||
45 | e.Cancel = true; | ||
46 | rvm.AutoClose = true; | ||
47 | } | ||
48 | } | ||
49 | } | ||
50 | } | ||
51 | } | ||