dockpanelsuite的一些修改

一个可以做出类似VS的免费控件,下载网址:http://sourceforge.net/projects/dockpanelsuite/

目前版本为2.3.1

方便应用,做了一些修改:

1.修改双击关闭(在DockPaneStripBase的WndProc方法里)

else if (m.Msg == (int)Win32.Msgs.WM_LBUTTONDBLCLK)

{

    base.WndProc(ref m);

   int index = GetHitTest();



if (DockPane.DockPanel.AllowRedocking && index != -1)

{

   IDockContent content = Tabs[index].Content;

   try {  
       //注释为原句 

      //  content.DockHandler.IsFloat = !content.DockHandler.IsFloat;   
     //替换为           
         content.DockHandler.Close();

       }   

  catch  {   }

}

return;

}
 
2.解决背景图片的问题(DockPanel的OnPaint方法里) 
2.2版本修改方法
protected override void OnPaint(PaintEventArgs e)

{



   base.OnPaint(e);

   //注释以下这两句

  //Graphics g = e.Graphics;

  //  g.FillRectangle(SystemBrushes.AppWorkspace, ClientRectangle);

}
2.3版本修改方法

protected override void OnPaint(PaintEventArgs e)
  {
    base.OnPaint(e);
      if (BackgroundImage != null)
          return;
      if (DockBackColor == BackColor) return;

      Graphics g = e.Graphics;
      SolidBrush bgBrush = new SolidBrush(DockBackColor);
      g.FillRectangle(bgBrush, ClientRectangle);
  }

3.解决背景色无法改变问题(VS2005DockPaneStrip的OnPaint方法里),在2.3中不需要修改,此处为2.2的修改方法
protected override void OnPaint(PaintEventArgs e)

{

    if (Appearance == DockPane.AppearanceStyle.Document)

    {

    //注释以下这两句

    //if (BackColor != SystemColors.Control)

    //    BackColor = SystemColors.Control;

    }

    else

    {

    if (BackColor != SystemColors.ControlLight)

        BackColor = SystemColors.ControlLight;

    }

    base.OnPaint (e);

    CalculateTabs();

    if (Appearance == DockPane.AppearanceStyle.Document 
         && DockPane.ActiveContent != null)

    {

        if (EnsureDocumentTabVisible(DockPane.ActiveContent, false))

            CalculateTabs();

    }



    DrawTabStrip(e.Graphics);

}

4.改变标签颜色(VS2005DockPaneStrip)2.3版本没有这个了,已经可以自定义标签颜色,包括渐变标签颜色,此处为2.2版本修改方法

private static Brush BrushDocumentActiveBackground { get { return new LinearGradientBrush(new Rectangle(0, 0, 1, 1),

Color.FromArgb(232, 242, 254),

Color.FromArgb(232, 242, 254), 1);/*SystemBrushes.ControlLightLight;*/ } } private static Brush BrushDocumentInactiveBackground { get { return new LinearGradientBrush(new Rectangle(0, 0, 1, 1),

Color.FromArgb(173, 193, 220),

Color.FromArgb(173, 193, 220), 1); } //SystemBrushes.ControlLight; } }

你可能感兴趣的:(Panel)