2 // ToolStripContainer.cs
4 // Permission is hereby granted, free of charge, to any person obtaining
5 // a copy of this software and associated documentation files (the
6 // "Software"), to deal in the Software without restriction, including
7 // without limitation the rights to use, copy, modify, merge, publish,
8 // distribute, sublicense, and/or sell copies of the Software, and to
9 // permit persons to whom the Software is furnished to do so, subject to
10 // the following conditions:
12 // The above copyright notice and this permission notice shall be
13 // included in all copies or substantial portions of the Software.
15 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 // Copyright (c) 2006 Jonathan Pobst
26 // Jonathan Pobst (monkey@jpobst.com)
32 using System.ComponentModel;
33 using System.Runtime.InteropServices;
35 namespace System.Windows.Forms
38 [ClassInterface (ClassInterfaceType.AutoDispatch)]
39 public class ToolStripContainer : ContainerControl
41 private ToolStripPanel bottom_panel;
42 private ToolStripContentPanel content_panel;
43 private ToolStripPanel left_panel;
44 private ToolStripPanel right_panel;
45 private ToolStripPanel top_panel;
47 #region Public Constructors
48 public ToolStripContainer () : base ()
50 this.top_panel = new ToolStripPanel ();
51 this.top_panel.Dock = DockStyle.Top;
52 this.top_panel.Height = 0;
53 this.Controls.Add (top_panel);
55 this.bottom_panel = new ToolStripPanel ();
56 this.bottom_panel.Dock = DockStyle.Bottom;
57 this.top_panel.Height = 0;
58 this.Controls.Add (bottom_panel);
60 this.left_panel = new ToolStripPanel ();
61 this.left_panel.Dock = DockStyle.Left;
62 this.left_panel.Width = 0;
63 this.Controls.Add (left_panel);
65 this.right_panel = new ToolStripPanel ();
66 this.right_panel.Dock = DockStyle.Right;
67 this.right_panel.Width = 0;
68 this.Controls.Add (right_panel);
70 content_panel = new ToolStripContentPanel ();
71 content_panel.Dock = DockStyle.Fill;
72 this.Controls.Add (content_panel);
76 #region Public Properties
78 [EditorBrowsable (EditorBrowsableState.Never)]
79 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
80 public override bool AutoScroll {
81 get { return base.AutoScroll; }
82 set { base.AutoScroll = value; }
86 [EditorBrowsable (EditorBrowsableState.Never)]
87 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
88 public new Size AutoScrollMargin {
89 get { return base.AutoScrollMargin; }
90 set { base.AutoScrollMargin = value; }
94 [EditorBrowsable (EditorBrowsableState.Never)]
95 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
96 public new Size AutoScrollMinSize {
97 get { return base.AutoScrollMinSize; }
98 set { base.AutoScrollMinSize = value; }
102 [EditorBrowsable (EditorBrowsableState.Never)]
103 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
104 public new Color BackColor {
105 get { return base.BackColor; }
106 set { base.BackColor = value; }
110 [EditorBrowsable (EditorBrowsableState.Never)]
111 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
112 public new Image BackgroundImage {
113 get { return base.BackgroundImage; }
114 set { base.BackgroundImage = value; }
118 [EditorBrowsable (EditorBrowsableState.Never)]
119 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
120 public override ImageLayout BackgroundImageLayout {
121 get { return base.BackgroundImageLayout; }
122 set { base.BackgroundImageLayout = value; }
125 [Localizable (false)]
126 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
127 public ToolStripPanel BottomToolStripPanel {
128 get { return this.bottom_panel; }
131 [DefaultValue (true)]
132 public bool BottomToolStripPanelVisible {
133 get { return this.bottom_panel.Visible; }
134 set { this.bottom_panel.Visible = value; }
138 [EditorBrowsable (EditorBrowsableState.Never)]
139 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
140 public new bool CausesValidation {
141 get { return base.CausesValidation; }
142 set { base.CausesValidation = value; }
145 [Localizable (false)]
146 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
147 public ToolStripContentPanel ContentPanel {
148 get { return this.content_panel; }
152 [EditorBrowsable (EditorBrowsableState.Never)]
153 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
154 public override ContextMenuStrip ContextMenuStrip {
155 get { return base.ContextMenuStrip; }
156 set { base.ContextMenuStrip = value; }
159 [EditorBrowsable (EditorBrowsableState.Never)]
160 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
161 public new ControlCollection Controls {
162 get { return base.Controls; }
166 [EditorBrowsable (EditorBrowsableState.Never)]
167 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
168 public override Cursor Cursor {
169 get { return base.Cursor; }
170 set { base.Cursor = value; }
174 [EditorBrowsable (EditorBrowsableState.Never)]
175 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
176 public new Color ForeColor {
177 get { return base.ForeColor; }
178 set { base.ForeColor = value; }
181 [Localizable (false)]
182 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
183 public ToolStripPanel LeftToolStripPanel {
184 get { return this.left_panel; }
187 [DefaultValue (true)]
188 public bool LeftToolStripPanelVisible {
189 get { return this.left_panel.Visible; }
190 set { this.left_panel.Visible = value; }
193 [Localizable (false)]
194 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
195 public ToolStripPanel RightToolStripPanel {
196 get { return this.right_panel; }
199 [DefaultValue (true)]
200 public bool RightToolStripPanelVisible {
201 get { return this.right_panel.Visible; }
202 set { this.right_panel.Visible = value; }
205 [Localizable (false)]
206 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
207 public ToolStripPanel TopToolStripPanel {
208 get { return this.top_panel; }
211 [DefaultValue (true)]
212 public bool TopToolStripPanelVisible {
213 get { return this.top_panel.Visible; }
214 set { this.top_panel.Visible = value; }
218 #region Protected Properties
219 protected override Size DefaultSize {
220 get { return new Size (150, 175); }
224 #region Protected Methods
225 [EditorBrowsable (EditorBrowsableState.Never)]
226 protected override ControlCollection CreateControlsInstance ()
228 return base.CreateControlsInstance ();
231 protected override void OnSizeChanged (EventArgs e)
233 base.OnSizeChanged (e);
237 #region Public Events
239 [EditorBrowsable (EditorBrowsableState.Never)]
240 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
241 public new event EventHandler BackColorChanged {
242 add { base.BackColorChanged += value; }
243 remove { base.BackColorChanged -= value; }
247 [EditorBrowsable (EditorBrowsableState.Never)]
248 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
249 public new event EventHandler BackgroundImageChanged {
250 add { base.BackgroundImageChanged += value; }
251 remove { base.BackgroundImageChanged -= value; }
255 [EditorBrowsable (EditorBrowsableState.Never)]
256 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
257 public new event EventHandler BackgroundImageLayoutChanged {
258 add { base.BackgroundImageLayoutChanged += value; }
259 remove { base.BackgroundImageLayoutChanged -= value; }
263 [EditorBrowsable (EditorBrowsableState.Never)]
264 public new event EventHandler CausesValidationChanged {
265 add { base.CausesValidationChanged += value; }
266 remove { base.CausesValidationChanged -= value; }
270 [EditorBrowsable (EditorBrowsableState.Never)]
271 public new event EventHandler ContextMenuStripChanged {
272 add { base.ContextMenuStripChanged += value; }
273 remove { base.ContextMenuStripChanged -= value; }
277 [EditorBrowsable (EditorBrowsableState.Never)]
278 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
279 public new event EventHandler CursorChanged {
280 add { base.CursorChanged += value; }
281 remove { base.CursorChanged -= value; }
285 [EditorBrowsable (EditorBrowsableState.Never)]
286 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
287 public new event EventHandler ForeColorChanged {
288 add { base.ForeColorChanged += value; }
289 remove { base.ForeColorChanged -= value; }