using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace crusherScanner { public partial class SettingsDialog : Form { public SettingsDialog() { InitializeComponent(); } /// /// Save and Exit. /// private void button5_Click(object sender, EventArgs e) { Properties.Settings.Default.CrusherNo = (int)numericUpDown1.Value; Properties.Settings.Default.PrepmasterMagazineSerial = textBox1.Text; Properties.Settings.Default.OreDefInFile = textBox2.Text; Properties.Settings.Default.OreDefWorkFile = textBox3.Text; Properties.Settings.Default.OreDefOutFile = textBox4.Text; Properties.Settings.Default.OutputFormat = comboBox1.Text; Properties.Settings.Default.Save(); Close(); } private void SettingsDialog_Load(object sender, EventArgs e) { numericUpDown1.Value = Properties.Settings.Default.CrusherNo; textBox1.Text = Properties.Settings.Default.PrepmasterMagazineSerial; textBox2.Text = Properties.Settings.Default.OreDefInFile; textBox3.Text = Properties.Settings.Default.OreDefWorkFile; textBox4.Text = Properties.Settings.Default.OreDefOutFile; comboBox1.Text = Properties.Settings.Default.OutputFormat; } /// /// Discard and exit. /// private void button4_Click(object sender, EventArgs e) { this.Close(); } /// /// OreDef input file dir. /// private void button1_Click(object sender, EventArgs e) { string returnPath = FolderBrowser(textBox2.Text); if (returnPath != "") { textBox2.Text = returnPath; } } /// /// OreDef working file dir. /// private void button2_Click(object sender, EventArgs e) { string returnPath = FolderBrowser(textBox3.Text); if (returnPath != "") { textBox3.Text = returnPath; } } /// /// OreDef output file dir. /// private void button3_Click(object sender, EventArgs e) { string returnPath = FolderBrowser(textBox4.Text); if (returnPath != "") { textBox4.Text = returnPath; } } /// /// Dynamic folder dialog. /// private string FolderBrowser(string path) { folderBrowserDialog1.Reset(); if (path != "") { //folderBrowserDialog1.InitialDirectory = path; folderBrowserDialog1.SelectedPath = path; } DialogResult result = folderBrowserDialog1.ShowDialog(); if (result == DialogResult.OK) { return folderBrowserDialog1.SelectedPath; } else { return ""; } } } }