BeamMeasurementSettings.cs 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. namespace OINA.Extender.Testharness
  2. {
  3. using System.Globalization;
  4. using System.Windows.Forms;
  5. /// <summary>
  6. /// BeamMeasurementSettings Form.
  7. /// </summary>
  8. public partial class BeamMeasurementSettings : Form
  9. {
  10. /// <summary>
  11. /// Last selected process time
  12. /// </summary>
  13. private int processTime;
  14. /// <summary>
  15. /// Last selected Energy Range
  16. /// </summary>
  17. private int energyRange;
  18. /// <summary>
  19. /// Last selected number of channels
  20. /// </summary>
  21. private int numberOfChannels;
  22. /// <summary>
  23. /// BeamMeasurementSettings Constructor.
  24. /// </summary>
  25. public BeamMeasurementSettings()
  26. {
  27. this.InitializeComponent();
  28. this.SaveLastSettings();
  29. this.SetComboBoxDataSource();
  30. this.ReadLastSettings();
  31. }
  32. /// <summary>
  33. /// Read Last Settings
  34. /// </summary>
  35. private void ReadLastSettings()
  36. {
  37. this.ProcesstimeCombobox.SelectedItem = this.processTime;
  38. this.EnergyRangeCombobox.SelectedItem = this.energyRange;
  39. this.NumberofchannelsCombobox.SelectedItem = this.numberOfChannels;
  40. this.TotalcountsTextbox.Text = OIHelper.QuantCalibrationSettings.TotalCountsInSpectrum.ToString(CultureInfo.InvariantCulture);
  41. }
  42. /// <summary>
  43. /// Save Last Settings
  44. /// </summary>
  45. private void SaveLastSettings()
  46. {
  47. this.processTime = OIHelper.QuantCalibrationSettings.EdSettings.ProcessTime;
  48. this.energyRange = OIHelper.QuantCalibrationSettings.EdSettings.EnergyRange;
  49. this.numberOfChannels = OIHelper.QuantCalibrationSettings.EdSettings.NumberOfChannels;
  50. }
  51. /// <summary>
  52. /// Set ComboBox DataSource
  53. /// </summary>
  54. private void SetComboBoxDataSource()
  55. {
  56. this.EnergyRangeCombobox.DataSource = OIHelper.EdSpectrumSettings.EdCapabilities.AllowedEnergyRanges;
  57. this.NumberofchannelsCombobox.DataSource = OIHelper.EdSpectrumSettings.EdCapabilities.AllowedNumberOfChannels;
  58. this.ProcesstimeCombobox.DataSource = OIHelper.EdSpectrumSettings.EdCapabilities.AllowedProcessTimes;
  59. }
  60. /// <summary>
  61. /// EnergyRangeCombobox_SelectedIndexChanged event handler
  62. /// </summary>
  63. /// <param name="sender">sender</param>
  64. /// <param name="e">EventArgs</param>
  65. private void EnergyRangeCombobox_SelectedValueChanged(object sender, System.EventArgs e)
  66. {
  67. if (this.EnergyRangeCombobox.SelectedValue != null)
  68. {
  69. OIHelper.QuantCalibrationSettings.EdSettings.EnergyRange = (int)this.EnergyRangeCombobox.SelectedValue;
  70. }
  71. }
  72. /// <summary>
  73. /// NumberofchannelsCombobox_SelectedIndexChanged event handler
  74. /// </summary>
  75. /// <param name="sender">sender</param>
  76. /// <param name="e">EventArgs</param>
  77. private void NumberofchannelsCombobox_SelectedValueChanged(object sender, System.EventArgs e)
  78. {
  79. if (this.NumberofchannelsCombobox.SelectedValue != null)
  80. {
  81. OIHelper.QuantCalibrationSettings.EdSettings.NumberOfChannels = (int)this.NumberofchannelsCombobox.SelectedValue;
  82. }
  83. }
  84. /// <summary>
  85. /// ProcesstimeCombobox_SelectedIndexChanged event handler
  86. /// </summary>
  87. /// <param name="sender">sender</param>
  88. /// <param name="e">EventArgs</param>
  89. private void ProcesstimeCombobox_SelectedValueChanged(object sender, System.EventArgs e)
  90. {
  91. if (this.ProcesstimeCombobox.SelectedValue != null)
  92. {
  93. OIHelper.QuantCalibrationSettings.EdSettings.ProcessTime = (int)this.ProcesstimeCombobox.SelectedValue;
  94. }
  95. }
  96. /// <summary>
  97. /// TotalcountsTextbox_TextChanged event handler
  98. /// </summary>
  99. /// <param name="sender">sender</param>
  100. /// <param name="e">e</param>
  101. private void TotalcountsTextbox_TextChanged(object sender, System.EventArgs e)
  102. {
  103. int totalCounts;
  104. if (int.TryParse(this.TotalcountsTextbox.Text, out totalCounts))
  105. {
  106. OIHelper.QuantCalibrationSettings.TotalCountsInSpectrum = totalCounts;
  107. }
  108. }
  109. /// <summary>
  110. /// Form closing event
  111. /// </summary>
  112. /// <param name="sender">sender</param>
  113. /// <param name="e">e</param>
  114. private void OnFormClosing(object sender, FormClosingEventArgs e)
  115. {
  116. OIHelper.QuantCalibrationSettings.EdSettings.ProcessTime = (int)this.ProcesstimeCombobox.SelectedValue;
  117. OIHelper.QuantCalibrationSettings.EdSettings.NumberOfChannels = (int)this.NumberofchannelsCombobox.SelectedValue;
  118. OIHelper.QuantCalibrationSettings.EdSettings.EnergyRange = (int)this.EnergyRangeCombobox.SelectedValue;
  119. }
  120. /// <summary>
  121. /// OKButton_Click
  122. /// </summary>
  123. /// <param name="sender">sender</param>
  124. /// <param name="e">e</param>
  125. private void OKButton_Click(object sender, System.EventArgs e)
  126. {
  127. this.Close();
  128. }
  129. }
  130. }