Ignore:
Timestamp:
Jan 31, 2011, 1:35:16 PM (11 years ago)
Author:
kopal
Message:

added "Remember my password" button. So the user can decide if he wants to save his password on the machine or not

File:
1 edited

Legend:

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

    r2497 r2540  
    9191            WrongPassword = false;
    9292
     93            string password = null;
     94            if (P2PSettings.Default.RememberPassword)
     95            {
     96                password = P2PBase.DecryptString(P2PSettings.Default.Password);
     97            }
     98            else
     99            {
     100                password = P2PBase.DecryptString(P2PBase.Password);
     101            }
     102
    93103            try
    94104            {
     
    109119            try
    110120            {
     121                     
    111122                if (CertificateServices.GetPeerCertificateByAvatar(PeerCertificate.DEFAULT_USER_CERTIFICATE_DIRECTORY,
    112                     P2PSettings.Default.PeerName, P2PBase.DecryptString(P2PSettings.Default.Password)) == null)
     123                    P2PSettings.Default.PeerName, password) == null)
    113124                {                   
    114125                    HaveCertificate = false;               
     
    136147                    certificateClient.InvalidCertificateRequest += InvalidCertificateRequest;
    137148                    certificateClient.CertificateReceived += CertificateReceived;
    138                     certificateClient.RequestCertificate(new CertificateRequest(P2PSettings.Default.PeerName, null, P2PBase.DecryptString(P2PSettings.Default.Password)));
     149                    certificateClient.RequestCertificate(new CertificateRequest(P2PSettings.Default.PeerName, null, password));
    139150                }
    140151                catch (Exception ex)
     
    253264        }
    254265
     266        private void RememberPasswordCheckbox_Click(object sender, RoutedEventArgs e)
     267        {
     268            ((P2PEditorSettings)((P2PEditor)GetValue(P2PEditorProperty)).Settings).RememberPassword = (bool)this.RememberPasswordCheckbox.IsChecked;
     269        }
     270
    255271        private void P2PUserControl_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
    256272        {           
    257273            this.Username.Text = ((P2PEditorSettings)((P2PEditor)GetValue(P2PEditorProperty)).Settings).PeerName;
    258274            this.Password.Password = ((P2PEditorSettings)((P2PEditor)GetValue(P2PEditorProperty)).Settings).Password;
     275            this.RememberPasswordCheckbox.IsChecked = ((P2PEditorSettings)((P2PEditor)GetValue(P2PEditorProperty)).Settings).RememberPassword;
    259276            this.RaiseP2PConnectingEvent(IsP2PConnecting);
    260277        }
     
    280297                    }
    281298                //},null);
    282             }           
     299            }
     300            if (args.PropertyName.Equals("RememberPassword"))
     301            {
     302                //this.Dispatcher.Invoke(DispatcherPriority.Normal, (SendOrPostCallback)delegate
     303                //{
     304                if (this.RememberPasswordCheckbox.IsChecked != ((P2PEditorSettings)sender).RememberPassword)
     305                {
     306                    this.RememberPasswordCheckbox.IsChecked = ((P2PEditorSettings)sender).RememberPassword;
     307                }
     308                //},null);
     309            }
    283310        }
    284311
     
    287314            ((P2PEditorSettings)((P2PEditor)GetValue(P2PEditorProperty)).Settings).PropertyChanged += OnPropertyChanged_Settings;
    288315        }
     316
     317       
    289318    }
    290319}
Note: See TracChangeset for help on using the changeset viewer.