SettingsDialog.cs 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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.Save();
  30. Close();
  31. }
  32. private void SettingsDialog_Load(object sender, EventArgs e)
  33. {
  34. numericUpDown1.Value = Properties.Settings.Default.CrusherNo;
  35. textBox1.Text = Properties.Settings.Default.PrepmasterMagazineSerial;
  36. textBox2.Text = Properties.Settings.Default.OreDefInFile;
  37. textBox3.Text = Properties.Settings.Default.OreDefWorkFile;
  38. textBox4.Text = Properties.Settings.Default.OreDefOutFile;
  39. comboBox1.Text = Properties.Settings.Default.OutputFormat;
  40. }
  41. /// <summary>
  42. /// Discard and exit.
  43. /// </summary>
  44. private void button4_Click(object sender, EventArgs e)
  45. {
  46. this.Close();
  47. }
  48. /// <summary>
  49. /// OreDef input file dir.
  50. /// </summary>
  51. private void button1_Click(object sender, EventArgs e)
  52. {
  53. string returnPath = FolderBrowser(textBox2.Text);
  54. if (returnPath != "")
  55. {
  56. textBox2.Text = returnPath;
  57. }
  58. }
  59. /// <summary>
  60. /// OreDef working file dir.
  61. /// </summary>
  62. private void button2_Click(object sender, EventArgs e)
  63. {
  64. string returnPath = FolderBrowser(textBox3.Text);
  65. if (returnPath != "")
  66. {
  67. textBox3.Text = returnPath;
  68. }
  69. }
  70. /// <summary>
  71. /// OreDef output file dir.
  72. /// </summary>
  73. private void button3_Click(object sender, EventArgs e)
  74. {
  75. string returnPath = FolderBrowser(textBox4.Text);
  76. if (returnPath != "")
  77. {
  78. textBox4.Text = returnPath;
  79. }
  80. }
  81. /// <summary>
  82. /// Dynamic folder dialog.
  83. /// </summary>
  84. private string FolderBrowser(string path)
  85. {
  86. folderBrowserDialog1.Reset();
  87. if (path != "")
  88. {
  89. //folderBrowserDialog1.InitialDirectory = path;
  90. folderBrowserDialog1.SelectedPath = path;
  91. }
  92. DialogResult result = folderBrowserDialog1.ShowDialog();
  93. if (result == DialogResult.OK)
  94. {
  95. return folderBrowserDialog1.SelectedPath;
  96. }
  97. else
  98. {
  99. return "";
  100. }
  101. }
  102. }
  103. }