Form_GroupId.cs 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553
  1. using SourceGrid;
  2. using SpectrumSTDEditor.BaseClass;
  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 SpectrumSTDEditor
  13. {
  14. public partial class Form_GroupId : Form
  15. {
  16. public Form_Main m_MainForm = null;
  17. //国际化
  18. Language lan;
  19. System.Collections.Hashtable table_GroupId;
  20. string MineralGroupDBAddress = Application.StartupPath + "\\Config\\SysData\\" + "OTSCleanlinesSTD.db";
  21. Dictionary<int,STDGroups> MineralGroupDictionary = new Dictionary<int, STDGroups>();
  22. //Dictionary<int, STDGroups> MineralGroupDictionaryInitial = new Dictionary<int, STDGroups>();
  23. /// <summary>
  24. ///数据库修改状态
  25. /// </summary>
  26. public enum DBInfoState
  27. {
  28. Add = 0,
  29. Modify = 1,
  30. Delete = 2
  31. }
  32. object Clone(Dictionary<int, STDGroups> Dictionary)
  33. {
  34. Dictionary<int, STDGroups> DictionaryInitial = new Dictionary<int, STDGroups>();
  35. foreach (var key in Dictionary.Keys)
  36. {
  37. STDGroups DGroups = new STDGroups();
  38. DGroups = DGroups.Clone(Dictionary[key]) as STDGroups;
  39. DictionaryInitial.Add(key,DGroups);
  40. }
  41. return DictionaryInitial;
  42. }
  43. bool LoadDataFromDb(string DBaddress)
  44. {
  45. try
  46. {
  47. System.Data.SQLite.SQLiteConnection m_dbConnection = new System.Data.SQLite.SQLiteConnection("data source='" + DBaddress + "'");
  48. m_dbConnection.Open();
  49. System.Data.SQLite.SQLiteDataAdapter m_dataAdapter = new System.Data.SQLite.SQLiteDataAdapter("select * from STDGroups order by iorder", m_dbConnection);
  50. DataSet ds = new DataSet();
  51. m_dataAdapter.Fill(ds);
  52. DataTable dt = ds.Tables[0];
  53. if (dt != null)
  54. {
  55. STDGroups new_data = new STDGroups();
  56. new_data.name = "Default";
  57. new_data.color = "#C9C9C9";
  58. new_data.iorder = 999;
  59. MineralGroupDictionary.Add(0, new_data);
  60. if (dt.Rows.Count > 0)
  61. {
  62. foreach (DataRow item in dt.Rows)
  63. {
  64. if (item["name"].ToString() != "Default")
  65. {
  66. STDGroups new_STDdata = new STDGroups();
  67. new_STDdata.name = item["name"].ToString();
  68. new_STDdata.color = item["color"].ToString();
  69. new_STDdata.iorder = int.Parse(item["iorder"].ToString());
  70. MineralGroupDictionary.Add(int.Parse(item["id"].ToString()), new_STDdata);
  71. }
  72. }
  73. }
  74. }
  75. m_dbConnection.Close();
  76. return true;
  77. }
  78. catch(Exception ee)
  79. {
  80. MessageBox.Show(ee.ToString());
  81. return false;
  82. }
  83. }
  84. private void clickEvent_Click(object sender, EventArgs e)
  85. {
  86. SourceGrid.CellContext context = (SourceGrid.CellContext)sender;
  87. int i = context.Position.Row;
  88. int j = context.Position.Column;
  89. /// 保证鼠标点击的GRID行和列是有效的
  90. if (i >= 0 && j == 1)
  91. {
  92. ColorDialog cd = new ColorDialog();
  93. cd.FullOpen = true;//自定义颜色界面打开
  94. DialogResult result = cd.ShowDialog();
  95. if (result == DialogResult.OK)
  96. {
  97. SourceGrid.Cells.Views.Cell view = new SourceGrid.Cells.Views.Cell();
  98. view.BackColor = cd.Color;
  99. Grid_FroupId[i, 1].View = view;
  100. MineralGroupDictionary[(int)Grid_FroupId[i, 0].Tag].color = shareFunction.ColorTostring10(Grid_FroupId[i, 1].View.BackColor);
  101. }
  102. }
  103. Grid_FroupId.Refresh();
  104. }
  105. void clickEvent_ValueChanged(object sender, EventArgs e)
  106. {
  107. SourceGrid.CellContext context = (SourceGrid.CellContext)sender;
  108. int i = context.Position.Row;
  109. int j = context.Position.Column;
  110. if (i >= 0 && j == 0)
  111. {
  112. MineralGroupDictionary[(int)Grid_FroupId[i, 0].Tag].name = Grid_FroupId[i, 0].Value.ToString();
  113. MineralGroupDictionary[(int)Grid_FroupId[i, 0].Tag].InfoState = (int)DBInfoState.Modify;
  114. }
  115. }
  116. //查询数据是否存在
  117. protected bool WhetherExistsInDBById(System.Data.SQLite.SQLiteConnection m_dbConnection, int id)
  118. {
  119. bool selResult = false;
  120. System.Data.SQLite.SQLiteDataAdapter m_dataAdapter = new System.Data.SQLite.SQLiteDataAdapter("select * from STDGroups where id=" + id.ToString() + "", m_dbConnection);
  121. DataSet ds = new DataSet();
  122. m_dataAdapter.Fill(ds);
  123. DataTable dt = ds.Tables[0];
  124. if (dt != null)
  125. {
  126. if (dt.Rows.Count > 0)
  127. {
  128. selResult = true;
  129. }
  130. }
  131. return selResult;
  132. }
  133. bool AddIntoDB(System.Data.SQLite.SQLiteConnection m_dbConnection,int id,string name,string color,int iorder)
  134. {
  135. System.Data.SQLite.SQLiteCommand cmm = m_dbConnection.CreateCommand();
  136. try
  137. {
  138. string insertstr = "Insert into STDGroups(id,name,color,iorder)";
  139. string aa = "values(" + id + ",'" + name + "','" + color + "'," + iorder+ ")";
  140. cmm.CommandText = insertstr + aa;
  141. cmm.ExecuteNonQuery();
  142. return true;
  143. }
  144. catch /*(Exception ex)*/
  145. {
  146. return false;
  147. }
  148. }
  149. bool UpdataInDB(System.Data.SQLite.SQLiteConnection m_dbConnection, int id, string name, string color, int iorder)
  150. {
  151. System.Data.SQLite.SQLiteCommand cmm = m_dbConnection.CreateCommand();
  152. try
  153. {
  154. string insertstr = "update STDGroups set name='" + name + "',color='"+ color + "',iorder=" + iorder+ " where id=" + id + ";";
  155. cmm.CommandText = insertstr;
  156. cmm.ExecuteNonQuery();
  157. return true;
  158. }
  159. catch /*(Exception ex)*/
  160. {
  161. return false;
  162. }
  163. }
  164. bool DeleteInDB(System.Data.SQLite.SQLiteConnection m_dbConnection, int id, string name, string color, int iorder)
  165. {
  166. System.Data.SQLite.SQLiteCommand cmm = m_dbConnection.CreateCommand();
  167. try
  168. {
  169. string insertstr = "delete from STDGroups where id=" + id + ";";
  170. cmm.CommandText = insertstr;
  171. cmm.ExecuteNonQuery();
  172. return true;
  173. }
  174. catch /*(Exception ex)*/
  175. {
  176. return false;
  177. }
  178. }
  179. void SaveDataIntoDB(string DBAddress)
  180. {
  181. for (int i = 2; i < Grid_FroupId.RowsCount; i++)
  182. {
  183. MineralGroupDictionary[(int)Grid_FroupId[i, 0].Tag].iorder = i-1;
  184. }
  185. System.Data.SQLite.SQLiteConnection m_dbConnection = new System.Data.SQLite.SQLiteConnection("data source='" + DBAddress + "'");
  186. m_dbConnection.Open();
  187. foreach (KeyValuePair<int, STDGroups> kv in MineralGroupDictionary)
  188. {
  189. int infoState = kv.Value.InfoState;
  190. if (infoState == (int)DBInfoState.Modify)
  191. {
  192. bool result = WhetherExistsInDBById(m_dbConnection, kv.Key);
  193. if (!result)
  194. {
  195. if (!AddIntoDB(m_dbConnection, kv.Key, kv.Value.name, kv.Value.color, kv.Value.iorder))
  196. {
  197. MessageBox.Show("Failed to add into database!", "Tip");
  198. }
  199. }
  200. else
  201. {
  202. if (!UpdataInDB(m_dbConnection, kv.Key, kv.Value.name, kv.Value.color, kv.Value.iorder))
  203. {
  204. MessageBox.Show("Failed to update to database!", "Tip");
  205. }
  206. }
  207. }
  208. else if (infoState == (int)DBInfoState.Delete)
  209. {
  210. if (!DeleteInDB(m_dbConnection, kv.Key, kv.Value.name, kv.Value.color, kv.Value.iorder))
  211. {
  212. MessageBox.Show("Failed to delete data in database!", "Tip");
  213. }
  214. }
  215. }
  216. m_dbConnection.Close();
  217. }
  218. public Form_GroupId(string DBAddress, Form_Main mainForm)
  219. {
  220. InitializeComponent();
  221. MineralGroupDBAddress = DBAddress;
  222. m_MainForm = mainForm;
  223. }
  224. private void Form_GroupId_Load(object sender, EventArgs e)
  225. {
  226. lan = new Language(this);
  227. table_GroupId = lan.GetNameTable("Form_GroupId");
  228. button_up.Enabled = false;
  229. button_down.Enabled = false;
  230. bool result = LoadDataFromDb(MineralGroupDBAddress);
  231. if(result)
  232. {
  233. Grid_FroupId.Redim(MineralGroupDictionary.Count + 1, 2);
  234. Grid_FroupId.Rows.SetHeight(0, 25);
  235. Grid_FroupId.AutoStretchColumnsToFitWidth = true;
  236. Grid_FroupId.Selection.EnableMultiSelection = false;
  237. Grid_FroupId.FixedRows = 1;
  238. Grid_FroupId.Columns[0].Width = 190;
  239. Grid_FroupId.Columns[1].Width = 135;
  240. if (table_GroupId["language"].ToString() == "ZH")
  241. {
  242. Grid_FroupId[0, 0] = new SourceGrid.Cells.Cell("组名称", typeof(string));
  243. Grid_FroupId[0, 1] = new SourceGrid.Cells.Cell("组颜色", typeof(string));
  244. }
  245. else
  246. {
  247. Grid_FroupId[0, 0] = new SourceGrid.Cells.Cell("Group Name", typeof(string));
  248. Grid_FroupId[0, 1] = new SourceGrid.Cells.Cell("Group Color", typeof(string));
  249. }
  250. SourceGrid.Cells.Views.Cell view = new SourceGrid.Cells.Views.Cell();
  251. view.Font = new Font(FontFamily.GenericSansSerif, 10, FontStyle.Bold);
  252. view.TextAlignment = DevAge.Drawing.ContentAlignment.MiddleCenter;
  253. view.BackColor = Color.LightGray;
  254. Grid_FroupId[0, 0].View = view;
  255. Grid_FroupId[0, 1].View = view;
  256. Grid_FroupId[0, 0].AddController(SourceGrid.Cells.Controllers.Unselectable.Default);
  257. Grid_FroupId[0, 1].AddController(SourceGrid.Cells.Controllers.Unselectable.Default);
  258. Grid_FroupId[1, 0] = new SourceGrid.Cells.Cell("Default", typeof(string));
  259. Grid_FroupId[1, 1] = new SourceGrid.Cells.Cell("", typeof(string));
  260. Grid_FroupId.Rows[1].Height = 25;
  261. Grid_FroupId[1, 0].Tag = 0;
  262. SourceGrid.Cells.Views.Cell vw = new SourceGrid.Cells.Views.Cell();
  263. //vw.BackColor = Attributes.colorHx16toRGB("#C9C9C9");
  264. Grid_FroupId[1, 1].View = vw;
  265. Grid_FroupId[1, 0].AddController(SourceGrid.Cells.Controllers.Unselectable.Default);
  266. Grid_FroupId[1, 1].AddController(SourceGrid.Cells.Controllers.Unselectable.Default);
  267. int i = 2;
  268. foreach (KeyValuePair<int, STDGroups> kv in MineralGroupDictionary)
  269. {
  270. if (kv.Key != 0)
  271. {
  272. Grid_FroupId[i, 0] = new SourceGrid.Cells.Cell(kv.Value.name, typeof(string));
  273. Grid_FroupId[i, 1] = new SourceGrid.Cells.Cell("", typeof(string));
  274. Grid_FroupId.Rows[i].Height = 25;
  275. Grid_FroupId[i, 0].Tag = kv.Key;
  276. SourceGrid.Cells.Views.Cell vew = new SourceGrid.Cells.Views.Cell();
  277. vew.BackColor = shareFunction.string10ToColor(kv.Value.color);
  278. Grid_FroupId[i, 1].View = vew;
  279. SourceGrid.Cells.Controllers.CustomEvents clickEvent = new SourceGrid.Cells.Controllers.CustomEvents();
  280. clickEvent.ValueChanged += new EventHandler(clickEvent_ValueChanged);
  281. Grid_FroupId[i, 0].AddController(clickEvent);
  282. SourceGrid.Cells.Controllers.CustomEvents clickEvent2 = new SourceGrid.Cells.Controllers.CustomEvents();
  283. clickEvent2.Click += new EventHandler(clickEvent_Click);
  284. Grid_FroupId[i, 1].AddController(clickEvent2);
  285. i++;
  286. }
  287. }
  288. }
  289. else
  290. {
  291. MessageBox.Show("Failed to read database", "Tip");
  292. }
  293. }
  294. public int AddMineralGroupDictionaryItem()
  295. {
  296. STDGroups new_MineralGroup = new STDGroups();//定义一个TreeNode节点对象
  297. new_MineralGroup.name = "New Group";
  298. new_MineralGroup.color = shareFunction.ColorTostring10(Color.Gray);
  299. new_MineralGroup.InfoState = (int)DBInfoState.Modify;
  300. int Id = 100;
  301. foreach (KeyValuePair<int, STDGroups> kv in MineralGroupDictionary)
  302. {
  303. if (Id < kv.Key)
  304. {
  305. Id = kv.Key;
  306. }
  307. }
  308. MineralGroupDictionary.Add(Id + 1, new_MineralGroup);
  309. return Id + 1;
  310. }
  311. public void AddNewRow(int Id, string GroupName, Color color)
  312. {
  313. Grid_FroupId.Rows.Insert(Grid_FroupId.Rows.Count);
  314. Grid_FroupId[Grid_FroupId.Rows.Count - 1, 0] = new SourceGrid.Cells.Cell(GroupName, typeof(string));
  315. Grid_FroupId[Grid_FroupId.Rows.Count - 1, 1] = new SourceGrid.Cells.Cell("", typeof(string));
  316. Grid_FroupId[Grid_FroupId.Rows.Count - 1, 0].Tag = Id;
  317. Grid_FroupId.Rows[Grid_FroupId.Rows.Count - 1].Height = 25;
  318. SourceGrid.Cells.Views.Cell view = new SourceGrid.Cells.Views.Cell();
  319. view.BackColor = color;
  320. Grid_FroupId[Grid_FroupId.Rows.Count - 1, 1].View = view;
  321. SourceGrid.Cells.Controllers.CustomEvents clickEvent = new SourceGrid.Cells.Controllers.CustomEvents();
  322. clickEvent.ValueChanged += new EventHandler(clickEvent_ValueChanged);
  323. Grid_FroupId[Grid_FroupId.Rows.Count - 1, 0].AddController(clickEvent);
  324. SourceGrid.Cells.Controllers.CustomEvents clickEvent2 = new SourceGrid.Cells.Controllers.CustomEvents();
  325. clickEvent2.Click += new EventHandler(clickEvent_Click);
  326. Grid_FroupId[Grid_FroupId.Rows.Count - 1, 1].AddController(clickEvent2);
  327. Grid_FroupId.Refresh();
  328. Position pos = new Position(Grid_FroupId.Rows.Count - 1, 0);
  329. Grid_FroupId.Selection.Focus(pos, true);
  330. }
  331. public void RemoveMineralGroupDictionaryItem(int Id)
  332. {
  333. //MineralGroupDictionary.Remove(Id);
  334. MineralGroupDictionary[Id].InfoState = (int)DBInfoState.Delete;
  335. }
  336. private void button_Cancel_Click(object sender, EventArgs e)
  337. {
  338. this.DialogResult = DialogResult.Cancel;
  339. this.Close();
  340. }
  341. private void button_OK_Click(object sender, EventArgs e)
  342. {
  343. for (int i = 1; i < Grid_FroupId.RowsCount; i++)
  344. {
  345. for (int j = i+1; j < Grid_FroupId.RowsCount; j++)
  346. {
  347. if(Grid_FroupId[i,0].ToString()== Grid_FroupId[j,0].ToString())
  348. {
  349. Position pos = new Position(i, 0);
  350. Grid_FroupId.Selection.Focus(pos, true);
  351. string DuplicateNames = Grid_FroupId[i, 0].ToString();
  352. MessageBox.Show("The names of groups are reusable which named " + DuplicateNames + ",please modify!", "Tip");
  353. return;
  354. }
  355. }
  356. }
  357. SaveDataIntoDB(MineralGroupDBAddress);
  358. this.DialogResult = DialogResult.Yes;
  359. this.Close();
  360. }
  361. private void 添加组ToolStripMenuItem_Click(object sender, EventArgs e)
  362. {
  363. int Id = AddMineralGroupDictionaryItem();
  364. AddNewRow(Id, "New Group", Color.Gray);
  365. }
  366. private void 删除组ToolStripMenuItem_Click(object sender, EventArgs e)
  367. {
  368. int x = Grid_FroupId.Selection.ActivePosition.Row;
  369. int y = Grid_FroupId.Selection.ActivePosition.Column;
  370. if (x > 0 && (y == 0|| y == 1))
  371. {
  372. bool bexist = false;
  373. //foreach (KeyValuePair<int, STDdata> kv in m_MainForm.STDDictionary)
  374. //{
  375. // if(kv.Value.GroupId.ToString()== Grid_FroupId[x, 0].Tag.ToString())
  376. // {
  377. // bexist = true;
  378. // break;
  379. // }
  380. //}
  381. if(bexist)
  382. {
  383. MessageBox.Show("There is a grouping in the user standard library that you want to delete!");
  384. return;
  385. }
  386. RemoveMineralGroupDictionaryItem((int)Grid_FroupId[x, 0].Tag);
  387. Grid_FroupId.Rows.Remove(x);
  388. Grid_FroupId.Refresh();
  389. if (Grid_FroupId.RowsCount > 1)
  390. {
  391. Position pos = new Position(1, 0);
  392. Grid_FroupId.Selection.Focus(pos, true);
  393. Grid_FroupId[1, 0].Grid.Select();
  394. }
  395. }
  396. else
  397. {
  398. MessageBox.Show("No gruop is selected!", "Tip");
  399. }
  400. }
  401. private void button_up_Click(object sender, EventArgs e)
  402. {
  403. Grid_FroupId.Focus(true);
  404. int selrow = Grid_FroupId.Selection.ActivePosition.Row;
  405. int id = (int)Grid_FroupId[selrow, 0].Tag;
  406. int id2 = (int)Grid_FroupId[selrow - 1, 0].Tag;
  407. string GroupName = Grid_FroupId[selrow, 0].Value.ToString();
  408. Color color = Grid_FroupId[selrow, 1].View.BackColor;
  409. Grid_FroupId[selrow, 0].Value = Grid_FroupId[selrow - 1, 0].Value;
  410. Grid_FroupId[selrow, 0].Tag = id2;
  411. SourceGrid.Cells.Views.Cell view = new SourceGrid.Cells.Views.Cell();
  412. view.BackColor = Grid_FroupId[selrow - 1, 1].View.BackColor;
  413. Grid_FroupId[selrow, 1].View = view;
  414. Grid_FroupId[selrow - 1, 0].Value = GroupName;
  415. Grid_FroupId[selrow - 1, 0].Tag = id;
  416. SourceGrid.Cells.Views.Cell view2 = new SourceGrid.Cells.Views.Cell();
  417. view2.BackColor = color;
  418. Grid_FroupId[selrow - 1, 1].View = view2;
  419. MineralGroupDictionary[id].name = Grid_FroupId[selrow - 1, 0].Value.ToString();
  420. MineralGroupDictionary[id2].name = Grid_FroupId[selrow, 0].Value.ToString();
  421. Grid_FroupId.Refresh();
  422. Position pos = new Position(selrow - 1, 0);
  423. Grid_FroupId[selrow - 1, 0].Grid.Select();
  424. Grid_FroupId.Selection.Focus(pos, true);
  425. button_down.Enabled = true;
  426. if (selrow - 1 == 1)
  427. {
  428. button_up.Enabled = false;
  429. }
  430. }
  431. private void button_down_Click(object sender, EventArgs e)
  432. {
  433. Grid_FroupId.Focus(true);
  434. int selrow = Grid_FroupId.Selection.ActivePosition.Row;
  435. int id = (int)Grid_FroupId[selrow, 0].Tag;
  436. int id2 = (int)Grid_FroupId[selrow + 1, 0].Tag;
  437. string GroupName = Grid_FroupId[selrow, 0].Value.ToString();
  438. Color color = Grid_FroupId[selrow, 1].View.BackColor;
  439. Grid_FroupId[selrow, 0].Value = Grid_FroupId[selrow + 1, 0].Value;
  440. Grid_FroupId[selrow, 0].Tag = (int)Grid_FroupId[selrow + 1, 0].Tag;
  441. SourceGrid.Cells.Views.Cell view = new SourceGrid.Cells.Views.Cell();
  442. view.BackColor = Grid_FroupId[selrow+1, 1].View.BackColor;
  443. Grid_FroupId[selrow, 1].View = view;
  444. Grid_FroupId[selrow + 1, 0].Value = GroupName;
  445. Grid_FroupId[selrow + 1, 0].Tag = id;
  446. SourceGrid.Cells.Views.Cell view2 = new SourceGrid.Cells.Views.Cell();
  447. view2.BackColor = color;
  448. Grid_FroupId[selrow + 1, 1].View = view2;
  449. MineralGroupDictionary[id].name = Grid_FroupId[selrow + 1, 0].Value.ToString();
  450. MineralGroupDictionary[id2].name = Grid_FroupId[selrow, 0].Value.ToString();
  451. Grid_FroupId.Refresh();
  452. Position pos = new Position(selrow + 1, 0);
  453. Grid_FroupId[selrow + 1, 0].Grid.Select();
  454. Grid_FroupId.Selection.Focus(pos, true);
  455. button_up.Enabled = true;
  456. if (selrow + 1 == Grid_FroupId.RowsCount - 1)
  457. {
  458. button_down.Enabled = false;
  459. }
  460. }
  461. private void Grid_FroupId_Click(object sender, EventArgs e)
  462. {
  463. SourceGrid.Grid ls_gd = (SourceGrid.Grid)sender;
  464. ls_gd.Focus();
  465. int i = ls_gd.Selection.ActivePosition.Row;
  466. int j = ls_gd.Selection.ActivePosition.Column;
  467. /// 保证鼠标点击的GRID行和列是有效的
  468. if (i >= 0 && j >= 0)
  469. {
  470. if (i == ls_gd.RowsCount - 1)
  471. {
  472. button_down.Enabled = false;
  473. }
  474. else
  475. {
  476. button_down.Enabled = true;
  477. }
  478. if (i == 1)
  479. {
  480. button_up.Enabled = false;
  481. //MessageBox.Show("Group by default, not editable!");
  482. //return;
  483. }
  484. else
  485. {
  486. button_up.Enabled = true;
  487. }
  488. }
  489. }
  490. }
  491. }