コード例 #1
0
        /// <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);
        }
コード例 #2
0
 private bool ReshowForm()
 {
     if (_createdForm != null)
     {
         try
         {
             _createdForm.Show();
             _createdForm.Refresh();
             _createdForm.Focus();
             _createdForm.PerformLayout();
         }
         catch (Win32Exception)
         {
             //note_: it will throw this error in testing.
         }
         catch (ObjectDisposedException)
         {
             //the window has been disposed, we need to create a new one
         }
         return(true);
     }
     return(false);
 }