/// <summary>
        /// 增加一个窗体
        /// </summary>
        /// <param name="frm"></param>
        public void AddAForm(Form frm)
        {
            var parent = this.ParentForm;

            if (!parent.IsMdiContainer)
            {
                throw new Exception("父窗体要设置成MDI窗体");
            }
            frm.MdiParent       = parent;
            frm.FormBorderStyle = FormBorderStyle.None;
            frm.ShowInTaskbar   = false;
            frm.WindowState     = FormWindowState.Normal;
            frm.Dock            = DockStyle.Fill;

            FormHeader header = new FormHeader();

            header.RenderForm = frm;
            frm.FormClosed   -= new FormClosedEventHandler(frm_FormClosed);
            frm.FormClosed   += new FormClosedEventHandler(frm_FormClosed);
            frm.Show();
            this.pHeader.Controls.Add(header);
            _Headers.Add(header);
            header.Click      -= new EventHandler(header_Click);
            header.Click      += new EventHandler(header_Click);
            header.BorderStyle = BorderStyle.None;
            _ActiveHeader      = header;
            HighLightForm(header);
            FreshHeader();
        }
 /// <summary>
 /// 移除一个窗体,如果在列表中存在的话
 /// </summary>
 /// <param name="frm"></param>
 public void RemoveForm(Form frm)
 {
     foreach (FormHeader header in _Headers)
     {
         if (object.ReferenceEquals(header.RenderForm, frm))
         {
             if (object.ReferenceEquals(header, _ActiveHeader)) //如果关闭的是当前的活动窗体
             {
                 int index = _Headers.IndexOf(header);
                 //如果当前活动窗体处理列表末尾,则前一个窗体变成活动窗体,其它情况下右边一个窗体为活动窗体
                 if (index == _Headers.Count - 1)
                 {
                     index -= 1;
                 }
                 else
                 {
                     index += 1;
                 }
                 if (index >= 0)
                 {
                     if (_Headers.Count > 0)
                     {
                         HighLightForm(_Headers[index]);
                     }
                 }
                 else
                 {
                     _ActiveHeader = null;
                 }
             }
             frm.FormClosed -= new FormClosedEventHandler(frm_FormClosed);
             _Headers.Remove(header);
             header.Click -= new EventHandler(header_Click);
             this.pHeader.Controls.Remove(header);
             FreshHeader();
             break;
         }
     }
 }
 /// <summary>
 /// 高亮显示窗体
 /// </summary>
 /// <param name="header"></param>
 private void HighLightForm(FormHeader header)
 {
     foreach (FormHeader h in _Headers)
     {
         if (object.ReferenceEquals(h, header))
         {
             h.Active();
             header.RenderForm.Activate();
             header.RenderForm.Show();
             if (!object.ReferenceEquals(h, _ActiveHeader))
             {
                 _ActiveHeader = h;
                 if (this.FormActivated != null)
                 {
                     this.FormActivated(header.RenderForm, EventArgs.Empty);
                 }
             }
         }
         else
         {
             h.Deactive();
         }
     }
 }
        private void header_Click(object sender, EventArgs e)
        {
            FormHeader header = sender as FormHeader;

            HighLightForm(header);
        }