private void GetHotButtonItem() { if (this.Controls.Count == 0) { return; } for (int i = 0; i < this._lstButton.Count; i++) { HotButtonItemInfo item = new HotButtonItemInfo(); item.Name = string.Empty; if (_lstButton[i] != null) { object btnCtrl = (_lstButton[i] as PanelControl).Controls[0]; if (btnCtrl.GetType() == typeof(LargeButtonControl)) { LargeButtonControl btn = btnCtrl as LargeButtonControl; item = GetLargeButtonItemContent(btn); } else { SmallButtonControl btn = btnCtrl as SmallButtonControl; item = GetSmallButtonItemContent(btn); } } _hotButtonItems.Add(item); } }
public void Load(object button) { if (typeof(SmallButtonControl) == button.GetType()) { SmallButtonControl btn = button as SmallButtonControl; txtName.Text = btn.ButtonName; _mainKey = btn.MainHotKey; _subKey = btn.SubHotKey; HotKeyChanged(); _hotButtonSettingFinish = true; ddlColor.EditValue = btn.ButtonColor; rdoSize.SelectedIndex = 0; LoadSignsFromSession(btn.Sign); } else if (typeof(LargeButtonControl) == button.GetType()) { LargeButtonControl btn = button as LargeButtonControl; txtName.Text = btn.ButtonName; _mainKey = btn.MainHotKey; _subKey = btn.SubHotKey; HotKeyChanged(); _hotButtonSettingFinish = true; ddlColor.EditValue = btn.ButtonColor; rdoSize.SelectedIndex = 1; LoadSignsFromSession(btn.Sign); } }
public void UpdateHotButtonData(object oldBtn, object newBtn, LiveSign[] signs) { for (int i = 0; i < this.Controls.Count; i++) { PanelControl panel = this.Controls[i] as PanelControl; if (panel.Controls.Count > 0) { Control ctrl = panel.Controls[0]; if (ctrl == oldBtn) { Control hotkey = newBtn as Control; hotkey.Dock = DockStyle.Fill; if (typeof(SmallButtonControl) == hotkey.GetType()) { SmallButtonControl btn = hotkey as SmallButtonControl; btn.Sign = signs; PanelControl newPanel = NewButtonContainer(HotButtonPanelControl.ButtonContainerType.Small); newPanel.Controls.Add(hotkey); UnRegisterEvent(panel); _lstButton.Remove(panel); _lstButton.Insert(i, newPanel); } else if (typeof(LargeButtonControl) == hotkey.GetType()) { LargeButtonControl btn = hotkey as LargeButtonControl; btn.Sign = signs; PanelControl newPanel = NewButtonContainer(HotButtonPanelControl.ButtonContainerType.Large); newPanel.Controls.Add(hotkey); UnRegisterEvent(panel); _lstButton.Remove(panel); _lstButton.Insert(i, newPanel); } break; } } } UpdateDrawGrid(); }
void panel_MouseDown(object sender, MouseEventArgs e) { if (sender.GetType() == typeof(SmallButtonControl)) { SmallButtonControl btnSamll = sender as SmallButtonControl; PanelControl panel = btnSamll.Parent as PanelControl; panel.DoDragDrop(panel, DragDropEffects.Move); } else if (sender.GetType() == typeof(LargeButtonControl)) { LargeButtonControl btnLarge = sender as LargeButtonControl; PanelControl panel = btnLarge.Parent as PanelControl; panel.DoDragDrop(panel, DragDropEffects.Move); } }
private HotButtonItemInfo GetLargeButtonItemContent(LargeButtonControl btn) { HotButtonItemInfo item = new HotButtonItemInfo(); item.CreateTime = DateTime.Now; item.Id = Guid.NewGuid().ToString(); item.Name = btn.ButtonName; item.Sign = btn.Sign; item.SubHotKey = btn.SubHotKey; item.MainHotKey = btn.MainHotKey; item.ButtonBackColor = btn.ButtonColor; item.IsLarge = true; item.ButtonName = btn.ButtonName; return(item); }
private void itmAddButton_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { HotButtonSettingForm frmHotButton = null; try { frmHotButton = new HotButtonSettingForm(); frmHotButton.SignList = SignList; if (frmHotButton.ShowDialog() == DialogResult.OK) { Control hotkey = frmHotButton.HotKeyButton; hotkey.Dock = DockStyle.Fill; if (typeof(SmallButtonControl) == hotkey.GetType()) { SmallButtonControl btn = hotkey as SmallButtonControl; btn.Sign = frmHotButton.LiveSigns; PanelControl panel = hotButtonPanelControl.NewButtonContainer(HotButtonPanelControl.ButtonContainerType.Small); panel.Controls.Add(btn); hotButtonPanelControl.AddButtonContainer(panel); } else if (typeof(LargeButtonControl) == hotkey.GetType()) { LargeButtonControl btn = hotkey as LargeButtonControl; btn.Sign = frmHotButton.LiveSigns; PanelControl panel = hotButtonPanelControl.NewButtonContainer(HotButtonPanelControl.ButtonContainerType.Large); panel.Controls.Add(hotkey); hotButtonPanelControl.AddButtonContainer(panel); } } } finally { if (frmHotButton != null) { frmHotButton.Dispose(); } ClosePoputMenu(); } }
private void SetHotButtonItem() { this.Controls.Clear(); this._lstButton.Clear(); for (int i = 0; i < _hotButtonItems.Count; i++) { object obj = null; if (_hotButtonItems[i].Name != string.Empty) { PanelControl panel = null; if (_hotButtonItems[i].IsLarge) { LargeButtonControl btn = new LargeButtonControl(); btn.ButtonName = _hotButtonItems[i].ButtonName; btn.BackColor = _hotButtonItems[i].ButtonBackColor; btn.Sign = _hotButtonItems[i].Sign; btn.MainHotKey = _hotButtonItems[i].MainHotKey; btn.SubHotKey = _hotButtonItems[i].SubHotKey; panel = NewButtonContainer(ButtonContainerType.Large); panel.Controls.Add(btn); } else { SmallButtonControl btn = new SmallButtonControl(); btn.ButtonName = _hotButtonItems[i].ButtonName; btn.BackColor = _hotButtonItems[i].ButtonBackColor; btn.Sign = _hotButtonItems[i].Sign; btn.MainHotKey = _hotButtonItems[i].MainHotKey; btn.SubHotKey = _hotButtonItems[i].SubHotKey; panel = NewButtonContainer(ButtonContainerType.Small); panel.Controls.Add(btn); } _lstButton.Add(panel); } else { _lstButton.Add(obj); } } }
private void UnRegisterEvent(PanelControl panel) { panel.DragEnter -= ctlPanel_DragEnter; panel.DragDrop -= ctlPanel_DragDrop; panel.MouseDown -= panel_MouseDown; panel.MouseClick += panel_MouseClick; if (panel.Controls.Count > 0) { if (panel.Controls[0].GetType() == typeof(SmallButtonControl)) { SmallButtonControl btn = panel.Controls[0] as SmallButtonControl; btn.MouseDown -= btnSmall_MouseDown; } else if (panel.Controls[0].GetType() == typeof(LargeButtonControl)) { LargeButtonControl btn = panel.Controls[0] as LargeButtonControl; btn.MouseDown -= btnLarge_MouseDown; } } }
private void RegisterEvent(PanelControl panel) { panel.DragEnter += new DragEventHandler(ctlPanel_DragEnter); panel.DragDrop += new DragEventHandler(ctlPanel_DragDrop); panel.MouseDown += new MouseEventHandler(panel_MouseDown); panel.MouseClick += new MouseEventHandler(panel_MouseClick); if (panel.Controls.Count > 0) { if (panel.Controls[0].GetType() == typeof(SmallButtonControl)) { SmallButtonControl btn = panel.Controls[0] as SmallButtonControl; btn.MouseDown += new MouseEventHandler(btnSmall_MouseDown); } else if (panel.Controls[0].GetType() == typeof(LargeButtonControl)) { LargeButtonControl btn = panel.Controls[0] as LargeButtonControl; btn.MouseDown += new MouseEventHandler(btnLarge_MouseDown); } } }