Example #1
0
 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);
     }
 }
Example #2
0
        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);
            }
        }
Example #3
0
        /// <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);
            }
        }