/// <summary> /// Called when the user selects the menu item to configure user-defined /// states. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void userStateMachinesToolStripMenuItem_Click(object sender, EventArgs e) { UserStatesConfig dlg = new UserStatesConfig(); if (dlg.ShowDialog() != DialogResult.OK) { return; } UserStatesEnabled = dlg.OptEnabled; UserStatesPath = dlg.XmlPath; }
/// <summary> /// Called when the program is loaded. Performs additional initialization. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void MainForm_Load(object sender, EventArgs e) { // Make certain we have an application data directory. string appDataFolder = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData); AppDataDirectory = Path.Combine(appDataFolder, DecodeProductName); if (!Directory.Exists(AppDataDirectory)) { try { Directory.CreateDirectory(AppDataDirectory); } catch (Exception ex) { MessageBox.Show(String.Format("Unable to create application data directory: {0}", ex.Message), "Fatal Error", MessageBoxButtons.OK, MessageBoxIcon.Stop); Application.Exit(); } } // Make certain we have a directory for the database. DatabaseCreator.DatabaseFolder = DatabaseConfig.ReadDatabaseFolder(); if (DatabaseCreator.DatabaseFolder == null) { DatabaseCreator.DatabaseFolder = ShowDatabaseConfiguration(); } if (DatabaseCreator.DatabaseFolder == null) { Application.Exit(); } // Make certain that we have a database. If not, create it. if (!DatabaseCreator.Exists()) { try { DatabaseCreator.CreateAndInitialize(); } catch (Exception ex) { string err = String.Format("Unable to coninue: failed to create and initialize the database. {0}", ex.Message); MessageBox.Show(err, "Fatal Database Error", MessageBoxButtons.OK, MessageBoxIcon.Stop); Application.Exit(); } } else { DatabaseCreator.PopulateConstantsMigrate(); } // Load the default filters. DecodeFilters.ResultFilters.LoadDefaultFilters(); // Load whether user-defined states are enabled. UserStatesEnabled = UserStatesConfig.ReadUserStateConfig(out UserStatesPath); }