-
Notifications
You must be signed in to change notification settings - Fork 0
/
NetworkListPanel.cs
389 lines (359 loc) · 16.9 KB
/
NetworkListPanel.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
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
// Type: Intel.Mobile.WiMAXCU.UI.Dashboard.NetworkListPanel
// 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.Drawing.Drawing2D;
using System.Windows.Forms;
namespace Intel.Mobile.WiMAXCU.UI.Dashboard
{
public class NetworkListPanel : UserControl
{
protected bool _drawDivider = true;
private int _normalNetworkListBoxHeight;
private int _normalNetworkListMessageHeight;
private bool _statusBarVisible;
private IContainer components;
protected NetworkListMessage NetworkListMessage;
protected CustomButtonPushHorizBox ButtonBoxConnect;
protected CustomButtonPush ConnectPushButton;
protected NetworkListBox NetworkListBox;
protected CustomButtonPush SearchForNetworksPushButton;
private NetworkListStatusBar NetworkListStatusBar;
private Label AvailableWiMAXNeworksLabel;
public NetworkListBox TheNetworkListBox
{
get
{
return this.NetworkListBox;
}
}
public NetworkListStatusBar TheStatusBar
{
get
{
return this.NetworkListStatusBar;
}
}
public NetworkListPanel()
{
this.InitializeComponent();
this.CustomInitializeComponents();
this.RegisterForEvents();
}
protected override void OnPaint(PaintEventArgs e)
{
if (this._drawDivider)
{
int x = this.NetworkListBox.Location.X;
e.Graphics.InterpolationMode = InterpolationMode.NearestNeighbor;
e.Graphics.PixelOffsetMode = PixelOffsetMode.Half;
Bitmap ncDividerPixel = ImageHelper.NcDividerPixel;
Point[] destPoints = new Point[3]
{
new Point(x, 0),
new Point(this.NetworkListBox.Width + x, 0),
new Point(x, ncDividerPixel.Height)
};
e.Graphics.DrawImage((Image) ncDividerPixel, destPoints);
}
base.OnPaint(e);
}
private void OnSearchForNetworksBtnPressed(object sender, EventArgs e)
{
if (Intel.Mobile.WiMAXCU.BizTier.ApplicationState.Singleton.BlockedForManualWideScan)
{
Logging.LogEvent(TraceModule.SDK, TraceLevel.Info, (object) this, "--> The user pressed the 'Stop Search' button.");
int errorCode = NetworkHandler.Singleton.StopScan();
if (errorCode == 0)
return;
ErrorHelper.ShowErrorDialog((Control) AppFramework.Dashboard, ErrorStringsHelper.GetString("General_StopSearchFailed"), ErrorHelper.TranslateErrorCodeToMessage(errorCode), (string) null, "StopSearchFailed");
}
else
{
Logging.LogEvent(TraceModule.SDK, TraceLevel.Info, (object) this, "--> The user pressed the 'Search for Networks' button.");
int errorCode = NetworkHandler.Singleton.StartWideScan();
if (errorCode == 0)
return;
ErrorHelper.ShowErrorDialog((Control) AppFramework.Dashboard, ErrorStringsHelper.GetString("General_ScanFailed"), ErrorHelper.TranslateErrorCodeToMessage(errorCode), (string) null, "SearchFailed");
}
}
private bool SetNetworkListMessage()
{
this.NetworkListMessage.SetMessageText("", (string) null, (LinkLabelLinkClickedEventHandler) null);
return false;
}
private void UpdateSearchForNetworksPushButtonState()
{
bool btnEnabled = this.SearchForNetworksPushButton.BtnEnabled;
string btnText = this.SearchForNetworksPushButton.BtnText;
this.SearchForNetworksPushButton.BtnEnabled = Intel.Mobile.WiMAXCU.BizTier.ApplicationState.Singleton.ShouldControlBeEnabled(DashboardControlEnum.NetworkListPanel_SearchForNetworksBtn);
if (!MediaHandler.TheMedia.WiMAXIsReady || !MediaHandler.IntelCUIsInControl || (!AdapterHandler.TheAdapter.RadioIsOn() || NetworkHandler.ConnectedNetworks.Count > 0))
this.SearchForNetworksPushButton.BtnEnabled = false;
this.SearchForNetworksPushButton.BtnText = Intel.Mobile.WiMAXCU.BizTier.ApplicationState.Singleton.BlockedForStopScan || Intel.Mobile.WiMAXCU.BizTier.ApplicationState.Singleton.BlockedForManualWideScan ? DashboardStringHelper.GetString("StopSearching") : DashboardStringHelper.GetString("SearchForNetworks");
if (btnEnabled == this.SearchForNetworksPushButton.BtnEnabled && !(btnText != this.SearchForNetworksPushButton.BtnText))
return;
this.SearchForNetworksPushButton.ResizeMe();
this.SearchForNetworksPushButton.Invalidate();
}
private bool ShouldConnectButtonBeEnabled()
{
return Intel.Mobile.WiMAXCU.BizTier.ApplicationState.Singleton.ShouldControlBeEnabled(DashboardControlEnum.NetworkListPanel_ConnectBtn);
}
private void OnConnectBtnPressed(object sender, EventArgs e)
{
if (Intel.Mobile.WiMAXCU.BizTier.ApplicationState.Singleton.BlockedForConnect)
{
Logging.LogEvent(TraceModule.SDK, TraceLevel.Info, (object) this, "--> The user pressed the 'Stop Connect' button.");
int errorCode = NetworkHandler.Singleton.StopConnect();
if (errorCode == 0)
return;
ErrorHelper.ShowErrorDialog((Control) AppFramework.Dashboard, ErrorStringsHelper.GetString("General_StopConnectFailed"), ErrorHelper.TranslateErrorCodeToMessage(errorCode), (string) null, "StopConnectFailed");
}
else
{
Logging.LogEvent(TraceModule.SDK, TraceLevel.Info, (object) this, "--> The user pressed the 'Connect' button.");
this.ConnectSelectedNetwork();
}
}
public virtual void UpdateUI(bool recreateNetworksListbox)
{
this.DoUpdateUI(recreateNetworksListbox);
}
public virtual bool ShowStatusBar()
{
return Intel.Mobile.WiMAXCU.BizTier.ApplicationState.Singleton.BlockedForScan;
}
public void ViewDetailsForSelectedNetwork()
{
if (this.NetworkListBox.GetSelectedNDI() == null)
return;
AppFramework.Dashboard.ShowNetworkDetailsDialog();
}
public void EditPropertiesForSelectedNetwork()
{
NetworkDisplayItem selectedNdi = this.NetworkListBox.GetSelectedNDI();
if (selectedNdi == null)
return;
AppFramework.Dashboard.ShowNetworkProperitesDialog(selectedNdi);
}
public void HandleStateChange()
{
this.UpdateUI(false);
}
public void UnregisterForEvents()
{
Eventing.DeRegisterAllUIEvents((object) this);
this.NetworkListStatusBar.Cleanup();
}
public void ConnectSelectedNetwork()
{
NetworkDisplayItem selectedNdi = this.NetworkListBox.GetSelectedNDI();
if (selectedNdi == null)
return;
DashboardAndTaskTray.ConnectToNetwork(selectedNdi);
}
public void OnAvailableNetworkListSelectionChanged(object sender, object[] eventArgs)
{
this.UpdateButtonState();
}
private void OnNetworkListChanged(object sender, object[] eventArgs)
{
this.UpdateUI(true);
}
private void OnOngoingScanNetworkListChanged(object sender, object[] eventArgs)
{
this.UpdateUI(true);
}
public void OnStateChange(object sender, object[] eventArgs)
{
this.HandleStateChange();
}
private void CustomInitializeComponents()
{
this.AccessibleName = "NetworkListPanel";
this.SearchForNetworksPushButton.AccessibleName = "NetworkListPanel_SearchForNetworksPushButton";
this.ConnectPushButton.AccessibleName = "NetworkListPanel_ConnectPushButton";
this.NetworkListMessage.AccessibleName = "NetworkListPanel_NetworkListMessage";
this.NetworkListBox.AccessibleName = "NetworkListPanel_NetworkListBox";
this.NetworkListStatusBar.AccessibleName = "NetworkListPanel_NetworkListStatusBar";
this.ButtonBoxConnect.AccessibleName = "NetworkListPanel_ButtonBoxCollapseConnect";
this.AvailableWiMAXNeworksLabel.AccessibleName = "NetworkListPanel_AvailableWiMAXNeworksLabel";
this.AvailableWiMAXNeworksLabel.Text = DashboardStringHelper.GetString("AvailableWiMAXNeworks");
this.SearchForNetworksPushButton.BtnText = DashboardStringHelper.GetString("SearchForNetworks");
this.SearchForNetworksPushButton.Pressed += new CustomButtonPush.PressedDelegate(this.OnSearchForNetworksBtnPressed);
this.ConnectPushButton.BtnText = DashboardStringHelper.GetString("Connect");
this.ConnectPushButton.Pressed += new CustomButtonPush.PressedDelegate(this.OnConnectBtnPressed);
this.NetworkListStatusBar.InitPanel();
}
private void RegisterForEvents()
{
Eventing.RegisterForUIEvent(new Eventing.EventDelegate(this.OnNetworkListChanged), (object) this, "WiMAXUI.OnNetworkListChanged");
Eventing.RegisterForUIEvent(new Eventing.EventDelegate(this.OnAvailableNetworkListSelectionChanged), (object) this, "WiMAXUI.OnAvailableNetworkListSelectionChanged");
Eventing.RegisterForUIEvent(new Eventing.EventDelegate(this.OnOngoingScanNetworkListChanged), (object) this, "WiMAXUI.OnOngoingScanNetworkListChanged");
Eventing.RegisterForUIEvent(new Eventing.EventDelegate(this.OnStateChange), (object) this, "WiMAXUI.OnStateChange");
}
private void UpdateButtonState()
{
this.UpdateSearchForNetworksPushButtonState();
this.UpdateConnectPushButtonState();
if (!this.ConnectPushButton.BtnEnabled)
this.ButtonBoxConnect.TabStop = false;
else
this.ButtonBoxConnect.TabStop = true;
}
private void UpdateConnectPushButtonState()
{
bool btnEnabled = this.ConnectPushButton.BtnEnabled;
string btnText = this.ConnectPushButton.BtnText;
this.ConnectPushButton.BtnEnabled = this.ShouldConnectButtonBeEnabled();
if (!MediaHandler.TheMedia.WiMAXIsReady || !MediaHandler.IntelCUIsInControl || (!AdapterHandler.TheAdapter.RadioIsOn() || this.NetworkListBox.GetSelectedNDI() == null) || NetworkHandler.ConnectedNetworks.Count > 0)
this.ConnectPushButton.BtnEnabled = false;
if (Intel.Mobile.WiMAXCU.BizTier.ApplicationState.Singleton.BlockedForConnect || Intel.Mobile.WiMAXCU.BizTier.ApplicationState.Singleton.BlockedForStopConnect)
{
this.ConnectPushButton.BtnText = DashboardStringHelper.GetString("StopConnecting");
this.ConnectPushButton.BtnColor = PushButtonColorEnum.BlueGrey;
}
else
{
this.ConnectPushButton.BtnText = DashboardStringHelper.GetString("Connect");
this.ConnectPushButton.BtnColor = PushButtonColorEnum.GreenGrey;
}
if (btnEnabled == this.ConnectPushButton.BtnEnabled && !(btnText != this.ConnectPushButton.BtnText))
return;
this.ConnectPushButton.ResizeMe();
this.ButtonBoxConnect.ResizeMe();
this.ConnectPushButton.Invalidate();
}
private void MakeRoomForStatusBar(int statusBarHeight)
{
if (this._normalNetworkListMessageHeight == 0)
this._normalNetworkListMessageHeight = this.NetworkListMessage.Height;
if (this._normalNetworkListBoxHeight == 0)
this._normalNetworkListBoxHeight = this.NetworkListBox.Height;
if (statusBarHeight == 0)
{
this.NetworkListBox.Height = DPIUtils.ScaleY(this._normalNetworkListBoxHeight);
this.NetworkListMessage.Height = DPIUtils.ScaleY(this._normalNetworkListMessageHeight);
}
else
{
NetworkListBox networkListBox = this.NetworkListBox;
int num1 = networkListBox.Height - statusBarHeight;
networkListBox.Height = num1;
NetworkListMessage networkListMessage = this.NetworkListMessage;
int num2 = networkListMessage.Height - statusBarHeight;
networkListMessage.Height = num2;
}
this.Invalidate(true);
}
protected void DoUpdateUI(bool recreateNetworksListbox)
{
bool flag = this.SetNetworkListMessage();
if (this.ShowStatusBar())
{
if (!this._statusBarVisible)
{
this.NetworkListStatusBar.ResetProgressBar();
this.MakeRoomForStatusBar(this.NetworkListStatusBar.Height + 2);
this.NetworkListStatusBar.Visible = true;
this._statusBarVisible = true;
}
this.NetworkListStatusBar.BringToFront();
this.NetworkListStatusBar.Invalidate();
}
else
{
this.MakeRoomForStatusBar(0);
this.NetworkListStatusBar.Visible = false;
this.NetworkListStatusBar.SendToBack();
this._statusBarVisible = false;
}
if (flag)
{
this.NetworkListBox.SendToBack();
this.NetworkListBox.TabStop = false;
this.NetworkListMessage.TabStop = false;
this.NetworkListMessage.BringToFront();
}
else
{
this.NetworkListBox.BringToFront();
this.NetworkListBox.TabStop = true;
this.NetworkListMessage.TabStop = false;
this.NetworkListMessage.SendToBack();
}
this.NetworkListBox.UpdateUI(NetworkHandler.AvailableNetworks, recreateNetworksListbox);
this.UpdateButtonState();
}
protected override void Dispose(bool disposing)
{
Eventing.DeRegisterAllUIEvents((object) this);
if (disposing && this.components != null)
this.components.Dispose();
base.Dispose(disposing);
}
private void InitializeComponent()
{
ComponentResourceManager componentResourceManager = new ComponentResourceManager(typeof (NetworkListPanel));
this.ButtonBoxConnect = new CustomButtonPushHorizBox();
this.ConnectPushButton = new CustomButtonPush();
this.SearchForNetworksPushButton = new CustomButtonPush();
this.AvailableWiMAXNeworksLabel = new Label();
this.NetworkListStatusBar = new NetworkListStatusBar();
this.NetworkListMessage = new NetworkListMessage();
this.NetworkListBox = new NetworkListBox();
this.ButtonBoxConnect.SuspendLayout();
this.SuspendLayout();
this.ButtonBoxConnect.Controls.Add((Control) this.ConnectPushButton);
componentResourceManager.ApplyResources((object) this.ButtonBoxConnect, "ButtonBoxConnect");
this.ButtonBoxConnect.HorizontalJustification = HorizontalJustificationEnum.Right;
this.ButtonBoxConnect.Name = "ButtonBoxConnect";
this.ConnectPushButton.BackColor = Color.Transparent;
this.ConnectPushButton.BtnColor = PushButtonColorEnum.GreenGrey;
this.ConnectPushButton.BtnDoubleEndCaps = true;
this.ConnectPushButton.BtnEnabled = true;
componentResourceManager.ApplyResources((object) this.ConnectPushButton, "ConnectPushButton");
this.ConnectPushButton.Name = "ConnectPushButton";
this.SearchForNetworksPushButton.BackColor = Color.Transparent;
this.SearchForNetworksPushButton.BtnColor = PushButtonColorEnum.BlueGrey;
this.SearchForNetworksPushButton.BtnDoubleEndCaps = false;
this.SearchForNetworksPushButton.BtnEnabled = true;
componentResourceManager.ApplyResources((object) this.SearchForNetworksPushButton, "SearchForNetworksPushButton");
this.SearchForNetworksPushButton.Name = "SearchForNetworksPushButton";
componentResourceManager.ApplyResources((object) this.AvailableWiMAXNeworksLabel, "AvailableWiMAXNeworksLabel");
this.AvailableWiMAXNeworksLabel.Name = "AvailableWiMAXNeworksLabel";
componentResourceManager.ApplyResources((object) this.NetworkListStatusBar, "NetworkListStatusBar");
this.NetworkListStatusBar.BackColor = Color.WhiteSmoke;
this.NetworkListStatusBar.Name = "NetworkListStatusBar";
this.NetworkListStatusBar.TabStop = false;
componentResourceManager.ApplyResources((object) this.NetworkListMessage, "NetworkListMessage");
this.NetworkListMessage.BackColor = Color.WhiteSmoke;
this.NetworkListMessage.ForeColor = Color.Black;
this.NetworkListMessage.Name = "NetworkListMessage";
this.NetworkListMessage.TabStop = false;
componentResourceManager.ApplyResources((object) this.NetworkListBox, "NetworkListBox");
this.NetworkListBox.BackColor = Color.White;
this.NetworkListBox.Name = "NetworkListBox";
this.BackColor = Color.White;
this.Controls.Add((Control) this.AvailableWiMAXNeworksLabel);
this.Controls.Add((Control) this.NetworkListStatusBar);
this.Controls.Add((Control) this.ButtonBoxConnect);
this.Controls.Add((Control) this.SearchForNetworksPushButton);
this.Controls.Add((Control) this.NetworkListMessage);
this.Controls.Add((Control) this.NetworkListBox);
componentResourceManager.ApplyResources((object) this, "$this");
this.Name = "NetworkListPanel";
this.ButtonBoxConnect.ResumeLayout(false);
this.ResumeLayout(false);
this.PerformLayout();
}
}
}