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"; } }
public void WaitingEncrypt() { System.Threading.Thread.Sleep(2000); if (File.Exists(AStatic.DbPath)) { while (true) { if (!IsFileInUse(AStatic.DbPath)) { AEncrypter encrypter = new AEncrypter(); encrypter.EncryptFile(AStatic.DbPath); AStatic.IsRunning = false; break; } } } }