private void MainForm_MdiChildActivate(object sender, EventArgs e)
 {
     Frm.statusStripMF.SuspendLayout();
     foreach (ToolStripItem but in Frm.statusStripMF.Items)
     {
         if (but is ToolStripButton && Frm.ActiveMdiChild != null)
         {
             but.Text = ((Form)but.Tag).Text;
             if (but.Tag == Frm.ActiveMdiChild)
             {
                 ((ToolStripButton)but).CheckState = CheckState.Checked;
                 but.Font = ActiveButtonFontB;
                 ListForm frm = Frm.ActiveMdiChild as ListForm;
                 if (frm != null && MergeMenu)
                 {
                     frm.FormController.MergeMenu();
                 }
             }
             else
             {
                 ((ToolStripButton)but).CheckState = CheckState.Unchecked;
                 but.Font = ActiveButtonFontR;
             }
         }
     }
     Frm.statusStripMF.ResumeLayout();
 }
示例#2
0
 public FormController(Form mdiForm, string name, string caption, Icon icon)
 {
     FForm             = new ListForm();
     FForm.Name        = name;
     FForm.Text        = caption;
     FForm.Icon        = icon;
     FForm.WindowState = FormWindowState.Maximized;
 }
        public void ActivateController <C>(BaseLoadFilter filter)
            where C : FormController //ListFormController
        {
            //ListFormController controller = null;
            FormController controller = null;

            try
            {
                foreach (Form form in Frm.MdiChildren)
                {
                    ListForm lf = form as ListForm;
                    if (lf != null && lf.FormController.GetType() == typeof(C))
                    {
                        controller = lf.FormController;
                        lf.Activate();
                        break;
                    }
                }

                if (controller == null && filter == null)
                {
                    //controller = (ListFormController)Activator.CreateInstance(typeof(C), Frm);
                    controller = (FormController)Activator.CreateInstance(typeof(C), Frm);
                }
                else if (controller == null)
                {
                    //controller = (ListFormController)Activator.CreateInstance(typeof(C), Frm, filter);
                    controller = (FormController)Activator.CreateInstance(typeof(C), Frm, filter);
                }
                else if (filter != null)
                {
                    controller.InitFilter(filter);
                    controller.Refresh();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(Common.ExMessage(ex), "Ошибка");
            }
        }