示例#1
0
        protected virtual void ShowForm(BaseForm form, bool showTab, bool canClose)
        {
            if (form == null)
            {
                throw new ArgumentNullException();
            }

            if (MdiClient != null)
            {
                MdiClient.ShowMdiForm(form);
            }
            else if (IsMdiContainer)
            {
                form.MdiParent   = this;
                form.WindowState = FormWindowState.Maximized;
                //form.FormBorderStyle = FormBorderStyle.None;
                form.ControlBox = false;
                form.Show();
            }

            form.TextChanged += Form_TextChanged;
            form.Activated   += Form_Activated;
            form.FormClosed  += Form_FormClosed;

            if (showTab && TaskBar != null)
            {
                var ti = new TabItem();
                ti.Text     = form.Text;
                ti.CanClose = canClose;
                ti.Tag      = form;
                if (form is BaseForm)
                {
                    ti.Icon = ((BaseForm)form).IconImage;
                }
                else
                {
                    ti.Icon = PaintHelper.IconToImage(form.Icon);
                }
                TaskBar.Items.Add(ti);

                TaskBar.SelectedItem = ti;
            }

            if (!Forms.Contains(form))
            {
                Forms.Add(form);
            }
        }