ReferenceLibrary.cs 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553
  1. using OTS.WinFormsUI.Docking;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.ComponentModel;
  5. using System.Data;
  6. using System.Drawing;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. using System.Windows.Forms;
  11. namespace OTSPartA_STDEditor
  12. {
  13. public partial class ReferenceLibrary : DockContent
  14. {
  15. public SubMidWindow m_SubMidWindow = null;
  16. protected SourceGrid.Cells.Views.Cell m_CellGroupType = null;
  17. public Dictionary<int, STDdata> ReferenceDictionary = new Dictionary<int, STDdata>();
  18. List<STDEditor.STDXray> ReferenceXrayList = null;
  19. byte[] ReferencexrayByteData = null;
  20. System.Collections.Hashtable table_ReferenceLibrary;
  21. public ReferenceLibrary(SubMidWindow SubMidWindow)
  22. {
  23. InitializeComponent();
  24. m_SubMidWindow = SubMidWindow;
  25. }
  26. private void InitGrid()
  27. {
  28. int iColumnWidth = 20; // 第一列的宽度
  29. int width = this.Width;
  30. PropGrid.Redim(1, 12);
  31. PropGrid.Columns.SetWidth(0, iColumnWidth);
  32. PropGrid.Columns.AutoSizeColumn(2); // 固定进度条
  33. PropGrid.Columns.SetWidth(2, 1 * (width - iColumnWidth) / 30);
  34. PropGrid.Columns.SetWidth(3, 25 * (width - iColumnWidth) / 30);
  35. PropGrid.Columns.SetWidth(4, 3 * (width - iColumnWidth) / 30);
  36. PropGrid.Columns.SetWidth(5, 1 * (width - iColumnWidth) / 30);
  37. PropGrid.Columns.SetWidth(6, 1 * (width - iColumnWidth) / 30);
  38. PropGrid.Columns.SetWidth(7, 2 * (width - iColumnWidth) / 30);
  39. PropGrid.Columns.SetWidth(8, 1 * (width - iColumnWidth) / 30);
  40. PropGrid.Columns.SetWidth(9, 3 * (width - iColumnWidth) / 30);
  41. PropGrid.Columns.SetWidth(10, 10 * (width - iColumnWidth) / 30);
  42. PropGrid.Columns.SetWidth(11, 1 * (width - iColumnWidth) / 30);
  43. PropGrid.AutoStretchColumnsToFitWidth = true;
  44. // 创建列标题
  45. if (null == PropGrid[0, 1])
  46. {
  47. List<String> listColName = new List<string>();
  48. if (m_SubMidWindow.m_MainForm.lan.GetNameTable("Form_ConstantsEditor2")["language"].ToString() == "ZH")
  49. {
  50. listColName.Add("规则名称");
  51. listColName.Add("颜色");
  52. listColName.Add("表达式");
  53. listColName.Add("必须存在元素");
  54. listColName.Add("硬度");
  55. listColName.Add("密度");
  56. listColName.Add("导电性");
  57. listColName.Add("BSE");
  58. listColName.Add("化学式");
  59. listColName.Add("元素");
  60. listColName.Add("分组名称");
  61. }
  62. else
  63. {
  64. listColName.Add("Rule Name");
  65. listColName.Add("Color");
  66. listColName.Add("Expression");
  67. listColName.Add("Elements must exist");
  68. listColName.Add("Hardness");
  69. listColName.Add("Density");
  70. listColName.Add("Conductivity");
  71. listColName.Add("BSE");
  72. listColName.Add("Formula");
  73. listColName.Add("Element");
  74. listColName.Add("GroupName");
  75. }
  76. for (int i = 0; i < listColName.Count; i++)
  77. {
  78. if (null == PropGrid[0, 1 + i])
  79. {
  80. PropGrid[0, 1 + i] = new SourceGrid.Cells.Cell(listColName[i]);
  81. }
  82. else
  83. {
  84. PropGrid[0, 1 + i].Value = listColName[i];
  85. }
  86. }
  87. PropGrid.FixedRows = 1; // 第一行是列标题不可以滚动
  88. PropGrid.Selection.EnableMultiSelection = false;
  89. PropGrid.Refresh();
  90. }
  91. }
  92. private void ComparativeLibrary_Load(object sender, EventArgs e)
  93. {
  94. m_SubMidWindow.m_MainForm.lan = new Language(this);
  95. table_ReferenceLibrary = m_SubMidWindow.m_MainForm.lan.GetNameTable("ReferenceLibrary");
  96. InitGrid();
  97. }
  98. bool LoadClassifyToDictionary(string DBAddress, ref Dictionary<int, STDdata> STDDictionary)
  99. {
  100. try
  101. {
  102. System.Data.SQLite.SQLiteConnection m_dbConnection = new System.Data.SQLite.SQLiteConnection("data source='" + DBAddress + "'");
  103. m_dbConnection.Open();
  104. //加载STD信息
  105. System.Data.SQLite.SQLiteDataAdapter m_dataAdapter = new System.Data.SQLite.SQLiteDataAdapter("select * from ClassifySTD", m_dbConnection);
  106. DataSet ds = new DataSet();
  107. m_dataAdapter.Fill(ds);
  108. DataTable dt = ds.Tables[0];
  109. STDDictionary.Clear();
  110. if (dt != null)
  111. {
  112. if (dt.Rows.Count > 0)
  113. {
  114. foreach (DataRow item in dt.Rows)
  115. {
  116. STDdata new_STDdata = new STDdata();
  117. new_STDdata.Hardness = item["Hardness"].ToString();
  118. new_STDdata.Density = item["Density"].ToString();
  119. new_STDdata.Electrical_conductivity = item["Electrical_conductivity"].ToString();
  120. new_STDdata.BSE = item["BSE"].ToString();
  121. new_STDdata.Formula = item["Formula"].ToString();
  122. new_STDdata.Element = item["Formula"].ToString();
  123. new_STDdata.StrName = item["StrName"].ToString();
  124. new_STDdata.Expression = item["Expression"].ToString();
  125. new_STDdata.Color = item["Color"].ToString();
  126. new_STDdata.KeyElementList = item["KeyElementList"].ToString();
  127. new_STDdata.SubElementList = item["SubElementList"].ToString();
  128. new_STDdata.GroupId = item["GroupId"].ToString();
  129. STDDictionary.Add(int.Parse(item["STDId"].ToString()), new_STDdata);
  130. }
  131. }
  132. }
  133. //加载Xray信息
  134. System.Data.SQLite.SQLiteDataAdapter m_dataAdapterXray = new System.Data.SQLite.SQLiteDataAdapter("select Id,SPEC from STDMinerals", m_dbConnection);
  135. DataSet dsXray = new DataSet();
  136. m_dataAdapterXray.Fill(dsXray);
  137. DataTable dtXray = dsXray.Tables[0];
  138. ReferenceXrayList=new List<STDEditor.STDXray>();
  139. if (dtXray != null)
  140. {
  141. if (dtXray.Rows.Count > 0)
  142. {
  143. foreach (DataRow item in dtXray.Rows)
  144. {
  145. STDEditor.STDXray sXray = new STDEditor.STDXray();
  146. sXray.StdID = item["Id"].ToString();
  147. sXray.XrayData = (byte[])item["SPEC"];
  148. ReferenceXrayList.Add(sXray);
  149. }
  150. }
  151. }
  152. return true;
  153. }
  154. catch /*(Exception ee)*/
  155. {
  156. MessageBox.Show(table_ReferenceLibrary["message1"].ToString(), table_ReferenceLibrary["message32"].ToString());
  157. return false;
  158. }
  159. }
  160. void AddDataToRefereceLiberary(Dictionary<int, STDdata> RefDictionary)
  161. {
  162. PropGrid.Redim(RefDictionary.Count+1, 12);
  163. int i = 1;
  164. foreach (KeyValuePair<int, STDdata> kv in RefDictionary)
  165. {
  166. if (null == PropGrid[i, 0])
  167. {
  168. PropGrid[i, 0] = new SourceGrid.Cells.CheckBox(null, false);
  169. SourceGrid.Cells.Controllers.CheckBox clickEvent = new SourceGrid.Cells.Controllers.CheckBox();
  170. clickEvent.CheckedChanged += new EventHandler(clickEvent_Click);
  171. PropGrid[i, 0].AddController(clickEvent);
  172. }
  173. else
  174. {
  175. PropGrid[i, 0].Value = false;
  176. }
  177. PropGrid.Rows[i].Height = 25;
  178. PropGrid.Rows[i].Tag = kv.Key;
  179. PropGrid[i, 1] = new SourceGrid.Cells.Cell(kv.Value.StrName, typeof(string));
  180. PropGrid[i, 1].Tag = kv.Key;
  181. PropGrid[i, 2] = new SourceGrid.Cells.Cell("", typeof(string));
  182. SourceGrid.Cells.Views.Cell view = new SourceGrid.Cells.Views.Cell();
  183. view.BackColor = STDRuleslist.colorHx16toRGB(kv.Value.Color);
  184. PropGrid[i, 2].View = view;
  185. PropGrid[i, 3] = new SourceGrid.Cells.Cell(kv.Value.Expression, typeof(string));
  186. PropGrid[i, 4] = new SourceGrid.Cells.Cell(kv.Value.KeyElementList, typeof(string));
  187. PropGrid[i, 5] = new SourceGrid.Cells.Cell(kv.Value.Hardness, typeof(string));
  188. PropGrid[i, 6] = new SourceGrid.Cells.Cell(kv.Value.Density, typeof(string));
  189. PropGrid[i, 7] = new SourceGrid.Cells.Cell(kv.Value.Electrical_conductivity, typeof(string));
  190. PropGrid[i, 8] = new SourceGrid.Cells.Cell(kv.Value.BSE, typeof(string));
  191. PropGrid[i, 9] = new SourceGrid.Cells.Cell(kv.Value.Formula, typeof(string));
  192. PropGrid[i, 10] = new SourceGrid.Cells.Cell(kv.Value.Element, typeof(string));
  193. PropGrid[i, 11] = new SourceGrid.Cells.Cell(m_SubMidWindow.m_MainForm.GroupIdDictionaryFromId[int.Parse(kv.Value.GroupId)], typeof(string));
  194. i++;
  195. }
  196. PropGrid.AutoSizeCells();
  197. int iColumnWidth = 45; // 第一列的宽度
  198. int width = this.Width;
  199. PropGrid.Columns.SetWidth(0, iColumnWidth);
  200. PropGrid.Columns.SetWidth(2, 1 * (width - iColumnWidth) / 20);
  201. //PropGrid.Columns.SetWidth(3, 25 * (width - iColumnWidth) / 30);
  202. //PropGrid.Columns.SetWidth(4, 3 * (width - iColumnWidth) / 30);
  203. //PropGrid.Columns.SetWidth(5, 1 * (width - iColumnWidth) / 30);
  204. //PropGrid.Columns.SetWidth(6, 1 * (width - iColumnWidth) / 30);
  205. //PropGrid.Columns.SetWidth(7, 2 * (width - iColumnWidth) / 30);
  206. //PropGrid.Columns.SetWidth(8, 1 * (width - iColumnWidth) / 30);
  207. //PropGrid.Columns.SetWidth(9, 3 * (width - iColumnWidth) / 30);
  208. //PropGrid.Columns.SetWidth(10, 10 * (width - iColumnWidth) / 30);
  209. for (int ro = 0; ro < PropGrid.RowsCount; ro++)
  210. {
  211. PropGrid.Rows.SetHeight(ro,25);
  212. }
  213. for (int col = 1; col < PropGrid.ColumnsCount; col++)
  214. {
  215. for (int ro = 0; ro < PropGrid.RowsCount; ro++)
  216. {
  217. PropGrid[ro,col].AddController(SourceGrid.Cells.Controllers.Unselectable.Default);
  218. }
  219. }
  220. PropGrid.Refresh();
  221. //为修改bug 第一次点击sourcegrid滚动界面时,取数不准问题(载入数据时将第一次点击落在1,0单元格)
  222. if (PropGrid[1,0] != null)
  223. {
  224. SourceGrid.Position pos = new SourceGrid.Position(1, 0);
  225. PropGrid.Selection.Focus(pos, true);
  226. }
  227. }
  228. public void MakeCheckboxUnchecked()
  229. {
  230. for (int i = 1; i < PropGrid.RowsCount; i++)
  231. {
  232. if ((bool)PropGrid[i, 0].Value == true)
  233. {
  234. PropGrid[i, 0].Value = false;
  235. }
  236. }
  237. }
  238. private void clickEvent_Click(object sender, EventArgs e)
  239. {
  240. int t = PropGrid.Selection.ActivePosition.Column;
  241. if (t == 0)//选择事件
  242. {
  243. if ((bool)PropGrid[PropGrid.Selection.ActivePosition.Row, 0].Value == true)
  244. {
  245. PropGrid[PropGrid.Selection.ActivePosition.Row, 0].Value = false;
  246. m_SubMidWindow.m_STDEditor.ShowXrayAtlas();
  247. }
  248. else
  249. {
  250. int r = PropGrid.Selection.ActivePosition.Row;
  251. SelReferenceXray((int)PropGrid.Rows[r].Tag,ReferenceDictionary[(int)PropGrid.Rows[r].Tag]);
  252. ShowReferenceContent(PropGrid.Rows[r].Tag.ToString());
  253. MakeCheckboxUnchecked();
  254. PropGrid[PropGrid.Selection.ActivePosition.Row, 0].Value = true;
  255. }
  256. PropGrid.Refresh();
  257. }
  258. }
  259. private void ShowReferenceContent(string stdID)
  260. {
  261. if (ReferenceXrayList != null)
  262. {
  263. for (int i = 0; i < ReferenceXrayList.Count; i++)
  264. {
  265. if (ReferenceXrayList[i].StdID == stdID)
  266. {
  267. //获取修改行的信息
  268. ReferencexrayByteData = (byte[])ReferenceXrayList[i].XrayData;
  269. }
  270. }
  271. }
  272. }
  273. /// <summary>
  274. /// 根据选择节点显示对应的Xray信息
  275. /// </summary>
  276. public void SelReferenceXray(int Key, STDdata sT)
  277. {
  278. if (sT == null)
  279. {
  280. return;
  281. }
  282. if (ReferenceXrayList != null)
  283. {
  284. //if (m_STDXrayList.Count > 0)
  285. //{
  286. bool isExists = false;
  287. foreach (STDEditor.STDXray item in ReferenceXrayList)
  288. {
  289. //修改XrayData信息
  290. if (item.StdID == Key.ToString())
  291. {
  292. string selColor = m_SubMidWindow.m_STDEditor.ParseRGB(STDEditor.colorHx16toRGB(sT.Color)).ToString();
  293. int colorValue = Convert.ToInt32(selColor);
  294. //显示Xray信息
  295. if (item.XrayData != null)
  296. {
  297. isExists = true;
  298. m_SubMidWindow.m_STDEditor.ShowXrayAtlas(colorValue, item.XrayData);
  299. }
  300. break;
  301. }
  302. }
  303. if (!isExists)
  304. {
  305. m_SubMidWindow.m_STDEditor.ShowXrayAtlas();
  306. }
  307. //}
  308. }
  309. }
  310. private void TSLoad_Click(object sender, EventArgs e)
  311. {
  312. OpenFileDialog fileSel = new OpenFileDialog();
  313. fileSel.Filter = "(*.db)|*.db";
  314. if (DialogResult.OK == fileSel.ShowDialog())
  315. {
  316. ReferenceDictionary.Clear();
  317. if (LoadClassifyToDictionary(fileSel.FileName, ref ReferenceDictionary))
  318. {
  319. AddDataToRefereceLiberary(ReferenceDictionary);
  320. this.Text += " " + fileSel.FileName;
  321. PropGrid.Refresh();
  322. }
  323. }
  324. }
  325. private void TSClose_Click(object sender, EventArgs e)
  326. {
  327. if (PropGrid.RowsCount > 1)
  328. {
  329. PropGrid.Rows.RemoveRange(1, PropGrid.RowsCount - 1);
  330. m_SubMidWindow.m_STDEditor.ShowXrayAtlas();
  331. ReferenceDictionary.Clear();
  332. this.Text = this.Text.Split(' ')[0];
  333. PropGrid.Refresh();
  334. }
  335. }
  336. private void PropGrid_MouseClick(object sender, MouseEventArgs e)
  337. {
  338. SourceGrid.Grid oSender = (SourceGrid.Grid)sender;
  339. oSender.Focus();
  340. // 表示右击的是无效区域, 则退出(第0行是标题)
  341. if (oSender.MouseCellPosition.Row < 1 || oSender.MouseCellPosition.Column < 0)
  342. {
  343. return;
  344. }
  345. // 右击的区域获取焦点
  346. PropGrid.Selection.Focus(new SourceGrid.Position(oSender.MouseCellPosition.Row, oSender.MouseCellPosition.Column), true);
  347. try
  348. {
  349. if (MouseButtons.Right == e.Button && e.Clicks == 1)
  350. {
  351. // 此处编写在什么情况下弹出右击菜单
  352. contextMenuStrip.Show(PointToScreen(e.Location));
  353. // 判断左侧区域是否已经选中了某个stdmineral
  354. bool bEnable = false;
  355. bEnable = (-1 == m_SubMidWindow.m_MainForm.m_STDRuleslist.PreRow) ? false : true;
  356. this.insertToolStripMenuItem.Enabled = bEnable;
  357. }
  358. }
  359. catch (Exception/* ex*/)
  360. {
  361. }
  362. }
  363. private void insertToolStripMenuItem_Click(object sender, EventArgs e)
  364. {
  365. m_SubMidWindow.m_MainForm.m_STDRuleslist.Grid_Minerals.Focus(true);
  366. int i = m_SubMidWindow.m_MainForm.m_STDRuleslist.Grid_Minerals.Selection.ActivePosition.Row;
  367. int j = m_SubMidWindow.m_MainForm.m_STDRuleslist.Grid_Minerals.Selection.ActivePosition.Column;
  368. /// 保证鼠标点击的GRID行和列是有效的
  369. if (i >= 0 && j >= 0)
  370. {
  371. //规则名称不为空
  372. if (m_SubMidWindow.m_MainForm.m_STDRuleslist.Grid_Minerals[i, 0].Value.ToString().Replace(" ", "").Trim() != "")
  373. {
  374. if (m_SubMidWindow.m_MainForm.CheckAttributes())
  375. {
  376. if (m_SubMidWindow.m_MainForm.Checktextbox_STDEditor())
  377. {
  378. m_SubMidWindow.m_MainForm.SaveDataOfSelRule(i, j);
  379. PropGrid.Focus(true);
  380. int selrow = PropGrid.Selection.ActivePosition.Row;
  381. int STDnum = (int)PropGrid[selrow, 1].Tag;
  382. int STDId = 1;
  383. foreach (KeyValuePair<int, STDdata> kv in m_SubMidWindow.m_MainForm.STDDictionary)
  384. {
  385. if (STDId < kv.Key)
  386. {
  387. STDId = kv.Key;
  388. }
  389. }
  390. STDdata sT = new STDdata();
  391. sT.BSE = ReferenceDictionary[STDnum].BSE;
  392. sT.StrName = ReferenceDictionary[STDnum].StrName;
  393. sT.Color = ReferenceDictionary[STDnum].Color;
  394. sT.Density = ReferenceDictionary[STDnum].Density;
  395. sT.Expression = ReferenceDictionary[STDnum].Expression;
  396. sT.Formula = ReferenceDictionary[STDnum].Formula;
  397. sT.Hardness = ReferenceDictionary[STDnum].Hardness;
  398. sT.UsingImgPropertyList = ReferenceDictionary[STDnum].UsingImgPropertyList;
  399. sT.UsingOtherPropertyList = ReferenceDictionary[STDnum].UsingOtherPropertyList;
  400. sT.KeyElementList = ReferenceDictionary[STDnum].KeyElementList;
  401. sT.SubElementList = ReferenceDictionary[STDnum].SubElementList;
  402. sT.Electrical_conductivity = ReferenceDictionary[STDnum].Electrical_conductivity;
  403. sT.Element = ReferenceDictionary[STDnum].Element;
  404. sT.GroupId = ReferenceDictionary[STDnum].GroupId;
  405. m_SubMidWindow.m_MainForm.STDDictionary.Add(STDId + 1, sT);
  406. m_SubMidWindow.m_MainForm.m_STDRuleslist.InsertNewRow(STDId + 1, sT.StrName, STDRuleslist.colorHx16toRGB(sT.Color));
  407. m_SubMidWindow.m_MainForm.m_STDRuleslist.Refresh();
  408. m_SubMidWindow.m_MainForm.m_STDRuleslist.PreRow = i;
  409. for (int k = 0; k < ReferenceXrayList.Count; k++)
  410. {
  411. if (int.Parse(ReferenceXrayList[k].StdID) == STDnum)
  412. {
  413. STDEditor.STDXray tDXray=new STDEditor.STDXray();
  414. tDXray.StdID = (STDId+1).ToString();
  415. tDXray.XrayData = ReferenceXrayList[k].XrayData;
  416. tDXray.InfoState = (int)STDEditor.STDXrayInfoState.Add;
  417. m_SubMidWindow.m_STDEditor.m_STDXrayList.Add(tDXray);
  418. }
  419. }
  420. }
  421. }
  422. }
  423. }
  424. }
  425. #region 因为复制容易引起用户误操作,故取消
  426. private void copyDataToolStripMenuItem_Click(object sender, EventArgs e)
  427. {
  428. //int selrow = PropGrid.Selection.ActivePosition.Row;
  429. //int STDnum = (int)PropGrid[selrow, 1].Tag;
  430. //int STDid = (int)m_SubMidWindow.m_MainForm.m_STDRuleslist.Grid_Minerals[m_SubMidWindow.m_MainForm.m_STDRuleslist.PreRow, 0].Tag;
  431. //m_SubMidWindow.m_MainForm.STDDictionary[STDid] = ReferenceDictionary[STDnum];
  432. //m_SubMidWindow.m_MainForm.m_STDRuleslist.ChangeStrName(m_SubMidWindow.m_MainForm.m_STDRuleslist.PreRow, ReferenceDictionary[STDnum].StrName);
  433. //m_SubMidWindow.m_MainForm.ChangeSTDEditorAndGrid_Attributes(STDid);
  434. //m_SubMidWindow.m_MainForm.m_STDRuleslist.Grid_Minerals.Refresh();
  435. }
  436. #endregion
  437. private void addIntoMainLabToolStripMenuItem_Click(object sender, EventArgs e)
  438. {
  439. m_SubMidWindow.m_MainForm.m_STDRuleslist.Grid_Minerals.Focus(true);
  440. int i = m_SubMidWindow.m_MainForm.m_STDRuleslist.Grid_Minerals.Selection.ActivePosition.Row;
  441. int j = m_SubMidWindow.m_MainForm.m_STDRuleslist.Grid_Minerals.Selection.ActivePosition.Column;
  442. /// 保证鼠标点击的GRID行和列是有效的
  443. if (i >= 0 && j >= 0)
  444. {
  445. //规则名称不为空
  446. if (m_SubMidWindow.m_MainForm.m_STDRuleslist.Grid_Minerals[i, j].Value.ToString().Replace(" ", "").Trim() != "")
  447. {
  448. if (m_SubMidWindow.m_MainForm.CheckAttributes())
  449. {
  450. if (m_SubMidWindow.m_MainForm.Checktextbox_STDEditor())
  451. {
  452. m_SubMidWindow.m_MainForm.SaveDataOfSelRule(i, j);
  453. PropGrid.Focus(true);
  454. int selrow = PropGrid.Selection.ActivePosition.Row;
  455. int STDnum = (int)PropGrid[selrow, 1].Tag;
  456. int STDId = 1;
  457. foreach (KeyValuePair<int, STDdata> kv in m_SubMidWindow.m_MainForm.STDDictionary)
  458. {
  459. if (STDId < kv.Key)
  460. {
  461. STDId = kv.Key;
  462. }
  463. }
  464. STDdata sT = new STDdata();
  465. sT.BSE = ReferenceDictionary[STDnum].BSE;
  466. sT.StrName = ReferenceDictionary[STDnum].StrName;
  467. sT.Color = ReferenceDictionary[STDnum].Color;
  468. sT.Density = ReferenceDictionary[STDnum].Density;
  469. sT.Expression = ReferenceDictionary[STDnum].Expression;
  470. sT.Formula = ReferenceDictionary[STDnum].Formula;
  471. sT.Hardness = ReferenceDictionary[STDnum].Hardness;
  472. sT.UsingImgPropertyList = ReferenceDictionary[STDnum].UsingImgPropertyList;
  473. sT.UsingOtherPropertyList = ReferenceDictionary[STDnum].UsingOtherPropertyList;
  474. sT.KeyElementList = ReferenceDictionary[STDnum].KeyElementList;
  475. sT.SubElementList = ReferenceDictionary[STDnum].SubElementList;
  476. sT.Electrical_conductivity = ReferenceDictionary[STDnum].Electrical_conductivity;
  477. sT.Element = ReferenceDictionary[STDnum].Element;
  478. sT.GroupId = ReferenceDictionary[STDnum].GroupId;
  479. m_SubMidWindow.m_MainForm.STDDictionary.Add(STDId + 1, sT);
  480. m_SubMidWindow.m_MainForm.m_STDRuleslist.AddNewRow(STDId + 1, sT.StrName, STDRuleslist.colorHx16toRGB(sT.Color));
  481. m_SubMidWindow.m_MainForm.m_STDRuleslist.Refresh();
  482. m_SubMidWindow.m_MainForm.m_STDRuleslist.PreRow = m_SubMidWindow.m_MainForm.m_STDRuleslist.Grid_Minerals.RowsCount - 1;
  483. for (int k = 0; k < ReferenceXrayList.Count; k++)
  484. {
  485. if (int.Parse(ReferenceXrayList[k].StdID) == STDnum)
  486. {
  487. STDEditor.STDXray tDXray = new STDEditor.STDXray();
  488. tDXray.StdID = (STDId + 1).ToString();
  489. tDXray.XrayData = ReferenceXrayList[k].XrayData;
  490. tDXray.InfoState = (int)STDEditor.STDXrayInfoState.Add;
  491. m_SubMidWindow.m_STDEditor.m_STDXrayList.Add(tDXray);
  492. }
  493. }
  494. }
  495. }
  496. }
  497. }
  498. }
  499. }
  500. }