SettingsDialog.cs 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. namespace crusherScanner
  11. {
  12. public partial class SettingsDialog : Form
  13. {
  14. public SettingsDialog()
  15. {
  16. InitializeComponent();
  17. }
  18. /// <summary>
  19. /// Save and Exit.
  20. /// </summary>
  21. private void button5_Click(object sender, EventArgs e)
  22. {
  23. Properties.Settings.Default.CrusherNo = (int)numericUpDown1.Value;
  24. Properties.Settings.Default.PrepmasterMagazineSerial = textBox1.Text;
  25. Properties.Settings.Default.OreDefInFile = textBox2.Text;
  26. Properties.Settings.Default.OreDefWorkFile = textBox3.Text;
  27. Properties.Settings.Default.OreDefOutFile = textBox4.Text;
  28. Properties.Settings.Default.OutputFormat = comboBox1.Text;
  29. Properties.Settings.Default.OreDefTypes = textBox5.Text;
  30. Properties.Settings.Default.LimsConnection = checkBox6.Checked;
  31. Properties.Settings.Default.LimsConnString = textBox6.Text;
  32. Properties.Settings.Default.PrepmasterConnection = checkBox1.Checked;
  33. Properties.Settings.Default.LoggingDebug = checkBox5.Checked;
  34. Properties.Settings.Default.LoggingInfo = checkBox4.Checked;
  35. Properties.Settings.Default.LoggingWarning = checkBox3.Checked;
  36. Properties.Settings.Default.LoggingError = checkBox2.Checked;
  37. Properties.Settings.Default.Save();
  38. Close();
  39. }
  40. private void SettingsDialog_Load(object sender, EventArgs e)
  41. {
  42. numericUpDown1.Value = Properties.Settings.Default.CrusherNo;
  43. textBox1.Text = Properties.Settings.Default.PrepmasterMagazineSerial;
  44. textBox2.Text = Properties.Settings.Default.OreDefInFile;
  45. textBox3.Text = Properties.Settings.Default.OreDefWorkFile;
  46. textBox4.Text = Properties.Settings.Default.OreDefOutFile;
  47. comboBox1.Text = Properties.Settings.Default.OutputFormat;
  48. textBox5.Text = Properties.Settings.Default.OreDefTypes;
  49. checkBox6.Checked = Properties.Settings.Default.LimsConnection;
  50. textBox6.Text = Properties.Settings.Default.LimsConnString;
  51. checkBox1.Checked = Properties.Settings.Default.PrepmasterConnection;
  52. checkBox5.Checked = Properties.Settings.Default.LoggingDebug;
  53. checkBox4.Checked = Properties.Settings.Default.LoggingInfo;
  54. checkBox3.Checked = Properties.Settings.Default.LoggingWarning;
  55. checkBox2.Checked = Properties.Settings.Default.LoggingError;
  56. }
  57. /// <summary>
  58. /// Discard and exit.
  59. /// </summary>
  60. private void button4_Click(object sender, EventArgs e)
  61. {
  62. this.Close();
  63. }
  64. /// <summary>
  65. /// OreDef input file dir.
  66. /// </summary>
  67. private void button1_Click(object sender, EventArgs e)
  68. {
  69. string returnPath = FolderBrowser(textBox2.Text);
  70. if (returnPath != "")
  71. {
  72. textBox2.Text = returnPath;
  73. }
  74. }
  75. /// <summary>
  76. /// OreDef working file dir.
  77. /// </summary>
  78. private void button2_Click(object sender, EventArgs e)
  79. {
  80. string returnPath = FolderBrowser(textBox3.Text);
  81. if (returnPath != "")
  82. {
  83. textBox3.Text = returnPath;
  84. }
  85. }
  86. /// <summary>
  87. /// OreDef output file dir.
  88. /// </summary>
  89. private void button3_Click(object sender, EventArgs e)
  90. {
  91. string returnPath = FolderBrowser(textBox4.Text);
  92. if (returnPath != "")
  93. {
  94. textBox4.Text = returnPath;
  95. }
  96. }
  97. /// <summary>
  98. /// Dynamic folder dialog.
  99. /// </summary>
  100. private string FolderBrowser(string path)
  101. {
  102. folderBrowserDialog1.Reset();
  103. if (path != "")
  104. {
  105. //folderBrowserDialog1.InitialDirectory = path;
  106. folderBrowserDialog1.SelectedPath = path;
  107. }
  108. DialogResult result = folderBrowserDialog1.ShowDialog();
  109. if (result == DialogResult.OK)
  110. {
  111. return folderBrowserDialog1.SelectedPath;
  112. }
  113. else
  114. {
  115. return "";
  116. }
  117. }
  118. }
  119. }