public void ConnectToDatabase(bool appStartup) { DBConnectionWindow window = new DBConnectionWindow(); DBConnectionViewModel vm = new DBConnectionViewModel(window); window.DataContext = vm; vm.Server = RegistrySettings.GetValue <string>("DatabaseServer", "localhost"); vm.Database = RegistrySettings.GetValue <string>("Database", "Lithnet.Acma"); bool?result = window.ShowDialog(); if (result.HasValue && result.Value) { try { ActiveConfig.OpenDatabase(vm.Server, vm.Database); this.Database = new AcmaDatabaseViewModel(this); RegistrySettings.SetValue("DatabaseServer", vm.Server); RegistrySettings.SetValue("Database", vm.Database); } catch (Exception ex) { MessageBox.Show("Could not connect to specified database. " + ex.Message); this.ConnectToDatabase(appStartup); } } else { if (appStartup) { Environment.Exit(0); } } }
private void AddMRUItem(string filename) { if (string.IsNullOrWhiteSpace(filename) || !System.IO.File.Exists(filename)) { return; } List <string> mrulist = this.GetMRUItems(); if (mrulist.Contains(filename)) { mrulist.Remove(filename); } mrulist.Insert(0, filename); if (mrulist.Count >= 10) { for (int i = 10; i < mrulist.Count; i++) { mrulist.RemoveAt(i); } } RegistrySettings.SetValue("MRUList", mrulist); }
private void RemoveMRUItem(string filename) { List <string> mrulist = this.GetMRUItems(); if (mrulist.Contains(filename)) { mrulist.Remove(filename); } RegistrySettings.SetValue("MRUList", mrulist); }
private void MainWindow_Closing(object sender, CancelEventArgs e) { this.UpdateFocusedBindings(); if (this.ViewModelIsDirty && !this.confirmedCloseOnDirtyViewModel) { if (MessageBox.Show("There are unsaved changes. Are you sure you want to exit?", "Unsaved Changes", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.No) { e.Cancel = true; } } //Save current TreeWidth value to registry. RegistrySettings.SetValue("TreeWidth", intTreeWidth.ToString()); }