xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:SpeedportHybridControl"
xmlns:model="clr-namespace:SpeedportHybridControl.Model"
+ xmlns:pagemodel="clr-namespace:SpeedportHybridControl.PageModel"
StartupUri="MainWindow.xaml">
<Application.Resources>
<ResourceDictionary>
- <model:MainWindowModel x:Key="MainWindowModel"></model:MainWindowModel>
- <model:LoginPageModel x:Key="LoginPageModel"></model:LoginPageModel>
+ <pagemodel:MainWindowModel x:Key="MainWindowModel"></pagemodel:MainWindowModel>
+ <pagemodel:LoginPageModel x:Key="LoginPageModel"></pagemodel:LoginPageModel>
+ <pagemodel:StatusPageModel x:Key="StatusPageModel"></pagemodel:StatusPageModel>
<model:Status x:Key="Status"></model:Status>
<model:LTE x:Key="LTE"></model:LTE>
using SpeedportHybridControl.Model;
using Newtonsoft.Json;
using System.Security;
+using SpeedportHybridControl.PageModel;
namespace SpeedportHybridControl.Data {
public class SpeedportHybridAPI : SingletonFactory<SpeedportHybridAPI> {
+++ /dev/null
-using System;
-using SpeedportHybridControl.Implementations;
-using SpeedportHybridControl.Data;
-using System.Windows;
-using System.Threading;
-using System.Security;
-
-namespace SpeedportHybridControl.Model {
- class LoginPageModel : SuperViewModel {
- private string _ip = "speedport.ip";
- private string _password;
- private string _loginButtonText = "Login";
- private bool _showPassword;
- private bool _savePassword;
- private Visibility _passwordBoxVisibility = Visibility.Visible;
- private Visibility _passwordTextBoxVisibility = Visibility.Hidden;
- private Visibility _loginFieldsVisibility = Visibility.Visible;
-
- private DelegateCommand _showPasswordCommand;
- private DelegateCommand _savePasswordCommand;
- private DelegateCommand _loginCommand;
-
- public string ip {
- get { return _ip; }
- set { SetProperty(ref _ip, value); }
- }
-
- public string password {
- get { return _password; }
- set { SetProperty(ref _password, value); }
- }
-
- public string LoginButtonText {
- get { return _loginButtonText; }
- set { SetProperty(ref _loginButtonText, value); }
- }
-
- public bool ShowPassword {
- get { return _showPassword; }
- set { SetProperty(ref _showPassword, value); }
- }
-
- public bool SavePassword {
- get { return _savePassword; }
- set { SetProperty(ref _savePassword, value); }
- }
-
- public Visibility PasswordBoxVisibility {
- get { return _passwordBoxVisibility; }
- set { SetProperty(ref _passwordBoxVisibility, value); }
- }
-
- public Visibility PasswordTextBoxVisibility {
- get { return _passwordTextBoxVisibility; }
- set { SetProperty(ref _passwordTextBoxVisibility, value); }
- }
-
- public Visibility LoginFieldsVisibility {
- get { return _loginFieldsVisibility; }
- set { SetProperty(ref _loginFieldsVisibility, value); }
- }
-
- public DelegateCommand ShowPasswordCommand {
- get { return _showPasswordCommand; }
- set { SetProperty(ref _showPasswordCommand, value); }
- }
-
- public DelegateCommand SavePasswordCommand {
- get { return _savePasswordCommand; }
- set { SetProperty(ref _savePasswordCommand, value); }
- }
-
- public DelegateCommand LoginCommand {
- get { return _loginCommand; }
- set { SetProperty(ref _loginCommand, value); }
- }
-
- private void OnShowPasswordCommandExecute () {
- if (ShowPassword.Equals(true)) {
- PasswordBoxVisibility = Visibility.Hidden;
- PasswordTextBoxVisibility = Visibility.Visible;
- }
- else {
- PasswordBoxVisibility = Visibility.Visible;
- PasswordTextBoxVisibility = Visibility.Hidden;
- }
- }
-
- private void OnSavePasswordCommandExecute () {
- Console.WriteLine(SavePassword);
- }
-
- private void OnLoginCommandExecute () {
- MainWindowModel mwm = Application.Current.FindResource("MainWindowModel") as MainWindowModel;
-
- if (LoginButtonText.Equals("Login")) {
- if (SpeedportHybridAPI.getInstance().ip.Equals(ip).Equals(false)) {
- SpeedportHybridAPI.getInstance().ip = ip;
- }
-
- bool login = SpeedportHybridAPI.getInstance().login(password);
- if (login.Equals(true)) {
- if (SavePassword.Equals(true)) {
-
- SettingsModel SettingsModel = new SettingsModel {
- password = password,
- ip = SpeedportHybridAPI.getInstance().ip
- };
-
- Settings.save(SettingsModel);
-
- }
- else {
-
- SettingsModel SettingsModel = new SettingsModel {
- password = string.Empty,
- ip = SpeedportHybridAPI.getInstance().ip
- };
-
- Settings.save(SettingsModel);
-
- }
- LoginFieldsVisibility = Visibility.Hidden;
- mwm.ButtonOverviewPageIsActive = true;
- mwm.ButtonDSLPageIsActive = true;
- mwm.ButtonLteInfoPageIsActive = true;
- mwm.ButtonSyslogPageIsActive = true;
- mwm.ButtonTR181PageIsActive = true;
- mwm.ButtonPhonePageIsActive = true;
- mwm.ButtonLanPageIsActive = true;
- mwm.ButtonControlsPageIsActive = true;
-
- LoginButtonText = "Logout";
- mwm.LoginButtonContent = "Logout";
- }
- else {
- new Thread(() => { MessageBox.Show("Login fehlgeschlagen. Sie haben ein falsches Gerätepasswort eingegeben. Bitte versuchen Sie es erneut und achten Sie auf die korrekte Schreibweise.", "Confirmation", MessageBoxButton.OK, MessageBoxImage.Error); }).Start();
- LogManager.WriteToLog("Login Failed, wrong password");
- }
- }
- else {
- if (SpeedportHybridAPI.getInstance().logout().Equals(true)) {
- // TODO: util.logout();
- LogoutAction();
- }
- }
- }
-
- public void LogoutAction () {
- MainWindowModel mwm = Application.Current.FindResource("MainWindowModel") as MainWindowModel;
- LoginFieldsVisibility = Visibility.Visible;
- mwm.ButtonOverviewPageIsActive = false;
- mwm.ButtonDSLPageIsActive = false;
- mwm.ButtonLteInfoPageIsActive = false;
- mwm.ButtonSyslogPageIsActive = false;
- mwm.ButtonTR181PageIsActive = false;
- mwm.ButtonPhonePageIsActive = false;
- mwm.ButtonLanPageIsActive = false;
- mwm.ButtonControlsPageIsActive = false;
-
- LoginButtonText = "Login";
- mwm.LoginButtonContent = "Login";
- }
-
- public LoginPageModel () {
- SettingsModel settings = Settings.load();
- if (settings.ip.IsNullOrEmpty().Equals(false)) {
- ip = settings.ip;
- }
-
- SpeedportHybridAPI.getInstance().ip = ip;
-
- if (settings.password.IsNullOrEmpty().Equals(false)) {
- SavePassword = true;
- password = settings.password;
- }
-
- ShowPasswordCommand = new DelegateCommand(new Action(OnShowPasswordCommandExecute));
- SavePasswordCommand = new DelegateCommand(new Action(OnSavePasswordCommandExecute));
- LoginCommand = new DelegateCommand(new Action(OnLoginCommandExecute));
- }
- }
-}
--- /dev/null
+using System;
+using SpeedportHybridControl.Implementations;
+using SpeedportHybridControl.Data;
+using System.Windows;
+using System.Threading;
+using System.Security;
+using SpeedportHybridControl.Model;
+
+namespace SpeedportHybridControl.PageModel {
+ class LoginPageModel : SuperViewModel {
+ private string _ip = "speedport.ip";
+ private string _password;
+ private string _loginButtonText = "Login";
+ private bool _showPassword;
+ private bool _savePassword;
+ private Visibility _passwordBoxVisibility = Visibility.Visible;
+ private Visibility _passwordTextBoxVisibility = Visibility.Hidden;
+ private Visibility _loginFieldsVisibility = Visibility.Visible;
+
+ private DelegateCommand _showPasswordCommand;
+ private DelegateCommand _savePasswordCommand;
+ private DelegateCommand _loginCommand;
+
+ public string ip {
+ get { return _ip; }
+ set { SetProperty(ref _ip, value); }
+ }
+
+ public string password {
+ get { return _password; }
+ set { SetProperty(ref _password, value); }
+ }
+
+ public string LoginButtonText {
+ get { return _loginButtonText; }
+ set { SetProperty(ref _loginButtonText, value); }
+ }
+
+ public bool ShowPassword {
+ get { return _showPassword; }
+ set { SetProperty(ref _showPassword, value); }
+ }
+
+ public bool SavePassword {
+ get { return _savePassword; }
+ set { SetProperty(ref _savePassword, value); }
+ }
+
+ public Visibility PasswordBoxVisibility {
+ get { return _passwordBoxVisibility; }
+ set { SetProperty(ref _passwordBoxVisibility, value); }
+ }
+
+ public Visibility PasswordTextBoxVisibility {
+ get { return _passwordTextBoxVisibility; }
+ set { SetProperty(ref _passwordTextBoxVisibility, value); }
+ }
+
+ public Visibility LoginFieldsVisibility {
+ get { return _loginFieldsVisibility; }
+ set { SetProperty(ref _loginFieldsVisibility, value); }
+ }
+
+ public DelegateCommand ShowPasswordCommand {
+ get { return _showPasswordCommand; }
+ set { SetProperty(ref _showPasswordCommand, value); }
+ }
+
+ public DelegateCommand SavePasswordCommand {
+ get { return _savePasswordCommand; }
+ set { SetProperty(ref _savePasswordCommand, value); }
+ }
+
+ public DelegateCommand LoginCommand {
+ get { return _loginCommand; }
+ set { SetProperty(ref _loginCommand, value); }
+ }
+
+ private void OnShowPasswordCommandExecute () {
+ if (ShowPassword.Equals(true)) {
+ PasswordBoxVisibility = Visibility.Hidden;
+ PasswordTextBoxVisibility = Visibility.Visible;
+ }
+ else {
+ PasswordBoxVisibility = Visibility.Visible;
+ PasswordTextBoxVisibility = Visibility.Hidden;
+ }
+ }
+
+ private void OnSavePasswordCommandExecute () {
+ Console.WriteLine(SavePassword);
+ }
+
+ private void OnLoginCommandExecute () {
+ MainWindowModel mwm = Application.Current.FindResource("MainWindowModel") as MainWindowModel;
+
+ if (LoginButtonText.Equals("Login")) {
+ if (SpeedportHybridAPI.getInstance().ip.Equals(ip).Equals(false)) {
+ SpeedportHybridAPI.getInstance().ip = ip;
+ }
+
+ bool login = SpeedportHybridAPI.getInstance().login(password);
+ if (login.Equals(true)) {
+ if (SavePassword.Equals(true)) {
+ SettingsModel SettingsModel = new SettingsModel {
+ password = password,
+ ip = SpeedportHybridAPI.getInstance().ip
+ };
+
+ Settings.save(SettingsModel);
+ }
+ else {
+ SettingsModel SettingsModel = new SettingsModel {
+ password = string.Empty,
+ ip = SpeedportHybridAPI.getInstance().ip
+ };
+
+ Settings.save(SettingsModel);
+ }
+ LoginFieldsVisibility = Visibility.Hidden;
+ mwm.ButtonOverviewPageIsActive = true;
+ mwm.ButtonDSLPageIsActive = true;
+ mwm.ButtonLteInfoPageIsActive = true;
+ mwm.ButtonSyslogPageIsActive = true;
+ mwm.ButtonTR181PageIsActive = true;
+ mwm.ButtonPhonePageIsActive = true;
+ mwm.ButtonLanPageIsActive = true;
+ mwm.ButtonControlsPageIsActive = true;
+
+ LoginButtonText = "Logout";
+ mwm.LoginButtonContent = "Logout";
+ }
+ else {
+ new Thread(() => { MessageBox.Show("Login fehlgeschlagen. Sie haben ein falsches Gerätepasswort eingegeben. Bitte versuchen Sie es erneut und achten Sie auf die korrekte Schreibweise.", "Confirmation", MessageBoxButton.OK, MessageBoxImage.Error); }).Start();
+ LogManager.WriteToLog("Login Failed, wrong password");
+ }
+ }
+ else {
+ if (SpeedportHybridAPI.getInstance().logout().Equals(true)) {
+ // TODO: util.logout();
+ LogoutAction();
+ }
+ }
+ }
+
+ public void LogoutAction () {
+ MainWindowModel mwm = Application.Current.FindResource("MainWindowModel") as MainWindowModel;
+ LoginFieldsVisibility = Visibility.Visible;
+ mwm.ButtonOverviewPageIsActive = false;
+ mwm.ButtonDSLPageIsActive = false;
+ mwm.ButtonLteInfoPageIsActive = false;
+ mwm.ButtonSyslogPageIsActive = false;
+ mwm.ButtonTR181PageIsActive = false;
+ mwm.ButtonPhonePageIsActive = false;
+ mwm.ButtonLanPageIsActive = false;
+ mwm.ButtonControlsPageIsActive = false;
+
+ LoginButtonText = "Login";
+ mwm.LoginButtonContent = "Login";
+ }
+
+ public LoginPageModel () {
+ SettingsModel settings = Settings.load();
+ if (settings.ip.IsNullOrEmpty().Equals(false)) {
+ ip = settings.ip;
+ }
+
+ SpeedportHybridAPI.getInstance().ip = ip;
+
+ if (settings.password.IsNullOrEmpty().Equals(false)) {
+ SavePassword = true;
+ password = settings.password;
+ }
+
+ ShowPasswordCommand = new DelegateCommand(new Action(OnShowPasswordCommandExecute));
+ SavePasswordCommand = new DelegateCommand(new Action(OnSavePasswordCommandExecute));
+ LoginCommand = new DelegateCommand(new Action(OnLoginCommandExecute));
+ }
+ }
+}
--- /dev/null
+using System;
+using SpeedportHybridControl.Implementations;
+using System.Windows.Controls;
+using SpeedportHybridControl.page;
+using System.Windows.Media;
+using System.Threading;
+using SpeedportHybridControl.Data;
+using SpeedportHybridControl.Model;
+
+namespace SpeedportHybridControl.PageModel {
+ class MainWindowModel : SuperViewModel {
+ private string _loginButtonContent = "Login";
+
+ private DelegateCommand _switchToLoginPage;
+ private DelegateCommand _switchToStatusPage;
+ private DelegateCommand _switchToOverviewPage;
+ private DelegateCommand _switchToDSLPage;
+ private DelegateCommand _switchToLteInfoPage;
+ private DelegateCommand _switchToSyslogPage;
+ private DelegateCommand _switchToTR181Page;
+ private DelegateCommand _switchToPhonePage;
+ private DelegateCommand _switchToLanPage;
+ private DelegateCommand _switchToControlsPage;
+ private DelegateCommand _sitchToAboutPage;
+
+ private bool _buttonOverviewPageIsActive = false;
+ private bool _buttonDSLPageIsActive = false;
+ private bool _buttonLteInfoPageIsActive = false;
+ private bool _buttonSyslogPageIsActive = false;
+ private bool _buttonTR181PageIsActive = false;
+ private bool _buttonPhonePageIsActive = false;
+ private bool _buttonLanPageIsActive = false;
+ private bool _buttonControlsPageIsActive = false;
+
+ private Brush _buttonLoginPageBackground = Brushes.LightGray;
+ private Brush _buttonStatusPageBackground = Brushes.LightGray;
+ private Brush _buttonOverviewPageBackground = Brushes.LightGray;
+ private Brush _buttonDSLPageBackground = Brushes.LightGray;
+ private Brush _buttonLteInfoPageBackground = Brushes.LightGray;
+ private Brush _buttonSyslogPageBackground = Brushes.LightGray;
+ private Brush _buttonTR181PageBackground = Brushes.LightGray;
+ private Brush _buttonPhonePageBackground = Brushes.LightGray;
+ private Brush _buttonLanPageBackground = Brushes.LightGray;
+ private Brush _buttonControlsPageBackground = Brushes.LightGray;
+ private Brush _buttonAboutPageBackground = Brushes.LightGray;
+
+ private Page _FrameSource;
+
+ public string LoginButtonContent {
+ get { return _loginButtonContent; }
+ set { SetProperty(ref _loginButtonContent, value); }
+ }
+
+ public DelegateCommand SwitchToLoginPage {
+ get { return _switchToLoginPage; }
+ set { SetProperty(ref _switchToLoginPage, value); }
+ }
+
+ public DelegateCommand SwitchToStatusPage {
+ get { return _switchToStatusPage; }
+ set { SetProperty(ref _switchToStatusPage, value); }
+ }
+
+ public DelegateCommand SwitchToOverviewPage {
+ get { return _switchToOverviewPage; }
+ set { SetProperty(ref _switchToOverviewPage, value); }
+ }
+
+ public DelegateCommand SwitchToDSLPage {
+ get { return _switchToDSLPage; }
+ set { SetProperty(ref _switchToDSLPage, value); }
+ }
+
+ public DelegateCommand SwitchToLteInfoPage {
+ get { return _switchToLteInfoPage; }
+ set { SetProperty(ref _switchToLteInfoPage, value); }
+ }
+
+ public DelegateCommand SwitchToSyslogPage {
+ get { return _switchToSyslogPage; }
+ set { SetProperty(ref _switchToSyslogPage, value); }
+ }
+
+ public DelegateCommand SwitchToTR181Page {
+ get { return _switchToTR181Page; }
+ set { SetProperty(ref _switchToTR181Page, value); }
+ }
+
+ public DelegateCommand SwitchToPhonePage {
+ get { return _switchToPhonePage; }
+ set { SetProperty(ref _switchToPhonePage, value); }
+ }
+
+ public DelegateCommand SwitchToLanPage {
+ get { return _switchToLanPage; }
+ set { SetProperty(ref _switchToLanPage, value); }
+ }
+
+ public DelegateCommand SwitchToControlsPage {
+ get { return _switchToControlsPage; }
+ set { SetProperty(ref _switchToControlsPage, value); }
+ }
+
+ public DelegateCommand SwitchToAboutPage {
+ get { return _sitchToAboutPage; }
+ set { SetProperty(ref _sitchToAboutPage, value); }
+ }
+
+ public bool ButtonOverviewPageIsActive {
+ get { return _buttonOverviewPageIsActive; }
+ set { SetProperty(ref _buttonOverviewPageIsActive, value); }
+ }
+
+ public bool ButtonDSLPageIsActive {
+ get { return _buttonDSLPageIsActive; }
+ set { SetProperty(ref _buttonDSLPageIsActive, value); }
+ }
+
+ public bool ButtonLteInfoPageIsActive {
+ get { return _buttonLteInfoPageIsActive; }
+ set { SetProperty(ref _buttonLteInfoPageIsActive, value); }
+ }
+
+ public bool ButtonSyslogPageIsActive {
+ get { return _buttonSyslogPageIsActive; }
+ set { SetProperty(ref _buttonSyslogPageIsActive, value); }
+ }
+
+ public bool ButtonTR181PageIsActive {
+ get { return _buttonTR181PageIsActive; }
+ set { SetProperty(ref _buttonTR181PageIsActive, value); }
+ }
+
+ public bool ButtonPhonePageIsActive {
+ get { return _buttonPhonePageIsActive; }
+ set { SetProperty(ref _buttonPhonePageIsActive, value); }
+ }
+
+ public bool ButtonLanPageIsActive {
+ get { return _buttonLanPageIsActive; }
+ set { SetProperty(ref _buttonLanPageIsActive, value); }
+ }
+
+ public bool ButtonControlsPageIsActive {
+ get { return _buttonControlsPageIsActive; }
+ set { SetProperty(ref _buttonControlsPageIsActive, value); }
+ }
+
+ public Brush ButtonLoginPageBackground {
+ get { return _buttonLoginPageBackground; }
+ set { SetProperty(ref _buttonLoginPageBackground, value); }
+ }
+
+ public Brush ButtonStatusPageBackground {
+ get { return _buttonStatusPageBackground; }
+ set { SetProperty(ref _buttonStatusPageBackground, value); }
+ }
+
+ public Brush ButtonOverviewPageBackground {
+ get { return _buttonOverviewPageBackground; }
+ set { SetProperty(ref _buttonOverviewPageBackground, value); }
+ }
+
+ public Brush ButtonDSLPageBackground {
+ get { return _buttonDSLPageBackground; }
+ set { SetProperty(ref _buttonDSLPageBackground, value); }
+ }
+
+ public Brush ButtonLteInfoPageBackground {
+ get { return _buttonLteInfoPageBackground; }
+ set { SetProperty(ref _buttonLteInfoPageBackground, value); }
+ }
+
+ public Brush ButtonSyslogPageBackground {
+ get { return _buttonSyslogPageBackground; }
+ set { SetProperty(ref _buttonSyslogPageBackground, value); }
+ }
+
+ public Brush ButtonTR181PageBackground {
+ get { return _buttonTR181PageBackground; }
+ set { SetProperty(ref _buttonTR181PageBackground, value); }
+ }
+
+ public Brush ButtonPhonePageBackground {
+ get { return _buttonPhonePageBackground; }
+ set { SetProperty(ref _buttonPhonePageBackground, value); }
+ }
+
+ public Brush ButtonLanPageBackground {
+ get { return _buttonLanPageBackground; }
+ set { SetProperty(ref _buttonLanPageBackground, value); }
+ }
+
+ public Brush ButtonControlsPageBackground {
+ get { return _buttonControlsPageBackground; }
+ set { SetProperty(ref _buttonControlsPageBackground, value); }
+ }
+
+ public Brush ButtonAboutPageBackground {
+ get { return _buttonAboutPageBackground; }
+ set { SetProperty(ref _buttonAboutPageBackground, value); }
+ }
+
+ public Page FrameSource {
+ get { return _FrameSource; }
+ set { SetProperty(ref _FrameSource, value); }
+ }
+
+ private void OnSwitchToLoginPageExecute () {
+ changePage("login");
+ }
+
+ private void OnSwitchToStatusPageExecute () {
+ changePage("status");
+ new Thread(() => { SpeedportHybrid.initStatus(); }).Start();
+ }
+
+ private void OnSwitchToOverviewPageExecute () {
+ changePage("overview");
+ new Thread(() => { SpeedportHybrid.initOverview(); }).Start();
+ }
+
+ private void OnSwitchToDSLPageExecute () {
+ changePage("dsl");
+ new Thread(() => { SpeedportHybrid.initDSL(); }).Start();
+ }
+
+ private void OnSwitchToLteInfoPageExecute () {
+ changePage("lte");
+ new Thread(() => { SpeedportHybrid.initLTE(); }).Start();
+ }
+
+ private void OnSwitchToSyslogPageExecute () {
+ changePage("syslog");
+ new Thread(() => { SpeedportHybrid.initSyslog(); }).Start();
+ }
+
+ private void OnSwitchToTR181PageExecute () {
+ changePage("tr181");
+ new Thread(() => { SpeedportHybrid.initTR181(); }).Start();
+ }
+
+ private void OnSwitchToPhonePageExecute () {
+ changePage("phone");
+ new Thread(() => { SpeedportHybrid.initPhone(); }).Start();
+ }
+
+ private void OnSwitchToLanPageExecute () {
+ changePage("lan");
+ new Thread(() => { SpeedportHybrid.initLan(); }).Start();
+ }
+
+ private void OnSwitchToControlsPageExecute () {
+ changePage("controls");
+ }
+
+ private void OnSwitchToAboutPageExecute () {
+ changePage("about");
+ }
+
+ private void changePage (string page) {
+ if (object.Equals(FrameSource, null).Equals(false)) {
+ if (FrameSource.Content.GetType().Equals(typeof(LteInfoPage))) {
+ // TODO: lteInfoPage.StopTimer();
+ }
+
+ if (FrameSource.Content.GetType().Equals(typeof(DslPage))) {
+ // TODO: dslPage.StopTimer();
+ }
+ }
+
+ if (page.Equals("login")) {
+ FrameSource = new LoginPage();
+ }
+ else if (page.Equals("status")) {
+ FrameSource = new StatusPage();
+ }
+ else if (page.Equals("overview")) {
+ FrameSource = new OverviewPage();
+ }
+ else if (page.Equals("dsl")) {
+ FrameSource = new DslPage();
+ }
+ else if (page.Equals("lte")) {
+ FrameSource = new LteInfoPage();
+ }
+ else if (page.Equals("syslog")) {
+ FrameSource = new SyslogPage();
+ }
+ else if (page.Equals("tr181")) {
+ FrameSource = new TR181Page();
+ }
+ else if (page.Equals("phone")) {
+ FrameSource = new PhonePage();
+ }
+ else if (page.Equals("lan")) {
+ FrameSource = new LanPage();
+ }
+ else if (page.Equals("controls")) {
+ FrameSource = new ControlsPage();
+ }
+ else if (page.Equals("about")) {
+ FrameSource = new AboutPage();
+ }
+
+ changeColor(page);
+ }
+
+ private void changeColor (string page) {
+ ButtonLoginPageBackground = Brushes.LightGray;
+ ButtonStatusPageBackground = Brushes.LightGray;
+ ButtonOverviewPageBackground = Brushes.LightGray;
+ ButtonDSLPageBackground = Brushes.LightGray;
+ ButtonLteInfoPageBackground = Brushes.LightGray;
+ ButtonSyslogPageBackground = Brushes.LightGray;
+ ButtonTR181PageBackground = Brushes.LightGray;
+ ButtonPhonePageBackground = Brushes.LightGray;
+ ButtonLanPageBackground = Brushes.LightGray;
+ ButtonControlsPageBackground = Brushes.LightGray;
+ ButtonAboutPageBackground = Brushes.LightGray;
+
+ if (page.Equals("login")) {
+ ButtonLoginPageBackground = Brushes.LightGreen;
+ }
+
+ if (page.Equals("status")) {
+ ButtonStatusPageBackground = Brushes.LightGreen;
+ }
+
+ if (page.Equals("overview")) {
+ ButtonOverviewPageBackground = Brushes.LightGreen;
+ }
+
+ if (page.Equals("dsl")) {
+ ButtonDSLPageBackground = Brushes.LightGreen;
+ }
+
+ if (page.Equals("lte")) {
+ ButtonLteInfoPageBackground = Brushes.LightGreen;
+ }
+
+ if (page.Equals("syslog")) {
+ ButtonSyslogPageBackground = Brushes.LightGreen;
+ }
+
+ if (page.Equals("tr181")) {
+ ButtonTR181PageBackground = Brushes.LightGreen;
+ }
+
+ if (page.Equals("phone")) {
+ ButtonPhonePageBackground = Brushes.LightGreen;
+ }
+
+ if (page.Equals("lan")) {
+ ButtonLanPageBackground = Brushes.LightGreen;
+ }
+
+ if (page.Equals("controls")) {
+ ButtonControlsPageBackground = Brushes.LightGreen;
+ }
+
+ if (page.Equals("about")) {
+ ButtonAboutPageBackground = Brushes.LightGreen;
+ }
+ }
+
+ public MainWindowModel () {
+ changePage("login");
+
+ SwitchToLoginPage = new DelegateCommand(new Action(OnSwitchToLoginPageExecute));
+ SwitchToStatusPage = new DelegateCommand(new Action(OnSwitchToStatusPageExecute));
+ SwitchToOverviewPage = new DelegateCommand(new Action(OnSwitchToOverviewPageExecute));
+ SwitchToDSLPage = new DelegateCommand(new Action(OnSwitchToDSLPageExecute));
+ SwitchToLteInfoPage = new DelegateCommand(new Action(OnSwitchToLteInfoPageExecute));
+ SwitchToSyslogPage = new DelegateCommand(new Action(OnSwitchToSyslogPageExecute));
+ SwitchToTR181Page = new DelegateCommand(new Action(OnSwitchToTR181PageExecute));
+ SwitchToPhonePage = new DelegateCommand(new Action(OnSwitchToPhonePageExecute));
+ SwitchToLanPage = new DelegateCommand(new Action(OnSwitchToLanPageExecute));
+ SwitchToControlsPage = new DelegateCommand(new Action(OnSwitchToControlsPageExecute));
+
+ SwitchToAboutPage = new DelegateCommand(new Action(OnSwitchToAboutPageExecute));
+ }
+ }
+}
--- /dev/null
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using SpeedportHybridControl.Model;
+using SpeedportHybridControl.Implementations;
+using System.Threading;
+using SpeedportHybridControl.Data;
+
+namespace SpeedportHybridControl.PageModel {
+ class StatusPageModel : SuperViewModel {
+ private DelegateCommand _reloadCommand;
+
+ public DelegateCommand ReloadCommand {
+ get { return _reloadCommand; }
+ set { SetProperty(ref _reloadCommand, value); }
+ }
+
+ private void OnReloadCommandExecute () {
+ new Thread(() => { SpeedportHybrid.initStatus(); }).Start();
+ }
+
+ public StatusPageModel () {
+ ReloadCommand = new DelegateCommand(new Action(OnReloadCommandExecute));
+ }
+ }
+}
<Compile Include="Model\bonding_client.cs" />
<Compile Include="Model\DeviceViewModel.cs" />
<Compile Include="Model\DSLViewModel.cs" />
- <Compile Include="Model\LoginPageModel.cs" />
+ <Compile Include="PageModel\LoginPageModel.cs" />
<Compile Include="Model\LTEViewModel.cs" />
- <Compile Include="Model\MainWindowModel.cs" />
+ <Compile Include="PageModel\MainWindowModel.cs" />
<Compile Include="Model\OverviewModel.cs" />
<Compile Include="Model\PhoneCallViewModel.cs" />
<Compile Include="Model\StatusViewModel.cs" />
<ItemGroup>
<Compile Include="Model\SyslogViewModel.cs" />
<Compile Include="Model\TR181ViewModel.cs" />
+ <Compile Include="PageModel\StatusPageModel.cs" />
<Compile Include="page\AboutPage.xaml.cs">
<DependentUpon>AboutPage.xaml</DependentUpon>
</Compile>
+++ /dev/null
-using System;
-using SpeedportHybridControl.Implementations;
-using System.Windows.Controls;
-using SpeedportHybridControl.page;
-using System.Windows.Media;
-using System.Threading;
-using SpeedportHybridControl.Data;
-
-namespace SpeedportHybridControl.Model {
- class MainWindowModel : SuperViewModel {
- private string _loginButtonContent = "Login";
-
- private DelegateCommand _switchToLoginPage;
- private DelegateCommand _switchToStatusPage;
- private DelegateCommand _switchToOverviewPage;
- private DelegateCommand _switchToDSLPage;
- private DelegateCommand _switchToLteInfoPage;
- private DelegateCommand _switchToSyslogPage;
- private DelegateCommand _switchToTR181Page;
- private DelegateCommand _switchToPhonePage;
- private DelegateCommand _switchToLanPage;
- private DelegateCommand _switchToControlsPage;
- private DelegateCommand _sitchToAboutPage;
-
- private bool _buttonOverviewPageIsActive = false;
- private bool _buttonDSLPageIsActive = false;
- private bool _buttonLteInfoPageIsActive = false;
- private bool _buttonSyslogPageIsActive = false;
- private bool _buttonTR181PageIsActive = false;
- private bool _buttonPhonePageIsActive = false;
- private bool _buttonLanPageIsActive = false;
- private bool _buttonControlsPageIsActive = false;
-
- private Brush _buttonLoginPageBackground = Brushes.LightGray;
- private Brush _buttonStatusPageBackground = Brushes.LightGray;
- private Brush _buttonOverviewPageBackground = Brushes.LightGray;
- private Brush _buttonDSLPageBackground = Brushes.LightGray;
- private Brush _buttonLteInfoPageBackground = Brushes.LightGray;
- private Brush _buttonSyslogPageBackground = Brushes.LightGray;
- private Brush _buttonTR181PageBackground = Brushes.LightGray;
- private Brush _buttonPhonePageBackground = Brushes.LightGray;
- private Brush _buttonLanPageBackground = Brushes.LightGray;
- private Brush _buttonControlsPageBackground = Brushes.LightGray;
- private Brush _buttonAboutPageBackground = Brushes.LightGray;
-
- private Page _FrameSource;
-
- public string LoginButtonContent {
- get { return _loginButtonContent; }
- set { SetProperty(ref _loginButtonContent, value); }
- }
-
- public DelegateCommand SwitchToLoginPage {
- get { return _switchToLoginPage; }
- set { SetProperty(ref _switchToLoginPage, value); }
- }
-
- public DelegateCommand SwitchToStatusPage {
- get { return _switchToStatusPage; }
- set { SetProperty(ref _switchToStatusPage, value); }
- }
-
- public DelegateCommand SwitchToOverviewPage {
- get { return _switchToOverviewPage; }
- set { SetProperty(ref _switchToOverviewPage, value); }
- }
-
- public DelegateCommand SwitchToDSLPage {
- get { return _switchToDSLPage; }
- set { SetProperty(ref _switchToDSLPage, value); }
- }
-
- public DelegateCommand SwitchToLteInfoPage {
- get { return _switchToLteInfoPage; }
- set { SetProperty(ref _switchToLteInfoPage, value); }
- }
-
- public DelegateCommand SwitchToSyslogPage {
- get { return _switchToSyslogPage; }
- set { SetProperty(ref _switchToSyslogPage, value); }
- }
-
- public DelegateCommand SwitchToTR181Page {
- get { return _switchToTR181Page; }
- set { SetProperty(ref _switchToTR181Page, value); }
- }
-
- public DelegateCommand SwitchToPhonePage {
- get { return _switchToPhonePage; }
- set { SetProperty(ref _switchToPhonePage, value); }
- }
-
- public DelegateCommand SwitchToLanPage {
- get { return _switchToLanPage; }
- set { SetProperty(ref _switchToLanPage, value); }
- }
-
- public DelegateCommand SwitchToControlsPage {
- get { return _switchToControlsPage; }
- set { SetProperty(ref _switchToControlsPage, value); }
- }
-
- public DelegateCommand SwitchToAboutPage {
- get { return _sitchToAboutPage; }
- set { SetProperty(ref _sitchToAboutPage, value); }
- }
-
- public bool ButtonOverviewPageIsActive {
- get { return _buttonOverviewPageIsActive; }
- set { SetProperty(ref _buttonOverviewPageIsActive, value); }
- }
-
- public bool ButtonDSLPageIsActive {
- get { return _buttonDSLPageIsActive; }
- set { SetProperty(ref _buttonDSLPageIsActive, value); }
- }
-
- public bool ButtonLteInfoPageIsActive {
- get { return _buttonLteInfoPageIsActive; }
- set { SetProperty(ref _buttonLteInfoPageIsActive, value); }
- }
-
- public bool ButtonSyslogPageIsActive {
- get { return _buttonSyslogPageIsActive; }
- set { SetProperty(ref _buttonSyslogPageIsActive, value); }
- }
-
- public bool ButtonTR181PageIsActive {
- get { return _buttonTR181PageIsActive; }
- set { SetProperty(ref _buttonTR181PageIsActive, value); }
- }
-
- public bool ButtonPhonePageIsActive {
- get { return _buttonPhonePageIsActive; }
- set { SetProperty(ref _buttonPhonePageIsActive, value); }
- }
-
- public bool ButtonLanPageIsActive {
- get { return _buttonLanPageIsActive; }
- set { SetProperty(ref _buttonLanPageIsActive, value); }
- }
-
- public bool ButtonControlsPageIsActive {
- get { return _buttonControlsPageIsActive; }
- set { SetProperty(ref _buttonControlsPageIsActive, value); }
- }
-
- public Brush ButtonLoginPageBackground {
- get { return _buttonLoginPageBackground; }
- set { SetProperty(ref _buttonLoginPageBackground, value); }
- }
-
- public Brush ButtonStatusPageBackground {
- get { return _buttonStatusPageBackground; }
- set { SetProperty(ref _buttonStatusPageBackground, value); }
- }
-
- public Brush ButtonOverviewPageBackground {
- get { return _buttonOverviewPageBackground; }
- set { SetProperty(ref _buttonOverviewPageBackground, value); }
- }
-
- public Brush ButtonDSLPageBackground {
- get { return _buttonDSLPageBackground; }
- set { SetProperty(ref _buttonDSLPageBackground, value); }
- }
-
- public Brush ButtonLteInfoPageBackground {
- get { return _buttonLteInfoPageBackground; }
- set { SetProperty(ref _buttonLteInfoPageBackground, value); }
- }
-
- public Brush ButtonSyslogPageBackground {
- get { return _buttonSyslogPageBackground; }
- set { SetProperty(ref _buttonSyslogPageBackground, value); }
- }
-
- public Brush ButtonTR181PageBackground {
- get { return _buttonTR181PageBackground; }
- set { SetProperty(ref _buttonTR181PageBackground, value); }
- }
-
- public Brush ButtonPhonePageBackground {
- get { return _buttonPhonePageBackground; }
- set { SetProperty(ref _buttonPhonePageBackground, value); }
- }
-
- public Brush ButtonLanPageBackground {
- get { return _buttonLanPageBackground; }
- set { SetProperty(ref _buttonLanPageBackground, value); }
- }
-
- public Brush ButtonControlsPageBackground {
- get { return _buttonControlsPageBackground; }
- set { SetProperty(ref _buttonControlsPageBackground, value); }
- }
-
- public Brush ButtonAboutPageBackground {
- get { return _buttonAboutPageBackground; }
- set { SetProperty(ref _buttonAboutPageBackground, value); }
- }
-
- public Page FrameSource {
- get { return _FrameSource; }
- set { SetProperty(ref _FrameSource, value); }
- }
-
- private void OnSwitchToLoginPageExecute () {
- changePage("login");
- }
-
- private void OnSwitchToStatusPageExecute () {
- changePage("status");
- new Thread(() => { SpeedportHybrid.initStatus(); }).Start();
- }
-
- private void OnSwitchToOverviewPageExecute () {
- changePage("overview");
- new Thread(() => { SpeedportHybrid.initOverview(); }).Start();
- }
-
- private void OnSwitchToDSLPageExecute () {
- changePage("dsl");
- new Thread(() => { SpeedportHybrid.initDSL(); }).Start();
- }
-
- private void OnSwitchToLteInfoPageExecute () {
- changePage("lte");
- new Thread(() => { SpeedportHybrid.initLTE(); }).Start();
- }
-
- private void OnSwitchToSyslogPageExecute () {
- changePage("syslog");
- new Thread(() => { SpeedportHybrid.initSyslog(); }).Start();
- }
-
- private void OnSwitchToTR181PageExecute () {
- changePage("tr181");
- new Thread(() => { SpeedportHybrid.initTR181(); }).Start();
- }
-
- private void OnSwitchToPhonePageExecute () {
- changePage("phone");
- new Thread(() => { SpeedportHybrid.initPhone(); }).Start();
- }
-
- private void OnSwitchToLanPageExecute () {
- changePage("lan");
- new Thread(() => { SpeedportHybrid.initLan(); }).Start();
- }
-
- private void OnSwitchToControlsPageExecute () {
- changePage("controls");
- }
-
- private void OnSwitchToAboutPageExecute () {
- changePage("about");
- }
-
- private void changePage (string page) {
- if (object.Equals(FrameSource, null).Equals(false)) {
- if (FrameSource.Content.GetType().Equals(typeof(LteInfoPage))) {
- // TODO: lteInfoPage.StopTimer();
- }
-
- if (FrameSource.Content.GetType().Equals(typeof(DslPage))) {
- // TODO: dslPage.StopTimer();
- }
- }
-
- if (page.Equals("login")) {
- FrameSource = new LoginPage();
- }
- else if (page.Equals("status")) {
- FrameSource = new StatusPage();
- }
- else if (page.Equals("overview")) {
- FrameSource = new OverviewPage();
- }
- else if (page.Equals("dsl")) {
- FrameSource = new DslPage();
- }
- else if (page.Equals("lte")) {
- FrameSource = new LteInfoPage();
- }
- else if (page.Equals("syslog")) {
- FrameSource = new SyslogPage();
- }
- else if (page.Equals("tr181")) {
- FrameSource = new TR181Page();
- }
- else if (page.Equals("phone")) {
- FrameSource = new PhonePage();
- }
- else if (page.Equals("lan")) {
- FrameSource = new LanPage();
- }
- else if (page.Equals("controls")) {
- FrameSource = new ControlsPage();
- }
- else if (page.Equals("about")) {
- FrameSource = new AboutPage();
- }
-
- changeColor(page);
- }
-
- private void changeColor (string page) {
- ButtonLoginPageBackground = Brushes.LightGray;
- ButtonStatusPageBackground = Brushes.LightGray;
- ButtonOverviewPageBackground = Brushes.LightGray;
- ButtonDSLPageBackground = Brushes.LightGray;
- ButtonLteInfoPageBackground = Brushes.LightGray;
- ButtonSyslogPageBackground = Brushes.LightGray;
- ButtonTR181PageBackground = Brushes.LightGray;
- ButtonPhonePageBackground = Brushes.LightGray;
- ButtonLanPageBackground = Brushes.LightGray;
- ButtonControlsPageBackground = Brushes.LightGray;
- ButtonAboutPageBackground = Brushes.LightGray;
-
- if (page.Equals("login")) {
- ButtonLoginPageBackground = Brushes.LightGreen;
- }
-
- if (page.Equals("status")) {
- ButtonStatusPageBackground = Brushes.LightGreen;
- }
-
- if (page.Equals("overview")) {
- ButtonOverviewPageBackground = Brushes.LightGreen;
- }
-
- if (page.Equals("dsl")) {
- ButtonDSLPageBackground = Brushes.LightGreen;
- }
-
- if (page.Equals("lte")) {
- ButtonLteInfoPageBackground = Brushes.LightGreen;
- }
-
- if (page.Equals("syslog")) {
- ButtonSyslogPageBackground = Brushes.LightGreen;
- }
-
- if (page.Equals("tr181")) {
- ButtonTR181PageBackground = Brushes.LightGreen;
- }
-
- if (page.Equals("phone")) {
- ButtonPhonePageBackground = Brushes.LightGreen;
- }
-
- if (page.Equals("lan")) {
- ButtonLanPageBackground = Brushes.LightGreen;
- }
-
- if (page.Equals("controls")) {
- ButtonControlsPageBackground = Brushes.LightGreen;
- }
-
- if (page.Equals("about")) {
- ButtonAboutPageBackground = Brushes.LightGreen;
- }
- }
-
- public MainWindowModel () {
- changePage("login");
-
- SwitchToLoginPage = new DelegateCommand(new Action(OnSwitchToLoginPageExecute));
- SwitchToStatusPage = new DelegateCommand(new Action(OnSwitchToStatusPageExecute));
- SwitchToOverviewPage = new DelegateCommand(new Action(OnSwitchToOverviewPageExecute));
- SwitchToDSLPage = new DelegateCommand(new Action(OnSwitchToDSLPageExecute));
- SwitchToLteInfoPage = new DelegateCommand(new Action(OnSwitchToLteInfoPageExecute));
- SwitchToSyslogPage = new DelegateCommand(new Action(OnSwitchToSyslogPageExecute));
- SwitchToTR181Page = new DelegateCommand(new Action(OnSwitchToTR181PageExecute));
- SwitchToPhonePage = new DelegateCommand(new Action(OnSwitchToPhonePageExecute));
- SwitchToLanPage = new DelegateCommand(new Action(OnSwitchToLanPageExecute));
- SwitchToControlsPage = new DelegateCommand(new Action(OnSwitchToControlsPageExecute));
-
- SwitchToAboutPage = new DelegateCommand(new Action(OnSwitchToAboutPageExecute));
- }
- }
-}
</GroupBox>
<TextBlock Text="{Binding datetime}" Margin="0,0,10,0" HorizontalAlignment="Right" VerticalAlignment="Bottom" />
- <Button x:Name="reload" Content="Aktualisieren" Margin="218,0,218,0" VerticalAlignment="Bottom" Click="button_click" />
+ <Button DataContext="{StaticResource StatusPageModel}" Command="{Binding Path=ReloadCommand}" x:Name="reload" Content="Aktualisieren" Margin="218,0,218,0" VerticalAlignment="Bottom"/>
</Grid>
</Page>