public void DoClick() { try { if (_habaneroMenuItem.CustomHandler != null) { _habaneroMenuItem.CustomHandler(this, new EventArgs()); } else { IControlHabanero control; if (_habaneroMenuItem.Form == null || _habaneroMenuItem.Form.Controls.Count <= 0) { return; } if (_habaneroMenuItem.FormControlCreator != null) { if (_formControl == null) { _formControl = _habaneroMenuItem.FormControlCreator(); } _formControl.SetForm(null); control = (IControlHabanero)_formControl; } else if (_habaneroMenuItem.ControlManagerCreator != null) { if (_controlManager == null) { _controlManager = _habaneroMenuItem.ControlManagerCreator(_habaneroMenuItem.ControlFactory); } control = _controlManager.Control; } else { throw new Exception ("Please set up the MenuItem with at least one Creational or custom handling delegate"); } control.Dock = Base.DockStyle.Fill; IControlHabanero controlToNestIn = _habaneroMenuItem.Form.Controls[0]; controlToNestIn.Controls.Clear(); controlToNestIn.Controls.Add(control); } } catch (Exception ex) { GlobalRegistry.UIExceptionNotifier.Notify(ex, null, null); } }
/// <summary> /// Sets the current control to the one with the specified heading /// </summary> /// <param name="heading">The heading</param> /// <returns>Returns the relevant IFormControl object</returns> public IFormControl SetCurrentControl(String heading) { if (_formsbyHeading == null) { _formsbyHeading = new Hashtable(); _formsbyForm = new Hashtable(); } if (_formsbyHeading.Contains(heading)) { IFormHabanero frm = (IFormHabanero)_formsbyHeading[heading]; if (_fontSize != 0.0f) { frm.Font = new Font(frm.Font.FontFamily, _fontSize); } frm.Show(); frm.Refresh(); frm.Focus(); frm.PerformLayout(); return((IFormControl)frm.Controls[0]); } IFormControl formCtl = GetFormControl(heading); IFormHabanero newMdiForm = _controlFactory.CreateForm(); newMdiForm.Width = 800; newMdiForm.Height = 600; newMdiForm.MdiParent = _parentForm; newMdiForm.WindowState = FormWindowState.Maximized; //IControlHabanero ctl = formCtl; newMdiForm.Text = heading; newMdiForm.Controls.Clear(); BorderLayoutManager layoutManager = _controlFactory.CreateBorderLayoutManager(newMdiForm); layoutManager.AddControl((IControlHabanero)formCtl, BorderLayoutManager.Position.Centre); newMdiForm.Show(); _formsbyHeading.Add(heading, newMdiForm); _formsbyForm.Add(newMdiForm, heading); formCtl.SetForm(newMdiForm); newMdiForm.Closed += MdiFormClosed; return(formCtl); }
public void DoClick() { try { if (_habaneroMenuItem.CustomHandler != null) { _habaneroMenuItem.CustomHandler(this, new EventArgs()); } else { if (ReshowForm()) { return; } if (_habaneroMenuItem.Form == null || _habaneroMenuItem.Form.Controls.Count <= 0) { return; } _createdForm = _habaneroMenuItem.ControlFactory.CreateForm(); _createdForm.Width = 800; _createdForm.Height = 600; _createdForm.MdiParent = (IFormHabanero)_habaneroMenuItem.Form; _createdForm.WindowState = Habanero.Faces.Base.FormWindowState.Maximized; _createdForm.Text = _habaneroMenuItem.Name; //Deerasha 2009/11/26: Line below prevents the std VS icon from appearing on form's upper right ((Form)_createdForm).ShowIcon = false; _createdForm.Controls.Clear(); BorderLayoutManager layoutManager = _habaneroMenuItem.ControlFactory.CreateBorderLayoutManager (_createdForm); IControlHabanero control; if (_habaneroMenuItem.FormControlCreator != null) { _formControl = _habaneroMenuItem.FormControlCreator(); _formControl.SetForm(_createdForm); control = (IControlHabanero)_formControl; } else if (_habaneroMenuItem.ControlManagerCreator != null) { _controlManager = _habaneroMenuItem.ControlManagerCreator(_habaneroMenuItem.ControlFactory); control = _controlManager.Control; } else { throw new Exception ("Please set up the MenuItem with at least one Creational or custom handling delegate"); } layoutManager.AddControl(control, BorderLayoutManager.Position.Centre); _createdForm.Show(); _createdForm.Closed += delegate { _createdForm = null; _formControl = null; _controlManager = null; }; } } catch (Exception ex) { GlobalRegistry.UIExceptionNotifier.Notify(ex, null, null); } }
/// <summary> /// This actually executes the Code when PerformClick is selected <see cref="T:Habanero.Faces.Base.IMenuItem" />. /// </summary> public void DoClick() { try { if (_habaneroMenuItem.CustomHandler != null) { _habaneroMenuItem.CustomHandler(this, new EventArgs()); } else { IControlHabanero control; if (_habaneroMenuItem.Form == null || _habaneroMenuItem.Form.Controls.Count <= 0) { return; } if (_habaneroMenuItem.FormControlCreator != null) { if (_formControl == null) { _formControl = _habaneroMenuItem.FormControlCreator(); } _formControl.SetForm(null); control = (IControlHabanero)_formControl; } else if (_habaneroMenuItem.ControlManagerCreator != null) { if (_controlManager == null) { _controlManager = _habaneroMenuItem.ControlManagerCreator(_habaneroMenuItem.ControlFactory); } control = _controlManager.Control; } else { throw new Exception ("Please set up the MenuItem with at least one Creational or custom handling delegate"); } control.Dock = Habanero.Faces.Base.DockStyle.Fill; // support the menu control either being the top control of the form, or the first subcontrol of the top control SplitContainer splitContainer; if (_habaneroMenuItem.Form.Controls[0] is SplitContainer) { splitContainer = (SplitContainer)_habaneroMenuItem.Form.Controls[0]; } else { splitContainer = (SplitContainer)_habaneroMenuItem.Form.Controls[0].Controls[0]; } SplitterPanel panel2 = splitContainer.Panel2; MainEditorPanelWin mainEditorPanel = (MainEditorPanelWin)panel2.Controls[0]; mainEditorPanel.MainTitleIconControl.Title.Text = _habaneroMenuItem.ParentMenu.Name + " > " + this.Text; mainEditorPanel.EditorPanel.Controls.Clear(); mainEditorPanel.EditorPanel.Controls.Add(control); mainEditorPanel.Width -= 1; mainEditorPanel.Width += 1; } } catch (Exception ex) { GlobalRegistry.UIExceptionNotifier.Notify(ex, null, null); } }