update version number
[GitHub/Stricted/SpeedportHybridControl.git] / SpeedportHybridControl / PageModel / MainWindowModel.cs
CommitLineData
491f6e3b 1using System;
491f6e3b 2using SpeedportHybridControl.Implementations;
491f6e3b 3using System.Windows.Controls;
5907d368 4using SpeedportHybridControl.page;
c60797cb 5using System.Windows.Media;
bd99ec80
S
6using System.Threading;
7using SpeedportHybridControl.Data;
bee257dd 8using SpeedportHybridControl.Model;
a8e0f728 9using System.Windows;
491f6e3b 10
a5a62e8d
S
11namespace SpeedportHybridControl.PageModel
12{
13 class MainWindowModel : SuperViewModel
14 {
370dc052 15 public const string VERSION = "1.0-pre13";
a5a62e8d
S
16
17 private string _loginButtonContent = "Login";
18
19 private DelegateCommand _switchToLoginPage;
20 private DelegateCommand _switchToStatusPage;
21 private DelegateCommand _switchToOverviewPage;
22 private DelegateCommand _switchToDSLPage;
23 private DelegateCommand _switchToLteInfoPage;
24 private DelegateCommand _switchToSyslogPage;
25 private DelegateCommand _switchToTR181Page;
26 private DelegateCommand _switchToPhonePage;
27 private DelegateCommand _switchToLanPage;
28 private DelegateCommand _switchToInterfacePage;
29 private DelegateCommand _switchToControlsPage;
30 private DelegateCommand _sitchToAboutPage;
31
32 private bool _buttonOverviewPageIsActive = false;
33 private bool _buttonDSLPageIsActive = false;
34 private bool _buttonLteInfoPageIsActive = false;
35 private bool _buttonSyslogPageIsActive = false;
36 private bool _buttonTR181PageIsActive = false;
37 private bool _buttonPhonePageIsActive = false;
38 private bool _buttonLanPageIsActive = false;
39 private bool _buttonInterfacePageIsActive = false;
40 private bool _buttonControlsPageIsActive = false;
41
42 private Brush _buttonLoginPageBackground = Brushes.LightGray;
43 private Brush _buttonStatusPageBackground = Brushes.LightGray;
44 private Brush _buttonOverviewPageBackground = Brushes.LightGray;
45 private Brush _buttonDSLPageBackground = Brushes.LightGray;
46 private Brush _buttonLteInfoPageBackground = Brushes.LightGray;
47 private Brush _buttonSyslogPageBackground = Brushes.LightGray;
48 private Brush _buttonTR181PageBackground = Brushes.LightGray;
49 private Brush _buttonPhonePageBackground = Brushes.LightGray;
50 private Brush _buttonLanPageBackground = Brushes.LightGray;
51 private Brush _buttonInterfacePageBackground = Brushes.LightGray;
52 private Brush _buttonControlsPageBackground = Brushes.LightGray;
53 private Brush _buttonAboutPageBackground = Brushes.LightGray;
54
55 private Page _FrameSource;
56
57 private string _title;
58
59 public string LoginButtonContent
60 {
61 get { return _loginButtonContent; }
62 set { SetProperty(ref _loginButtonContent, value); }
63 }
64
65 public DelegateCommand SwitchToLoginPage
66 {
67 get { return _switchToLoginPage; }
68 set { SetProperty(ref _switchToLoginPage, value); }
69 }
70
71 public DelegateCommand SwitchToStatusPage
72 {
73 get { return _switchToStatusPage; }
74 set { SetProperty(ref _switchToStatusPage, value); }
75 }
76
77 public DelegateCommand SwitchToOverviewPage
78 {
79 get { return _switchToOverviewPage; }
80 set { SetProperty(ref _switchToOverviewPage, value); }
81 }
82
83 public DelegateCommand SwitchToDSLPage
84 {
85 get { return _switchToDSLPage; }
86 set { SetProperty(ref _switchToDSLPage, value); }
87 }
88
89 public DelegateCommand SwitchToLteInfoPage
90 {
91 get { return _switchToLteInfoPage; }
92 set { SetProperty(ref _switchToLteInfoPage, value); }
93 }
94
95 public DelegateCommand SwitchToSyslogPage
96 {
97 get { return _switchToSyslogPage; }
98 set { SetProperty(ref _switchToSyslogPage, value); }
99 }
100
101 public DelegateCommand SwitchToTR181Page
102 {
103 get { return _switchToTR181Page; }
104 set { SetProperty(ref _switchToTR181Page, value); }
105 }
106
107 public DelegateCommand SwitchToPhonePage
108 {
109 get { return _switchToPhonePage; }
110 set { SetProperty(ref _switchToPhonePage, value); }
111 }
112
113 public DelegateCommand SwitchToLanPage
114 {
115 get { return _switchToLanPage; }
116 set { SetProperty(ref _switchToLanPage, value); }
117 }
118
119 public DelegateCommand SwitchToInterfacePage
120 {
121 get { return _switchToInterfacePage; }
122 set { SetProperty(ref _switchToInterfacePage, value); }
123 }
124
125 public DelegateCommand SwitchToControlsPage
126 {
127 get { return _switchToControlsPage; }
128 set { SetProperty(ref _switchToControlsPage, value); }
129 }
130
131 public DelegateCommand SwitchToAboutPage
132 {
133 get { return _sitchToAboutPage; }
134 set { SetProperty(ref _sitchToAboutPage, value); }
135 }
136
137 public bool ButtonOverviewPageIsActive
138 {
139 get { return _buttonOverviewPageIsActive; }
140 set { SetProperty(ref _buttonOverviewPageIsActive, value); }
141 }
142
143 public bool ButtonDSLPageIsActive
144 {
145 get { return _buttonDSLPageIsActive; }
146 set { SetProperty(ref _buttonDSLPageIsActive, value); }
147 }
148
149 public bool ButtonLteInfoPageIsActive
150 {
151 get { return _buttonLteInfoPageIsActive; }
152 set { SetProperty(ref _buttonLteInfoPageIsActive, value); }
153 }
154
155 public bool ButtonSyslogPageIsActive
156 {
157 get { return _buttonSyslogPageIsActive; }
158 set { SetProperty(ref _buttonSyslogPageIsActive, value); }
159 }
160
161 public bool ButtonTR181PageIsActive
162 {
163 get { return _buttonTR181PageIsActive; }
164 set { SetProperty(ref _buttonTR181PageIsActive, value); }
165 }
166
167 public bool ButtonPhonePageIsActive
168 {
169 get { return _buttonPhonePageIsActive; }
170 set { SetProperty(ref _buttonPhonePageIsActive, value); }
171 }
172
173 public bool ButtonLanPageIsActive
174 {
175 get { return _buttonLanPageIsActive; }
176 set { SetProperty(ref _buttonLanPageIsActive, value); }
177 }
178
179 public bool ButtonInterfacePageIsActive
180 {
181 get { return _buttonInterfacePageIsActive; }
182 set { SetProperty(ref _buttonInterfacePageIsActive, value); }
183 }
184
185 public bool ButtonControlsPageIsActive
186 {
187 get { return _buttonControlsPageIsActive; }
188 set { SetProperty(ref _buttonControlsPageIsActive, value); }
189 }
190
191 public Brush ButtonLoginPageBackground
192 {
193 get { return _buttonLoginPageBackground; }
194 set { SetProperty(ref _buttonLoginPageBackground, value); }
195 }
196
197 public Brush ButtonStatusPageBackground
198 {
199 get { return _buttonStatusPageBackground; }
200 set { SetProperty(ref _buttonStatusPageBackground, value); }
201 }
202
203 public Brush ButtonOverviewPageBackground
204 {
205 get { return _buttonOverviewPageBackground; }
206 set { SetProperty(ref _buttonOverviewPageBackground, value); }
207 }
208
209 public Brush ButtonDSLPageBackground
210 {
211 get { return _buttonDSLPageBackground; }
212 set { SetProperty(ref _buttonDSLPageBackground, value); }
213 }
214
215 public Brush ButtonLteInfoPageBackground
216 {
217 get { return _buttonLteInfoPageBackground; }
218 set { SetProperty(ref _buttonLteInfoPageBackground, value); }
219 }
220
221 public Brush ButtonSyslogPageBackground
222 {
223 get { return _buttonSyslogPageBackground; }
224 set { SetProperty(ref _buttonSyslogPageBackground, value); }
225 }
226
227 public Brush ButtonTR181PageBackground
228 {
229 get { return _buttonTR181PageBackground; }
230 set { SetProperty(ref _buttonTR181PageBackground, value); }
231 }
232
233 public Brush ButtonPhonePageBackground
234 {
235 get { return _buttonPhonePageBackground; }
236 set { SetProperty(ref _buttonPhonePageBackground, value); }
237 }
238
239 public Brush ButtonLanPageBackground
240 {
241 get { return _buttonLanPageBackground; }
242 set { SetProperty(ref _buttonLanPageBackground, value); }
243 }
244
245 public Brush ButtonInterfacePageBackground
246 {
247 get { return _buttonInterfacePageBackground; }
248 set { SetProperty(ref _buttonInterfacePageBackground, value); }
249 }
250
251 public Brush ButtonControlsPageBackground
252 {
253 get { return _buttonControlsPageBackground; }
254 set { SetProperty(ref _buttonControlsPageBackground, value); }
255 }
256
257 public Brush ButtonAboutPageBackground
258 {
259 get { return _buttonAboutPageBackground; }
260 set { SetProperty(ref _buttonAboutPageBackground, value); }
261 }
262
263 public Page FrameSource
264 {
265 get { return _FrameSource; }
266 set { SetProperty(ref _FrameSource, value); }
267 }
268
269 public string Title
270 {
271 get { return _title; }
272 set { SetProperty(ref _title, value); }
273 }
274
275 private void OnSwitchToLoginPageExecute()
276 {
277 changePage("login");
278 }
279
280 private void OnSwitchToStatusPageExecute()
281 {
282 changePage("status");
283 new Thread(() => { SpeedportHybrid.initStatus(); }).Start();
284 }
285
286 private void OnSwitchToOverviewPageExecute()
287 {
288 changePage("overview");
289 new Thread(() => { SpeedportHybrid.initOverview(); }).Start();
290 }
291
292 private void OnSwitchToDSLPageExecute()
293 {
294 changePage("dsl");
295 new Thread(() => { SpeedportHybrid.initDSL(); }).Start();
296 }
297
298 private void OnSwitchToLteInfoPageExecute()
299 {
300 changePage("lte");
301 new Thread(() => { SpeedportHybrid.initLTE(); }).Start();
302 }
303
304 private void OnSwitchToSyslogPageExecute()
305 {
306 changePage("syslog");
307 new Thread(() => { SpeedportHybrid.initSyslog(); }).Start();
308 }
309
310 private void OnSwitchToTR181PageExecute()
311 {
312 changePage("tr181");
313 new Thread(() => { SpeedportHybrid.initTR181(); }).Start();
314 }
315
316 private void OnSwitchToPhonePageExecute()
317 {
318 changePage("phone");
319 new Thread(() => { SpeedportHybrid.initPhone(); }).Start();
320 }
321
322 private void OnSwitchToLanPageExecute()
323 {
324 changePage("lan");
325 new Thread(() => { SpeedportHybrid.initLan(); }).Start();
326 }
327
328 private void OnSwitchToInterfacePageExecute()
329 {
330 changePage("interface");
331 new Thread(() => { SpeedportHybrid.initInterface(); }).Start();
332 }
333
334 private void OnSwitchToControlsPageExecute()
335 {
336 changePage("controls");
337 }
338
339 private void OnSwitchToAboutPageExecute()
340 {
341 changePage("about");
342 }
343
344 private void changePage(string page)
345 {
346 if (object.Equals(FrameSource, null).Equals(false))
347 {
348 if (FrameSource.GetType().Equals(typeof(LteInfoPage)))
349 {
350 LteInfoModel lte = Application.Current.FindResource("LteInfoModel") as LteInfoModel;
351 lte.StopTimer();
352 }
353
354 if (FrameSource.GetType().Equals(typeof(DslPage)))
355 {
356 DslPageModel dsl = Application.Current.FindResource("DslPageModel") as DslPageModel;
357 dsl.StopTimer();
358 }
359 }
360
361 if (page.Equals("login"))
362 {
363 FrameSource = new LoginPage();
364 }
365 else if (page.Equals("status"))
366 {
367 FrameSource = new StatusPage();
368 }
369 else if (page.Equals("overview"))
370 {
371 FrameSource = new OverviewPage();
372 }
373 else if (page.Equals("dsl"))
374 {
375 FrameSource = new DslPage();
376 }
377 else if (page.Equals("lte"))
378 {
379 FrameSource = new LteInfoPage();
380 }
381 else if (page.Equals("syslog"))
382 {
383 FrameSource = new SyslogPage();
384 }
385 else if (page.Equals("tr181"))
386 {
387 FrameSource = new TR181Page();
388 }
389 else if (page.Equals("phone"))
390 {
391 FrameSource = new PhonePage();
392 }
393 else if (page.Equals("lan"))
394 {
395 FrameSource = new LanPage();
396 }
397 else if (page.Equals("interface"))
398 {
399 FrameSource = new InterfacePage();
400 }
401 else if (page.Equals("controls"))
402 {
403 FrameSource = new ControlsPage();
404 }
405 else if (page.Equals("about"))
406 {
407 FrameSource = new AboutPage();
408 }
409
410 changeColor(page);
411 }
412
413 private void changeColor(string page)
414 {
415 ButtonLoginPageBackground = Brushes.LightGray;
416 ButtonStatusPageBackground = Brushes.LightGray;
417 ButtonOverviewPageBackground = Brushes.LightGray;
418 ButtonDSLPageBackground = Brushes.LightGray;
419 ButtonLteInfoPageBackground = Brushes.LightGray;
420 ButtonSyslogPageBackground = Brushes.LightGray;
421 ButtonTR181PageBackground = Brushes.LightGray;
422 ButtonPhonePageBackground = Brushes.LightGray;
423 ButtonLanPageBackground = Brushes.LightGray;
424 ButtonInterfacePageBackground = Brushes.LightGray;
425 ButtonControlsPageBackground = Brushes.LightGray;
426 ButtonAboutPageBackground = Brushes.LightGray;
427
428 if (page.Equals("login"))
429 {
430 ButtonLoginPageBackground = Brushes.LightGreen;
431 }
432
433 if (page.Equals("status"))
434 {
435 ButtonStatusPageBackground = Brushes.LightGreen;
436 }
437
438 if (page.Equals("overview"))
439 {
440 ButtonOverviewPageBackground = Brushes.LightGreen;
441 }
442
443 if (page.Equals("dsl"))
444 {
445 ButtonDSLPageBackground = Brushes.LightGreen;
446 }
447
448 if (page.Equals("lte"))
449 {
450 ButtonLteInfoPageBackground = Brushes.LightGreen;
451 }
452
453 if (page.Equals("syslog"))
454 {
455 ButtonSyslogPageBackground = Brushes.LightGreen;
456 }
457
458 if (page.Equals("tr181"))
459 {
460 ButtonTR181PageBackground = Brushes.LightGreen;
461 }
462
463 if (page.Equals("phone"))
464 {
465 ButtonPhonePageBackground = Brushes.LightGreen;
466 }
467
468 if (page.Equals("lan"))
469 {
470 ButtonLanPageBackground = Brushes.LightGreen;
471 }
472
473 if (page.Equals("interface"))
474 {
475 ButtonInterfacePageBackground = Brushes.LightGreen;
476 }
477
478 if (page.Equals("controls"))
479 {
480 ButtonControlsPageBackground = Brushes.LightGreen;
481 }
482
483 if (page.Equals("about"))
484 {
485 ButtonAboutPageBackground = Brushes.LightGreen;
486 }
487 }
488
489 public MainWindowModel()
490 {
491 Title = string.Concat("Speedport Hybrid Konfigurationsprogramm", " (version ", VERSION, ")");
492
493 if (util.checkInstalled("Microsoft Visual C++ 2010 x86 Redistributable - 10.0.40219").Equals(false))
494 {
495 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();
496 }
497
498 if (util.checkUpdate(VERSION).Equals(true))
499 {
500 new Thread(() => { MessageBox.Show("Ein Update ist verfügbar.", "Confirmation", MessageBoxButton.OK, MessageBoxImage.Warning); }).Start();
501 }
502
503 changePage("login");
504
505 SwitchToLoginPage = new DelegateCommand(new Action(OnSwitchToLoginPageExecute));
506 SwitchToStatusPage = new DelegateCommand(new Action(OnSwitchToStatusPageExecute));
507 SwitchToOverviewPage = new DelegateCommand(new Action(OnSwitchToOverviewPageExecute));
508 SwitchToDSLPage = new DelegateCommand(new Action(OnSwitchToDSLPageExecute));
509 SwitchToLteInfoPage = new DelegateCommand(new Action(OnSwitchToLteInfoPageExecute));
510 SwitchToSyslogPage = new DelegateCommand(new Action(OnSwitchToSyslogPageExecute));
511 SwitchToTR181Page = new DelegateCommand(new Action(OnSwitchToTR181PageExecute));
512 SwitchToPhonePage = new DelegateCommand(new Action(OnSwitchToPhonePageExecute));
513 SwitchToLanPage = new DelegateCommand(new Action(OnSwitchToLanPageExecute));
514 SwitchToInterfacePage = new DelegateCommand(new Action(OnSwitchToInterfacePageExecute));
515 SwitchToControlsPage = new DelegateCommand(new Action(OnSwitchToControlsPageExecute));
516
517 SwitchToAboutPage = new DelegateCommand(new Action(OnSwitchToAboutPageExecute));
518 }
519 }
491f6e3b 520}