DockPaneCaptionBase.cs 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /*******************************************************************************
  2. * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:DockPaneCaptionBase.cs
  5. * 2.功能描述:类文件
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 陈晓野 2014/09/01 1.00 新建
  9. *******************************************************************************/
  10. using System.Drawing;
  11. using System.Security.Permissions;
  12. using System.Windows.Forms;
  13. namespace Dongke.IBOSS.PRD.Basics.DockPanel
  14. {
  15. /// <summary>
  16. /// 类文件
  17. /// </summary>
  18. public abstract class DockPaneCaptionBase : Control
  19. {
  20. protected internal DockPaneCaptionBase(DockPane pane)
  21. {
  22. m_dockPane = pane;
  23. SetStyle(ControlStyles.OptimizedDoubleBuffer |
  24. ControlStyles.ResizeRedraw |
  25. ControlStyles.UserPaint |
  26. ControlStyles.AllPaintingInWmPaint, true);
  27. SetStyle(ControlStyles.Selectable, false);
  28. }
  29. private DockPane m_dockPane;
  30. protected DockPane DockPane
  31. {
  32. get
  33. {
  34. return m_dockPane;
  35. }
  36. }
  37. protected DockPane.AppearanceStyle Appearance
  38. {
  39. get
  40. {
  41. return DockPane.Appearance;
  42. }
  43. }
  44. protected bool HasTabPageContextMenu
  45. {
  46. get
  47. {
  48. return DockPane.HasTabPageContextMenu;
  49. }
  50. }
  51. protected void ShowTabPageContextMenu(Point position)
  52. {
  53. DockPane.ShowTabPageContextMenu(this, position);
  54. }
  55. protected override void OnMouseUp(MouseEventArgs e)
  56. {
  57. base.OnMouseUp(e);
  58. if (e.Button == MouseButtons.Right)
  59. ShowTabPageContextMenu(new Point(e.X, e.Y));
  60. }
  61. protected override void OnMouseDown(MouseEventArgs e)
  62. {
  63. base.OnMouseDown(e);
  64. if (e.Button == MouseButtons.Left &&
  65. DockPane.DockPanel.AllowEndUserDocking &&
  66. DockPane.AllowDockDragAndDrop &&
  67. !DockHelper.IsDockStateAutoHide(DockPane.DockState) &&
  68. DockPane.ActiveContent != null)
  69. DockPane.DockPanel.BeginDrag(DockPane);
  70. }
  71. [SecurityPermission(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.UnmanagedCode)]
  72. protected override void WndProc(ref Message m)
  73. {
  74. if (m.Msg == (int)Win32.Msgs.WM_LBUTTONDBLCLK)
  75. {
  76. if (DockHelper.IsDockStateAutoHide(DockPane.DockState))
  77. {
  78. DockPane.DockPanel.ActiveAutoHideContent = null;
  79. return;
  80. }
  81. if (DockPane.IsFloat)
  82. DockPane.RestoreToPanel();
  83. else
  84. DockPane.Float();
  85. }
  86. base.WndProc(ref m);
  87. }
  88. internal void RefreshChanges()
  89. {
  90. if (IsDisposed)
  91. return;
  92. OnRefreshChanges();
  93. }
  94. protected virtual void OnRightToLeftLayoutChanged()
  95. {
  96. }
  97. protected virtual void OnRefreshChanges()
  98. {
  99. }
  100. protected internal abstract int MeasureHeight();
  101. }
  102. }