/[RomCheater]/trunk/deps/WeifenLuo.WinFormsUI.Docking/WinFormsUI/Docking/DockContent.cs
ViewVC logotype

Contents of /trunk/deps/WeifenLuo.WinFormsUI.Docking/WinFormsUI/Docking/DockContent.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 854 - (show annotations) (download)
Tue Sep 16 21:08:49 2014 UTC (6 years, 9 months ago) by william
File size: 8407 byte(s)
+ modify WinFormsUI - Docking support to allow setting the dockhandler

1 using System;
2 using System.ComponentModel;
3 using System.Drawing;
4 using System.Windows.Forms;
5 using System.Runtime.InteropServices;
6 using System.Diagnostics.CodeAnalysis;
7
8 namespace WeifenLuo.WinFormsUI.Docking
9 {
10 public class DockContent : Form, IDockContent
11 {
12 public DockContent()
13 {
14 m_dockHandler = new DockContentHandler(this, new GetPersistStringCallback(GetPersistString));
15 m_dockHandler.DockStateChanged += new EventHandler(DockHandler_DockStateChanged);
16 //Suggested as a fix by bensty regarding form resize
17 this.ParentChanged += new EventHandler(DockContent_ParentChanged);
18 }
19
20 //Suggested as a fix by bensty regarding form resize
21 private void DockContent_ParentChanged(object Sender, EventArgs e)
22 {
23 if (this.Parent != null)
24 this.Font = this.Parent.Font;
25 }
26
27 private DockContentHandler m_dockHandler = null;
28 [Browsable(false)]
29 public DockContentHandler DockHandler
30 {
31 get { return m_dockHandler; }
32 set { m_dockHandler = value; }
33 }
34
35 [LocalizedCategory("Category_Docking")]
36 [LocalizedDescription("DockContent_AllowEndUserDocking_Description")]
37 [DefaultValue(true)]
38 public bool AllowEndUserDocking
39 {
40 get { return DockHandler.AllowEndUserDocking; }
41 set { DockHandler.AllowEndUserDocking = value; }
42 }
43
44 [LocalizedCategory("Category_Docking")]
45 [LocalizedDescription("DockContent_DockAreas_Description")]
46 [DefaultValue(DockAreas.DockLeft|DockAreas.DockRight|DockAreas.DockTop|DockAreas.DockBottom|DockAreas.Document|DockAreas.Float)]
47 public DockAreas DockAreas
48 {
49 get { return DockHandler.DockAreas; }
50 set { DockHandler.DockAreas = value; }
51 }
52
53 [LocalizedCategory("Category_Docking")]
54 [LocalizedDescription("DockContent_AutoHidePortion_Description")]
55 [DefaultValue(0.25)]
56 public double AutoHidePortion
57 {
58 get { return DockHandler.AutoHidePortion; }
59 set { DockHandler.AutoHidePortion = value; }
60 }
61
62 [Localizable(true)]
63 [LocalizedCategory("Category_Docking")]
64 [LocalizedDescription("DockContent_TabText_Description")]
65 [DefaultValue(null)]
66 private string m_tabText = null;
67 public string TabText
68 {
69 get { return m_tabText; }
70 set { DockHandler.TabText = m_tabText = value; }
71 }
72 private bool ShouldSerializeTabText()
73 {
74 return (m_tabText != null);
75 }
76
77 [LocalizedCategory("Category_Docking")]
78 [LocalizedDescription("DockContent_CloseButton_Description")]
79 [DefaultValue(true)]
80 public bool CloseButton
81 {
82 get { return DockHandler.CloseButton; }
83 set { DockHandler.CloseButton = value; }
84 }
85
86 [LocalizedCategory("Category_Docking")]
87 [LocalizedDescription("DockContent_CloseButtonVisible_Description")]
88 [DefaultValue(true)]
89 public bool CloseButtonVisible
90 {
91 get { return DockHandler.CloseButtonVisible; }
92 set { DockHandler.CloseButtonVisible = value; }
93 }
94
95 [Browsable(false)]
96 public DockPanel DockPanel
97 {
98 get { return DockHandler.DockPanel; }
99 set { DockHandler.DockPanel = value; }
100 }
101
102 [Browsable(false)]
103 public DockState DockState
104 {
105 get { return DockHandler.DockState; }
106 set { DockHandler.DockState = value; }
107 }
108
109 [Browsable(false)]
110 public DockPane Pane
111 {
112 get { return DockHandler.Pane; }
113 set { DockHandler.Pane = value; }
114 }
115
116 [Browsable(false)]
117 public bool IsHidden
118 {
119 get { return DockHandler.IsHidden; }
120 set { DockHandler.IsHidden = value; }
121 }
122
123 [Browsable(false)]
124 public DockState VisibleState
125 {
126 get { return DockHandler.VisibleState; }
127 set { DockHandler.VisibleState = value; }
128 }
129
130 [Browsable(false)]
131 public bool IsFloat
132 {
133 get { return DockHandler.IsFloat; }
134 set { DockHandler.IsFloat = value; }
135 }
136
137 [Browsable(false)]
138 public DockPane PanelPane
139 {
140 get { return DockHandler.PanelPane; }
141 set { DockHandler.PanelPane = value; }
142 }
143
144 [Browsable(false)]
145 public DockPane FloatPane
146 {
147 get { return DockHandler.FloatPane; }
148 set { DockHandler.FloatPane = value; }
149 }
150
151 [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")]
152 protected virtual string GetPersistString()
153 {
154 return GetType().ToString();
155 }
156
157 [LocalizedCategory("Category_Docking")]
158 [LocalizedDescription("DockContent_HideOnClose_Description")]
159 [DefaultValue(false)]
160 public bool HideOnClose
161 {
162 get { return DockHandler.HideOnClose; }
163 set { DockHandler.HideOnClose = value; }
164 }
165
166 [LocalizedCategory("Category_Docking")]
167 [LocalizedDescription("DockContent_ShowHint_Description")]
168 [DefaultValue(DockState.Unknown)]
169 public DockState ShowHint
170 {
171 get { return DockHandler.ShowHint; }
172 set { DockHandler.ShowHint = value; }
173 }
174
175 [Browsable(false)]
176 public bool IsActivated
177 {
178 get { return DockHandler.IsActivated; }
179 }
180
181 public bool IsDockStateValid(DockState dockState)
182 {
183 return DockHandler.IsDockStateValid(dockState);
184 }
185
186 [LocalizedCategory("Category_Docking")]
187 [LocalizedDescription("DockContent_TabPageContextMenu_Description")]
188 [DefaultValue(null)]
189 public ContextMenu TabPageContextMenu
190 {
191 get { return DockHandler.TabPageContextMenu; }
192 set { DockHandler.TabPageContextMenu = value; }
193 }
194
195 [LocalizedCategory("Category_Docking")]
196 [LocalizedDescription("DockContent_TabPageContextMenuStrip_Description")]
197 [DefaultValue(null)]
198 public ContextMenuStrip TabPageContextMenuStrip
199 {
200 get { return DockHandler.TabPageContextMenuStrip; }
201 set { DockHandler.TabPageContextMenuStrip = value; }
202 }
203
204 [Localizable(true)]
205 [Category("Appearance")]
206 [LocalizedDescription("DockContent_ToolTipText_Description")]
207 [DefaultValue(null)]
208 public string ToolTipText
209 {
210 get { return DockHandler.ToolTipText; }
211 set { DockHandler.ToolTipText = value; }
212 }
213
214 public new void Activate()
215 {
216 DockHandler.Activate();
217 }
218
219 public new void Hide()
220 {
221 DockHandler.Hide();
222 }
223
224 public new void Show()
225 {
226 DockHandler.Show();
227 }
228
229 public void Show(DockPanel dockPanel)
230 {
231 DockHandler.Show(dockPanel);
232 }
233
234 public void Show(DockPanel dockPanel, DockState dockState)
235 {
236 DockHandler.Show(dockPanel, dockState);
237 }
238
239 [SuppressMessage("Microsoft.Naming", "CA1720:AvoidTypeNamesInParameters")]
240 public void Show(DockPanel dockPanel, Rectangle floatWindowBounds)
241 {
242 DockHandler.Show(dockPanel, floatWindowBounds);
243 }
244
245 public void Show(DockPane pane, IDockContent beforeContent)
246 {
247 DockHandler.Show(pane, beforeContent);
248 }
249
250 public void Show(DockPane previousPane, DockAlignment alignment, double proportion)
251 {
252 DockHandler.Show(previousPane, alignment, proportion);
253 }
254
255 [SuppressMessage("Microsoft.Naming", "CA1720:AvoidTypeNamesInParameters")]
256 public void FloatAt(Rectangle floatWindowBounds)
257 {
258 DockHandler.FloatAt(floatWindowBounds);
259 }
260
261 public void DockTo(DockPane paneTo, DockStyle dockStyle, int contentIndex)
262 {
263 DockHandler.DockTo(paneTo, dockStyle, contentIndex);
264 }
265
266 public void DockTo(DockPanel panel, DockStyle dockStyle)
267 {
268 DockHandler.DockTo(panel, dockStyle);
269 }
270
271 #region IDockContent Members
272 void IDockContent.OnActivated<T>(T e)
273 {
274 this.OnActivated(e);
275 }
276 void IDockContent.OnDeactivate<T>(T e)
277 {
278 this.OnDeactivate(e);
279 }
280 #endregion
281
282 #region Events
283 private void DockHandler_DockStateChanged(object sender, EventArgs e)
284 {
285 OnDockStateChanged(e);
286 }
287
288 private static readonly object DockStateChangedEvent = new object();
289 [LocalizedCategory("Category_PropertyChanged")]
290 [LocalizedDescription("Pane_DockStateChanged_Description")]
291 public event EventHandler DockStateChanged
292 {
293 add { Events.AddHandler(DockStateChangedEvent, value); }
294 remove { Events.RemoveHandler(DockStateChangedEvent, value); }
295 }
296 protected virtual void OnDockStateChanged(EventArgs e)
297 {
298 EventHandler handler = (EventHandler)Events[DockStateChangedEvent];
299 if (handler != null)
300 handler(this, e);
301 }
302 #endregion
303 }
304 }

  ViewVC Help
Powered by ViewVC 1.1.22