blob: 2dfd214e84f8def263811d288dceddda4034eb70 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
|
// 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.
namespace WixToolset.WixBA
{
using System;
using System.Windows;
using System.Windows.Input;
using System.Windows.Threading;
using WixToolset.Mba.Core;
/// <summary>
/// The errors returned from the engine
/// </summary>
public enum Error
{
UserCancelled = 1223,
}
/// <summary>
/// The model of the root view in WixBA.
/// </summary>
public class RootViewModel : PropertyNotifyBase
{
private ICommand cancelCommand;
private ICommand closeCommand;
private bool canceled;
private InstallationState installState;
private DetectionState detectState;
private UpgradeDetectionState upgradeDetectState;
/// <summary>
/// Creates a new model of the root view.
/// </summary>
public RootViewModel()
{
this.InstallationViewModel = new InstallationViewModel(this);
this.ProgressViewModel = new ProgressViewModel(this);
this.UpdateViewModel = new UpdateViewModel(this);
}
public InstallationViewModel InstallationViewModel { get; private set; }
public ProgressViewModel ProgressViewModel { get; private set; }
public UpdateViewModel UpdateViewModel { get; private set; }
public Dispatcher Dispatcher { get; set; }
public IntPtr ViewWindowHandle { get; set; }
public bool AutoClose { get; set; }
public ICommand CloseCommand
{
get
{
if (this.closeCommand == null)
{
this.closeCommand = new RelayCommand(param => WixBA.View.Close());
}
return this.closeCommand;
}
}
public ICommand CancelCommand
{
get
{
if (this.cancelCommand == null)
{
this.cancelCommand = new RelayCommand(param =>
{
this.CancelButton_Click();
},
param => !this.Canceled);
}
return this.cancelCommand;
}
}
public bool CancelAvailable
{
get { return InstallationState.Applying == this.InstallState; }
}
public bool Canceled
{
get
{
return this.canceled;
}
set
{
if (this.canceled != value)
{
this.canceled = value;
base.OnPropertyChanged("Canceled");
}
}
}
/// <summary>
/// Gets and sets the detect state of the view's model.
/// </summary>
public DetectionState DetectState
{
get
{
return this.detectState;
}
set
{
if (this.detectState != value)
{
this.detectState = value;
// Notify all the properties derived from the state that the state changed.
base.OnPropertyChanged("DetectState");
}
}
}
/// <summary>
/// Gets and sets the upgrade detect state of the view's model.
/// </summary>
public UpgradeDetectionState UpgradeDetectState
{
get
{
return this.upgradeDetectState;
}
set
{
if (this.upgradeDetectState != value)
{
this.upgradeDetectState = value;
// Notify all the properties derived from the state that the state changed.
base.OnPropertyChanged("UpgradeDetectState");
}
}
}
/// <summary>
/// Gets and sets the installation state of the view's model.
/// </summary>
public InstallationState InstallState
{
get
{
return this.installState;
}
set
{
if (this.installState != value)
{
this.installState = value;
// Notify all the properties derived from the state that the state changed.
base.OnPropertyChanged("InstallState");
base.OnPropertyChanged("CancelAvailable");
}
}
}
/// <summary>
/// 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.
/// </summary>
public InstallationState PreApplyState { get; set; }
/// <summary>
/// Gets and sets the path where the bundle is currently installed or will be installed.
/// </summary>
public string InstallDirectory
{
get
{
return WixBA.Model.InstallDirectory;
}
set
{
if (WixBA.Model.InstallDirectory != value)
{
WixBA.Model.InstallDirectory = value;
base.OnPropertyChanged("InstallDirectory");
}
}
}
/// <summary>
/// The Title of this bundle.
/// </summary>
public string Title
{
get
{
return WixDistribution.ShortProduct;
}
}
/// <summary>
/// Prompts the user to make sure they want to cancel.
/// This needs to run on the UI thread, use Dispatcher.Invoke to call this from a background thread.
/// </summary>
public void CancelButton_Click()
{
if (this.Canceled)
{
return;
}
if (Display.Full == WixBA.Model.Command.Display)
{
this.Canceled = (MessageBoxResult.Yes == MessageBox.Show(WixBA.View, "Are you sure you want to cancel?", "WiX Toolset", MessageBoxButton.YesNo, MessageBoxImage.Error));
}
else
{
this.Canceled = true;
}
}
}
}
|