Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.ExtLibs/HeuristicLab.WinFormsUI/2.7.0/WinFormsUI-2.7.0/Docking/DockPanelExtender.cs @ 15377

Last change on this file since 15377 was 8616, checked in by mkommend, 12 years ago

#1939: Added DockPanelSuite 2.7.0 to ExtLibs.

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