Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.ExtLibs/HeuristicLab.WinFormsUI/2.3.1/WinFormsUI-2.3.1/Docking/DockContent.cs @ 4068

Last change on this file since 4068 was 4068, checked in by swagner, 14 years ago

Sorted usings and removed unused usings in entire solution (#1094)

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