--- /dev/null
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+
+namespace SpeedportHybridControl.Implementations {
+ public static class PasswordHelper {
+ public static readonly DependencyProperty PasswordProperty =
+ DependencyProperty.RegisterAttached("Password",
+ typeof(string), typeof(PasswordHelper),
+ new FrameworkPropertyMetadata(string.Empty, OnPasswordPropertyChanged));
+
+ public static readonly DependencyProperty AttachProperty =
+ DependencyProperty.RegisterAttached("Attach",
+ typeof(bool), typeof(PasswordHelper), new PropertyMetadata(false, Attach));
+
+ private static readonly DependencyProperty IsUpdatingProperty =
+ DependencyProperty.RegisterAttached("IsUpdating", typeof(bool),
+ typeof(PasswordHelper));
+
+
+ public static void SetAttach (DependencyObject dp, bool value) {
+ dp.SetValue(AttachProperty, value);
+ }
+
+ public static bool GetAttach (DependencyObject dp) {
+ return (bool)dp.GetValue(AttachProperty);
+ }
+
+ public static string GetPassword (DependencyObject dp) {
+ return (string)dp.GetValue(PasswordProperty);
+ }
+
+ public static void SetPassword (DependencyObject dp, string value) {
+ dp.SetValue(PasswordProperty, value);
+ }
+
+ private static bool GetIsUpdating (DependencyObject dp) {
+ return (bool)dp.GetValue(IsUpdatingProperty);
+ }
+
+ private static void SetIsUpdating (DependencyObject dp, bool value) {
+ dp.SetValue(IsUpdatingProperty, value);
+ }
+
+ private static void OnPasswordPropertyChanged (DependencyObject sender,
+ DependencyPropertyChangedEventArgs e) {
+ PasswordBox passwordBox = sender as PasswordBox;
+ passwordBox.PasswordChanged -= PasswordChanged;
+
+ if (!(bool)GetIsUpdating(passwordBox)) {
+ passwordBox.Password = (string)e.NewValue;
+ }
+ passwordBox.PasswordChanged += PasswordChanged;
+ }
+
+ private static void Attach (DependencyObject sender,
+ DependencyPropertyChangedEventArgs e) {
+ PasswordBox passwordBox = sender as PasswordBox;
+
+ if (passwordBox == null)
+ return;
+
+ if ((bool)e.OldValue) {
+ passwordBox.PasswordChanged -= PasswordChanged;
+ }
+
+ if ((bool)e.NewValue) {
+ passwordBox.PasswordChanged += PasswordChanged;
+ }
+ }
+
+ private static void PasswordChanged (object sender, RoutedEventArgs e) {
+ PasswordBox passwordBox = sender as PasswordBox;
+ SetIsUpdating(passwordBox, true);
+ SetPassword(passwordBox, passwordBox.Password);
+ SetIsUpdating(passwordBox, false);
+ }
+ }
+}
<Private>True</Private>
</Reference>
<Reference Include="PresentationCore" />
+ <Reference Include="PresentationFramework" />
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
+ <Reference Include="WindowsBase" />
</ItemGroup>
<ItemGroup>
<Compile Include="Cryptography.cs" />
<Compile Include="DelegateCommand.cs" />
<Compile Include="LogManager.cs" />
+ <Compile Include="PasswordHelper.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SingletonFactory.cs" />
<Compile Include="sjcl.cs" />
<Application.Resources>
<ResourceDictionary>
<model:MainWindowModel x:Key="MainWindowModel"></model:MainWindowModel>
-
+ <model:LoginPageModel x:Key="LoginPageModel"></model:LoginPageModel>
+
<model:Status x:Key="Status"></model:Status>
<model:LTE x:Key="LTE"></model:LTE>
<model:LTE x:Key="LTE2"></model:LTE>
</Style>
</StackPanel.Resources>
- <Button Command="{Binding Path=SwitchToLoginPage}" Background="{Binding Path=ButtonLoginPageBackground}" x:Name="btnLogin" Content="Login"/>
+ <Button Command="{Binding Path=SwitchToLoginPage}" Background="{Binding Path=ButtonLoginPageBackground}" x:Name="btnLogin" Content="{Binding Path=LoginButtonContent}"/>
<Button Command="{Binding Path=SwitchToStatusPage}" Background="{Binding Path=ButtonStatusPageBackground}" Click="button_click" x:Name="btnStatus" Content="Status"/>
<Button Command="{Binding Path=SwitchToOverviewPage}" IsEnabled="{Binding Path=ButtonOverviewPageIsActive}" Background="{Binding Path=ButtonOverviewPageBackground}" x:Name="btnOverview" Content="Overview"/>
<Button Command="{Binding Path=SwitchToDSLPage}" IsEnabled="{Binding Path=ButtonDSLPageIsActive}" Background="{Binding Path=ButtonDSLPageBackground}" x:Name="btnDsl" Content="DSL"/>
--- /dev/null
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using SpeedportHybridControl.Implementations;
+
+namespace SpeedportHybridControl.Model {
+ class LoginPageModel : SuperViewModel {
+ private string _ip = "speedport.ip";
+ private string _password;
+ private bool _showPassword;
+ private bool _savePassword;
+
+ 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 bool ShowPassword {
+ get { return _showPassword; }
+ set { SetProperty(ref _showPassword, value); }
+ }
+
+ public bool SavePassword {
+ get { return _savePassword; }
+ set { SetProperty(ref _savePassword, 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 () {
+ Console.WriteLine(ShowPassword);
+ }
+
+ private void OnSavePasswordCommandExecute () {
+ Console.WriteLine(SavePassword);
+ }
+
+ private void OnLoginCommandExecute () {
+ Console.WriteLine(password);
+ }
+
+ public LoginPageModel () {
+ ShowPasswordCommand = new DelegateCommand(new Action(OnShowPasswordCommandExecute));
+ SavePasswordCommand = new DelegateCommand(new Action(OnSavePasswordCommandExecute));
+ LoginCommand = new DelegateCommand(new Action(OnLoginCommandExecute));
+ }
+ }
+}
<Compile Include="Model\bonding_client.cs" />
<Compile Include="Model\DeviceViewModel.cs" />
<Compile Include="Model\DSLViewModel.cs" />
+ <Compile Include="Model\LoginPageModel.cs" />
<Compile Include="Model\LTEViewModel.cs" />
<Compile Include="Model\MainWindowModel.cs" />
<Compile Include="Model\OverviewModel.cs" />
namespace SpeedportHybridControl.Model {
class MainWindowModel : SuperViewModel {
+ private string _loginButtonContent = "Login";
+
private DelegateCommand _switchToLoginPage;
private DelegateCommand _switchToStatusPage;
private DelegateCommand _switchToOverviewPage;
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); }
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:SpeedportHybridControl"
+ xmlns:Implementations="clr-namespace:SpeedportHybridControl.Implementations;assembly=SpeedportHybridControl.Implementations"
mc:Ignorable="d"
Loaded="loaded"
Width="Auto" Height="Auto"
Title="LoginPage">
- <Grid>
+ <Grid DataContext="{StaticResource LoginPageModel}">
<TextBlock x:Name="diTextBlock" HorizontalAlignment="Left" Margin="51,21,0,0" TextWrapping="Wrap" Text="Domain/IP:" VerticalAlignment="Top"/>
- <TextBox x:Name="tbip" HorizontalAlignment="Left" Height="23" Margin="115,14,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="120"/>
+ <TextBox Text="{Binding Path=ip, Mode=TwoWay}" x:Name="tbip" HorizontalAlignment="Left" Height="23" Margin="115,14,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="120"/>
<TextBlock x:Name="tbpw" Text="Passwort:" HorizontalAlignment="Left" Margin="55,49,0,0" VerticalAlignment="Top" />
- <PasswordBox x:Name="PasswordBox" HorizontalAlignment="Left" Height="23" Margin="115,42,0,0" VerticalAlignment="Top" Width="120" ForceCursor="True"/>
- <TextBox x:Name="PasswordTextBox" HorizontalAlignment="Left" Height="23" Margin="115,42,0,0" VerticalAlignment="Top" Width="120" Visibility="Hidden"/>
- <CheckBox x:Name="PasswordCheckBox" Content="Passwort anzeigen" Margin="240,50,0,0" Checked="CheckBox" Unchecked="CheckBox" HorizontalAlignment="Left" VerticalAlignment="Top" />
- <CheckBox x:Name="cbSave" Content="Passwort speichern" Margin="240,65,0,0" Checked="CheckBox" Unchecked="CheckBox" HorizontalAlignment="Left" VerticalAlignment="Top" />
- <Button x:Name="button1" Content="Login" HorizontalAlignment="Left" Margin="115,70,0,0" VerticalAlignment="Top" Width="75" Click="button_click" IsDefault="True"/>
+ <PasswordBox Implementations:PasswordHelper.Attach="True" Implementations:PasswordHelper.Password="{Binding Path=password, Mode=TwoWay}" x:Name="PasswordBox" HorizontalAlignment="Left" Height="23" Margin="115,42,0,0" VerticalAlignment="Top" Width="120" ForceCursor="True" />
+ <TextBox Text="{Binding Path=password, Mode=TwoWay}" x:Name="PasswordTextBox" HorizontalAlignment="Left" Height="23" Margin="115,42,0,0" VerticalAlignment="Top" Width="120" Visibility="Hidden"/>
+ <CheckBox Command="{Binding Path=ShowPasswordCommand}" IsChecked="{Binding Path=ShowPassword, Mode=TwoWay}" x:Name="PasswordCheckBox" Content="Passwort anzeigen" Margin="240,50,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" />
+ <CheckBox Command="{Binding Path=SavePasswordCommand}" IsChecked="{Binding Path=SavePassword, Mode=TwoWay}" x:Name="cbSave" Content="Passwort speichern" Margin="240,65,0,0" Checked="CheckBox" Unchecked="CheckBox" HorizontalAlignment="Left" VerticalAlignment="Top" />
+ <Button Command="{Binding Path=LoginCommand}" x:Name="button1" Content="Login" HorizontalAlignment="Left" Margin="115,70,0,0" VerticalAlignment="Top" Width="75" IsDefault="True"/>
</Grid>
</Page>
using System.Windows;
using System.Windows.Controls;
using System.Threading;
+using System;
+using SpeedportHybridControl.Model;
namespace SpeedportHybridControl.page {
/// <summary>