-
Notifications
You must be signed in to change notification settings - Fork 0
/
ConnectionSubDetailUptime.cs
153 lines (137 loc) · 6.3 KB
/
ConnectionSubDetailUptime.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
// Type: Intel.Mobile.WiMAXCU.UI.Dashboard.ConnectionSubDetailUptime
// 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 System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
namespace Intel.Mobile.WiMAXCU.UI.Dashboard
{
public class ConnectionSubDetailUptime : UserControl
{
private static TimeSpan _connectedTime = new TimeSpan();
private static string _connectedTimeStr = "";
private Label UptimeLabel;
private IContainer components;
private Timer _updateTimeConnectedTimer;
public static string ConnectedTime
{
get
{
return ConnectionSubDetailUptime._connectedTimeStr;
}
set
{
ConnectionSubDetailUptime._connectedTimeStr = value;
}
}
static ConnectionSubDetailUptime()
{
}
public ConnectionSubDetailUptime()
{
this.InitializeComponent();
this.CustomInitializeComponents();
this.RegisterForEvents();
this.SetStyle(ControlStyles.SupportsTransparentBackColor, true);
this.BackColor = Color.Transparent;
this.StartOrStopTimer();
}
private void InitializeComponent()
{
ComponentResourceManager componentResourceManager = new ComponentResourceManager(typeof (ConnectionSubDetailUptime));
this.UptimeLabel = new Label();
this.SuspendLayout();
componentResourceManager.ApplyResources((object) this.UptimeLabel, "UptimeLabel");
this.UptimeLabel.Name = "UptimeLabel";
this.Controls.Add((Control) this.UptimeLabel);
componentResourceManager.ApplyResources((object) this, "$this");
this.Name = "ConnectionSubDetailUptime";
this.ResumeLayout(false);
}
protected override void Dispose(bool disposing)
{
if (disposing)
{
if (this.components != null)
this.components.Dispose();
Eventing.DeRegisterAllUIEvents((object) this);
if (this._updateTimeConnectedTimer != null)
this._updateTimeConnectedTimer.Stop();
}
base.Dispose(disposing);
}
protected override void OnVisibleChanged(EventArgs e)
{
if (this.Visible)
this.ResetTimeConnected();
base.OnVisibleChanged(e);
}
private void StartOrStopTimer()
{
if (this._updateTimeConnectedTimer == null)
{
this._updateTimeConnectedTimer = new Timer();
this._updateTimeConnectedTimer.Tick += new EventHandler(this.OnUpdateTimeConnectedTick);
this._updateTimeConnectedTimer.Interval = TimerSettings.ConnectionSubDetailUptime_UpdateTimeConnectedTimer_Interval;
}
if (MediaHandler.TheMedia.WiMAXIsReady && MediaHandler.IntelCUIsInControl && (AdapterHandler.TheAdapter.RadioIsOn() && NetworkHandler.ConnectedNetworks.Count > 0))
this._updateTimeConnectedTimer.Start();
else
this._updateTimeConnectedTimer.Stop();
}
private void OnUpdateTimeConnectedTick(object sender, EventArgs e)
{
if (NetworkHandler.ConnectedNetworks.Count == 0)
return;
ConnectionSubDetailUptime._connectedTime = ConnectionSubDetailUptime._connectedTime.Add(new TimeSpan(0, 0, 1));
if (this.Parent == null || !this.Parent.Visible)
return;
this.UpdateUI();
}
public void OnNetworkListChanged(object sender, object[] eventArgs)
{
this.ResetTimeConnected();
this.StartOrStopTimer();
}
public void OnSomethingChanged(object sender, object[] eventArgs)
{
this.StartOrStopTimer();
}
public void UpdateUI()
{
if (ConnectionSubDetailUptime._connectedTime.Days == 0)
ConnectionSubDetailUptime._connectedTimeStr = string.Format(DashboardStringHelper.GetString("UptimeFormat"), (object) ConnectionSubDetailUptime._connectedTime.Hours, (object) ConnectionSubDetailUptime._connectedTime.Minutes, (object) ConnectionSubDetailUptime._connectedTime.Seconds);
else if (ConnectionSubDetailUptime._connectedTime.Days == 1)
ConnectionSubDetailUptime._connectedTimeStr = string.Format(DashboardStringHelper.GetString("UptimeFormatOneDay"), (object) ConnectionSubDetailUptime._connectedTime.Hours, (object) ConnectionSubDetailUptime._connectedTime.Minutes, (object) ConnectionSubDetailUptime._connectedTime.Seconds);
else
ConnectionSubDetailUptime._connectedTimeStr = string.Format(DashboardStringHelper.GetString("UptimeFormatXDays"), (object) ConnectionSubDetailUptime._connectedTime.Days, (object) ConnectionSubDetailUptime._connectedTime.Hours, (object) ConnectionSubDetailUptime._connectedTime.Minutes, (object) ConnectionSubDetailUptime._connectedTime.Seconds);
this.UptimeLabel.Text = ConnectionSubDetailUptime._connectedTimeStr;
}
private void CustomInitializeComponents()
{
this.AccessibleName = "ConnectionSubDetailUptime";
this.UptimeLabel.AccessibleName = "ConnectionPanel_ConnectionSubDetailUptime_UptimeLabel";
}
private void RegisterForEvents()
{
Eventing.RegisterForUIEvent(new Eventing.EventDelegate(this.OnNetworkListChanged), (object) this, "WiMAXUI.OnNetworkListChanged");
Eventing.RegisterForUIEvent(new Eventing.EventDelegate(this.OnSomethingChanged), (object) this, "WiMAXUI.OnMediaStatusChanged");
Eventing.RegisterForUIEvent(new Eventing.EventDelegate(this.OnSomethingChanged), (object) this, "WiMAXUI.OnAdapterListChanged");
Eventing.RegisterForUIEvent(new Eventing.EventDelegate(this.OnSomethingChanged), (object) this, "WiMAXUI.OnIntelCUControlChanged");
Eventing.RegisterForUIEvent(new Eventing.EventDelegate(this.OnSomethingChanged), (object) this, "WiMAXUI.OnPostInitApplication");
}
private void ResetTimeConnected()
{
int numSecondsConnected = 0;
NetworkHandler.Singleton.GetConnectionTime(ref numSecondsConnected);
if (NetworkHandler.ConnectedNetworks.Count == 1)
ConnectionSubDetailUptime._connectedTime = new TimeSpan(0, 0, numSecondsConnected);
else
ConnectionSubDetailUptime._connectedTime = new TimeSpan(0, 0, 0);
}
}
}