STDRuleslist.cs 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597
  1. using OTS.WinFormsUI.Docking;
  2. using SourceGrid;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.ComponentModel;
  6. using System.Data;
  7. using System.Drawing;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Threading.Tasks;
  11. using System.Windows.Forms;
  12. namespace OTSPartA_STDEditor
  13. {
  14. public partial class STDRuleslist : DockContent
  15. {
  16. public int PreRow = 1;//之前选中的位置
  17. public Form_ConstantsEditor2 m_MainForm = null;
  18. ValueChangedEvent m_ValueChangedEvent = null;//单元格内容改变事件
  19. public STDRuleslist(Form_ConstantsEditor2 mainForm)
  20. {
  21. InitializeComponent();
  22. m_MainForm = mainForm;
  23. m_ValueChangedEvent = new ValueChangedEvent(this);
  24. }
  25. System.Collections.Hashtable table_STDRuleslist;
  26. private void STDRuleslist_Load(object sender, EventArgs e)
  27. {
  28. m_MainForm.lan = new Language(this);
  29. table_STDRuleslist = m_MainForm.lan.GetNameTable("Attributes");
  30. Grid_Minerals.Redim(m_MainForm.STDDictionary.Count + 1, 2);
  31. SourceGrid.Cells.ColumnHeader head1 = null;
  32. if (m_MainForm.lan.GetNameTable("Form_ConstantsEditor2")["language"].ToString() == "EN")
  33. {
  34. head1 = new SourceGrid.Cells.ColumnHeader("Rule Name");
  35. }
  36. else
  37. {
  38. head1 = new SourceGrid.Cells.ColumnHeader("规则名称");
  39. }
  40. Grid_Minerals[0, 0] = head1;
  41. SourceGrid.Cells.ColumnHeader head2 = null;
  42. if (m_MainForm.lan.GetNameTable("Form_ConstantsEditor2")["language"].ToString() == "EN")
  43. {
  44. head2 = new SourceGrid.Cells.ColumnHeader("Color");
  45. }
  46. else
  47. {
  48. head2 = new SourceGrid.Cells.ColumnHeader("颜色");
  49. }
  50. Grid_Minerals[0, 1] = head2;
  51. SourceGrid.Cells.Views.ColumnHeader boldHeader = new SourceGrid.Cells.Views.ColumnHeader();
  52. boldHeader.Font = new Font("Microsoft YaHei UI", 11, FontStyle.Bold);
  53. boldHeader.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleCenter;
  54. Grid_Minerals[0, 0].View = boldHeader;
  55. Grid_Minerals[0, 1].View = boldHeader;
  56. Grid_Minerals.Rows.SetHeight(0, 25);
  57. head1.AutomaticSortEnabled = false;
  58. head2.AutomaticSortEnabled = false;
  59. Grid_Minerals.Selection.EnableMultiSelection = false;
  60. Grid_Minerals.AutoStretchColumnsToFitWidth = true;
  61. Grid_Minerals.Columns[0].Width = this.Width/2-10;
  62. Grid_Minerals.Columns[1].Width = this.Width/2-20;
  63. int i = 1;
  64. foreach (KeyValuePair<int, STDdata> kv in m_MainForm.STDDictionary)
  65. {
  66. Grid_Minerals[i, 0] = new SourceGrid.Cells.Cell(kv.Value.StrName, typeof(string));
  67. Grid_Minerals.Rows[i].Height = 25;
  68. Grid_Minerals[i, 0].Tag = kv.Key;
  69. Grid_Minerals[i, 1] = new SourceGrid.Cells.Cell();
  70. SourceGrid.Cells.Views.Cell view = new SourceGrid.Cells.Views.Cell();
  71. view.BackColor = colorHx16toRGB(kv.Value.Color);
  72. Grid_Minerals[i, 1].View = view;
  73. //Grid_Minerals[i, 1].AddController(SourceGrid.Cells.Controllers.Unselectable.Default);
  74. i++;
  75. }
  76. Grid_Minerals.Controller.AddController(m_ValueChangedEvent);
  77. Grid_Minerals.FixedRows = 1;// 第一行是列标题不可以滚动
  78. Grid_Minerals.Selection.FocusStyle = FocusStyle.None;
  79. }
  80. /// <summary>
  81. /// [颜色:16进制转成RGB]
  82. /// </summary>
  83. /// <param name="strColor">设置16进制颜色 [返回RGB]</param>
  84. /// <returns></returns>
  85. public static System.Drawing.Color colorHx16toRGB(string strHxColor)
  86. {
  87. try
  88. {
  89. if (strHxColor.Length == 0)
  90. {//如果为空
  91. return System.Drawing.Color.FromArgb(255, 255, 204);//设为白色
  92. }
  93. else
  94. {//转换颜色
  95. return System.Drawing.Color.FromArgb(System.Int32.Parse(strHxColor.Substring(1, 2), System.Globalization.NumberStyles.AllowHexSpecifier), System.Int32.Parse(strHxColor.Substring(3, 2), System.Globalization.NumberStyles.AllowHexSpecifier), System.Int32.Parse(strHxColor.Substring(5, 2), System.Globalization.NumberStyles.AllowHexSpecifier));
  96. }
  97. }
  98. catch
  99. {//设为白色
  100. return System.Drawing.Color.FromArgb(255, 255, 204);
  101. }
  102. }
  103. private void MineralsGrid_Click(object sender, EventArgs e)
  104. {
  105. SourceGrid.Grid ls_gd = (SourceGrid.Grid)sender;
  106. ls_gd.Focus();
  107. int i = ls_gd.Selection.ActivePosition.Row;
  108. int j = ls_gd.Selection.ActivePosition.Column;
  109. /// 保证鼠标点击的GRID行和列是有效的
  110. if (i >= 0 && j >= 0)
  111. {
  112. if (i == 1)
  113. {
  114. button_UpOrder.Enabled = false;
  115. }
  116. else
  117. {
  118. button_UpOrder.Enabled = true;
  119. }
  120. if (i == ls_gd.RowsCount - 1)
  121. {
  122. button_DownOrder.Enabled = false;
  123. }
  124. else
  125. {
  126. button_DownOrder.Enabled = true;
  127. }
  128. if (PreRow != -1)
  129. {
  130. //规则名称不为空
  131. if (Grid_Minerals[i, 0].Value.ToString().Replace(" ", "").Trim() != "")
  132. {
  133. if (m_MainForm.CheckAttributes())
  134. {
  135. if (m_MainForm.Checktextbox_STDEditor())
  136. {
  137. m_MainForm.SaveDataOfSelRule(PreRow, 0);
  138. m_MainForm.ChangeSTDEditorAndGrid_Attributes(int.Parse(Grid_Minerals[i, 0].Tag.ToString()));
  139. m_MainForm.m_SubMidWindow.m_ComparativeLibrary.MakeCheckboxUnchecked();
  140. PreRow = i;
  141. }
  142. else
  143. {
  144. Position pos = new Position(PreRow, 0);
  145. Grid_Minerals.Selection.Focus(pos, true);
  146. m_MainForm.m_SubMidWindow.m_ComparativeLibrary.MakeCheckboxUnchecked();
  147. }
  148. }
  149. else
  150. {
  151. Position pos = new Position(PreRow, 0);
  152. Grid_Minerals.Selection.Focus(pos, true);
  153. m_MainForm.m_SubMidWindow.m_ComparativeLibrary.MakeCheckboxUnchecked();
  154. }
  155. }
  156. else
  157. {
  158. Position pos = new Position(PreRow, 0);
  159. Grid_Minerals.Selection.Focus(pos, true);
  160. m_MainForm.m_SubMidWindow.m_ComparativeLibrary.MakeCheckboxUnchecked();
  161. }
  162. }
  163. else
  164. {
  165. m_MainForm.ChangeSTDEditorAndGrid_Attributes(int.Parse(Grid_Minerals[i, j].Tag.ToString()));
  166. PreRow = i;
  167. m_MainForm.m_SubMidWindow.m_ComparativeLibrary.MakeCheckboxUnchecked();
  168. }
  169. }
  170. }
  171. private void ToolStripMenuItem_New_Click(object sender, EventArgs e)
  172. {
  173. int i = Grid_Minerals.Selection.ActivePosition.Row;
  174. int j = Grid_Minerals.Selection.ActivePosition.Column;
  175. /// 保证鼠标点击的GRID行和列是有效的
  176. if (i >= 0 && j >= 0)
  177. {
  178. //规则名称不为空
  179. if (Grid_Minerals[i, j].Value.ToString().Replace(" ", "").Trim() != "")
  180. {
  181. if (m_MainForm.CheckAttributes())
  182. {
  183. if (m_MainForm.Checktextbox_STDEditor())
  184. {
  185. m_MainForm.SaveDataOfSelRule(i, j);
  186. int STDId = m_MainForm.AddSTDDictionaryItem();
  187. AddNewRow(STDId, "NewRuleName", Color.Gray);
  188. m_MainForm.m_SubMidWindow.m_ComparativeLibrary.MakeCheckboxUnchecked();
  189. }
  190. }
  191. }
  192. }
  193. else
  194. {
  195. int STDId = m_MainForm.AddSTDDictionaryItem();
  196. AddNewRow(STDId, "NewRuleName", Color.Gray);
  197. m_MainForm.m_SubMidWindow.m_ComparativeLibrary.MakeCheckboxUnchecked();
  198. }
  199. }
  200. public void AddNewRow(int STDId, string RuleName, Color color)
  201. {
  202. Grid_Minerals.Rows.Insert(Grid_Minerals.Rows.Count);
  203. Grid_Minerals[Grid_Minerals.Rows.Count - 1, 0] = new SourceGrid.Cells.Cell(RuleName, typeof(string));
  204. Grid_Minerals[Grid_Minerals.Rows.Count - 1, 0].Tag = STDId;
  205. Grid_Minerals.Rows[Grid_Minerals.Rows.Count - 1].Height = 25;
  206. Grid_Minerals[Grid_Minerals.Rows.Count - 1, 1] = new SourceGrid.Cells.Cell();
  207. //Grid_Minerals[Grid_Minerals.Rows.Count - 1, 1].AddController(SourceGrid.Cells.Controllers.Unselectable.Default);
  208. m_MainForm.ChangeSTDEditorAndGrid_Attributes(STDId);
  209. SourceGrid.Cells.Views.Cell view = new SourceGrid.Cells.Views.Cell();
  210. view.BackColor = color;
  211. Grid_Minerals[Grid_Minerals.Rows.Count - 1, 1].View = view;
  212. Position pos = new Position(Grid_Minerals.Rows.Count - 1, 0);
  213. Grid_Minerals.Selection.Focus(pos, true);
  214. PreRow = Grid_Minerals.Rows.Count - 1;
  215. }
  216. void Grid_MineralsDelRow()
  217. {
  218. int x = Grid_Minerals.Selection.ActivePosition.Row;
  219. if (x > 0)
  220. {
  221. m_MainForm.RemoveSTDDictionaryItem((int)Grid_Minerals[x, 0].Tag);
  222. m_MainForm.m_SubMidWindow.m_STDEditor.DelSTDXray((int)Grid_Minerals[x, 0].Tag);
  223. Grid_Minerals.Rows.Remove(x);
  224. if (Grid_Minerals.RowsCount > 1)
  225. {
  226. if (x != Grid_Minerals.RowsCount)
  227. {
  228. Position pos = new Position(x, 0);
  229. Grid_Minerals.Selection.Focus(pos, true);
  230. Grid_Minerals[x, 0].Grid.Select();
  231. m_MainForm.ChangeSTDEditorAndGrid_Attributes(int.Parse(Grid_Minerals[x, 0].Tag.ToString()));
  232. PreRow = x;
  233. }
  234. else
  235. {
  236. Position pos = new Position(x - 1, 0);
  237. Grid_Minerals.Selection.Focus(pos, true);
  238. Grid_Minerals[x - 1, 0].Grid.Select();
  239. m_MainForm.ChangeSTDEditorAndGrid_Attributes(int.Parse(Grid_Minerals[x - 1, 0].Tag.ToString()));
  240. PreRow = x - 1;
  241. }
  242. }
  243. else
  244. {
  245. m_MainForm.SetNull();
  246. PreRow = -1;
  247. }
  248. }
  249. else
  250. {
  251. MessageBox.Show(table_STDRuleslist["message1"].ToString(), "Tip");
  252. }
  253. }
  254. private void ToolStripMenuItem_Del_Click(object sender, EventArgs e)
  255. {
  256. Grid_MineralsDelRow();
  257. }
  258. public class ValueChangedEvent : SourceGrid.Cells.Controllers.ControllerBase
  259. {
  260. protected STDRuleslist m_parentWnd = null;
  261. public ValueChangedEvent(STDRuleslist parentWnd)
  262. {
  263. m_parentWnd = parentWnd;
  264. }
  265. public override void OnValueChanged(SourceGrid.CellContext sender, EventArgs e)
  266. {
  267. base.OnValueChanged(sender, e);
  268. if (sender.Value != null&& sender.Value.ToString().Replace(" ", "").Trim() != "")
  269. {
  270. m_parentWnd.ChangeStrName(sender.Position.Row, sender.Value.ToString());
  271. }
  272. else
  273. {
  274. m_parentWnd.ChangeStrName(sender.Position.Row, "NewRuleName");
  275. m_parentWnd.Grid_Minerals[sender.Position.Row,0].Value = "NewRuleName";
  276. }
  277. }
  278. }
  279. public void ChangeStrName(int RowNum, string NewStrName)
  280. {
  281. m_MainForm.ChangeStrName(RowNum, NewStrName);
  282. }
  283. private void Grid_Minerals_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
  284. {
  285. if (e.KeyCode == Keys.Up)
  286. {
  287. SourceGrid.Grid ls_gd = (SourceGrid.Grid)sender;
  288. ls_gd.Focus();
  289. int i = ls_gd.Selection.ActivePosition.Row;
  290. int j = ls_gd.Selection.ActivePosition.Column;
  291. if (i == 1)
  292. {
  293. button_UpOrder.Enabled = false;
  294. }
  295. else
  296. {
  297. button_UpOrder.Enabled = true;
  298. }
  299. if (i == ls_gd.RowsCount - 1)
  300. {
  301. button_DownOrder.Enabled = false;
  302. }
  303. else
  304. {
  305. button_DownOrder.Enabled = true;
  306. }
  307. /// 保证鼠标点击的GRID行和列是有效的
  308. if (i >= 2 && j >= 0)
  309. {
  310. //规则名称不为空
  311. if (Grid_Minerals[i, 0].Value.ToString().Replace(" ", "").Trim() != "")
  312. {
  313. if (m_MainForm.CheckAttributes())
  314. {
  315. if (m_MainForm.Checktextbox_STDEditor())
  316. {
  317. m_MainForm.SaveDataOfSelRule(i, 0);
  318. m_MainForm.ChangeSTDEditorAndGrid_Attributes(int.Parse(Grid_Minerals[i - 1, 0].Tag.ToString()));
  319. m_MainForm.m_SubMidWindow.m_ComparativeLibrary.MakeCheckboxUnchecked();
  320. PreRow = i;
  321. }
  322. else
  323. {
  324. Position pos = new Position(i + 1, 0);
  325. Grid_Minerals.Selection.Focus(pos, true);
  326. m_MainForm.m_SubMidWindow.m_ComparativeLibrary.MakeCheckboxUnchecked();
  327. }
  328. }
  329. else
  330. {
  331. Position pos = new Position(i + 1, 0);
  332. Grid_Minerals.Selection.Focus(pos, true);
  333. m_MainForm.m_SubMidWindow.m_ComparativeLibrary.MakeCheckboxUnchecked();
  334. }
  335. }
  336. else
  337. {
  338. Position pos = new Position(i + 1, 0);
  339. Grid_Minerals.Selection.Focus(pos, true);
  340. m_MainForm.m_SubMidWindow.m_ComparativeLibrary.MakeCheckboxUnchecked();
  341. }
  342. }
  343. }
  344. if (e.KeyCode == Keys.Down)
  345. {
  346. SourceGrid.Grid ls_gd = (SourceGrid.Grid)sender;
  347. ls_gd.Focus();
  348. int i = ls_gd.Selection.ActivePosition.Row;
  349. int j = ls_gd.Selection.ActivePosition.Column;
  350. if (i == 1)
  351. {
  352. button_UpOrder.Enabled = false;
  353. }
  354. else
  355. {
  356. button_UpOrder.Enabled = true;
  357. }
  358. if (i == ls_gd.RowsCount - 1)
  359. {
  360. button_DownOrder.Enabled = false;
  361. }
  362. else
  363. {
  364. button_DownOrder.Enabled = true;
  365. }
  366. /// 保证鼠标点击的GRID行和列是有效的
  367. if (i < ls_gd.RowsCount - 1 && j >= 0)
  368. {
  369. //规则名称不为空
  370. //if (Grid_Minerals[i, 0].Value.ToString().Replace(" ", "").Trim() != "")
  371. //{
  372. if (m_MainForm.CheckAttributes())
  373. {
  374. if (m_MainForm.Checktextbox_STDEditor())
  375. {
  376. m_MainForm.SaveDataOfSelRule(i, 0);
  377. m_MainForm.ChangeSTDEditorAndGrid_Attributes(int.Parse(Grid_Minerals[i + 1, 0].Tag.ToString()));
  378. PreRow = i;
  379. m_MainForm.m_SubMidWindow.m_ComparativeLibrary.MakeCheckboxUnchecked();
  380. }
  381. else
  382. {
  383. Position pos = new Position(i - 1, 0);
  384. Grid_Minerals.Selection.Focus(pos, true);
  385. m_MainForm.m_SubMidWindow.m_ComparativeLibrary.MakeCheckboxUnchecked();
  386. }
  387. }
  388. else
  389. {
  390. Position pos = new Position(i - 1, 0);
  391. Grid_Minerals.Selection.Focus(pos, true);
  392. m_MainForm.m_SubMidWindow.m_ComparativeLibrary.MakeCheckboxUnchecked();
  393. }
  394. //}
  395. //else
  396. //{
  397. // Position pos = new Position(i - 1, 0);
  398. // Grid_Minerals.Selection.Focus(pos, true);
  399. // m_MainForm.m_SubMidWindow.m_ComparativeLibrary.MakeCheckboxUnchecked();
  400. //}
  401. }
  402. }
  403. if (e.KeyCode == Keys.Delete)
  404. {
  405. Grid_MineralsDelRow();
  406. }
  407. }
  408. public int ChangeSTDRulesLISTBackColor()
  409. {
  410. if (Grid_Minerals.RowsCount > 1)
  411. {
  412. Position pos = new Position(1, 0);
  413. Grid_Minerals[1, 0].Grid.Select();
  414. Grid_Minerals[Grid_Minerals.Selection.ActivePosition.Row, 1].View.BackColor = m_MainForm.m_Attributes.Grid_Attributes[3, 1].View.BackColor;
  415. m_MainForm.STDDictionary[(int)Grid_Minerals[Grid_Minerals.Selection.ActivePosition.Row, 0].Tag].Color= Attributes.colorRGBtoHx16(m_MainForm.m_Attributes.Grid_Attributes[3, 1].View.BackColor.R, m_MainForm.m_Attributes.Grid_Attributes[3, 1].View.BackColor.G, m_MainForm.m_Attributes.Grid_Attributes[3, 1].View.BackColor.B);
  416. Grid_Minerals.Refresh();
  417. return (int)Grid_Minerals[Grid_Minerals.Selection.ActivePosition.Row, 0].Tag;
  418. }
  419. else
  420. {
  421. return -1;
  422. }
  423. }
  424. private void MenuStrip_STDRulelist_Resize(object sender, EventArgs e)
  425. {
  426. }
  427. private void button_UpOrder_Click(object sender, EventArgs e)
  428. {
  429. Grid_Minerals.Focus(true);
  430. int selrow = Grid_Minerals.Selection.ActivePosition.Row;
  431. int id = (int)Grid_Minerals[selrow, 0].Tag;
  432. int id2 = (int)Grid_Minerals[selrow - 1, 0].Tag;
  433. string sname = Grid_Minerals[selrow, 0].Value.ToString();
  434. Grid_Minerals[selrow, 0].Value = Grid_Minerals[selrow - 1, 0].Value;
  435. Grid_Minerals[selrow, 0].Tag = id2;
  436. SourceGrid.Cells.Views.Cell view = new SourceGrid.Cells.Views.Cell();
  437. view.BackColor = colorHx16toRGB(m_MainForm.STDDictionary[id2].Color);
  438. Grid_Minerals[selrow, 1].View = view;
  439. Grid_Minerals[selrow - 1, 0].Value = sname;
  440. Grid_Minerals[selrow - 1, 0].Tag = id;
  441. SourceGrid.Cells.Views.Cell view2 = new SourceGrid.Cells.Views.Cell();
  442. view2.BackColor = colorHx16toRGB(m_MainForm.STDDictionary[id].Color);
  443. Grid_Minerals[selrow - 1, 1].View = view2;
  444. m_MainForm.STDDictionary[id].StrName = Grid_Minerals[selrow - 1, 0].Value.ToString();
  445. m_MainForm.STDDictionary[id2].StrName = Grid_Minerals[selrow, 0].Value.ToString();
  446. Position pos = new Position(selrow - 1, 0);
  447. Grid_Minerals[selrow - 1, 0].Grid.Select();
  448. Grid_Minerals.Selection.Focus(pos, true);
  449. PreRow = selrow - 1;
  450. button_DownOrder.Enabled = true;
  451. if (selrow - 1 == 1)
  452. {
  453. button_UpOrder.Enabled = false;
  454. }
  455. m_MainForm.IsModified = true;
  456. //m_MainForm.ChangeSTDEditorAndGrid_Attributes(int.Parse(Grid_Minerals[selrow-1, 0].Tag.ToString()));
  457. }
  458. private void button_DownOrder_Click(object sender, EventArgs e)
  459. {
  460. Grid_Minerals.Focus(true);
  461. int selrow = Grid_Minerals.Selection.ActivePosition.Row;
  462. int id = (int)Grid_Minerals[selrow, 0].Tag;
  463. int id2 = (int)Grid_Minerals[selrow + 1, 0].Tag;
  464. string sname = Grid_Minerals[selrow, 0].Value.ToString();
  465. Grid_Minerals[selrow, 0].Value = Grid_Minerals[selrow + 1, 0].Value;
  466. Grid_Minerals[selrow, 0].Tag = id2;
  467. SourceGrid.Cells.Views.Cell view = new SourceGrid.Cells.Views.Cell();
  468. view.BackColor = colorHx16toRGB(m_MainForm.STDDictionary[id2].Color);
  469. Grid_Minerals[selrow, 1].View = view;
  470. Grid_Minerals[selrow + 1, 0].Value = sname;
  471. Grid_Minerals[selrow + 1, 0].Tag = id;
  472. SourceGrid.Cells.Views.Cell view2 = new SourceGrid.Cells.Views.Cell();
  473. view2.BackColor = colorHx16toRGB(m_MainForm.STDDictionary[id].Color);
  474. Grid_Minerals[selrow + 1, 1].View = view2;
  475. m_MainForm.STDDictionary[id].StrName = Grid_Minerals[selrow + 1, 0].Value.ToString();
  476. m_MainForm.STDDictionary[id2].StrName = Grid_Minerals[selrow, 0].Value.ToString();
  477. Position pos = new Position(selrow + 1, 0);
  478. Grid_Minerals[selrow + 1, 0].Grid.Select();
  479. Grid_Minerals.Selection.Focus(pos, true);
  480. PreRow = selrow + 1;
  481. button_UpOrder.Enabled = true;
  482. if (selrow + 1 == Grid_Minerals.RowsCount - 1)
  483. {
  484. button_DownOrder.Enabled = false;
  485. }
  486. #region 添加修改stdid顺序 ,由于需求改变只完成一部分(差相应修改能谱部分)
  487. //DialogResult result=MessageBox.Show("检测到顺序已修改,是否调整STDId?", "提示",MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
  488. //if (result == DialogResult.Yes)
  489. //{
  490. // ChangeSTDidFromNum changeSTDidFromNum = new ChangeSTDidFromNum();
  491. // DialogResult res=changeSTDidFromNum.ShowDialog();
  492. // {
  493. // if (res == DialogResult.OK)
  494. // {
  495. // int StartId = int.Parse(changeSTDidFromNum.textBox_NewFirstSTDId.Text);
  496. // Dictionary<int, STDdata> STDDictionaryCopy = new Dictionary<int, STDdata>();
  497. // for (int i = 0; i < Grid_Minerals.RowsCount-1; i++)
  498. // {
  499. // STDdata dataCopy = m_MainForm.STDDictionary[(int)Grid_Minerals[i+1, 0].Tag];
  500. // STDDictionaryCopy.Add(StartId + i, dataCopy);
  501. // }
  502. // m_MainForm.STDDictionary.Clear();
  503. // m_MainForm.STDDictionary = STDDictionaryCopy;
  504. // }
  505. // }
  506. //}
  507. #endregion
  508. m_MainForm.IsModified = true;
  509. }
  510. public void InsertNewRow(int STDId, string RuleName, Color color)
  511. {
  512. Grid_Minerals.Focus(true);
  513. Grid_Minerals.Rows.InsertRange(Grid_Minerals.Selection.ActivePosition.Row, 1);
  514. //Grid_Minerals.Rows.Insert(Grid_Minerals.Rows.Count);
  515. int i = Grid_Minerals.Selection.ActivePosition.Row;
  516. Grid_Minerals[Grid_Minerals.Selection.ActivePosition.Row, 0] = new SourceGrid.Cells.Cell(RuleName, typeof(string));
  517. Grid_Minerals[Grid_Minerals.Selection.ActivePosition.Row, 0].Tag = STDId;
  518. Grid_Minerals.Rows[Grid_Minerals.Selection.ActivePosition.Row].Height = 25;
  519. Grid_Minerals[Grid_Minerals.Selection.ActivePosition.Row, 1] = new SourceGrid.Cells.Cell();
  520. m_MainForm.ChangeSTDEditorAndGrid_Attributes(STDId);
  521. Grid_Minerals.Focus(true);
  522. SourceGrid.Cells.Views.Cell view = new SourceGrid.Cells.Views.Cell();
  523. view.BackColor = color;
  524. Grid_Minerals[Grid_Minerals.Selection.ActivePosition.Row, 1].View = view;
  525. Position pos = new Position(Grid_Minerals.Selection.ActivePosition.Row, 0);
  526. Grid_Minerals.Selection.Focus(pos, true);
  527. PreRow = Grid_Minerals.Selection.ActivePosition.Row - 1;
  528. }
  529. private void Grid_Minerals_VScrollPositionChanged(object sender, ScrollPositionChangedEventArgs e)
  530. {
  531. //Grid_Minerals.Refresh();
  532. }
  533. }
  534. }