public void UpdateModule(NavBarGroup group) { _GZTable.ClearControl(); this.Text = group.Caption; this.SuspendLayout(); if (group != null) { NavBarItem item; List <Control> lstAdd = new List <Control>(); foreach (NavBarItemLink itemLink in group.VisibleItemLinks) { item = itemLink.Item; var fun = item.Tag as ModuleFunction; SimpleButton btn = new SimpleButton(); btn.Text = fun.FunctionName; btn.Appearance.Options.UseTextOptions = true; btn.Appearance.TextOptions.WordWrap = DevExpress.Utils.WordWrap.Wrap; btn.ImageLocation = DevExpress.XtraEditors.ImageLocation.TopCenter; btn.Image = ClothingPSISQLite.Library.MyClass.LoadUIImage.LoadFunctionButtonImg(fun.FunctionPngLarge); btn.Margin = new System.Windows.Forms.Padding(5); btn.Padding = new System.Windows.Forms.Padding(3, 1, 3, 1); btn.Appearance.TextOptions.WordWrap = DevExpress.Utils.WordWrap.Wrap; btn.Tag = fun; btn.Click += btn_Click; if (fun.IsNew == true) { lstAdd.Add(btn); btn.ForeColor = Color.FromArgb(0x99, 0x00, 0x33); btn.Font = new Font(btn.Font, FontStyle.Bold); continue; } _GZTable.SetControl(fun.GroupIndex, fun.ItemIndex, btn); } if (lstAdd.Count > 0) { for (int i = 0; i < _GZTable.GT.RowCount; i++) { for (int j = 0; j < _GZTable.GT.CellCount; j++) { if (_GZTable.GT[i][j].IsUsed == false) { _GZTable.SetControl(i, j, lstAdd[0]); lstAdd.RemoveAt(0); } if (lstAdd.Count == 0) { break; } } if (lstAdd.Count == 0) { break; } } } } this.Activate(); this.ResumeLayout(); }
public void UpdateModule(NavBarGroup group) { if (FocusButton != null) { FocusButton.Appearance.Font = new System.Drawing.Font("Tahoma", 9F, System.Drawing.FontStyle.Regular); FocusButton.Appearance.Options.UseFont = true; FocusButton.ForeColor = Color.Empty; } FocusButton = null; //_GZTable.RemoveButton(); _GZTable.ClearControl(); this.SuspendLayout(); if (group != null) { NavBarItem item; int RowIndex = 0, OrderID = 0; List <Control> lstAdd = new List <Control>(); foreach (NavBarItemLink itemLink in group.VisibleItemLinks) { item = itemLink.Item; DataRow dr = item.Tag as DataRow; RowIndex = ConvertEx.ToInt(dr[sys_ModulesFunction.GroupIndex]); OrderID = ConvertEx.ToInt(dr[sys_ModulesFunction.ItemIndex]); SimpleButton btn = new SimpleButton(); btn.Text = item.Caption; btn.Appearance.Options.UseTextOptions = true; btn.Appearance.TextOptions.WordWrap = DevExpress.Utils.WordWrap.Wrap; btn.ImageLocation = DevExpress.XtraEditors.ImageLocation.TopCenter; btn.Image = ClothingPSISQLite.Library.MyClass.LoadUIImage.LoadFunctionButtonImg((item.Tag as DataRow)[sys_ModulesFunction.ImgLarge].ToString()); btn.Margin = new System.Windows.Forms.Padding(5); btn.Padding = new System.Windows.Forms.Padding(3, 1, 3, 1); btn.Appearance.TextOptions.WordWrap = DevExpress.Utils.WordWrap.Wrap; btn.Tag = item; btn.GotFocus += btn_GotFocus; if (dr.RowState == DataRowState.Added) { lstAdd.Add(btn); btn.ForeColor = Color.FromArgb(0x99, 0x00, 0x33); btn.Font = new Font(btn.Font, FontStyle.Bold); continue; } _GZTable.SetControl(RowIndex, OrderID, btn); } if (lstAdd.Count > 0) { for (int i = 0; i < _GZTable.GT.RowCount; i++) { for (int j = 0; j < _GZTable.GT.CellCount; j++) { if (_GZTable.GT[i][j].IsUsed == false) { _GZTable.SetControl(i, j, lstAdd[0]); DataRow dr = (lstAdd[0].Tag as NavBarItem).Tag as DataRow; dr[sys_ModulesFunction.GroupIndex] = i; dr[sys_ModulesFunction.ItemIndex] = j; lstAdd.RemoveAt(0); } if (lstAdd.Count == 0) { break; } } if (lstAdd.Count == 0) { break; } } } } this.Activate(); this.ResumeLayout(); }