aboutsummaryrefslogtreecommitdiff
path: root/src/WixToolset.WixBA/RootViewModel.cs
diff options
context:
space:
mode:
authorSean Hall <r.sean.hall@gmail.com>2021-05-06 18:55:18 -0500
committerSean Hall <r.sean.hall@gmail.com>2021-05-11 19:11:19 -0500
commit8c27fbe1bc8a6d83859aead2105d6d528c307726 (patch)
tree1e26f482e119fd9bcb348412766eaba31bf4fc84 /src/WixToolset.WixBA/RootViewModel.cs
parent3c88529e8e29f9763a6830f8d3ac29cd56a4cb33 (diff)
downloadwix-8c27fbe1bc8a6d83859aead2105d6d528c307726.tar.gz
wix-8c27fbe1bc8a6d83859aead2105d6d528c307726.tar.bz2
wix-8c27fbe1bc8a6d83859aead2105d6d528c307726.zip
Move WixToolset.WixBA into test/burn and use new PackageReferences.
Diffstat (limited to 'src/WixToolset.WixBA/RootViewModel.cs')
-rw-r--r--src/WixToolset.WixBA/RootViewModel.cs202
1 files changed, 0 insertions, 202 deletions
diff --git a/src/WixToolset.WixBA/RootViewModel.cs b/src/WixToolset.WixBA/RootViewModel.cs
deleted file mode 100644
index 8cff7274..00000000
--- a/src/WixToolset.WixBA/RootViewModel.cs
+++ /dev/null
@@ -1,202 +0,0 @@
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
3namespace WixToolset.WixBA
4{
5 using System;
6 using System.Windows;
7 using System.Windows.Input;
8 using System.Windows.Threading;
9 using WixToolset.Mba.Core;
10
11 /// <summary>
12 /// The errors returned from the engine
13 /// </summary>
14 public enum Error
15 {
16 UserCancelled = 1223,
17 }
18
19 /// <summary>
20 /// The model of the root view in WixBA.
21 /// </summary>
22 public class RootViewModel : PropertyNotifyBase
23 {
24 private ICommand cancelCommand;
25 private ICommand closeCommand;
26
27 private bool canceled;
28 private InstallationState installState;
29 private DetectionState detectState;
30
31 /// <summary>
32 /// Creates a new model of the root view.
33 /// </summary>
34 public RootViewModel()
35 {
36 this.InstallationViewModel = new InstallationViewModel(this);
37 this.ProgressViewModel = new ProgressViewModel(this);
38 this.UpdateViewModel = new UpdateViewModel(this);
39 }
40
41 public InstallationViewModel InstallationViewModel { get; private set; }
42 public ProgressViewModel ProgressViewModel { get; private set; }
43 public UpdateViewModel UpdateViewModel { get; private set; }
44 public Dispatcher Dispatcher { get; set; }
45 public IntPtr ViewWindowHandle { get; set; }
46 public bool AutoClose { get; set; }
47
48 public ICommand CloseCommand
49 {
50 get
51 {
52 if (this.closeCommand == null)
53 {
54 this.closeCommand = new RelayCommand(param => WixBA.View.Close());
55 }
56
57 return this.closeCommand;
58 }
59 }
60
61 public ICommand CancelCommand
62 {
63 get
64 {
65 if (this.cancelCommand == null)
66 {
67 this.cancelCommand = new RelayCommand(param =>
68 {
69 this.CancelButton_Click();
70 },
71 param => !this.Canceled);
72 }
73
74 return this.cancelCommand;
75 }
76 }
77
78 public bool CancelAvailable
79 {
80 get { return InstallationState.Applying == this.InstallState; }
81 }
82
83 public bool Canceled
84 {
85 get
86 {
87 return this.canceled;
88 }
89
90 set
91 {
92 if (this.canceled != value)
93 {
94 this.canceled = value;
95 base.OnPropertyChanged("Canceled");
96 }
97 }
98 }
99
100 /// <summary>
101 /// Gets and sets the detect state of the view's model.
102 /// </summary>
103 public DetectionState DetectState
104 {
105 get
106 {
107 return this.detectState;
108 }
109
110 set
111 {
112 if (this.detectState != value)
113 {
114 this.detectState = value;
115
116 // Notify all the properties derived from the state that the state changed.
117 base.OnPropertyChanged("DetectState");
118 }
119 }
120 }
121
122 /// <summary>
123 /// Gets and sets the installation state of the view's model.
124 /// </summary>
125 public InstallationState InstallState
126 {
127 get
128 {
129 return this.installState;
130 }
131
132 set
133 {
134 if (this.installState != value)
135 {
136 this.installState = value;
137
138 // Notify all the properties derived from the state that the state changed.
139 base.OnPropertyChanged("InstallState");
140 base.OnPropertyChanged("CancelAvailable");
141 }
142 }
143 }
144
145 /// <summary>
146 /// Gets and sets the state of the view's model before apply begins in order to return to that state if cancel or rollback occurs.
147 /// </summary>
148 public InstallationState PreApplyState { get; set; }
149
150 /// <summary>
151 /// Gets and sets the path where the bundle is currently installed or will be installed.
152 /// </summary>
153 public string InstallDirectory
154 {
155 get
156 {
157 return WixBA.Model.InstallDirectory;
158 }
159
160 set
161 {
162 if (WixBA.Model.InstallDirectory != value)
163 {
164 WixBA.Model.InstallDirectory = value;
165 base.OnPropertyChanged("InstallDirectory");
166 }
167 }
168 }
169
170 /// <summary>
171 /// The Title of this bundle.
172 /// </summary>
173 public string Title
174 {
175 get
176 {
177 return WixDistribution.ShortProduct;
178 }
179 }
180
181 /// <summary>
182 /// Prompts the user to make sure they want to cancel.
183 /// This needs to run on the UI thread, use Dispatcher.Invoke to call this from a background thread.
184 /// </summary>
185 public void CancelButton_Click()
186 {
187 if (this.Canceled)
188 {
189 return;
190 }
191
192 if (Display.Full == WixBA.Model.Command.Display)
193 {
194 this.Canceled = (MessageBoxResult.Yes == MessageBox.Show(WixBA.View, "Are you sure you want to cancel?", "WiX Toolset", MessageBoxButton.YesNo, MessageBoxImage.Error));
195 }
196 else
197 {
198 this.Canceled = true;
199 }
200 }
201 }
202}