private void signin_button_Click(object sender, RoutedEventArgs e) { AUtils t = new AUtils(); AEncrypter encrypter = new AEncrypter(); encrypter.ReadKeyFile(); AStatic.StringKey = key_textBox.Text; if (encrypter.ValidKey(AStatic.StringKey)) { if (encrypter.DecryptFile(AStatic.DbPath)) { AStatic.IsRunning = true; t.ReadCatalog(); NavigationService.Navigate(new Uri("AHome.xaml", UriKind.Relative)); } } else { signinlabel.Content = FindResource("StrUid_wrongkey").ToString(); } }
private void good_button_Click(object sender, RoutedEventArgs e) { DelFromDb(tag); AUtils tool = new AUtils(); tool.ReadCatalog(); NavigationService.Navigate(new AHome()); }
/// <summary> /// 程序启动后即读取配置文件config.ini /// 获取数据库的文件路径和语言设置 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void App_Startup(object sender, StartupEventArgs e) { AUtils t = new AUtils(); t.ReadDbpath(); t.ReadLang(); t.ChooseLang(AStatic.Lang); }
private void comboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { string chooselang = dic[comboBox.SelectedIndex]; if (chooselang != AStatic.Lang) { AStatic.Lang = chooselang; AUtils t = new AUtils(); t.ChooseLang(chooselang); t.WriteLang(); } }
private void start_button_Click(object sender, RoutedEventArgs e) { // save dbpath to config.ini if (db_textBox.Text != "" && key_textBox.Text != "") { AUtils tool = new AUtils(); AEncrypter encrypter = new AEncrypter(); // 1 weite to config.ini tool.WriteConfig(db_textBox.Text); tool.ReadDbpath(); // 2 gen key file AStatic.StringKey = key_textBox.Text; encrypter.WriteKeyFile(key_textBox.Text); encrypter.ReadKeyFile(); // 3 create db Createdbtable(); DisableInit(); // 4 envrypt db encrypter.EncryptFile(AStatic.DbPath); Window m = Application.Current.Properties["mainwindow"] as Window; Frame main_frame = m.FindName("main_frame") as Frame; main_frame.Navigate(new ASignin()); } else if (db_textBox.Text == "") { db_textBox.Foreground = Brushes.Red; db_textBox.Text = "DB path can NOT be null"; } else if (key_textBox.Text == "") { key_textBox.Foreground = Brushes.Red; key_textBox.Text = "Key can NOT be null"; } }
private void search_textBox_TextChanged(object sender, TextChangedEventArgs e) { List<ALibModel> searchList; isHit = search_textBox.Text.Length < searchStrLen ? false : isHit; if (!isHit) { hitList.Clear(); } searchStrLen = search_textBox.Text.Length; comList.Clear(); if (AStatic.Catalog != null && search_textBox.Text != "") { AUtils t = new AUtils(); searchList = isHit ? hitList : AStatic.Catalog; foreach (ALibModel item in searchList) { if (PyIndex(search_textBox.Text, item) == item.Tag) { comList.Add(item); if (!isHit) { hitList.Add(item); } } } if (comList.Count > 0) { isHit = true; //complete_grid.Height = 100; // complete_grid.MaxHeight = 300; //complete_grid.Height = completeListBox.Items.Count * 40; //completeListBox.Height; //complete_grid.Children.Add(completeBorder); //ac.Focus(); AComplete com = new AComplete(); lib_frame.Navigate(com); ListBox comlb = com.FindName("listBox") as ListBox; comViewModel = comlb.DataContext as ACompleteViewModel; foreach (ALibModel item in comList) { comViewModel.Accountlist.Add(item); } comViewModel.Selectedindex = 0; } else { isHit = false; // if no result in search, show a tip. ALib a = new ALib(); lib_frame.Navigate(a); TextBox b = new TextBox() { FontSize = 16 }; b.Text = FindResource("StrUid_noresult") as string; b.Text += " \"" + search_textBox.Text + "\""; Grid c = a.FindName("grid") as Grid; c.Children.Add(b); } } else { isHit = false; lib_frame.Navigate(new Uri("ALib.xaml", UriKind.Relative)); } }