-//\r
-// SplitContainer.cs\r
-//\r
-// Permission is hereby granted, free of charge, to any person obtaining\r
-// a copy of this software and associated documentation files (the\r
-// "Software"), to deal in the Software without restriction, including\r
-// without limitation the rights to use, copy, modify, merge, publish,\r
-// distribute, sublicense, and/or sell copies of the Software, and to\r
-// permit persons to whom the Software is furnished to do so, subject to\r
-// the following conditions:\r
-// \r
-// The above copyright notice and this permission notice shall be\r
-// included in all copies or substantial portions of the Software.\r
-// \r
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\r
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\r
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\r
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
-//\r
-// Copyright (c) 2006 Jonathan Pobst\r
-//\r
-// Authors:\r
-// Jonathan Pobst (monkey@jpobst.com)\r
-//\r
-\r
-#if NET_2_0\r
-using System;\r
-using System.Runtime.InteropServices;\r
-using System.ComponentModel;\r
-using System.Drawing;\r
-using System.Drawing.Drawing2D;\r
-\r
-namespace System.Windows.Forms\r
-{\r
- [ComVisibleAttribute (true)]\r
- [ClassInterfaceAttribute (ClassInterfaceType.AutoDispatch)]\r
- public class SplitContainer : ContainerControl\r
- {\r
- #region Local Variables\r
- private FixedPanel fixed_panel;\r
- private int splitter_distance;\r
- private int splitter_width;\r
- private int splitter_increment;\r
- private Orientation orientation;\r
- private bool binding_context_set;\r
-\r
- private SplitterPanel panel1;\r
- private bool panel1_collapsed;\r
- private int panel1_min_size;\r
-\r
- private SplitterPanel panel2;\r
- private bool panel2_collapsed;\r
- private int panel2_min_size;\r
-\r
- private Splitter splitter;\r
- #endregion\r
-\r
- #region Public Events\r
- [Browsable (false)]\r
- [EditorBrowsable (EditorBrowsableState.Never)]\r
- new public event EventHandler AutoSizeChanged;\r
- public event SplitterEventHandler SplitterMoved;\r
- public event SplitterCancelEventHandler SplitterMoving;\r
- #endregion\r
-\r
- #region Public Constructors\r
- public SplitContainer ()\r
- {\r
- fixed_panel = FixedPanel.None;\r
- orientation = Orientation.Vertical;\r
- splitter_distance = 50;\r
- splitter_width = 4;\r
- splitter_increment = 1;\r
- panel1_collapsed = false;\r
- panel2_collapsed = false;\r
- panel1_min_size = 25;\r
- panel2_min_size = 25;\r
- binding_context_set = false;\r
-\r
- panel1 = new SplitterPanel (this);\r
- panel2 = new SplitterPanel (this);\r
- splitter = new Splitter ();\r
-\r
- splitter.TabStop = true;\r
- splitter.Size = new System.Drawing.Size (4, 4);\r
- splitter.SplitterMoved += new SplitterEventHandler (splitter_SplitterMoved);\r
- splitter.SplitterMoving += new SplitterEventHandler (splitter_SplitterMoving);\r
-\r
- panel1.Size = new Size (50, 50);\r
-\r
- this.Controls.Add (panel2);\r
- this.Controls.Add (splitter);\r
- this.Controls.Add (panel1);\r
-\r
- panel1.Dock = DockStyle.Left;\r
- panel2.Dock = DockStyle.Fill;\r
- splitter.Dock = DockStyle.Left;\r
- }\r
- #endregion\r
-\r
- #region Public Properties\r
- [Browsable (false)]\r
- [EditorBrowsable (EditorBrowsableState.Never)]\r
- [Localizable (true)]\r
- public override bool AutoScroll {\r
- get { return base.AutoScroll; }\r
- set { }\r
- }\r
-\r
- [Browsable (false)]\r
- [EditorBrowsable (EditorBrowsableState.Never)]\r
- new public Size AutoScrollMargin {\r
- get { return base.AutoScrollMargin; }\r
- set { base.AutoScrollMargin = value; }\r
- }\r
-\r
- [Browsable (false)]\r
- [EditorBrowsable (EditorBrowsableState.Never)]\r
- new public Size AutoScrollMinSize {\r
- get { return base.AutoScrollMinSize; }\r
- set { base.AutoScrollMinSize = value; }\r
- }\r
-\r
- //Uncomment once this has been implemented in Control.cs\r
- //[Browsable (false)]\r
- //[EditorBrowsable (EditorBrowsableState.Never)]\r
- //public override Point AutoScrollOffset {\r
- // get { return base.AutoScrollOffset; }\r
- // set { base.AutoScrollOffset = value; }\r
- //}\r
-\r
- [Browsable (false)]\r
- [EditorBrowsable (EditorBrowsableState.Never)]\r
- new public Point AutoScrollPosition {\r
- get { return base.AutoScrollPosition; }\r
- set { base.AutoScrollPosition = value; }\r
- }\r
-\r
- [Browsable (false)]\r
- [EditorBrowsable (EditorBrowsableState.Never)]\r
- public override bool AutoSize {\r
- get { return base.AutoSize; }\r
- set {\r
- base.AutoSize = value;\r
- if (AutoSizeChanged != null) AutoSizeChanged (this, new EventArgs ());\r
- }\r
- }\r
-\r
- public override Image BackgroundImage {\r
- get { return base.BackgroundImage; }\r
- set {\r
- base.BackgroundImage = value;\r
- UpdateSplitterBackground ();\r
- }\r
- }\r
-\r
- //Uncomment once this has been implemented in Control.cs\r
- //[Browsable (false)]\r
- //[EditorBrowsable (EditorBrowsableState.Never)]\r
- //public override ImageLayout BackgroundImageLayout {\r
- // get { return base.BackgroundImageLayout; }\r
- // set { base.BackgroundImageLayout = value; }\r
- //}\r
-\r
- [Browsable (false)]\r
- [EditorBrowsable (EditorBrowsableState.Never)]\r
- public override BindingContext BindingContext {\r
- get { return binding_context_set ? base.BindingContext : null; }\r
- set {\r
- binding_context_set = true;\r
- base.BindingContext = value;\r
- }\r
- }\r
-\r
- // MSDN says default is Fixed3D, creating a new SplitContainer says otherwise.\r
- [DefaultValue (BorderStyle.None)]\r
- public BorderStyle BorderStyle\r
- {\r
- get { return panel1.BorderStyle; }\r
- set {\r
- if (!Enum.IsDefined (typeof (BorderStyle), value))\r
- throw new InvalidEnumArgumentException (string.Format ("Enum argument value '{0}' is not valid for BorderStyle", value));\r
- \r
- panel1.BorderStyle = value;\r
- panel2.BorderStyle = value;\r
- }\r
- }\r
-\r
- [Browsable (false)]\r
- [EditorBrowsable (EditorBrowsableState.Never)]\r
- new public ControlCollection Controls { get { return base.Controls; } }\r
-\r
- new public DockStyle Dock {\r
- get { return base.Dock; }\r
- set { base.Dock = value; }\r
- }\r
-\r
- [DefaultValue (FixedPanel.None)]\r
- public FixedPanel FixedPanel {\r
- get { return this.fixed_panel; }\r
- set {\r
- if (!Enum.IsDefined (typeof (FixedPanel), value))\r
- throw new InvalidEnumArgumentException (string.Format ("Enum argument value '{0}' is not valid for FixedPanel", value));\r
-\r
- this.fixed_panel = value;\r
- }\r
- }\r
-\r
- [Localizable (true)]\r
- [DefaultValue (false)]\r
- public bool IsSplitterFixed {\r
- get { return !splitter.Enabled; }\r
- set { splitter.Enabled = !value; }\r
- }\r
-\r
- [Localizable (true)]\r
- [DefaultValue (Orientation.Vertical)]\r
- public Orientation Orientation {\r
- get { return this.orientation; }\r
- set {\r
- if (!Enum.IsDefined (typeof (Orientation), value))\r
- throw new InvalidEnumArgumentException (string.Format ("Enum argument value '{0}' is not valid for Orientation", value));\r
-\r
- if (this.orientation != value) {\r
- this.orientation = value;\r
-\r
- switch (value) {\r
- case Orientation.Vertical:\r
- panel1.Dock = DockStyle.Left;\r
- panel2.Dock = DockStyle.Fill;\r
- splitter.Dock = DockStyle.Left;\r
- splitter.Width = this.splitter_width;\r
- panel1.InternalWidth = this.splitter_distance;\r
- if (panel2.Width < panel2_min_size)\r
- panel1.InternalWidth = this.Width - this.splitter_width - panel2_min_size;\r
- break;\r
- case Orientation.Horizontal:\r
- default:\r
- panel1.Dock = DockStyle.Top;\r
- panel2.Dock = DockStyle.Fill;\r
- splitter.Dock = DockStyle.Top;\r
- splitter.Height = this.splitter_width;\r
- panel1.InternalHeight = this.splitter_distance;\r
- if (panel2.Height < panel2_min_size)\r
- panel1.InternalHeight = this.Height - this.splitter_width - panel2_min_size;\r
- break;\r
- }\r
-\r
- this.PerformLayout ();\r
- }\r
- }\r
- }\r
-\r
- [Browsable (false)]\r
- [EditorBrowsable (EditorBrowsableState.Never)]\r
- new public Padding Padding {\r
- get { return base.Padding; }\r
- set { base.Padding = value; }\r
- }\r
-\r
- [Localizable (false)]\r
- public SplitterPanel Panel1 { get { return this.panel1; } }\r
-\r
- [DefaultValue (false)]\r
- public bool Panel1Collapsed {\r
- get { return this.panel1_collapsed; }\r
- set {\r
- this.panel1_collapsed = value;\r
- this.panel1.Visible = !value;\r
- this.splitter.Visible = !value;\r
- }\r
- }\r
-\r
- [Localizable (true)]\r
- [DefaultValue (25)]\r
- public int Panel1MinSize {\r
- get { return this.panel1_min_size; }\r
- set { \r
- this.panel1_min_size = value; \r
- this.splitter.MinSize = value; \r
- }\r
- }\r
-\r
- [Localizable (false)]\r
- public SplitterPanel Panel2 { get { return this.panel2; } }\r
-\r
- [DefaultValue (false)]\r
- public bool Panel2Collapsed {\r
- get { return this.panel2_collapsed; }\r
- set {\r
- this.panel2_collapsed = value; \r
- this.panel2.Visible = !value;\r
- this.splitter.Visible = !value;\r
- }\r
- }\r
-\r
- [Localizable (true)]\r
- [DefaultValue (25)]\r
- public int Panel2MinSize {\r
- get { return this.panel2_min_size; }\r
- set { this.panel2_min_size = value; this.splitter.MinExtra = value; }\r
- }\r
-\r
- // MSDN says the default is 40, MS's implementation defaults to 50.\r
- [Localizable (true)]\r
- [DefaultValue (50)]\r
- public int SplitterDistance {\r
- get { return this.splitter_distance; }\r
- set {\r
- if (value < 0)\r
- throw new ArgumentOutOfRangeException ();\r
-\r
- if (value < this.panel1_min_size)\r
- value = this.panel1_min_size;\r
-\r
- switch (this.orientation) {\r
- case Orientation.Vertical:\r
- if (value > this.Width - this.panel2_min_size - this.splitter_width)\r
- value = this.Width - this.panel2_min_size - this.splitter_width;\r
- panel1.InternalWidth = value;\r
- break;\r
- case Orientation.Horizontal:\r
- default:\r
- if (value > this.Height - this.panel2_min_size - this.splitter_width)\r
- value = this.Height - this.panel2_min_size - this.splitter_width;\r
- panel1.InternalHeight = value;\r
- break;\r
- }\r
-\r
- this.splitter_distance = value;\r
-\r
- UpdateSplitterBackground ();\r
- }\r
- }\r
-\r
- [Localizable (true)]\r
- [DefaultValue (1)]\r
- [MonoTODO ("Not implemented.")]\r
- public int SplitterIncrement {\r
- get { return this.splitter_increment; }\r
- set { this.splitter_increment = value; }\r
- }\r
-\r
- [Browsable (false)]\r
- public Rectangle SplitterRectangle { get { return splitter.Bounds; } }\r
-\r
- [Localizable (true)]\r
- [DefaultValue (4)]\r
- public int SplitterWidth {\r
- get { return this.splitter_width; }\r
- set {\r
- if (value < 1)\r
- throw new ArgumentOutOfRangeException ();\r
-\r
- this.splitter_width = value;\r
-\r
- switch (this.orientation) {\r
- case Orientation.Horizontal:\r
- splitter.Height = value;\r
- break;\r
- case Orientation.Vertical:\r
- default:\r
- splitter.Width = value;\r
- break;\r
- }\r
- }\r
- }\r
-\r
- [DefaultValue (true)]\r
- new public bool TabStop {\r
- get { return splitter.TabStop; }\r
- set { splitter.TabStop = value; }\r
- }\r
-\r
- [Browsable (false)]\r
- [EditorBrowsable (EditorBrowsableState.Never)]\r
- [Bindable (false)]\r
- public override string Text {\r
- get { return base.Text; }\r
- set { base.Text = value; }\r
- }\r
- #endregion\r
-\r
- #region Protected Properties\r
- protected override Size DefaultSize { get { return new Size (150, 100); } }\r
- #endregion\r
-\r
- #region Public Methods\r
- public void OnSplitterMoved (SplitterEventArgs e)\r
- {\r
- if (SplitterMoved != null) SplitterMoved (this, e);\r
- }\r
-\r
- public void OnSplitterMoving (SplitterCancelEventArgs e)\r
- {\r
- if (SplitterMoving != null) SplitterMoving (this, e);\r
-\r
- if (e.Cancel == true) {\r
- e.SplitX = splitter.Location.X;\r
- e.SplitY = splitter.Location.Y;\r
- }\r
- }\r
- #endregion\r
-\r
- #region Private Methods\r
- private void splitter_SplitterMoving (object sender, SplitterEventArgs e)\r
- {\r
- SplitterCancelEventArgs ea = new SplitterCancelEventArgs (e.X, e.Y, e.SplitX, e.SplitY);\r
- this.OnSplitterMoving (ea);\r
- e.SplitX = ea.SplitX;\r
- e.SplitY = ea.SplitY;\r
- }\r
-\r
- private void splitter_SplitterMoved (object sender, SplitterEventArgs e)\r
- {\r
- this.OnSplitterMoved (e);\r
- }\r
-\r
- private void UpdateSplitterBackground ()\r
- {\r
- if (this.BackgroundImage != null) {\r
- Bitmap b = new Bitmap (splitter.Width, splitter.Height);\r
- Graphics.FromImage (b).DrawImage (base.BackgroundImage, new Rectangle (0, 0, b.Width, b.Height), this.SplitterRectangle, GraphicsUnit.Pixel);\r
- splitter.BackgroundImage = b;\r
- }\r
- else\r
- splitter.BackgroundImage = this.BackgroundImage;\r
- }\r
- #endregion\r
- }\r
-}\r
-#endif
\ No newline at end of file
+//
+// SplitContainer.cs
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Copyright (c) 2006 Jonathan Pobst
+//
+// Authors:
+// Jonathan Pobst (monkey@jpobst.com)
+//
+
+#if NET_2_0
+using System;
+using System.Runtime.InteropServices;
+using System.ComponentModel;
+using System.Drawing;
+using System.Drawing.Drawing2D;
+
+namespace System.Windows.Forms
+{
+ [ComVisibleAttribute (true)]
+ [ClassInterfaceAttribute (ClassInterfaceType.AutoDispatch)]
+ [DefaultEvent ("SplitterMoved")]
+ [Docking (DockingBehavior.AutoDock)]
+ public class SplitContainer : ContainerControl
+ {
+ #region Local Variables
+ private FixedPanel fixed_panel;
+ private int splitter_distance;
+ private int splitter_width;
+ private int splitter_increment;
+ private Orientation orientation;
+ private bool binding_context_set;
+
+ private SplitterPanel panel1;
+ private bool panel1_collapsed;
+ private int panel1_min_size;
+
+ private SplitterPanel panel2;
+ private bool panel2_collapsed;
+ private int panel2_min_size;
+
+ private Splitter splitter;
+ #endregion
+
+ #region Public Events
+ static object SplitterMovedEvent = new object ();
+ static object SplitterMovingEvent = new object ();
+
+ //[Browsable (false)]
+ //[EditorBrowsable (EditorBrowsableState.Never)]
+ //new public event EventHandler AutoSizeChanged;
+
+ [Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ public new event EventHandler BackgroundImageChanged {
+ add { base.BackgroundImageChanged += value; }
+ remove { base.BackgroundImageChanged -= value; }
+ }
+
+ [Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ public new event EventHandler BackgroundImageLayoutChanged {
+ add { base.BackgroundImageLayoutChanged += value; }
+ remove { base.BackgroundImageLayoutChanged -= value; }
+ }
+
+ [Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ public new event ControlEventHandler ControlAdded {
+ add { base.ControlAdded += value; }
+ remove { base.ControlAdded -= value; }
+ }
+
+ [Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ public new event ControlEventHandler ControlRemoved {
+ add { base.ControlRemoved += value; }
+ remove { base.ControlRemoved -= value; }
+ }
+
+ [Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ public new event EventHandler PaddingChanged {
+ add { base.PaddingChanged += value; }
+ remove { base.PaddingChanged -= value; }
+ }
+
+ public event SplitterEventHandler SplitterMoved {
+ add { Events.AddHandler (SplitterMovedEvent, value); }
+ remove { Events.RemoveHandler (SplitterMovedEvent, value); }
+ }
+
+ public event SplitterCancelEventHandler SplitterMoving {
+ add { Events.AddHandler (SplitterMovingEvent, value); }
+ remove { Events.RemoveHandler (SplitterMovingEvent, value); }
+ }
+
+ [Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ public new event EventHandler TextChanged {
+ add { base.TextChanged += value; }
+ remove { base.TextChanged -= value; }
+ }
+ #endregion
+
+ #region Public Constructors
+ public SplitContainer ()
+ {
+ fixed_panel = FixedPanel.None;
+ orientation = Orientation.Vertical;
+ splitter_distance = 50;
+ splitter_width = 4;
+ splitter_increment = 1;
+ panel1_collapsed = false;
+ panel2_collapsed = false;
+ panel1_min_size = 25;
+ panel2_min_size = 25;
+ binding_context_set = false;
+
+ panel1 = new SplitterPanel (this);
+ panel2 = new SplitterPanel (this);
+ splitter = new Splitter ();
+
+ splitter.TabStop = true;
+ splitter.Size = new System.Drawing.Size (4, 4);
+ splitter.SplitterMoved += new SplitterEventHandler (splitter_SplitterMoved);
+ splitter.SplitterMoving += new SplitterEventHandler (splitter_SplitterMoving);
+
+ panel1.Size = new Size (50, 50);
+
+ this.Controls.Add (panel2);
+ this.Controls.Add (splitter);
+ this.Controls.Add (panel1);
+
+ panel1.Dock = DockStyle.Left;
+ panel2.Dock = DockStyle.Fill;
+ splitter.Dock = DockStyle.Left;
+ }
+ #endregion
+
+ #region Public Properties
+ [Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ [Localizable (true)]
+ [DefaultValue (false)]
+ public override bool AutoScroll {
+ get { return base.AutoScroll; }
+ set { base.AutoScroll = value; }
+ }
+
+ [Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+ new public Size AutoScrollMargin {
+ get { return base.AutoScrollMargin; }
+ set { base.AutoScrollMargin = value; }
+ }
+
+ [Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+ new public Size AutoScrollMinSize {
+ get { return base.AutoScrollMinSize; }
+ set { base.AutoScrollMinSize = value; }
+ }
+
+ //Uncomment once this has been implemented in Control.cs
+ //[Browsable (false)]
+ //[EditorBrowsable (EditorBrowsableState.Never)]
+ //public override Point AutoScrollOffset {
+ // get { return base.AutoScrollOffset; }
+ // set { base.AutoScrollOffset = value; }
+ //}
+
+ [Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+ new public Point AutoScrollPosition {
+ get { return base.AutoScrollPosition; }
+ set { base.AutoScrollPosition = value; }
+ }
+
+ [Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+ public override bool AutoSize {
+ get { return base.AutoSize; }
+ set { base.AutoSize = value; }
+ }
+
+ [Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ public override Image BackgroundImage {
+ get { return base.BackgroundImage; }
+ set {
+ base.BackgroundImage = value;
+ UpdateSplitterBackground ();
+ }
+ }
+
+ [Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ public override ImageLayout BackgroundImageLayout {
+ get { return base.BackgroundImageLayout; }
+ set { base.BackgroundImageLayout = value; }
+ }
+
+ [Browsable (false)]
+ public override BindingContext BindingContext {
+ get { return binding_context_set ? base.BindingContext : null; }
+ set {
+ binding_context_set = true;
+ base.BindingContext = value;
+ }
+ }
+
+ // MSDN says default is Fixed3D, creating a new SplitContainer says otherwise.
+ [DefaultValue (BorderStyle.None)]
+ public BorderStyle BorderStyle
+ {
+ get { return panel1.BorderStyle; }
+ set {
+ if (!Enum.IsDefined (typeof (BorderStyle), value))
+ throw new InvalidEnumArgumentException (string.Format ("Enum argument value '{0}' is not valid for BorderStyle", value));
+
+ panel1.BorderStyle = value;
+ panel2.BorderStyle = value;
+ }
+ }
+
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
+ new public ControlCollection Controls { get { return base.Controls; } }
+
+ new public DockStyle Dock {
+ get { return base.Dock; }
+ set { base.Dock = value; }
+ }
+
+ [DefaultValue (FixedPanel.None)]
+ public FixedPanel FixedPanel {
+ get { return this.fixed_panel; }
+ set {
+ if (!Enum.IsDefined (typeof (FixedPanel), value))
+ throw new InvalidEnumArgumentException (string.Format ("Enum argument value '{0}' is not valid for FixedPanel", value));
+
+ this.fixed_panel = value;
+ }
+ }
+
+ [Localizable (true)]
+ [DefaultValue (false)]
+ public bool IsSplitterFixed {
+ get { return !splitter.Enabled; }
+ set { splitter.Enabled = !value; }
+ }
+
+ [Localizable (true)]
+ [DefaultValue (Orientation.Vertical)]
+ public Orientation Orientation {
+ get { return this.orientation; }
+ set {
+ if (!Enum.IsDefined (typeof (Orientation), value))
+ throw new InvalidEnumArgumentException (string.Format ("Enum argument value '{0}' is not valid for Orientation", value));
+
+ if (this.orientation != value) {
+ this.orientation = value;
+
+ switch (value) {
+ case Orientation.Vertical:
+ panel1.Dock = DockStyle.Left;
+ panel2.Dock = DockStyle.Fill;
+ splitter.Dock = DockStyle.Left;
+ splitter.Width = this.splitter_width;
+ panel1.InternalWidth = this.splitter_distance;
+ if (panel2.Width < panel2_min_size)
+ panel1.InternalWidth = this.Width - this.splitter_width - panel2_min_size;
+ break;
+ case Orientation.Horizontal:
+ default:
+ panel1.Dock = DockStyle.Top;
+ panel2.Dock = DockStyle.Fill;
+ splitter.Dock = DockStyle.Top;
+ splitter.Height = this.splitter_width;
+ panel1.InternalHeight = this.splitter_distance;
+ if (panel2.Height < panel2_min_size)
+ panel1.InternalHeight = this.Height - this.splitter_width - panel2_min_size;
+ break;
+ }
+
+ this.PerformLayout ();
+ }
+ }
+ }
+
+ [Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+ new public Padding Padding {
+ get { return base.Padding; }
+ set { base.Padding = value; }
+ }
+
+ [Localizable (false)]
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+ public SplitterPanel Panel1 { get { return this.panel1; } }
+
+ [DefaultValue (false)]
+ public bool Panel1Collapsed {
+ get { return this.panel1_collapsed; }
+ set {
+ this.panel1_collapsed = value;
+ this.panel1.Visible = !value;
+ this.splitter.Visible = !value;
+ }
+ }
+
+ [Localizable (true)]
+ [DefaultValue (25)]
+ [RefreshProperties (RefreshProperties.All)]
+ public int Panel1MinSize {
+ get { return this.panel1_min_size; }
+ set {
+ this.panel1_min_size = value;
+ this.splitter.MinSize = value;
+ }
+ }
+
+ [Localizable (false)]
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+ public SplitterPanel Panel2 { get { return this.panel2; } }
+
+ [DefaultValue (false)]
+ public bool Panel2Collapsed {
+ get { return this.panel2_collapsed; }
+ set {
+ this.panel2_collapsed = value;
+ this.panel2.Visible = !value;
+ this.splitter.Visible = !value;
+ }
+ }
+
+ [Localizable (true)]
+ [DefaultValue (25)]
+ [RefreshProperties (RefreshProperties.All)]
+ public int Panel2MinSize {
+ get { return this.panel2_min_size; }
+ set { this.panel2_min_size = value; this.splitter.MinExtra = value; }
+ }
+
+ // MSDN says the default is 40, MS's implementation defaults to 50.
+ [Localizable (true)]
+ [DefaultValue (50)]
+ [SettingsBindable (true)]
+ public int SplitterDistance {
+ get { return this.splitter_distance; }
+ set {
+ if (value < 0)
+ throw new ArgumentOutOfRangeException ();
+
+ if (value < this.panel1_min_size)
+ value = this.panel1_min_size;
+
+ switch (this.orientation) {
+ case Orientation.Vertical:
+ if (value > this.Width - this.panel2_min_size - this.splitter_width)
+ value = this.Width - this.panel2_min_size - this.splitter_width;
+ panel1.InternalWidth = value;
+ break;
+ case Orientation.Horizontal:
+ default:
+ if (value > this.Height - this.panel2_min_size - this.splitter_width)
+ value = this.Height - this.panel2_min_size - this.splitter_width;
+ panel1.InternalHeight = value;
+ break;
+ }
+
+ this.splitter_distance = value;
+
+ UpdateSplitterBackground ();
+ }
+ }
+
+ [Localizable (true)]
+ [DefaultValue (1)]
+ [MonoTODO ("Not implemented.")]
+ public int SplitterIncrement {
+ get { return this.splitter_increment; }
+ set { this.splitter_increment = value; }
+ }
+
+ [Browsable (false)]
+ public Rectangle SplitterRectangle { get { return splitter.Bounds; } }
+
+ [Localizable (true)]
+ [DefaultValue (4)]
+ public int SplitterWidth {
+ get { return this.splitter_width; }
+ set {
+ if (value < 1)
+ throw new ArgumentOutOfRangeException ();
+
+ this.splitter_width = value;
+
+ switch (this.orientation) {
+ case Orientation.Horizontal:
+ splitter.Height = value;
+ break;
+ case Orientation.Vertical:
+ default:
+ splitter.Width = value;
+ break;
+ }
+ }
+ }
+
+ [DefaultValue (true)]
+ new public bool TabStop {
+ get { return splitter.TabStop; }
+ set { splitter.TabStop = value; }
+ }
+
+ [Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ [Bindable (false)]
+ public override string Text {
+ get { return base.Text; }
+ set { base.Text = value; }
+ }
+ #endregion
+
+ #region Protected Properties
+ protected override Size DefaultSize { get { return new Size (150, 100); } }
+ #endregion
+
+ #region Public Methods
+ public void OnSplitterMoved (SplitterEventArgs e)
+ {
+ SplitterEventHandler eh = (SplitterEventHandler)(Events [SplitterMovedEvent]);
+ if (eh != null)
+ eh (this, e);
+ }
+
+ public void OnSplitterMoving (SplitterCancelEventArgs e)
+ {
+ SplitterCancelEventHandler eh = (SplitterCancelEventHandler)(Events [SplitterMovingEvent]);
+ if (eh != null)
+ eh (this, e);
+
+ if (e.Cancel == true) {
+ e.SplitX = splitter.Location.X;
+ e.SplitY = splitter.Location.Y;
+ }
+ }
+ #endregion
+
+ #region Protected Methods
+ protected override ControlCollection CreateControlsInstance ()
+ {
+ return new SplitContainerTypedControlCollection (this);
+ }
+
+ [MonoTODO ("Special focus semantics not implemented")]
+ protected override void OnGotFocus (EventArgs e)
+ {
+ base.OnGotFocus (e);
+ }
+
+ protected override void OnKeyDown (KeyEventArgs e)
+ {
+ base.OnKeyDown (e);
+ }
+
+ protected override void OnKeyUp (KeyEventArgs e)
+ {
+ base.OnKeyUp (e);
+ }
+
+ protected override void OnLayout (LayoutEventArgs levent)
+ {
+ base.OnLayout (levent);
+ }
+
+ protected override void OnMouseDown (MouseEventArgs e)
+ {
+ base.OnMouseDown (e);
+ }
+
+ protected override void OnMouseLeave (EventArgs e)
+ {
+ base.OnMouseLeave (e);
+ }
+
+ protected override void OnMouseMove (MouseEventArgs e)
+ {
+ base.OnMouseMove (e);
+ }
+
+ protected override void OnMouseUp (MouseEventArgs e)
+ {
+ base.OnMouseUp (e);
+ }
+
+ protected override void OnPaint (PaintEventArgs e)
+ {
+ base.OnPaint (e);
+ }
+
+ protected override void OnRightToLeftChanged (EventArgs e)
+ {
+ base.OnRightToLeftChanged (e);
+ }
+
+ [MonoTODO ("Special focus semantics not implemented")]
+ protected override bool ProcessDialogKey (Keys keyData)
+ {
+ return base.ProcessDialogKey (keyData);
+ }
+
+ [MonoTODO ("Special focus semantics not implemented")]
+ protected override bool ProcessTabKey (bool forward)
+ {
+ return base.ProcessTabKey (forward);
+ }
+
+ [MonoTODO ("Special focus semantics not implemented")]
+ protected override void Select (bool directed, bool forward)
+ {
+ base.Select (directed, forward);
+ }
+
+ protected override void SetBoundsCore (int x, int y, int width, int height, BoundsSpecified specified)
+ {
+ base.SetBoundsCore (x, y, width, height, specified);
+ }
+
+ protected override void WndProc (ref Message m)
+ {
+ base.WndProc (ref m);
+ }
+ #endregion
+
+ #region Private Methods
+ private void splitter_SplitterMoving (object sender, SplitterEventArgs e)
+ {
+ SplitterCancelEventArgs ea = new SplitterCancelEventArgs (e.X, e.Y, e.SplitX, e.SplitY);
+ this.OnSplitterMoving (ea);
+ e.SplitX = ea.SplitX;
+ e.SplitY = ea.SplitY;
+ }
+
+ private void splitter_SplitterMoved (object sender, SplitterEventArgs e)
+ {
+ this.OnSplitterMoved (e);
+ }
+
+ private void UpdateSplitterBackground ()
+ {
+ if (this.BackgroundImage != null) {
+ Bitmap b = new Bitmap (splitter.Width, splitter.Height);
+ Graphics.FromImage (b).DrawImage (base.BackgroundImage, new Rectangle (0, 0, b.Width, b.Height), this.SplitterRectangle, GraphicsUnit.Pixel);
+ splitter.BackgroundImage = b;
+ }
+ else
+ splitter.BackgroundImage = this.BackgroundImage;
+ }
+ #endregion
+
+ #region Internal Classes
+ internal class SplitContainerTypedControlCollection : ControlCollection
+ {
+ public SplitContainerTypedControlCollection (Control owner) : base (owner)
+ {
+ }
+ }
+ #endregion
+ }
+}
+#endif