--- /dev/null
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using SpeedportHybridControl.Implementations;
+using SpeedportHybridControl.Model;
+using SpeedportHybridControl.Data;
+using System.Windows;
+using System.Threading;
+using System.Diagnostics;
+
+namespace SpeedportHybridControl.PageModel {
+ class ControlsPageModel : SuperViewModel {
+ private DelegateCommand _rebootCommand;
+ private DelegateCommand _dslReconnectCommand;
+ private DelegateCommand _lteReconnectCommand;
+ private DelegateCommand _dslLteReconnectCommand;
+ private DelegateCommand _checkFirmwareUpdateCommand;
+ private DelegateCommand _clearDNSCacheCommand;
+ private DelegateCommand _speedtestNetCommand;
+ private DelegateCommand _speedtestTKCommand;
+ private DelegateCommand _disconnectDslCommand;
+ private DelegateCommand _connectDslCommand;
+ private DelegateCommand _disconnectLteCommand;
+ private DelegateCommand _connectLteCommand;
+ private DelegateCommand _resetToFactoryCommand;
+
+ public DelegateCommand RebootCommand {
+ get { return _rebootCommand; }
+ set { SetProperty(ref _rebootCommand, value); }
+ }
+
+ public DelegateCommand DslReconnectcommand {
+ get { return _dslReconnectCommand; }
+ set { SetProperty(ref _dslReconnectCommand, value); }
+ }
+
+ public DelegateCommand LteReconncetCommand {
+ get { return _lteReconnectCommand; }
+ set { SetProperty(ref _lteReconnectCommand, value); }
+ }
+
+ public DelegateCommand DslLteReconnectCommand {
+ get { return _dslLteReconnectCommand; }
+ set { SetProperty(ref _dslLteReconnectCommand, value); }
+ }
+
+ public DelegateCommand CheckFirmwareUpdateCommand {
+ get { return _checkFirmwareUpdateCommand; }
+ set { SetProperty(ref _checkFirmwareUpdateCommand, value); }
+ }
+
+ public DelegateCommand ClearDNSCacheCommand {
+ get { return _clearDNSCacheCommand; }
+ set { SetProperty(ref _clearDNSCacheCommand, value); }
+ }
+
+ public DelegateCommand SpeedtestNetCommand {
+ get { return _speedtestNetCommand; }
+ set { SetProperty(ref _speedtestNetCommand, value); }
+ }
+
+ public DelegateCommand SpeedtestTKCommand {
+ get { return _speedtestTKCommand; }
+ set { SetProperty(ref _speedtestTKCommand, value); }
+ }
+
+ public DelegateCommand DisconnectDslCommand {
+ get { return _disconnectDslCommand; }
+ set { SetProperty(ref _disconnectDslCommand, value); }
+ }
+
+ public DelegateCommand ConnectDslCommand {
+ get { return _connectDslCommand; }
+ set { SetProperty(ref _connectDslCommand, value); }
+ }
+
+ public DelegateCommand DisconnectLteCommand {
+ get { return _disconnectLteCommand; }
+ set { SetProperty(ref _disconnectLteCommand, value); }
+ }
+
+ public DelegateCommand ConnectLteCommand {
+ get { return _connectLteCommand; }
+ set { SetProperty(ref _connectLteCommand, value); }
+ }
+
+ public DelegateCommand ResetToFactoryCommand {
+ get { return _resetToFactoryCommand; }
+ set { SetProperty(ref _resetToFactoryCommand, value); }
+ }
+
+ private void OnRebootCommandExecute () {
+ MessageBoxResult result = MessageBox.Show("Willst du den Router wirklich neustarten?", "Confirmation", MessageBoxButton.YesNoCancel, MessageBoxImage.Question);
+ if (result.Equals(MessageBoxResult.Yes)) {
+ SpeedportHybridAPI.getInstance().reboot();
+ }
+ }
+
+ private void OnDslReconnectcommandExecute () {
+ new Thread(() => {
+ bool reconnectDSL = SpeedportHybridAPI.getInstance().reconnectDSL();
+ if (reconnectDSL.Equals(false)) {
+ new Thread(() => { MessageBox.Show("Could not reconnect DSL.", "Confirmation", MessageBoxButton.OK, MessageBoxImage.Error); }).Start();
+ LogManager.WriteToLog("Could not reconnect DSL.");
+ }
+ else {
+ new Thread(() => { MessageBox.Show("DSL reconnected", "Confirmation", MessageBoxButton.OK, MessageBoxImage.Information); }).Start();
+ }
+ }).Start();
+ }
+
+ private void OnLteReconncetCommandExecute () {
+ new Thread(() => {
+ bool reconnectLte = SpeedportHybridAPI.getInstance().reconnectLte();
+ if (reconnectLte.Equals(false)) {
+ new Thread(() => { MessageBox.Show("Could not reconnect LTE.", "Confirmation", MessageBoxButton.OK, MessageBoxImage.Error); }).Start();
+ LogManager.WriteToLog("Could not reconnect LTE.");
+ }
+ else {
+ new Thread(() => { MessageBox.Show("LTE reconnected", "Confirmation", MessageBoxButton.OK, MessageBoxImage.Information); }).Start();
+ }
+ }).Start();
+ }
+
+ private void OnDslLteReconnectCommandExecute () {
+ //TODO
+ }
+
+ private void OnCheckFirmwareUpdateCommandExecute () {
+ SpeedportHybridAPI.getInstance().checkFirmware();
+ }
+
+ private void OnClearDNSCacheCommandExecute () {
+ new Thread(() => { SpeedportHybridAPI.getInstance().flushDNS(); }).Start();
+ }
+
+ private void OnSpeedtestNetCommandExecute () {
+ Process.Start("http://www.speedtest.net/");
+ }
+
+ private void OnSpeedtestTKCommandExecute () {
+ Process.Start("http://speedtest.t-online.de/");
+ }
+
+ private void OnDisconnectDslCommandExecute () {
+ bool status = SpeedportHybridAPI.getInstance().changeDSLStatus("offline");
+ if (status.Equals(false)) {
+ new Thread(() => { MessageBox.Show("DSL Trennen Fehlgeschlagen", "Confirmation", MessageBoxButton.OK, MessageBoxImage.Error); }).Start();
+ LogManager.WriteToLog("Could not disconnect DSL.");
+ }
+ else {
+ new Thread(() => { MessageBox.Show("DSL Trennen erfolgreich.", "Confirmation", MessageBoxButton.OK, MessageBoxImage.Information); }).Start();
+ }
+ }
+
+ private void OnConnectDslCommandExecute () {
+ bool status = SpeedportHybridAPI.getInstance().changeDSLStatus("online");
+ if (status.Equals(false)) {
+ new Thread(() => { MessageBox.Show("DSL Verbinden Fehlgeschlagen", "Confirmation", MessageBoxButton.OK, MessageBoxImage.Error); }).Start();
+ LogManager.WriteToLog("Could not connect DSL.");
+ }
+ else {
+ new Thread(() => { MessageBox.Show("DSL Verbinden erfolgreich.", "Confirmation", MessageBoxButton.OK, MessageBoxImage.Information); }).Start();
+ }
+ }
+
+ private void OnDisconnectLteCommandExecute () {
+ bool status = SpeedportHybridAPI.getInstance().changeLTEStatus("offline");
+ if (status.Equals(false)) {
+ new Thread(() => { MessageBox.Show("LTE Trennen Fehlgeschlagen", "Confirmation", MessageBoxButton.OK, MessageBoxImage.Error); }).Start();
+ LogManager.WriteToLog("Could not disconnect LTE.");
+ }
+ else {
+ new Thread(() => { MessageBox.Show("LTE Trennen erfolgreich.", "Confirmation", MessageBoxButton.OK, MessageBoxImage.Information); }).Start();
+ }
+ }
+
+ private void OnConnectLteCommandExecute () {
+ bool status = SpeedportHybridAPI.getInstance().changeLTEStatus("online");
+ if (status.Equals(false)) {
+ new Thread(() => { MessageBox.Show("LTE Verbinden Fehlgeschlagen", "Confirmation", MessageBoxButton.OK, MessageBoxImage.Error); }).Start();
+ LogManager.WriteToLog("Could not connect LTE.");
+ }
+ else {
+ new Thread(() => { MessageBox.Show("LTE Verbinden erfolgreich.", "Confirmation", MessageBoxButton.OK, MessageBoxImage.Information); }).Start();
+ }
+ }
+
+ private void OnResetToFactoryCommandExecute () {
+ MessageBoxResult result = MessageBox.Show("Beim Zurücksetzen auf die Werkseinstellungen gehen alle Ihre Einstellungen verloren.\nSind Sie sicher, dass Sie den Router zurücksetzen möchten ? ", "Confirmation", MessageBoxButton.YesNoCancel, MessageBoxImage.Question);
+ if (result.Equals(MessageBoxResult.Yes)) {
+ bool reconnectDSL = SpeedportHybridAPI.getInstance().resetToFactoryDefault();
+ if (reconnectDSL.Equals(false)) {
+ new Thread(() => { MessageBox.Show("Could not reset the router.", "Confirmation", MessageBoxButton.OK, MessageBoxImage.Error); }).Start();
+ LogManager.WriteToLog("Could not reset the router.");
+ }
+ }
+ }
+
+ public ControlsPageModel () {
+ RebootCommand = new DelegateCommand(new Action(OnRebootCommandExecute));
+ DslReconnectcommand = new DelegateCommand(new Action(OnDslReconnectcommandExecute));
+ LteReconncetCommand = new DelegateCommand(new Action(OnLteReconncetCommandExecute));
+ DslLteReconnectCommand = new DelegateCommand(new Action(OnDslLteReconnectCommandExecute));
+ CheckFirmwareUpdateCommand = new DelegateCommand(new Action(OnCheckFirmwareUpdateCommandExecute));
+ ClearDNSCacheCommand = new DelegateCommand(new Action(OnClearDNSCacheCommandExecute));
+ SpeedtestNetCommand = new DelegateCommand(new Action(OnSpeedtestNetCommandExecute));
+ SpeedtestTKCommand = new DelegateCommand(new Action(OnSpeedtestTKCommandExecute));
+ DisconnectDslCommand = new DelegateCommand(new Action(OnDisconnectDslCommandExecute));
+ ConnectDslCommand = new DelegateCommand(new Action(OnConnectDslCommandExecute));
+ DisconnectLteCommand = new DelegateCommand(new Action(OnDisconnectLteCommandExecute));
+ ConnectLteCommand = new DelegateCommand(new Action(OnConnectLteCommandExecute));
+ ResetToFactoryCommand = new DelegateCommand(new Action(OnResetToFactoryCommandExecute));
+ }
+ }
+}
Width="Auto" Height="Auto"
Title="ControlsPage">
- <Grid>
+ <Grid DataContext="{StaticResource ControlsPageModel}">
<StackPanel HorizontalAlignment="Left" Width="117" Height="282" VerticalAlignment="Top" Margin="10,0,0,0">
<StackPanel.Resources>
<Style TargetType="{x:Type Button}">
</Style>
</StackPanel.Resources>
- <Button x:Name="button7" Content="Router Neustarten" Click="button_click"/>
- <Button x:Name="button9" Content="DSL neu verbinden" Click="button_click"/>
- <Button x:Name="button10" Content="Firmware-Update" Click="button_click"/>
- <Button x:Name="btnflushdns" Content="DNS Cache Leeren" Click="button_click"/>
- <Button x:Name="btnSpeedtest" Content="speedtest.net" Click="button_click"/>
+ <Button Command="{Binding Path=RebootCommand}" Content="Router Neustarten"/>
+ <Button Command="{Binding Path=DslReconnectcommand}" Content="DSL neu verbinden"/>
+ <Button Command="{Binding Path=CheckFirmwareUpdateCommand}" Content="Firmware-Update"/>
+ <Button Command="{Binding Path=ClearDNSCacheCommand}" Content="DNS Cache Leeren"/>
+ <Button Command="{Binding Path=SpeedtestNetCommand}" Content="speedtest.net"/>
<Button Visibility="Hidden" Content="[SPACER]"/>
<Button Visibility="Hidden" Content="[SPACER]"/>
<Button Visibility="Hidden" Content="[SPACER]"/>
<Button Visibility="Hidden" Content="[SPACER]"/>
<Button Visibility="Hidden" Content="[SPACER]"/>
- <Button x:Name="button17" Content="Werkseinstellungen" Click="button_click" />
+ <Button Command="{Binding Path=ResetToFactoryCommand}" Content="Werkseinstellungen" />
</StackPanel>
<StackPanel HorizontalAlignment="Left" Width="117" Height="282" VerticalAlignment="Top" Margin="132,0,0,0">
</StackPanel.Resources>
<Button Visibility="Hidden" Content="[SPACER]"/>
- <Button x:Name="button8" Content="LTE neu verbinden" Click="button_click" />
+ <Button Command="{Binding Path=LteReconncetCommand}" Content="LTE neu verbinden" />
<Button Visibility="Hidden" Content="[SPACER]"/>
<Button Visibility="Hidden" Content="[SPACER]"/>
- <Button x:Name="btnSpeedtest2" Content="speedtest.t-online.de" Click="button_click"/>
+ <Button Command="{Binding Path=SpeedtestTKCommand}" Content="speedtest.t-online.de"/>
<Button Visibility="Hidden" Content="[SPACER]"/>
- <Button x:Name="btnDSLdisconnect" Content="DSL Trennen" Click="button_click"/>
- <Button x:Name="btnLTEdisconnect" Content="LTE Trennen" Click="button_click"/>
+ <Button Command="{Binding Path=DisconnectDslCommand}" Content="DSL Trennen"/>
+ <Button Command="{Binding Path=DisconnectLteCommand}" Content="LTE Trennen"/>
<Button Visibility="Hidden" Content="[SPACER]"/>
<Button Visibility="Hidden" Content="[SPACER]"/>
<Button Visibility="Hidden" Content="[SPACER]"/>
</StackPanel.Resources>
<Button Visibility="Hidden" Content="[SPACER]"/>
- <Button IsEnabled="False" x:Name="button" Content="DSL + LTE neu verbinden"/>
+ <Button IsEnabled="False" Command="{Binding Path=DslLteReconnectCommand}" Content="DSL + LTE neu verbinden"/>
<Button Visibility="Hidden" Content="[SPACER]"/>
<Button Visibility="Hidden" Content="[SPACER]"/>
<Button Visibility="Hidden" Content="[SPACER]"/>
<Button Visibility="Hidden" Content="[SPACER]"/>
- <Button x:Name="btnDSLconnect" Content="DSL Verbinden" Click="button_click"/>
- <Button x:Name="btnLTEconnect" Content="LTE Verbinden" Click="button_click"/>
+ <Button Command="{Binding Path=ConnectDslCommand}" Content="DSL Verbinden"/>
+ <Button Command="{Binding Path=ConnectLteCommand}" Content="LTE Verbinden"/>
<Button Visibility="Hidden" Content="[SPACER]"/>
<Button Visibility="Hidden" Content="[SPACER]"/>
<Button Visibility="Hidden" Content="[SPACER]"/>
-using System.Windows;
-using System.Windows.Controls;
-using System.Threading;
-using System.Diagnostics;
+using System.Windows.Controls;
namespace SpeedportHybridControl.page {
/// <summary>
public ControlsPage() {
InitializeComponent();
}
-
- private void button_click (object sender, RoutedEventArgs e) {
- /*
- if (sender.Equals(button7)) {
- MessageBoxResult result = MessageBox.Show("Willst du den Router wirklich neustarten?", "Confirmation", MessageBoxButton.YesNoCancel, MessageBoxImage.Question);
- if (result.Equals(MessageBoxResult.Yes)) {
- SpeedportHybridAPI.getInstance().reboot();
- }
- }
- else if (sender.Equals(button8)) {
- new Thread(() => {
- bool reconnectLte = SpeedportHybridAPI.getInstance().reconnectLte();
- if (reconnectLte.Equals(false)) {
- new Thread(() => { MessageBox.Show("Could not reconnect LTE.", "Confirmation", MessageBoxButton.OK, MessageBoxImage.Error); }).Start();
- LogManager.WriteToLog("Could not reconnect LTE.");
- }
- else {
- new Thread(() => { MessageBox.Show("LTE reconnected", "Confirmation", MessageBoxButton.OK, MessageBoxImage.Information); }).Start();
- }
- }).Start();
- }
- else if (sender.Equals(button9)) {
- new Thread(() => {
- bool reconnectDSL = SpeedportHybridAPI.getInstance().reconnectDSL();
- if (reconnectDSL.Equals(false)) {
- new Thread(() => { MessageBox.Show("Could not reconnect DSL.", "Confirmation", MessageBoxButton.OK, MessageBoxImage.Error); }).Start();
- LogManager.WriteToLog("Could not reconnect DSL.");
- }
- else {
- new Thread(() => { MessageBox.Show("DSL reconnected", "Confirmation", MessageBoxButton.OK, MessageBoxImage.Information); }).Start();
- }
- }).Start();
- }
- else if (sender.Equals(button10)) {
- SpeedportHybridAPI.getInstance().checkFirmware();
- }
- else if (sender.Equals(button17)) {
- MessageBoxResult result = MessageBox.Show("Beim Zurücksetzen auf die Werkseinstellungen gehen alle Ihre Einstellungen verloren.\nSind Sie sicher, dass Sie den Router zurücksetzen möchten ? ", "Confirmation", MessageBoxButton.YesNoCancel, MessageBoxImage.Question);
- if (result.Equals(MessageBoxResult.Yes)) {
- bool reconnectDSL = SpeedportHybridAPI.getInstance().resetToFactoryDefault();
- if (reconnectDSL.Equals(false)) {
- new Thread(() => { MessageBox.Show("Could not reset the router.", "Confirmation", MessageBoxButton.OK, MessageBoxImage.Error); }).Start();
- LogManager.WriteToLog("Could not reset the router.");
- }
- }
- }
- else if (sender.Equals(btnflushdns)) {
- new Thread(() => { SpeedportHybridAPI.getInstance().flushDNS(); }).Start();
- }
- else if (sender.Equals(btnSpeedtest)) {
- Process.Start("http://www.speedtest.net/");
- }
- else if (sender.Equals(btnSpeedtest2)) {
- Process.Start("http://speedtest.t-online.de/");
- }
- else if (sender.Equals(btnDSLconnect)) {
- bool status = SpeedportHybridAPI.getInstance().changeDSLStatus("online");
- if (status.Equals(false)) {
- new Thread(() => { MessageBox.Show("DSL Verbinden Fehlgeschlagen", "Confirmation", MessageBoxButton.OK, MessageBoxImage.Error); }).Start();
- LogManager.WriteToLog("Could not connect DSL.");
- }
- else {
- new Thread(() => { MessageBox.Show("DSL Verbinden erfolgreich.", "Confirmation", MessageBoxButton.OK, MessageBoxImage.Information); }).Start();
- }
- }
- else if (sender.Equals(btnDSLdisconnect)) {
- bool status = SpeedportHybridAPI.getInstance().changeDSLStatus("offline");
- if (status.Equals(false)) {
- new Thread(() => { MessageBox.Show("DSL Trennen Fehlgeschlagen", "Confirmation", MessageBoxButton.OK, MessageBoxImage.Error); }).Start();
- LogManager.WriteToLog("Could not disconnect DSL.");
- }
- else {
- new Thread(() => { MessageBox.Show("DSL Trennen erfolgreich.", "Confirmation", MessageBoxButton.OK, MessageBoxImage.Information); }).Start();
- }
- }
- else if (sender.Equals(btnLTEconnect)) {
- bool status = SpeedportHybridAPI.getInstance().changeLTEStatus("online");
- if (status.Equals(false)) {
- new Thread(() => { MessageBox.Show("LTE Verbinden Fehlgeschlagen", "Confirmation", MessageBoxButton.OK, MessageBoxImage.Error); }).Start();
- LogManager.WriteToLog("Could not connect LTE.");
- }
- else {
- new Thread(() => { MessageBox.Show("LTE Verbinden erfolgreich.", "Confirmation", MessageBoxButton.OK, MessageBoxImage.Information); }).Start();
- }
- }
- else if (sender.Equals(btnLTEdisconnect)) {
- bool status = SpeedportHybridAPI.getInstance().changeLTEStatus("offline");
- if (status.Equals(false)) {
- new Thread(() => { MessageBox.Show("LTE Trennen Fehlgeschlagen", "Confirmation", MessageBoxButton.OK, MessageBoxImage.Error); }).Start();
- LogManager.WriteToLog("Could not disconnect LTE.");
- }
- else {
- new Thread(() => { MessageBox.Show("LTE Trennen erfolgreich.", "Confirmation", MessageBoxButton.OK, MessageBoxImage.Information); }).Start();
- }
- }
- */
- }
}
}