SpecialParticleForm.cs 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. using OTSCommon;
  2. using OTSModelSharp.ServiceInterface;
  3. using System;
  4. using System.Collections;
  5. using System.Collections.Generic;
  6. using System.ComponentModel;
  7. using System.Data;
  8. using System.Drawing;
  9. using System.Linq;
  10. using System.Text;
  11. using System.Threading;
  12. using System.Threading.Tasks;
  13. using System.Windows.Forms;
  14. namespace OTSMeasureApp
  15. {
  16. public partial class SpecialParticleForm : Form
  17. {
  18. private string xmlPath = "";
  19. private string str_RegName = "default";
  20. private string str_start = "0";
  21. private string str_end = "100";
  22. private string str_diameterStart = "0";
  23. private string str_diameterEnd = "100";
  24. OTSIncAMeasureAppForm m_mainForm;
  25. OTSMeasureStatusWindow m_measureStatuWindow;
  26. byte[] m_BseData;
  27. int m_imageWidth;
  28. int m_imageHeight;
  29. //国际化
  30. OTSCommon.Language lan;
  31. Hashtable table;
  32. //the datasource of datagridview
  33. DataSet ds1;
  34. public SpecialParticleForm(string xmlPath, OTSIncAMeasureAppForm mainForm,byte[] bBseData,int width,int height, OTSMeasureStatusWindow measureStatuWindow)
  35. {
  36. InitializeComponent();
  37. this.xmlPath = xmlPath;
  38. m_mainForm = mainForm;
  39. m_measureStatuWindow = measureStatuWindow;
  40. m_BseData = bBseData;
  41. m_imageWidth = width;
  42. m_imageHeight = height;
  43. ShowXmlInfo();
  44. //国际化
  45. lan = new OTSCommon.Language(this);
  46. table = lan.GetNameTable(this.Name);
  47. }
  48. private void ShowXmlInfo()
  49. {
  50. ds1 = XMLoperate.GetXMLRegList(xmlPath, "Member");
  51. dg1.DataSource = ds1.Tables[0];
  52. var ds2 = XMLoperate.GetXMLRegList(xmlPath, "XMLData");
  53. var ifrun = Convert.ToBoolean(ds2.Tables[0].Rows[0]["ToRun"]);
  54. checkBox1.Checked = ifrun;
  55. }
  56. private void button1_Click(object sender, EventArgs e)
  57. {
  58. var nr = ds1.Tables[0].NewRow();
  59. nr["RegName"] = str_RegName;
  60. nr["start"] = str_start;
  61. nr["end"] = str_end;
  62. nr["diameterStart"] = str_diameterStart;
  63. nr["diameterEnd"] = str_diameterEnd;
  64. nr["collectXray"] = "false";
  65. ds1.Tables[0].Rows.Add(nr);
  66. }
  67. private void button3_Click(object sender, EventArgs e)
  68. {
  69. ds1.Tables[0].Rows.RemoveAt(dg1.CurrentRow.Index);
  70. }
  71. private void dg1_CellContentClick(object sender, DataGridViewCellEventArgs e)
  72. {
  73. if (dg1.Columns[e.ColumnIndex].Name == "rangeChoose" && e.RowIndex >= 0)
  74. {
  75. frmSpecialGrayParticle toolWindow = new frmSpecialGrayParticle(m_mainForm, m_measureStatuWindow);
  76. int grayStart = 0;
  77. int grayEnd = 0;
  78. if (m_BseData != null)
  79. {
  80. Bitmap bitmap = CImageHandler.ToGrayBitmap(m_BseData, m_imageWidth, m_imageHeight);
  81. toolWindow.BseImg = bitmap;
  82. toolWindow.SetBBseData(m_BseData);
  83. grayStart = Convert.ToInt32( dg1.Rows[e.RowIndex].Cells["start"].Value);
  84. grayEnd = Convert.ToInt32(dg1.Rows[e.RowIndex].Cells["end"].Value);
  85. //设置可视化中的属性
  86. toolWindow.BseGrayMinValue = grayStart;
  87. toolWindow.BseGrayMaxValue = grayEnd;
  88. }
  89. DialogResult dialogResult = toolWindow.ShowDialog();
  90. if (dialogResult == DialogResult.OK)
  91. {
  92. dg1.Rows[e.RowIndex].Cells["start"].Value = toolWindow.BseGrayMinValue;
  93. dg1.Rows[e.RowIndex].Cells["end"].Value = toolWindow.BseGrayMaxValue;
  94. }
  95. }
  96. }
  97. private void confirm_Click(object sender, EventArgs e)
  98. {
  99. XMLoperate.UpdateSpecialGrayXMLFile(xmlPath, dg1, checkBox1.Checked);
  100. this.Close();
  101. }
  102. private void button2_Click(object sender, EventArgs e)
  103. {
  104. this.Close();
  105. }
  106. }
  107. }