예제 #1
0
 private void Window_Loaded(object sender, RoutedEventArgs e)
 {
     //tUsername.Text = preferencesData.UserId;
     preferencesData = Global.CurrentPreferences;
     if (preferencesData == null)
         return;
     this.DataContext = preferencesData;
     tPassword.Password = string.IsNullOrEmpty(preferencesData.Password) ? string.Empty : "12345678";
     tPassword.PasswordChanged += (s, args) => encryptedPassword = DataProtector.EncryptData(tPassword.Password);
 }
예제 #2
0
 private void Ok_Click(object sender, RoutedEventArgs e)
 {
     string encryptedPwd = DataProtector.EncryptData(tPassword.Password);
     Preferences preferences = new Preferences{
         UserId = tUsername.Text,
         Password = encryptedPwd
     };
     XmlManager.Serialize(preferences, Global.SettingsFile );
     Global.CurrentPreferences = preferences;
     Close();
 }
예제 #3
0
        private void Ok_Click(object sender, RoutedEventArgs e)
        {
            //string encryptedPwd = DataProtector.EncryptData(tPassword.Password);
            Currency currency = cbCurrency.SelectedItem == null ? Currency.Unknown : (Currency) cbCurrency.SelectedItem;

            Preferences preferences = new Preferences{
                UserId = tUsername.Text,
                Password = string.IsNullOrEmpty(encryptedPassword) ? Global.CurrentPreferences.Password : encryptedPassword,
                Currency = currency,
                ProxyAddress = tbProxyServer.Text,
                ProxyPort = int.Parse(tbProxyPort.Text)
            };

            XmlManager.Serialize(preferences, Path.Combine(Global.CurrentDir, Global.SettingsFile));
            Global.CurrentPreferences = preferences;
            Close();
        }
예제 #4
0
        public static void Init()
        {
            string localAppData = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "BrickLab");
            if (!Directory.Exists(localAppData))
                Directory.CreateDirectory(localAppData);

            CurrentDir = localAppData;

            string settingsPath = Path.Combine(CurrentDir, SettingsFile);
            if (File.Exists(settingsPath))
                CurrentPreferences = XmlManager.Deserialize<Preferences>(settingsPath);
            else
                CurrentPreferences = new Preferences();
        }