Ignore:
Timestamp:
Jan 18, 2011, 10:10:46 PM (11 years ago)
Author:
kopal
Message:
  • changing user name and/or password in settings now changes these also on the connect view
  • removed the lase message boxes and replaced them by label outputs
Location:
trunk/CrypPlugins/P2PEditor
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/CrypPlugins/P2PEditor/GUI/Controls/ConnectView.xaml

    r2376 r2379  
    1 <GUI:P2PUserControl x:Class="Cryptool.P2PEditor.GUI.Controls.ConnectTab" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:GUI="clr-namespace:Cryptool.P2PEditor.GUI" xmlns:Converters="clr-namespace:Cryptool.P2PEditor.Converters" mc:Ignorable="d" d:DesignHeight="550" d:DesignWidth="360" IsVisibleChanged="P2PUserControl_IsVisibleChanged">
     1<GUI:P2PUserControl x:Class="Cryptool.P2PEditor.GUI.Controls.ConnectTab" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:GUI="clr-namespace:Cryptool.P2PEditor.GUI" xmlns:Converters="clr-namespace:Cryptool.P2PEditor.Converters" mc:Ignorable="d" d:DesignHeight="550" d:DesignWidth="360" IsVisibleChanged="P2PUserControl_IsVisibleChanged" Loaded="P2PUserControl_Loaded">
    22        <GUI:P2PUserControl.Resources>
    33                <Converters:InverseBooleanConverter x:Key="InverseBooleanConverter" />
     
    1010        <ScrollViewer VerticalScrollBarVisibility="Auto">
    1111                    <StackPanel VerticalAlignment="Center" HorizontalAlignment="Center" Margin="15,15,15,15">
    12                 <Label FontSize="20" HorizontalContentAlignment="Center">CrypTool 2.0</Label>
    13                 <Label FontSize="13" HorizontalContentAlignment="Center">Distributed Computing Platform</Label>               
     12                <Label FontSize="20" HorizontalContentAlignment="Center" Width="200">CrypTool 2.0</Label>
     13                <Label FontSize="13" HorizontalContentAlignment="Center" Width="200">Distributed Computing Platform</Label>
    1414                <Image Width="200" Name="WorldIcon" Source="..\..\images\connected.png" RenderTransformOrigin="0.5,0.5">
    1515                    <Image.RenderTransform>
     
    1717                    </Image.RenderTransform>
    1818                </Image>
    19                 <Label>Username:</Label>
    20                 <TextBox Name="Username" TextChanged="Username_TextChanged" IsEnabled="{Binding IsP2PConnecting, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Converter={StaticResource InverseBooleanConverter}}" />
    21                 <TextBlock FontSize="12" MouseDown="GetACertificateLabel_Click" Cursor="Hand" HorizontalAlignment="Right" IsEnabled="{Binding IsP2PConnecting, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Converter={StaticResource InverseBooleanConverter}}" Foreground="{Binding IsP2PConnecting, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Converter={StaticResource ForegroundColorConverter}}">
     19                <Label Name="MessageLabel" Foreground="Red" Content="" Grid.Row="1" Grid.ColumnSpan="2" />
     20                <Label Width="200">Username:</Label>
     21                <TextBox Width="200" Name="Username" TextChanged="Username_TextChanged" IsEnabled="{Binding IsP2PConnecting, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Converter={StaticResource InverseBooleanConverter}}" />
     22                <TextBlock Width="200" FontSize="12" MouseDown="GetACertificateLabel_Click" Cursor="Hand" HorizontalAlignment="Center" IsEnabled="{Binding IsP2PConnecting, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Converter={StaticResource InverseBooleanConverter}}" Foreground="{Binding IsP2PConnecting, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Converter={StaticResource ForegroundColorConverter}}">
    2223                    <Underline>Create a new account</Underline>
    2324                </TextBlock>
    24                 <Label>Password:</Label>
    25                 <PasswordBox Name="Password" PasswordChanged="Password_PasswordChanged" IsEnabled="{Binding IsP2PConnecting, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Converter={StaticResource InverseBooleanConverter}}" />
    26                 <TextBlock FontSize="12" MouseDown="ForgotPasswordLabel_Click" Cursor="Hand" HorizontalAlignment="Right" IsEnabled="{Binding IsP2PConnecting, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Converter={StaticResource InverseBooleanConverter}}" Foreground="{Binding IsP2PConnecting, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Converter={StaticResource ForegroundColorConverter}}">
     25                <Label Width="200">Password:</Label>
     26                <PasswordBox Width="200" Name="Password" PasswordChanged="Password_PasswordChanged" IsEnabled="{Binding IsP2PConnecting, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Converter={StaticResource InverseBooleanConverter}}" />
     27                <TextBlock Width="200" FontSize="12" MouseDown="ForgotPasswordLabel_Click" Cursor="Hand" HorizontalAlignment="Center" IsEnabled="{Binding IsP2PConnecting, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Converter={StaticResource InverseBooleanConverter}}" Foreground="{Binding IsP2PConnecting, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Converter={StaticResource ForegroundColorConverter}}">
    2728                    <Underline>Forgot password</Underline>
    2829                </TextBlock>
    2930                <Label/>
    30                 <Button Name="ConnectButton" IsDefault="True" Content="Connect" Height="38" FontFamily="Consolas" FontSize="20" Click="ConnectButtonClick" IsEnabled="{Binding IsP2PConnecting, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Converter={StaticResource InverseBooleanConverter}}" />               
     31                <Button Width="200" Name="ConnectButton" IsDefault="True" Content="Connect" Height="38" FontFamily="Consolas" FontSize="20" Click="ConnectButtonClick" IsEnabled="{Binding IsP2PConnecting, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Converter={StaticResource InverseBooleanConverter}}" />               
    3132            </StackPanel>
    3233        </ScrollViewer>
  • trunk/CrypPlugins/P2PEditor/GUI/Controls/ConnectView.xaml.cs

    r2376 r2379  
    99using Cryptool.PluginBase;
    1010using System.IO;
     11using System.ComponentModel;
    1112
    1213namespace Cryptool.P2PEditor.GUI.Controls
     
    5556                    , null);         
    5657                }
    57             });
    58 
     58            });           
    5959        }
    6060
    6161        private void ConnectButtonClick(object sender, RoutedEventArgs e)
    6262        {
     63            this.MessageLabel.Visibility = Visibility.Hidden;
    6364            try
    6465            {
    6566                if (CertificateServices.GetPeerCertificateByAvatar(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "PeersAtPlay" + Path.DirectorySeparatorChar + "Certificates" + Path.DirectorySeparatorChar),
    66                     P2PSettings.Default.PeerName, P2PSettings.Default.Password) == null)
     67                    P2PSettings.Default.PeerName, P2PBase.DecryptString(P2PSettings.Default.Password)) == null)
    6768                {
    68                     System.Windows.MessageBox.Show("Cannot connect, account \"" + P2PSettings.Default.PeerName + "\" not found!", "Can not connect.");
     69                    this.MessageLabel.Content = "Cannot connect, account \"" + P2PSettings.Default.PeerName + "\" not found!";
     70                    this.MessageLabel.Visibility = Visibility.Visible;
    6971                    return;
    7072                }
     
    7274            catch (NoCertificateFoundException)
    7375            {
    74                 System.Windows.MessageBox.Show("Cannot connect, account \"" + P2PSettings.Default.PeerName + "\" not found!", "Can not connect.");
     76                this.MessageLabel.Content = "Cannot connect, account \"" + P2PSettings.Default.PeerName + "\" not found!";
     77                this.MessageLabel.Visibility = Visibility.Visible;
    7578                return;
    7679            }           
    7780            catch (Exception ex)
    7881            {
    79                 System.Windows.MessageBox.Show("Cannot connect using account \"" + P2PSettings.Default.PeerName + "\": " + (ex.InnerException != null ? ex.InnerException.Message : ex.Message), "Can not connect.");
     82                this.MessageLabel.Content = "Cannot connect using account \"" + P2PSettings.Default.PeerName + "\": " + (ex.InnerException != null ? ex.InnerException.Message : ex.Message);
     83                this.MessageLabel.Visibility = Visibility.Visible;
    8084                return;
    8185            }
     
    125129            }
    126130        }
     131
     132        private void OnPropertyChanged_Settings(object sender, PropertyChangedEventArgs args)
     133        {           
     134            if(args.PropertyName.Equals("PeerName")){
     135                //this.Dispatcher.Invoke(DispatcherPriority.Normal, (SendOrPostCallback)delegate
     136                //{
     137                    if (this.Username.Text != ((P2PEditorSettings)sender).PeerName)
     138                    {
     139
     140                        this.Username.Text = ((P2PEditorSettings)sender).PeerName;
     141                    }
     142                //},null);
     143            }
     144            if(args.PropertyName.Equals("Password")){
     145                //this.Dispatcher.Invoke(DispatcherPriority.Normal, (SendOrPostCallback)delegate
     146                //{
     147                    if (this.Password.Password != ((P2PEditorSettings)sender).Password)
     148                    {
     149                        this.Password.Password = ((P2PEditorSettings)sender).Password;
     150                    }
     151                //},null);
     152            }           
     153        }
     154
     155        private void P2PUserControl_Loaded(object sender, RoutedEventArgs e)
     156        {
     157            ((P2PEditorSettings)((P2PEditor)GetValue(P2PEditorProperty)).Settings).PropertyChanged += OnPropertyChanged_Settings;
     158        }
    127159    }
    128160}
  • trunk/CrypPlugins/P2PEditor/GUI/Controls/GetNewCertificateView.xaml.cs

    r2378 r2379  
    179179                        this.Dispatcher.Invoke(DispatcherPriority.Normal, (SendOrPostCallback)delegate
    180180                        {
    181                             this.MessageLabel.Content = "The username already exists. Please chose another one.";
     181                            this.MessageLabel.Content = "The username already exists. Please choose another one.";
    182182                            this.MessageLabel.Visibility = Visibility.Visible;
    183183                        }, null);
     
    186186                        this.Dispatcher.Invoke(DispatcherPriority.Normal, (SendOrPostCallback)delegate
    187187                        {
    188                             this.MessageLabel.Content = "The email already exists. Please chose another ones.";
     188                            this.MessageLabel.Content = "The email already exists. Please choose another one.";
    189189                            this.MessageLabel.Visibility = Visibility.Visible;
    190190                        }, null);
  • trunk/CrypPlugins/P2PEditor/P2PEditorSettings.cs

    r2378 r2379  
    2424using System.Security.Cryptography;
    2525using System;
     26using Cryptool.P2P.Internal;
    2627
    2728namespace Cryptool.P2PEditor
     
    112113        public string Password
    113114        {
    114             get { return settings.Password; }
    115             set
    116             {
    117                 if (value != settings.Password)
    118                 {
    119                     settings.Password = value;
     115            get { return P2PBase.DecryptString(settings.Password); }
     116            set
     117            {
     118                if (P2PBase.EncryptString(value) != settings.Password)
     119                {
     120                    settings.Password = P2PBase.EncryptString(value);
    120121                    OnPropertyChanged("Password");
    121122                    HasChanges = true;
     
    356357            P2PSettings.Default.Save();
    357358        }
     359
    358360    }
    359361}
Note: See TracChangeset for help on using the changeset viewer.