Exemple #1
0
        /// <summary>
        /// Loads the configuration file.
        /// </summary>
        /// <returns>Dictionary of name and command pairs.</returns>
        private static IList<string[]> LoadConfigFile()
        {
            IList<string[]> commands = new List<string []>();

            // Load config file.
            // Check if file exists
            while (!File.Exists(Properties.Settings.Default.ConfigurationFile))
            {
                string message = "Config file not found. Please check settings and try again.";
                string caption = "File Not Found";
                MessageBoxButtons buttons = MessageBoxButtons.OKCancel;

                DialogResult result = MessageBox.Show(message, caption, buttons);
                if (result == DialogResult.OK)
                {
                    SettingsForm setting = new SettingsForm();
                    setting.ShowDialog();
                    setting.Dispose();
                }
                else
                {
                    Application.Exit();
                    return commands;
                }
            }

            using (var reader = new StreamReader(File.OpenRead(Properties.Settings.Default.ConfigurationFile)))
            {
                while (!reader.EndOfStream)
                {
                    var line = reader.ReadLine();
                    var values = line.Split(';');
                    string[] newCommand = new string[2] { values[0], values[1] };
                    commands.Add(newCommand);
                }
            }

            return commands;
        }
Exemple #2
0
 /// <summary>
 /// Handles the Click event of the SettingsToolStripMenuItem control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
 private void SettingsToolStripMenuItem_Click(object sender, EventArgs e)
 {
     SettingsForm setting = new SettingsForm();
     setting.ShowDialog();
     setting.Dispose();
 }