STDRuleslist.cs 23 KB

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