-
Notifications
You must be signed in to change notification settings - Fork 0
/
CustomMessageBox.cs
285 lines (261 loc) · 9.82 KB
/
CustomMessageBox.cs
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
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
// Type: Intel.Mobile.WiMAXCU.UI.Dashboard.CustomMessageBox
// Assembly: WiMAXCU, Version=6.2.4357.25644, Culture=neutral, PublicKeyToken=null
// MVID: 3C622363-C72C-43B7-9311-DD8942A58F18
// Assembly location: E:\Extracted\program files\Intel\WiMAX\Bin\WiMAXCU.exe
using Intel.Mobile.WiMAXCU.BizTier;
using Intel.Mobile.WiMAXCU.Common;
using Intel.Mobile.WiMAXCU.SDKInterop;
using Intel.Mobile.WiMAXCU.UI.CustomControls;
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Media;
using System.Threading;
using System.Windows.Forms;
namespace Intel.Mobile.WiMAXCU.UI.Dashboard
{
public class CustomMessageBox : CustomForm
{
protected string _message = string.Empty;
private CustomMessageBoxLocation _customMessageBoxLocation = CustomMessageBoxLocation.CenterOfDashboard;
protected CustomMessageBoxPanel _customMessageBoxPanel;
protected CustomMessageBoxStyle _style;
protected DontShowThisMessageAgainOptions _dontShowThisMessageAgainOption;
protected bool _userGaveResponse;
private IContainer components;
public string Message
{
get
{
return this._message;
}
set
{
this._message = value;
this._customMessageBoxPanel.UpdateTextControl();
}
}
public CustomMessageBoxStyle Style
{
get
{
return this._style;
}
}
public DontShowThisMessageAgainOptions DontShowThisMessageAgainOption
{
get
{
return this._dontShowThisMessageAgainOption;
}
}
public bool UserGaveResponse
{
get
{
return this._userGaveResponse;
}
set
{
this._userGaveResponse = value;
}
}
public CustomMessageBoxLocation LocationOfMessageBox
{
get
{
return this._customMessageBoxLocation;
}
set
{
this._customMessageBoxLocation = value;
}
}
public CustomMessageBox(string message)
: this(message, true)
{
}
protected CustomMessageBox(string message, bool scaleControls)
{
this.Text = DashboardStringHelper.GetString("ShortenedApplicationCaption");
this._message = message;
this.InitializeComponent();
int num = scaleControls ? 1 : 0;
}
public CustomMessageBox(string message, CustomMessageBoxStyle style)
: this(message, style, true)
{
}
protected CustomMessageBox(string message, CustomMessageBoxStyle style, bool scaleControls)
{
this.Text = DashboardStringHelper.GetString("ShortenedApplicationCaption");
this._message = message;
this._style = style;
this.InitializeComponent();
int num = scaleControls ? 1 : 0;
}
public CustomMessageBox(string message, CustomMessageBoxStyle style, DontShowThisMessageAgainOptions dontShowThisMessageAgainOption)
: this(message, style, dontShowThisMessageAgainOption, true)
{
}
protected CustomMessageBox(string message, CustomMessageBoxStyle style, DontShowThisMessageAgainOptions dontShowThisMessageAgainOption, bool scaleControls)
{
this.Text = DashboardStringHelper.GetString("ShortenedApplicationCaption");
this._message = message;
this._style = style;
this._dontShowThisMessageAgainOption = dontShowThisMessageAgainOption;
this.InitializeComponent();
int num = scaleControls ? 1 : 0;
}
public CustomMessageBox(string title, string message, CustomMessageBoxStyle style)
: this(title, message, style, true)
{
}
protected CustomMessageBox(string title, string message, CustomMessageBoxStyle style, bool scaleControls)
{
this.Text = title;
this._message = message;
this._style = style;
this.InitializeComponent();
int num = scaleControls ? 1 : 0;
}
public void CustomShow(IWin32Window parent, bool showPopupOnlyIfPrimaryCUAndSDKReady)
{
if (showPopupOnlyIfPrimaryCUAndSDKReady && (!MediaHandler.TheMedia.WiMAXIsReady || !MediaHandler.IntelCUIsInControl))
return;
if (this.SetupControls())
{
if (this._customMessageBoxLocation == CustomMessageBoxLocation.CenterOfDashboardOrInTaskTrayOnTop || this._customMessageBoxLocation == CustomMessageBoxLocation.AlwaysInTaskTrayOnTop)
UIHelper.ShowAsTopMostForm((Form) this);
else
UIHelper.ShowAsBottomMostForm((Form) this);
}
else if (parent == null)
((Control) this).Show();
else
this.Show(parent);
}
public DialogResult CustomShowDialog(IWin32Window parent, bool showPopupOnlyIfPrimaryCUAndSDKReady)
{
DialogResult dialogResult1 = DialogResult.OK;
if (showPopupOnlyIfPrimaryCUAndSDKReady && (!MediaHandler.TheMedia.WiMAXIsReady || !MediaHandler.IntelCUIsInControl))
return dialogResult1;
bool flag = this.SetupControls();
try
{
if (this._style == CustomMessageBoxStyle.YesNo || this._style == CustomMessageBoxStyle.YesNoCancel)
{
SystemSounds.Exclamation.Play();
}
else
{
if (this._style != CustomMessageBoxStyle.Ok)
{
if (this._style != CustomMessageBoxStyle.OkCancel)
goto label_9;
}
SystemSounds.Asterisk.Play();
}
}
catch (Exception ex)
{
Logging.LogEvent(TraceModule.SDK, TraceLevel.Warning, (object) this, Logging.GetMessageForException(ex));
}
label_9:
DialogResult dialogResult2;
if (flag)
{
UIHelper.ShowAsTopMostForm((Form) this);
while (this.Visible)
{
Application.DoEvents();
Thread.Sleep(100);
}
dialogResult2 = this.DialogResult;
}
else
dialogResult2 = parent != null ? this.ShowDialog(parent) : this.ShowDialog();
return dialogResult2;
}
protected override void OnClosing(CancelEventArgs e)
{
if (!this._userGaveResponse)
{
if (this._style == CustomMessageBoxStyle.YesNo)
this.DialogResult = DialogResult.No;
else if (this._style == CustomMessageBoxStyle.YesRemindMeLater)
this.DialogResult = DialogResult.No;
else if (this._style == CustomMessageBoxStyle.YesNoCancel || this._style == CustomMessageBoxStyle.OkCancel)
this.DialogResult = DialogResult.Cancel;
else
this.DialogResult = DialogResult.OK;
}
base.OnClosing(e);
}
protected override void OnCreateControl()
{
this._customMessageBoxPanel.AccessibleName = this.AccessibleName + "_Panel";
base.OnCreateControl();
}
protected virtual void CustomInitializeComponents()
{
this.BackColor = CustomForm.FormBackColor;
if (this._customMessageBoxPanel != null)
this.Controls.Remove((Control) this._customMessageBoxPanel);
this._customMessageBoxPanel = new CustomMessageBoxPanel(this);
this._customMessageBoxPanel.Location = new Point(ImageHelper.Unscaled.FrameLeftPixel.Width, ImageHelper.Unscaled.FrameTopPixel.Height);
this.Controls.Add((Control) this._customMessageBoxPanel);
this.Size = new Size(this._customMessageBoxPanel.Width + ImageHelper.Unscaled.FrameLeftPixel.Width + ImageHelper.Unscaled.FrameRightPixel.Width, this._customMessageBoxPanel.Height + ImageHelper.Unscaled.FrameTopPixel.Height + ImageHelper.Unscaled.FrameBottomPixel.Height);
}
protected override void OnHandleCreated(EventArgs e)
{
base.OnHandleCreated(e);
this.ScaleMe();
}
private bool SetupControls()
{
this.CustomInitializeComponents();
if (this._customMessageBoxLocation == CustomMessageBoxLocation.AlwaysInTaskTrayBottom || this._customMessageBoxLocation == CustomMessageBoxLocation.AlwaysInTaskTrayOnTop || this._customMessageBoxLocation == CustomMessageBoxLocation.CenterOfDashboardOrInTaskTrayBottom && AppFramework.TaskTray.ShowPopupInTaskTray() || this._customMessageBoxLocation == CustomMessageBoxLocation.CenterOfDashboardOrInTaskTrayOnTop && AppFramework.TaskTray.ShowPopupInTaskTray())
{
if (this._style == CustomMessageBoxStyle.Ok)
this.FormType = FormTypeEnum.TaskTrayWithCloseBtn;
else
this.FormType = FormTypeEnum.TaskTrayWithoutCloseBtn;
this.StartPosition = FormStartPosition.Manual;
this.Location = AppFramework.TaskTray.GetTaskTrayPopupLocation(DPIUtils.ScaleSize(this.Size));
return true;
}
else
{
if (AppFramework.Dashboard != null && AppFramework.Dashboard.WindowState == FormWindowState.Minimized)
AppFramework.Dashboard.WindowState = FormWindowState.Normal;
AppFramework.Dashboard.BringToFront();
this.FormType = FormTypeEnum.Dialog;
if (AppFramework.Dashboard != null && AppFramework.Dashboard.Visible)
this.StartPosition = FormStartPosition.CenterParent;
else
this.StartPosition = FormStartPosition.CenterScreen;
return false;
}
}
protected override void Dispose(bool disposing)
{
if (disposing && this.components != null)
this.components.Dispose();
base.Dispose(disposing);
}
private void InitializeComponent()
{
ComponentResourceManager componentResourceManager = new ComponentResourceManager(typeof (CustomMessageBox));
this.SuspendLayout();
this.AutoScaleMode = AutoScaleMode.Inherit;
componentResourceManager.ApplyResources((object) this, "$this");
this.ForeColor = Color.Black;
this.FormType = FormTypeEnum.Dialog;
this.Name = "CustomMessageBox";
this.ShowInTaskbar = false;
this.ResumeLayout(false);
}
}
}