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