using OTSCommon; using OTSModelSharp.ServiceCenter; using System; using System.Collections; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; namespace OTSMeasureApp { public partial class SpecialParticleForm : Form { private string xmlPath = ""; private string str_RegName = "default"; private string str_start = "0"; private string str_end = "100"; private string str_diameterStart = "0"; private string str_diameterEnd = "100"; OTSIncAMeasureAppForm m_mainForm; OTSMeasureStatusWindow m_measureStatuWindow; byte[] m_BseData; int m_imageWidth; int m_imageHeight; //国际化 OTSCommon.Language lan; Hashtable table; //the datasource of datagridview DataSet ds1; public SpecialParticleForm(string xmlPath, OTSIncAMeasureAppForm mainForm,byte[] bBseData,int width,int height, OTSMeasureStatusWindow measureStatuWindow) { InitializeComponent(); this.xmlPath = xmlPath; m_mainForm = mainForm; m_measureStatuWindow = measureStatuWindow; m_BseData = bBseData; m_imageWidth = width; m_imageHeight = height; ShowXmlInfo(); //国际化 lan = new OTSCommon.Language(this); table = lan.GetNameTable(this.Name); } private void ShowXmlInfo() { ds1 = XMLoperate.GetXMLRegList(xmlPath, "Member"); if (ds1.Tables.Count > 0) { dg1.DataSource = ds1.Tables[0]; var ds2 = XMLoperate.GetXMLRegList(xmlPath, "XMLData"); var ifrun = Convert.ToBoolean(ds2.Tables[0].Rows[0]["ToRun"]); checkBox1.Checked = ifrun; } } private void button1_Click(object sender, EventArgs e) { if (ds1.Tables.Count == 0) { var t = new DataTable(); t.Columns.Add(new DataColumn("RegName")); t.Columns.Add(new DataColumn("start")); t.Columns.Add(new DataColumn("end")); t.Columns.Add(new DataColumn("diameterStart")); t.Columns.Add(new DataColumn("diameterEnd")); t.Columns.Add(new DataColumn("collectXray")); ds1.Tables.Add(t); } var nr = ds1.Tables[0].NewRow(); nr["RegName"] = str_RegName; nr["start"] = str_start; nr["end"] = str_end; nr["diameterStart"] = str_diameterStart; nr["diameterEnd"] = str_diameterEnd; nr["collectXray"] = "false"; ds1.Tables[0].Rows.Add(nr); dg1.DataSource = ds1.Tables[0]; } private void button3_Click(object sender, EventArgs e) { if (ds1.Tables[0].Rows.Count > 0) { ds1.Tables[0].Rows.RemoveAt(dg1.CurrentRow.Index); } } private void dg1_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (dg1.Columns[e.ColumnIndex].Name == "rangeChoose" && e.RowIndex >= 0) { frmSpecialGrayParticle toolWindow = new frmSpecialGrayParticle(m_mainForm, m_measureStatuWindow); int grayStart = 0; int grayEnd = 0; if (m_BseData != null) { Bitmap bitmap = CImageHandler.ToGrayBitmap(m_BseData, m_imageWidth, m_imageHeight); toolWindow.BseImg = bitmap; toolWindow.SetBBseData(m_BseData); grayStart = Convert.ToInt32( dg1.Rows[e.RowIndex].Cells["start"].Value); grayEnd = Convert.ToInt32(dg1.Rows[e.RowIndex].Cells["end"].Value); //设置可视化中的属性 toolWindow.BseGrayMinValue = grayStart; toolWindow.BseGrayMaxValue = grayEnd; } DialogResult dialogResult = toolWindow.ShowDialog(); if (dialogResult == DialogResult.OK) { dg1.Rows[e.RowIndex].Cells["start"].Value = toolWindow.BseGrayMinValue; dg1.Rows[e.RowIndex].Cells["end"].Value = toolWindow.BseGrayMaxValue; } } } private void confirm_Click(object sender, EventArgs e) { XMLoperate.UpdateSpecialGrayXMLFile(xmlPath, dg1, checkBox1.Checked); this.Close(); } private void button2_Click(object sender, EventArgs e) { this.Close(); } } }