1 | using System;
|
---|
2 | using System.Diagnostics.CodeAnalysis;
|
---|
3 | using System.Drawing;
|
---|
4 |
|
---|
5 | namespace WeifenLuo.WinFormsUI.Docking {
|
---|
6 | public sealed class DockPanelExtender {
|
---|
7 | [SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible")]
|
---|
8 | public interface IDockPaneFactory {
|
---|
9 | DockPane CreateDockPane(IDockContent content, DockState visibleState, bool show);
|
---|
10 | [SuppressMessage("Microsoft.Naming", "CA1720:AvoidTypeNamesInParameters", MessageId = "1#")]
|
---|
11 | DockPane CreateDockPane(IDockContent content, FloatWindow floatWindow, bool show);
|
---|
12 | DockPane CreateDockPane(IDockContent content, DockPane previousPane, DockAlignment alignment, double proportion, bool show);
|
---|
13 | [SuppressMessage("Microsoft.Naming", "CA1720:AvoidTypeNamesInParameters", MessageId = "1#")]
|
---|
14 | DockPane CreateDockPane(IDockContent content, Rectangle floatWindowBounds, bool show);
|
---|
15 | }
|
---|
16 |
|
---|
17 | [SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible")]
|
---|
18 | public interface IFloatWindowFactory {
|
---|
19 | FloatWindow CreateFloatWindow(DockPanel dockPanel, DockPane pane);
|
---|
20 | FloatWindow CreateFloatWindow(DockPanel dockPanel, DockPane pane, Rectangle bounds);
|
---|
21 | }
|
---|
22 |
|
---|
23 | [SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible")]
|
---|
24 | public interface IDockPaneCaptionFactory {
|
---|
25 | DockPaneCaptionBase CreateDockPaneCaption(DockPane pane);
|
---|
26 | }
|
---|
27 |
|
---|
28 | [SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible")]
|
---|
29 | public interface IDockPaneStripFactory {
|
---|
30 | DockPaneStripBase CreateDockPaneStrip(DockPane pane);
|
---|
31 | }
|
---|
32 |
|
---|
33 | [SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible")]
|
---|
34 | public interface IAutoHideStripFactory {
|
---|
35 | AutoHideStripBase CreateAutoHideStrip(DockPanel panel);
|
---|
36 | }
|
---|
37 |
|
---|
38 | #region DefaultDockPaneFactory
|
---|
39 | private class DefaultDockPaneFactory : IDockPaneFactory {
|
---|
40 | public DockPane CreateDockPane(IDockContent content, DockState visibleState, bool show) {
|
---|
41 | return new DockPane(content, visibleState, show);
|
---|
42 | }
|
---|
43 |
|
---|
44 | public DockPane CreateDockPane(IDockContent content, FloatWindow floatWindow, bool show) {
|
---|
45 | return new DockPane(content, floatWindow, show);
|
---|
46 | }
|
---|
47 |
|
---|
48 | public DockPane CreateDockPane(IDockContent content, DockPane prevPane, DockAlignment alignment, double proportion, bool show) {
|
---|
49 | return new DockPane(content, prevPane, alignment, proportion, show);
|
---|
50 | }
|
---|
51 |
|
---|
52 | public DockPane CreateDockPane(IDockContent content, Rectangle floatWindowBounds, bool show) {
|
---|
53 | return new DockPane(content, floatWindowBounds, show);
|
---|
54 | }
|
---|
55 | }
|
---|
56 | #endregion
|
---|
57 |
|
---|
58 | #region DefaultFloatWindowFactory
|
---|
59 | private class DefaultFloatWindowFactory : IFloatWindowFactory {
|
---|
60 | public FloatWindow CreateFloatWindow(DockPanel dockPanel, DockPane pane) {
|
---|
61 | return new FloatWindow(dockPanel, pane);
|
---|
62 | }
|
---|
63 |
|
---|
64 | public FloatWindow CreateFloatWindow(DockPanel dockPanel, DockPane pane, Rectangle bounds) {
|
---|
65 | return new FloatWindow(dockPanel, pane, bounds);
|
---|
66 | }
|
---|
67 | }
|
---|
68 | #endregion
|
---|
69 |
|
---|
70 | #region DefaultDockPaneCaptionFactory
|
---|
71 | private class DefaultDockPaneCaptionFactory : IDockPaneCaptionFactory {
|
---|
72 | public DockPaneCaptionBase CreateDockPaneCaption(DockPane pane) {
|
---|
73 | return new VS2005DockPaneCaption(pane);
|
---|
74 | }
|
---|
75 | }
|
---|
76 | #endregion
|
---|
77 |
|
---|
78 | #region DefaultDockPaneTabStripFactory
|
---|
79 | private class DefaultDockPaneStripFactory : IDockPaneStripFactory {
|
---|
80 | public DockPaneStripBase CreateDockPaneStrip(DockPane pane) {
|
---|
81 | return new VS2005DockPaneStrip(pane);
|
---|
82 | }
|
---|
83 | }
|
---|
84 | #endregion
|
---|
85 |
|
---|
86 | #region DefaultAutoHideStripFactory
|
---|
87 | private class DefaultAutoHideStripFactory : IAutoHideStripFactory {
|
---|
88 | public AutoHideStripBase CreateAutoHideStrip(DockPanel panel) {
|
---|
89 | return new VS2005AutoHideStrip(panel);
|
---|
90 | }
|
---|
91 | }
|
---|
92 | #endregion
|
---|
93 |
|
---|
94 | internal DockPanelExtender(DockPanel dockPanel) {
|
---|
95 | m_dockPanel = dockPanel;
|
---|
96 | }
|
---|
97 |
|
---|
98 | private DockPanel m_dockPanel;
|
---|
99 | private DockPanel DockPanel {
|
---|
100 | get { return m_dockPanel; }
|
---|
101 | }
|
---|
102 |
|
---|
103 | private IDockPaneFactory m_dockPaneFactory = null;
|
---|
104 | public IDockPaneFactory DockPaneFactory {
|
---|
105 | get {
|
---|
106 | if (m_dockPaneFactory == null)
|
---|
107 | m_dockPaneFactory = new DefaultDockPaneFactory();
|
---|
108 |
|
---|
109 | return m_dockPaneFactory;
|
---|
110 | }
|
---|
111 | set {
|
---|
112 | if (DockPanel.Panes.Count > 0)
|
---|
113 | throw new InvalidOperationException();
|
---|
114 |
|
---|
115 | m_dockPaneFactory = value;
|
---|
116 | }
|
---|
117 | }
|
---|
118 |
|
---|
119 | private IFloatWindowFactory m_floatWindowFactory = null;
|
---|
120 | public IFloatWindowFactory FloatWindowFactory {
|
---|
121 | get {
|
---|
122 | if (m_floatWindowFactory == null)
|
---|
123 | m_floatWindowFactory = new DefaultFloatWindowFactory();
|
---|
124 |
|
---|
125 | return m_floatWindowFactory;
|
---|
126 | }
|
---|
127 | set {
|
---|
128 | if (DockPanel.FloatWindows.Count > 0)
|
---|
129 | throw new InvalidOperationException();
|
---|
130 |
|
---|
131 | m_floatWindowFactory = value;
|
---|
132 | }
|
---|
133 | }
|
---|
134 |
|
---|
135 | private IDockPaneCaptionFactory m_dockPaneCaptionFactory = null;
|
---|
136 | public IDockPaneCaptionFactory DockPaneCaptionFactory {
|
---|
137 | get {
|
---|
138 | if (m_dockPaneCaptionFactory == null)
|
---|
139 | m_dockPaneCaptionFactory = new DefaultDockPaneCaptionFactory();
|
---|
140 |
|
---|
141 | return m_dockPaneCaptionFactory;
|
---|
142 | }
|
---|
143 | set {
|
---|
144 | if (DockPanel.Panes.Count > 0)
|
---|
145 | throw new InvalidOperationException();
|
---|
146 |
|
---|
147 | m_dockPaneCaptionFactory = value;
|
---|
148 | }
|
---|
149 | }
|
---|
150 |
|
---|
151 | private IDockPaneStripFactory m_dockPaneStripFactory = null;
|
---|
152 | public IDockPaneStripFactory DockPaneStripFactory {
|
---|
153 | get {
|
---|
154 | if (m_dockPaneStripFactory == null)
|
---|
155 | m_dockPaneStripFactory = new DefaultDockPaneStripFactory();
|
---|
156 |
|
---|
157 | return m_dockPaneStripFactory;
|
---|
158 | }
|
---|
159 | set {
|
---|
160 | if (DockPanel.Contents.Count > 0)
|
---|
161 | throw new InvalidOperationException();
|
---|
162 |
|
---|
163 | m_dockPaneStripFactory = value;
|
---|
164 | }
|
---|
165 | }
|
---|
166 |
|
---|
167 | private IAutoHideStripFactory m_autoHideStripFactory = null;
|
---|
168 | public IAutoHideStripFactory AutoHideStripFactory {
|
---|
169 | get {
|
---|
170 | if (m_autoHideStripFactory == null)
|
---|
171 | m_autoHideStripFactory = new DefaultAutoHideStripFactory();
|
---|
172 |
|
---|
173 | return m_autoHideStripFactory;
|
---|
174 | }
|
---|
175 | set {
|
---|
176 | if (DockPanel.Contents.Count > 0)
|
---|
177 | throw new InvalidOperationException();
|
---|
178 |
|
---|
179 | if (m_autoHideStripFactory == value)
|
---|
180 | return;
|
---|
181 |
|
---|
182 | m_autoHideStripFactory = value;
|
---|
183 | DockPanel.ResetAutoHideStripControl();
|
---|
184 | }
|
---|
185 | }
|
---|
186 | }
|
---|
187 | }
|
---|