STDRuleslist.cs 23 KB

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