DockPaneCaptionBase.cs
上传用户:szlfmled
上传日期:2020-11-22
资源大小:978k
文件大小:3k
源码类别:

C#编程

开发平台:

C#

  1. using System;
  2. using System.Windows.Forms;
  3. using System.Drawing;
  4. using System.Runtime.InteropServices;
  5. using System.Security.Permissions;
  6. namespace WeifenLuo.WinFormsUI.Docking
  7. {
  8. public abstract class DockPaneCaptionBase : Control
  9. {
  10. protected internal DockPaneCaptionBase(DockPane pane)
  11. {
  12. m_dockPane = pane;
  13. SetStyle(ControlStyles.OptimizedDoubleBuffer |
  14.                 ControlStyles.ResizeRedraw |
  15.                 ControlStyles.UserPaint |
  16.                 ControlStyles.AllPaintingInWmPaint, true);
  17. SetStyle(ControlStyles.Selectable, false);
  18. }
  19. private DockPane m_dockPane;
  20. protected DockPane DockPane
  21. {
  22. get { return m_dockPane; }
  23. }
  24. protected DockPane.AppearanceStyle Appearance
  25. {
  26. get { return DockPane.Appearance; }
  27. }
  28.         protected bool HasTabPageContextMenu
  29.         {
  30.             get { return DockPane.HasTabPageContextMenu; }
  31.         }
  32.         protected void ShowTabPageContextMenu(Point position)
  33.         {
  34.             DockPane.ShowTabPageContextMenu(this, position);
  35.         }
  36.         protected override void OnMouseUp(MouseEventArgs e)
  37.         {
  38.             base.OnMouseUp(e);
  39.             if (e.Button == MouseButtons.Right)
  40.                 ShowTabPageContextMenu(new Point(e.X, e.Y));
  41.         }
  42.         protected override void OnMouseDown(MouseEventArgs e)
  43.         {
  44.             base.OnMouseDown(e);
  45.             if (e.Button == MouseButtons.Left &&
  46.     DockPane.DockPanel.AllowEndUserDocking &&
  47.                 DockPane.AllowDockDragAndDrop &&
  48. !DockHelper.IsDockStateAutoHide(DockPane.DockState) &&
  49.                 DockPane.ActiveContent != null)
  50. DockPane.DockPanel.BeginDrag(DockPane);
  51.         }
  52.         [SecurityPermission(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.UnmanagedCode)]         
  53.         protected override void WndProc(ref Message m)
  54.         {
  55.             if (m.Msg == (int)Win32.Msgs.WM_LBUTTONDBLCLK)
  56.             {
  57.                 if (DockHelper.IsDockStateAutoHide(DockPane.DockState))
  58.                 {
  59.                     DockPane.DockPanel.ActiveAutoHideContent = null;
  60.                     return;
  61.                 }
  62.                 if (DockPane.IsFloat)
  63.                     DockPane.RestoreToPanel();
  64.                 else
  65.                     DockPane.Float();
  66.             }
  67.             base.WndProc(ref m);
  68.         }
  69. internal void RefreshChanges()
  70. {
  71.             if (IsDisposed)
  72.                 return;
  73. OnRefreshChanges();
  74. }
  75.         protected virtual void OnRightToLeftLayoutChanged()
  76.         {
  77.         }
  78. protected virtual void OnRefreshChanges()
  79. {
  80. }
  81. protected internal abstract int MeasureHeight();
  82. }
  83. }