Commit | Line | Data |
---|---|---|
491f6e3b | 1 | using System; |
491f6e3b | 2 | using SpeedportHybridControl.Implementations; |
491f6e3b | 3 | using System.Windows.Controls; |
5907d368 | 4 | using SpeedportHybridControl.page; |
c60797cb | 5 | using System.Windows.Media; |
bd99ec80 S |
6 | using System.Threading; |
7 | using SpeedportHybridControl.Data; | |
bee257dd | 8 | using SpeedportHybridControl.Model; |
a8e0f728 | 9 | using System.Windows; |
491f6e3b | 10 | |
bee257dd | 11 | namespace SpeedportHybridControl.PageModel { |
491f6e3b | 12 | class MainWindowModel : SuperViewModel { |
a8e0f728 S |
13 | public const string VERSION = "1.0-pre9"; //TODO: change this later |
14 | ||
3fcd2f96 S |
15 | private string _loginButtonContent = "Login"; |
16 | ||
491f6e3b S |
17 | private DelegateCommand _switchToLoginPage; |
18 | private DelegateCommand _switchToStatusPage; | |
19 | private DelegateCommand _switchToOverviewPage; | |
20 | private DelegateCommand _switchToDSLPage; | |
21 | private DelegateCommand _switchToLteInfoPage; | |
22 | private DelegateCommand _switchToSyslogPage; | |
23 | private DelegateCommand _switchToTR181Page; | |
24 | private DelegateCommand _switchToPhonePage; | |
25 | private DelegateCommand _switchToLanPage; | |
26 | private DelegateCommand _switchToControlsPage; | |
27 | private DelegateCommand _sitchToAboutPage; | |
28 | ||
5907d368 | 29 | private bool _buttonOverviewPageIsActive = false; |
491f6e3b | 30 | private bool _buttonDSLPageIsActive = false; |
5907d368 S |
31 | private bool _buttonLteInfoPageIsActive = false; |
32 | private bool _buttonSyslogPageIsActive = false; | |
33 | private bool _buttonTR181PageIsActive = false; | |
34 | private bool _buttonPhonePageIsActive = false; | |
35 | private bool _buttonLanPageIsActive = false; | |
36 | private bool _buttonControlsPageIsActive = false; | |
37 | ||
c60797cb S |
38 | private Brush _buttonLoginPageBackground = Brushes.LightGray; |
39 | private Brush _buttonStatusPageBackground = Brushes.LightGray; | |
40 | private Brush _buttonOverviewPageBackground = Brushes.LightGray; | |
41 | private Brush _buttonDSLPageBackground = Brushes.LightGray; | |
42 | private Brush _buttonLteInfoPageBackground = Brushes.LightGray; | |
43 | private Brush _buttonSyslogPageBackground = Brushes.LightGray; | |
44 | private Brush _buttonTR181PageBackground = Brushes.LightGray; | |
45 | private Brush _buttonPhonePageBackground = Brushes.LightGray; | |
46 | private Brush _buttonLanPageBackground = Brushes.LightGray; | |
47 | private Brush _buttonControlsPageBackground = Brushes.LightGray; | |
48 | private Brush _buttonAboutPageBackground = Brushes.LightGray; | |
49 | ||
5907d368 | 50 | private Page _FrameSource; |
491f6e3b | 51 | |
3fcd2f96 S |
52 | public string LoginButtonContent { |
53 | get { return _loginButtonContent; } | |
54 | set { SetProperty(ref _loginButtonContent, value); } | |
55 | } | |
56 | ||
491f6e3b S |
57 | public DelegateCommand SwitchToLoginPage { |
58 | get { return _switchToLoginPage; } | |
59 | set { SetProperty(ref _switchToLoginPage, value); } | |
60 | } | |
61 | ||
62 | public DelegateCommand SwitchToStatusPage { | |
63 | get { return _switchToStatusPage; } | |
64 | set { SetProperty(ref _switchToStatusPage, value); } | |
65 | } | |
66 | ||
67 | public DelegateCommand SwitchToOverviewPage { | |
68 | get { return _switchToOverviewPage; } | |
69 | set { SetProperty(ref _switchToOverviewPage, value); } | |
70 | } | |
71 | ||
72 | public DelegateCommand SwitchToDSLPage { | |
73 | get { return _switchToDSLPage; } | |
74 | set { SetProperty(ref _switchToDSLPage, value); } | |
75 | } | |
76 | ||
77 | public DelegateCommand SwitchToLteInfoPage { | |
78 | get { return _switchToLteInfoPage; } | |
79 | set { SetProperty(ref _switchToLteInfoPage, value); } | |
80 | } | |
81 | ||
82 | public DelegateCommand SwitchToSyslogPage { | |
83 | get { return _switchToSyslogPage; } | |
84 | set { SetProperty(ref _switchToSyslogPage, value); } | |
85 | } | |
86 | ||
87 | public DelegateCommand SwitchToTR181Page { | |
88 | get { return _switchToTR181Page; } | |
89 | set { SetProperty(ref _switchToTR181Page, value); } | |
90 | } | |
91 | ||
92 | public DelegateCommand SwitchToPhonePage { | |
93 | get { return _switchToPhonePage; } | |
94 | set { SetProperty(ref _switchToPhonePage, value); } | |
95 | } | |
96 | ||
97 | public DelegateCommand SwitchToLanPage { | |
98 | get { return _switchToLanPage; } | |
99 | set { SetProperty(ref _switchToLanPage, value); } | |
100 | } | |
101 | ||
102 | public DelegateCommand SwitchToControlsPage { | |
103 | get { return _switchToControlsPage; } | |
104 | set { SetProperty(ref _switchToControlsPage, value); } | |
105 | } | |
106 | ||
107 | public DelegateCommand SwitchToAboutPage { | |
108 | get { return _sitchToAboutPage; } | |
109 | set { SetProperty(ref _sitchToAboutPage, value); } | |
110 | } | |
111 | ||
5907d368 S |
112 | public bool ButtonOverviewPageIsActive { |
113 | get { return _buttonOverviewPageIsActive; } | |
114 | set { SetProperty(ref _buttonOverviewPageIsActive, value); } | |
115 | } | |
116 | ||
491f6e3b S |
117 | public bool ButtonDSLPageIsActive { |
118 | get { return _buttonDSLPageIsActive; } | |
119 | set { SetProperty(ref _buttonDSLPageIsActive, value); } | |
120 | } | |
121 | ||
5907d368 S |
122 | public bool ButtonLteInfoPageIsActive { |
123 | get { return _buttonLteInfoPageIsActive; } | |
124 | set { SetProperty(ref _buttonLteInfoPageIsActive, value); } | |
125 | } | |
126 | ||
127 | public bool ButtonSyslogPageIsActive { | |
128 | get { return _buttonSyslogPageIsActive; } | |
129 | set { SetProperty(ref _buttonSyslogPageIsActive, value); } | |
130 | } | |
131 | ||
132 | public bool ButtonTR181PageIsActive { | |
133 | get { return _buttonTR181PageIsActive; } | |
134 | set { SetProperty(ref _buttonTR181PageIsActive, value); } | |
135 | } | |
136 | ||
137 | public bool ButtonPhonePageIsActive { | |
138 | get { return _buttonPhonePageIsActive; } | |
139 | set { SetProperty(ref _buttonPhonePageIsActive, value); } | |
140 | } | |
141 | ||
142 | public bool ButtonLanPageIsActive { | |
143 | get { return _buttonLanPageIsActive; } | |
144 | set { SetProperty(ref _buttonLanPageIsActive, value); } | |
145 | } | |
146 | ||
147 | public bool ButtonControlsPageIsActive { | |
148 | get { return _buttonControlsPageIsActive; } | |
149 | set { SetProperty(ref _buttonControlsPageIsActive, value); } | |
150 | } | |
151 | ||
c60797cb S |
152 | public Brush ButtonLoginPageBackground { |
153 | get { return _buttonLoginPageBackground; } | |
154 | set { SetProperty(ref _buttonLoginPageBackground, value); } | |
155 | } | |
156 | ||
157 | public Brush ButtonStatusPageBackground { | |
158 | get { return _buttonStatusPageBackground; } | |
159 | set { SetProperty(ref _buttonStatusPageBackground, value); } | |
160 | } | |
161 | ||
162 | public Brush ButtonOverviewPageBackground { | |
163 | get { return _buttonOverviewPageBackground; } | |
164 | set { SetProperty(ref _buttonOverviewPageBackground, value); } | |
165 | } | |
166 | ||
167 | public Brush ButtonDSLPageBackground { | |
168 | get { return _buttonDSLPageBackground; } | |
169 | set { SetProperty(ref _buttonDSLPageBackground, value); } | |
170 | } | |
171 | ||
172 | public Brush ButtonLteInfoPageBackground { | |
173 | get { return _buttonLteInfoPageBackground; } | |
174 | set { SetProperty(ref _buttonLteInfoPageBackground, value); } | |
175 | } | |
176 | ||
177 | public Brush ButtonSyslogPageBackground { | |
178 | get { return _buttonSyslogPageBackground; } | |
179 | set { SetProperty(ref _buttonSyslogPageBackground, value); } | |
180 | } | |
181 | ||
182 | public Brush ButtonTR181PageBackground { | |
183 | get { return _buttonTR181PageBackground; } | |
184 | set { SetProperty(ref _buttonTR181PageBackground, value); } | |
185 | } | |
186 | ||
187 | public Brush ButtonPhonePageBackground { | |
188 | get { return _buttonPhonePageBackground; } | |
189 | set { SetProperty(ref _buttonPhonePageBackground, value); } | |
190 | } | |
191 | ||
192 | public Brush ButtonLanPageBackground { | |
193 | get { return _buttonLanPageBackground; } | |
194 | set { SetProperty(ref _buttonLanPageBackground, value); } | |
195 | } | |
196 | ||
197 | public Brush ButtonControlsPageBackground { | |
198 | get { return _buttonControlsPageBackground; } | |
199 | set { SetProperty(ref _buttonControlsPageBackground, value); } | |
200 | } | |
201 | ||
202 | public Brush ButtonAboutPageBackground { | |
203 | get { return _buttonAboutPageBackground; } | |
204 | set { SetProperty(ref _buttonAboutPageBackground, value); } | |
205 | } | |
206 | ||
491f6e3b S |
207 | public Page FrameSource { |
208 | get { return _FrameSource; } | |
209 | set { SetProperty(ref _FrameSource, value); } | |
210 | } | |
211 | ||
5907d368 | 212 | private void OnSwitchToLoginPageExecute () { |
de3d004c | 213 | changePage("login"); |
491f6e3b S |
214 | } |
215 | ||
5907d368 | 216 | private void OnSwitchToStatusPageExecute () { |
de3d004c | 217 | changePage("status"); |
bd99ec80 | 218 | new Thread(() => { SpeedportHybrid.initStatus(); }).Start(); |
5907d368 S |
219 | } |
220 | ||
221 | private void OnSwitchToOverviewPageExecute () { | |
de3d004c S |
222 | changePage("overview"); |
223 | new Thread(() => { SpeedportHybrid.initOverview(); }).Start(); | |
491f6e3b S |
224 | } |
225 | ||
226 | private void OnSwitchToDSLPageExecute () { | |
de3d004c S |
227 | changePage("dsl"); |
228 | new Thread(() => { SpeedportHybrid.initDSL(); }).Start(); | |
5907d368 S |
229 | } |
230 | ||
231 | private void OnSwitchToLteInfoPageExecute () { | |
de3d004c S |
232 | changePage("lte"); |
233 | new Thread(() => { SpeedportHybrid.initLTE(); }).Start(); | |
5907d368 S |
234 | } |
235 | ||
236 | private void OnSwitchToSyslogPageExecute () { | |
de3d004c S |
237 | changePage("syslog"); |
238 | new Thread(() => { SpeedportHybrid.initSyslog(); }).Start(); | |
491f6e3b S |
239 | } |
240 | ||
5907d368 | 241 | private void OnSwitchToTR181PageExecute () { |
de3d004c S |
242 | changePage("tr181"); |
243 | new Thread(() => { SpeedportHybrid.initTR181(); }).Start(); | |
5907d368 S |
244 | } |
245 | ||
246 | private void OnSwitchToPhonePageExecute () { | |
de3d004c S |
247 | changePage("phone"); |
248 | new Thread(() => { SpeedportHybrid.initPhone(); }).Start(); | |
5907d368 S |
249 | } |
250 | ||
251 | private void OnSwitchToLanPageExecute () { | |
de3d004c S |
252 | changePage("lan"); |
253 | new Thread(() => { SpeedportHybrid.initLan(); }).Start(); | |
5907d368 | 254 | } |
491f6e3b | 255 | |
5907d368 | 256 | private void OnSwitchToControlsPageExecute () { |
de3d004c | 257 | changePage("controls"); |
491f6e3b S |
258 | } |
259 | ||
5907d368 | 260 | private void OnSwitchToAboutPageExecute () { |
de3d004c | 261 | changePage("about"); |
5907d368 | 262 | } |
c60797cb | 263 | |
de3d004c S |
264 | private void changePage (string page) { |
265 | if (object.Equals(FrameSource, null).Equals(false)) { | |
6c89a163 S |
266 | Console.WriteLine("HERE!!!"); |
267 | if (FrameSource.GetType().Equals(typeof(LteInfoPage))) { | |
de3d004c S |
268 | // TODO: lteInfoPage.StopTimer(); |
269 | } | |
270 | ||
6c89a163 S |
271 | if (FrameSource.GetType().Equals(typeof(DslPage))) { |
272 | DslPageModel dsl = Application.Current.FindResource("DslPageModel") as DslPageModel; | |
273 | dsl.StopTimer(); | |
de3d004c S |
274 | } |
275 | } | |
276 | ||
277 | if (page.Equals("login")) { | |
278 | FrameSource = new LoginPage(); | |
279 | } | |
280 | else if (page.Equals("status")) { | |
281 | FrameSource = new StatusPage(); | |
282 | } | |
283 | else if (page.Equals("overview")) { | |
284 | FrameSource = new OverviewPage(); | |
285 | } | |
286 | else if (page.Equals("dsl")) { | |
287 | FrameSource = new DslPage(); | |
288 | } | |
289 | else if (page.Equals("lte")) { | |
290 | FrameSource = new LteInfoPage(); | |
291 | } | |
292 | else if (page.Equals("syslog")) { | |
293 | FrameSource = new SyslogPage(); | |
294 | } | |
295 | else if (page.Equals("tr181")) { | |
296 | FrameSource = new TR181Page(); | |
297 | } | |
298 | else if (page.Equals("phone")) { | |
299 | FrameSource = new PhonePage(); | |
300 | } | |
301 | else if (page.Equals("lan")) { | |
302 | FrameSource = new LanPage(); | |
303 | } | |
304 | else if (page.Equals("controls")) { | |
305 | FrameSource = new ControlsPage(); | |
306 | } | |
307 | else if (page.Equals("about")) { | |
308 | FrameSource = new AboutPage(); | |
309 | } | |
310 | ||
311 | changeColor(page); | |
312 | } | |
313 | ||
314 | private void changeColor (string page) { | |
c60797cb S |
315 | ButtonLoginPageBackground = Brushes.LightGray; |
316 | ButtonStatusPageBackground = Brushes.LightGray; | |
317 | ButtonOverviewPageBackground = Brushes.LightGray; | |
318 | ButtonDSLPageBackground = Brushes.LightGray; | |
319 | ButtonLteInfoPageBackground = Brushes.LightGray; | |
320 | ButtonSyslogPageBackground = Brushes.LightGray; | |
321 | ButtonTR181PageBackground = Brushes.LightGray; | |
322 | ButtonPhonePageBackground = Brushes.LightGray; | |
323 | ButtonLanPageBackground = Brushes.LightGray; | |
324 | ButtonControlsPageBackground = Brushes.LightGray; | |
325 | ButtonAboutPageBackground = Brushes.LightGray; | |
326 | ||
de3d004c | 327 | if (page.Equals("login")) { |
c60797cb S |
328 | ButtonLoginPageBackground = Brushes.LightGreen; |
329 | } | |
330 | ||
de3d004c | 331 | if (page.Equals("status")) { |
c60797cb S |
332 | ButtonStatusPageBackground = Brushes.LightGreen; |
333 | } | |
334 | ||
de3d004c | 335 | if (page.Equals("overview")) { |
c60797cb S |
336 | ButtonOverviewPageBackground = Brushes.LightGreen; |
337 | } | |
338 | ||
de3d004c | 339 | if (page.Equals("dsl")) { |
c60797cb S |
340 | ButtonDSLPageBackground = Brushes.LightGreen; |
341 | } | |
342 | ||
de3d004c | 343 | if (page.Equals("lte")) { |
c60797cb S |
344 | ButtonLteInfoPageBackground = Brushes.LightGreen; |
345 | } | |
346 | ||
de3d004c | 347 | if (page.Equals("syslog")) { |
c60797cb S |
348 | ButtonSyslogPageBackground = Brushes.LightGreen; |
349 | } | |
350 | ||
de3d004c | 351 | if (page.Equals("tr181")) { |
c60797cb S |
352 | ButtonTR181PageBackground = Brushes.LightGreen; |
353 | } | |
354 | ||
de3d004c | 355 | if (page.Equals("phone")) { |
c60797cb S |
356 | ButtonPhonePageBackground = Brushes.LightGreen; |
357 | } | |
358 | ||
de3d004c | 359 | if (page.Equals("lan")) { |
c60797cb S |
360 | ButtonLanPageBackground = Brushes.LightGreen; |
361 | } | |
362 | ||
de3d004c | 363 | if (page.Equals("controls")) { |
c60797cb S |
364 | ButtonControlsPageBackground = Brushes.LightGreen; |
365 | } | |
366 | ||
de3d004c | 367 | if (page.Equals("about")) { |
c60797cb S |
368 | ButtonAboutPageBackground = Brushes.LightGreen; |
369 | } | |
370 | } | |
371 | ||
491f6e3b | 372 | public MainWindowModel () { |
a8e0f728 S |
373 | if (util.checkInstalled("Microsoft Visual C++ 2010 x86 Redistributable - 10.0.40219").Equals(false)) { |
374 | new Thread(() => { MessageBox.Show("Bitte installiere das 'Microsoft Visual C++ 2010 Redistributable Package' aus den ordner 'vcredis' um das programm vollständig benutzen zu können.", "Confirmation", MessageBoxButton.OK, MessageBoxImage.Warning); }).Start(); | |
375 | } | |
376 | ||
377 | if (util.checkUpdate(VERSION).Equals(true)) { | |
378 | new Thread(() => { MessageBox.Show("Ein Update ist verfügbar.", "Confirmation", MessageBoxButton.OK, MessageBoxImage.Warning); }).Start(); | |
379 | } | |
380 | ||
381 | ||
de3d004c | 382 | changePage("login"); |
5907d368 S |
383 | |
384 | SwitchToLoginPage = new DelegateCommand(new Action(OnSwitchToLoginPageExecute)); | |
385 | SwitchToStatusPage = new DelegateCommand(new Action(OnSwitchToStatusPageExecute)); | |
386 | SwitchToOverviewPage = new DelegateCommand(new Action(OnSwitchToOverviewPageExecute)); | |
491f6e3b | 387 | SwitchToDSLPage = new DelegateCommand(new Action(OnSwitchToDSLPageExecute)); |
5907d368 S |
388 | SwitchToLteInfoPage = new DelegateCommand(new Action(OnSwitchToLteInfoPageExecute)); |
389 | SwitchToSyslogPage = new DelegateCommand(new Action(OnSwitchToSyslogPageExecute)); | |
390 | SwitchToTR181Page = new DelegateCommand(new Action(OnSwitchToTR181PageExecute)); | |
391 | SwitchToPhonePage = new DelegateCommand(new Action(OnSwitchToPhonePageExecute)); | |
392 | SwitchToLanPage = new DelegateCommand(new Action(OnSwitchToLanPageExecute)); | |
393 | SwitchToControlsPage = new DelegateCommand(new Action(OnSwitchToControlsPageExecute)); | |
491f6e3b S |
394 | |
395 | SwitchToAboutPage = new DelegateCommand(new Action(OnSwitchToAboutPageExecute)); | |
396 | } | |
397 | } | |
398 | } |