/// <summary> ///This method sets up the form so that the menu is displayed and the form is able to ///display the controls loaded when the menu item is clicked. /// </summary> /// <param name="form">The form to set up with the menu</param> /// <param name="menuWidth">The width of the menu - configurable to so that each application can set its menu width</param> public void DockInForm(IControlHabanero form, int menuWidth) { if (form == null) { throw new ArgumentNullException("form"); } _splitContainer = this.ControlFactory.CreateSplitContainer(); _splitContainer.Name = "SplitContainer"; BorderLayoutManager layoutManager = this.ControlFactory.CreateBorderLayoutManager(form); layoutManager.AddControl(_splitContainer, BorderLayoutManager.Position.Centre); SplitContainer splitContainer1 = (SplitContainer)_splitContainer; //splitContainer1.IsSplitterFixed = true; splitContainer1.FixedPanel = FixedPanel.Panel1; splitContainer1.Size = new System.Drawing.Size(400, 450); splitContainer1.SplitterDistance = menuWidth; splitContainer1.Panel1MinSize = menuWidth; splitContainer1.Orientation = System.Windows.Forms.Orientation.Vertical; this.Dock = System.Windows.Forms.DockStyle.Fill; splitContainer1.Panel1.Controls.Add(this); MainEditorPanelWin mainEditorPanel = new MainEditorPanelWin(this.ControlFactory); mainEditorPanel.Dock = System.Windows.Forms.DockStyle.Fill; splitContainer1.Panel2.Controls.Add(mainEditorPanel); }
/// <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); } }