Free cookie consent management tool by TermsFeed Policy Generator

source: branches/Persistence Test/WinFormsUI/Docking/DockContent.cs @ 3962

Last change on this file since 3962 was 2134, checked in by gkronber, 15 years ago

Added up to date source of Weifen Luo dock panel suit in a separate project (and added strong name key). Removed binary versions of Weifen Luo dock panel suite and references to it. #687 (Update AdvancedOptimizationFrontend to use more recent version of Weifen Luo Docking library)

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