1 | using System;
|
---|
2 | using System.Drawing;
|
---|
3 | using System.Windows.Forms;
|
---|
4 |
|
---|
5 | namespace WeifenLuo.WinFormsUI.Docking
|
---|
6 | {
|
---|
7 | internal abstract class DockOutlineBase
|
---|
8 | {
|
---|
9 | public DockOutlineBase()
|
---|
10 | {
|
---|
11 | Init();
|
---|
12 | }
|
---|
13 |
|
---|
14 | private void Init()
|
---|
15 | {
|
---|
16 | SetValues(Rectangle.Empty, null, DockStyle.None, -1);
|
---|
17 | SaveOldValues();
|
---|
18 | }
|
---|
19 |
|
---|
20 | private Rectangle m_oldFloatWindowBounds;
|
---|
21 | protected Rectangle OldFloatWindowBounds
|
---|
22 | {
|
---|
23 | get { return m_oldFloatWindowBounds; }
|
---|
24 | }
|
---|
25 |
|
---|
26 | private Control m_oldDockTo;
|
---|
27 | protected Control OldDockTo
|
---|
28 | {
|
---|
29 | get { return m_oldDockTo; }
|
---|
30 | }
|
---|
31 |
|
---|
32 | private DockStyle m_oldDock;
|
---|
33 | protected DockStyle OldDock
|
---|
34 | {
|
---|
35 | get { return m_oldDock; }
|
---|
36 | }
|
---|
37 |
|
---|
38 | private int m_oldContentIndex;
|
---|
39 | protected int OldContentIndex
|
---|
40 | {
|
---|
41 | get { return m_oldContentIndex; }
|
---|
42 | }
|
---|
43 |
|
---|
44 | protected bool SameAsOldValue
|
---|
45 | {
|
---|
46 | get
|
---|
47 | {
|
---|
48 | return FloatWindowBounds == OldFloatWindowBounds &&
|
---|
49 | DockTo == OldDockTo &&
|
---|
50 | Dock == OldDock &&
|
---|
51 | ContentIndex == OldContentIndex;
|
---|
52 | }
|
---|
53 | }
|
---|
54 |
|
---|
55 | private Rectangle m_floatWindowBounds;
|
---|
56 | public Rectangle FloatWindowBounds
|
---|
57 | {
|
---|
58 | get { return m_floatWindowBounds; }
|
---|
59 | }
|
---|
60 |
|
---|
61 | private Control m_dockTo;
|
---|
62 | public Control DockTo
|
---|
63 | {
|
---|
64 | get { return m_dockTo; }
|
---|
65 | }
|
---|
66 |
|
---|
67 | private DockStyle m_dock;
|
---|
68 | public DockStyle Dock
|
---|
69 | {
|
---|
70 | get { return m_dock; }
|
---|
71 | }
|
---|
72 |
|
---|
73 | private int m_contentIndex;
|
---|
74 | public int ContentIndex
|
---|
75 | {
|
---|
76 | get { return m_contentIndex; }
|
---|
77 | }
|
---|
78 |
|
---|
79 | public bool FlagFullEdge
|
---|
80 | {
|
---|
81 | get { return m_contentIndex != 0; }
|
---|
82 | }
|
---|
83 |
|
---|
84 | private bool m_flagTestDrop = false;
|
---|
85 | public bool FlagTestDrop
|
---|
86 | {
|
---|
87 | get { return m_flagTestDrop; }
|
---|
88 | set { m_flagTestDrop = value; }
|
---|
89 | }
|
---|
90 |
|
---|
91 | private void SaveOldValues()
|
---|
92 | {
|
---|
93 | m_oldDockTo = m_dockTo;
|
---|
94 | m_oldDock = m_dock;
|
---|
95 | m_oldContentIndex = m_contentIndex;
|
---|
96 | m_oldFloatWindowBounds = m_floatWindowBounds;
|
---|
97 | }
|
---|
98 |
|
---|
99 | protected abstract void OnShow();
|
---|
100 |
|
---|
101 | protected abstract void OnClose();
|
---|
102 |
|
---|
103 | private void SetValues(Rectangle floatWindowBounds, Control dockTo, DockStyle dock, int contentIndex)
|
---|
104 | {
|
---|
105 | m_floatWindowBounds = floatWindowBounds;
|
---|
106 | m_dockTo = dockTo;
|
---|
107 | m_dock = dock;
|
---|
108 | m_contentIndex = contentIndex;
|
---|
109 | FlagTestDrop = true;
|
---|
110 | }
|
---|
111 |
|
---|
112 | private void TestChange()
|
---|
113 | {
|
---|
114 | if (m_floatWindowBounds != m_oldFloatWindowBounds ||
|
---|
115 | m_dockTo != m_oldDockTo ||
|
---|
116 | m_dock != m_oldDock ||
|
---|
117 | m_contentIndex != m_oldContentIndex)
|
---|
118 | OnShow();
|
---|
119 | }
|
---|
120 |
|
---|
121 | public void Show()
|
---|
122 | {
|
---|
123 | SaveOldValues();
|
---|
124 | SetValues(Rectangle.Empty, null, DockStyle.None, -1);
|
---|
125 | TestChange();
|
---|
126 | }
|
---|
127 |
|
---|
128 | public void Show(DockPane pane, DockStyle dock)
|
---|
129 | {
|
---|
130 | SaveOldValues();
|
---|
131 | SetValues(Rectangle.Empty, pane, dock, -1);
|
---|
132 | TestChange();
|
---|
133 | }
|
---|
134 |
|
---|
135 | public void Show(DockPane pane, int contentIndex)
|
---|
136 | {
|
---|
137 | SaveOldValues();
|
---|
138 | SetValues(Rectangle.Empty, pane, DockStyle.Fill, contentIndex);
|
---|
139 | TestChange();
|
---|
140 | }
|
---|
141 |
|
---|
142 | public void Show(DockPanel dockPanel, DockStyle dock, bool fullPanelEdge)
|
---|
143 | {
|
---|
144 | SaveOldValues();
|
---|
145 | SetValues(Rectangle.Empty, dockPanel, dock, fullPanelEdge ? -1 : 0);
|
---|
146 | TestChange();
|
---|
147 | }
|
---|
148 |
|
---|
149 | public void Show(Rectangle floatWindowBounds)
|
---|
150 | {
|
---|
151 | SaveOldValues();
|
---|
152 | SetValues(floatWindowBounds, null, DockStyle.None, -1);
|
---|
153 | TestChange();
|
---|
154 | }
|
---|
155 |
|
---|
156 | public void Close()
|
---|
157 | {
|
---|
158 | OnClose();
|
---|
159 | }
|
---|
160 | }
|
---|
161 | }
|
---|