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.OreDefTypes = textBox5.Text;
Properties.Settings.Default.LimsConnection = checkBox6.Checked;
Properties.Settings.Default.LimsConnString = textBox6.Text;
Properties.Settings.Default.PrepmasterConnection = checkBox1.Checked;
Properties.Settings.Default.LoggingDebug = checkBox5.Checked;
Properties.Settings.Default.LoggingInfo = checkBox4.Checked;
Properties.Settings.Default.LoggingWarning = checkBox3.Checked;
Properties.Settings.Default.LoggingError = checkBox2.Checked;
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;
textBox5.Text = Properties.Settings.Default.OreDefTypes;
checkBox6.Checked = Properties.Settings.Default.LimsConnection;
textBox6.Text = Properties.Settings.Default.LimsConnString;
checkBox1.Checked = Properties.Settings.Default.PrepmasterConnection;
checkBox5.Checked = Properties.Settings.Default.LoggingDebug;
checkBox4.Checked = Properties.Settings.Default.LoggingInfo;
checkBox3.Checked = Properties.Settings.Default.LoggingWarning;
checkBox2.Checked = Properties.Settings.Default.LoggingError;
}
///
/// 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 "";
}
}
}
}