/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs
C# | 6728 lines | 5302 code | 1158 blank | 268 comment | 1215 complexity | 78e5bdf745b8d860b07ccbff92d06a4c MD5 | raw file
Possible License(s): Unlicense, Apache-2.0, LGPL-2.0, MPL-2.0-no-copyleft-exception, CC-BY-SA-3.0, GPL-2.0
Large files files are truncated, but you can click here to view the full file
- // 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) 2004-2006 Novell, Inc.
- //
- // Authors:
- // Peter Bartok pbartok@novell.com
- //
- // Partially based on work by:
- // Aleksey Ryabchuk ryabchuk@yahoo.com
- // Alexandre Pigolkine pigolkine@gmx.de
- // Dennis Hayes dennish@raytek.com
- // Jaak Simm jaaksimm@firm.ee
- // John Sohn jsohn@columbus.rr.com
- //
- #undef DebugRecreate
- #undef DebugFocus
- #undef DebugMessages
- using System;
- using System.ComponentModel;
- using System.ComponentModel.Design;
- using System.ComponentModel.Design.Serialization;
- using System.Collections;
- using System.Diagnostics;
- using System.Drawing;
- using System.Drawing.Drawing2D;
- using System.Reflection;
- using System.Runtime.InteropServices;
- using System.Security;
- using System.Threading;
- namespace System.Windows.Forms
- {
- [ComVisible(true)]
- [ClassInterface (ClassInterfaceType.AutoDispatch)]
- [Designer("System.Windows.Forms.Design.ControlDesigner, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.IDesigner")]
- [DefaultProperty("Text")]
- [DefaultEvent("Click")]
- [DesignerSerializer("System.Windows.Forms.Design.ControlCodeDomSerializer, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.Serialization.CodeDomSerializer, " + Consts.AssemblySystem_Design)]
- [ToolboxItemFilter("System.Windows.Forms")]
- public class Control : Component, ISynchronizeInvoke, IWin32Window
- , IBindableComponent, IDropTarget, IBounds
- {
- #region Local Variables
- // Basic
- internal Rectangle bounds; // bounding rectangle for control (client area + decorations)
- Rectangle explicit_bounds; // explicitly set bounds
- internal object creator_thread; // thread that created the control
- internal ControlNativeWindow window; // object for native window handle
- private IWindowTarget window_target;
- string name; // for object naming
- // State
- bool is_created; // true if OnCreateControl has been sent
- internal bool has_focus; // true if control has focus
- internal bool is_visible; // true if control is visible
- internal bool is_entered; // is the mouse inside the control?
- internal bool is_enabled; // true if control is enabled (usable/not grayed out)
- bool is_accessible; // true if the control is visible to accessibility applications
- bool is_captured; // tracks if the control has captured the mouse
- internal bool is_toplevel; // tracks if the control is a toplevel window
- bool is_recreating; // tracks if the handle for the control is being recreated
- bool causes_validation; // tracks if validation is executed on changes
- bool is_focusing; // tracks if Focus has been called on the control and has not yet finished
- int tab_index; // position in tab order of siblings
- bool tab_stop; // is the control a tab stop?
- bool is_disposed; // has the window already been disposed?
- bool is_disposing; // is the window getting disposed?
- Size client_size; // size of the client area (window excluding decorations)
- Rectangle client_rect; // rectangle with the client area (window excluding decorations)
- ControlStyles control_style; // rather win32-specific, style bits for control
- ImeMode ime_mode;
- object control_tag; // object that contains data about our control
- internal int mouse_clicks; // Counter for mouse clicks
- Cursor cursor; // Cursor for the window
- internal bool allow_drop; // true if the control accepts droping objects on it
- Region clip_region; // User-specified clip region for the window
- // Visuals
- internal Color foreground_color; // foreground color for control
- internal Color background_color; // background color for control
- Image background_image; // background image for control
- internal Font font; // font for control
- string text; // window/title text for control
- internal BorderStyle border_style; // Border style of control
- bool show_keyboard_cues; // Current keyboard cues
- internal bool show_focus_cues; // Current focus cues
- internal bool force_double_buffer; // Always doublebuffer regardless of ControlStyle
- // Layout
- internal enum LayoutType {
- Anchor,
- Dock
- }
- Layout.LayoutEngine layout_engine;
- internal int layout_suspended;
- bool layout_pending; // true if our parent needs to re-layout us
- internal AnchorStyles anchor_style; // anchoring requirements for our control
- internal DockStyle dock_style; // docking requirements for our control
- LayoutType layout_type;
- private bool recalculate_distances = true; // Delay anchor calculations
- // Please leave the next 2 as internal until DefaultLayout (2.0) is rewritten
- internal int dist_right; // distance to the right border of the parent
- internal int dist_bottom; // distance to the bottom border of the parent
- // to be categorized...
- ControlCollection child_controls; // our children
- Control parent; // our parent control
- BindingContext binding_context;
- RightToLeft right_to_left; // drawing direction for control
- ContextMenu context_menu; // Context menu associated with the control
- internal bool use_compatible_text_rendering;
- private bool use_wait_cursor;
- //accessibility
- string accessible_name;
- string accessible_description;
- string accessible_default_action;
- AccessibleRole accessible_role = AccessibleRole.Default;
- AccessibleObject accessibility_object; // object that contains accessibility information about our control
- // double buffering
- DoubleBuffer backbuffer;
- ControlBindingsCollection data_bindings;
- static bool verify_thread_handle;
- Padding padding;
- ImageLayout backgroundimage_layout;
- Size maximum_size;
- Size minimum_size;
- Padding margin;
- private ContextMenuStrip context_menu_strip;
- private bool nested_layout = false;
- Point auto_scroll_offset;
- private AutoSizeMode auto_size_mode;
- private bool suppressing_key_press;
- #endregion // Local Variables
- #region Private Classes
- // This helper class allows us to dispatch messages to Control.WndProc
- internal class ControlNativeWindow : NativeWindow {
- private Control owner;
- public ControlNativeWindow(Control control) : base() {
- this.owner=control;
- }
- public Control Owner {
- get {
- return owner;
- }
- }
- protected override void OnHandleChange()
- {
- this.owner.WindowTarget.OnHandleChange(this.owner.Handle);
- }
- static internal Control ControlFromHandle(IntPtr hWnd) {
- ControlNativeWindow window;
- window = (ControlNativeWindow)NativeWindow.FromHandle (hWnd);
- if (window != null) {
- return window.owner;
- }
- return null;
- }
- static internal Control ControlFromChildHandle (IntPtr handle) {
- ControlNativeWindow window;
- Hwnd hwnd = Hwnd.ObjectFromHandle (handle);
- while (hwnd != null) {
- window = (ControlNativeWindow)NativeWindow.FromHandle (handle);
- if (window != null) {
- return window.owner;
- }
- hwnd = hwnd.Parent;
- }
- return null;
- }
- protected override void WndProc(ref Message m) {
- owner.WindowTarget.OnMessage(ref m);
- }
- }
- private class ControlWindowTarget : IWindowTarget
- {
- private Control control;
- public ControlWindowTarget(Control control)
- {
- this.control = control;
- }
- public void OnHandleChange(IntPtr newHandle)
- {
- }
- public void OnMessage(ref Message m)
- {
- control.WndProc(ref m);
- }
- }
- #endregion
-
- #region Public Classes
- [ComVisible(true)]
- public class ControlAccessibleObject : AccessibleObject {
- IntPtr handle;
- #region ControlAccessibleObject Constructors
- public ControlAccessibleObject(Control ownerControl)
- : base (ownerControl)
- {
- if (ownerControl == null)
- throw new ArgumentNullException ("owner");
- handle = ownerControl.Handle;
- }
- #endregion // ControlAccessibleObject Constructors
- #region ControlAccessibleObject Public Instance Properties
- public override string DefaultAction {
- get {
- return base.DefaultAction;
- }
- }
- public override string Description {
- get {
- return base.Description;
- }
- }
- public IntPtr Handle {
- get {
- return handle;
- }
- set {
- // We don't want to let them set it
- }
- }
- public override string Help {
- get {
- return base.Help;
- }
- }
- public override string KeyboardShortcut {
- get {
- return base.KeyboardShortcut;
- }
- }
- public override string Name {
- get {
- return base.Name;
- }
- set {
- base.Name = value;
- }
- }
- public Control Owner {
- get {
- return base.owner;
- }
- }
- public override AccessibleObject Parent {
- get {
- return base.Parent;
- }
- }
- public override AccessibleRole Role {
- get {
- return base.Role;
- }
- }
- #endregion // ControlAccessibleObject Public Instance Properties
- #region ControlAccessibleObject Public Instance Methods
- public override int GetHelpTopic (out string fileName)
- {
- return base.GetHelpTopic (out fileName);
- }
- [MonoTODO ("Stub, does nothing")]
- public void NotifyClients (AccessibleEvents accEvent)
- {
- }
- [MonoTODO ("Stub, does nothing")]
- public void NotifyClients (AccessibleEvents accEvent, int childID)
- {
- }
- [MonoTODO ("Stub, does nothing")]
- public void NotifyClients (AccessibleEvents accEvent, int objectID, int childID)
- {
- }
- public override string ToString() {
- return "ControlAccessibleObject: Owner = " + owner.ToString() + ", Text: " + owner.text;
- }
- #endregion // ControlAccessibleObject Public Instance Methods
- }
- private class DoubleBuffer : IDisposable
- {
- public Region InvalidRegion;
- private Stack real_graphics;
- private object back_buffer;
- private Control parent;
- private bool pending_disposal;
-
- public DoubleBuffer (Control parent) {
- this.parent = parent;
- real_graphics = new Stack ();
- int width = parent.Width;
- int height = parent.Height;
- if (width < 1) width = 1;
- if (height < 1) height = 1;
- XplatUI.CreateOffscreenDrawable (parent.Handle, width, height, out back_buffer);
- Invalidate ();
- }
-
- public void Blit (PaintEventArgs pe) {
- Graphics buffered_graphics;
- buffered_graphics = XplatUI.GetOffscreenGraphics (back_buffer);
- XplatUI.BlitFromOffscreen (parent.Handle, pe.Graphics, back_buffer, buffered_graphics, pe.ClipRectangle);
- buffered_graphics.Dispose ();
- }
-
- public void Start (PaintEventArgs pe) {
- // We need to get the graphics for every paint.
- real_graphics.Push(pe.SetGraphics (XplatUI.GetOffscreenGraphics (back_buffer)));
- }
- public void End (PaintEventArgs pe) {
- Graphics buffered_graphics;
- buffered_graphics = pe.SetGraphics ((Graphics) real_graphics.Pop ());
- if (pending_disposal)
- Dispose ();
- else {
- XplatUI.BlitFromOffscreen (parent.Handle, pe.Graphics, back_buffer, buffered_graphics, pe.ClipRectangle);
- InvalidRegion.Exclude (pe.ClipRectangle);
- }
- buffered_graphics.Dispose ();
- }
-
- public void Invalidate ()
- {
- if (InvalidRegion != null)
- InvalidRegion.Dispose ();
- InvalidRegion = new Region (parent.ClientRectangle);
- }
-
- public void Dispose () {
- if (real_graphics.Count > 0) {
- pending_disposal = true;
- return;
- }
-
- XplatUI.DestroyOffscreenDrawable (back_buffer);
- if (InvalidRegion != null)
- InvalidRegion.Dispose ();
- InvalidRegion = null;
- back_buffer = null;
- GC.SuppressFinalize (this);
- }
- #region IDisposable Members
- void IDisposable.Dispose () {
- Dispose ();
- }
- #endregion
-
- ~DoubleBuffer () {
- Dispose ();
- }
- }
- [ListBindable (false)]
- [ComVisible (false)]
- public class ControlCollection : Layout.ArrangedElementCollection, IList, ICollection, ICloneable, IEnumerable {
- #region ControlCollection Local Variables
- ArrayList impl_list;
- Control [] all_controls;
- Control owner;
- #endregion // ControlCollection Local Variables
- #region ControlCollection Public Constructor
- public ControlCollection (Control owner)
- {
- this.owner = owner;
- }
- #endregion
- #region ControlCollection Public Instance Properties
- public Control Owner {
- get { return this.owner; }
- }
-
- public virtual Control this[string key] {
- get {
- int index = IndexOfKey (key);
-
- if (index >= 0)
- return this[index];
-
- return null;
- }
- }
-
- new public virtual Control this[int index] {
- get {
- if (index < 0 || index >= list.Count) {
- throw new ArgumentOutOfRangeException("index", index, "ControlCollection does not have that many controls");
- }
- return (Control)list[index];
- }
-
-
- }
- #endregion // ControlCollection Public Instance Properties
-
- #region ControlCollection Instance Methods
- public virtual void Add (Control value)
- {
- if (value == null)
- return;
- Form form_value = value as Form;
- Form form_owner = owner as Form;
- bool owner_permits_toplevels = (owner is MdiClient) || (form_owner != null && form_owner.IsMdiContainer);
- bool child_is_toplevel = value.GetTopLevel();
- bool child_is_mdichild = form_value != null && form_value.IsMdiChild;
- if (child_is_toplevel && !(owner_permits_toplevels && child_is_mdichild))
- throw new ArgumentException("Cannot add a top level control to a control.", "value");
-
- if (child_is_mdichild && form_value.MdiParent != null && form_value.MdiParent != owner && form_value.MdiParent != owner.Parent) {
- throw new ArgumentException ("Form cannot be added to the Controls collection that has a valid MDI parent.", "value");
- }
-
- value.recalculate_distances = true;
-
- if (Contains (value)) {
- owner.PerformLayout();
- return;
- }
- if (value.tab_index == -1) {
- int end;
- int index;
- int use;
- use = 0;
- end = owner.child_controls.Count;
- for (int i = 0; i < end; i++) {
- index = owner.child_controls[i].tab_index;
- if (index >= use) {
- use = index + 1;
- }
- }
- value.tab_index = use;
- }
- if (value.parent != null) {
- value.parent.Controls.Remove(value);
- }
- all_controls = null;
- list.Add (value);
- value.ChangeParent(owner);
- value.InitLayout();
- if (owner.Visible)
- owner.UpdateChildrenZOrder();
- owner.PerformLayout(value, "Parent");
- owner.OnControlAdded(new ControlEventArgs(value));
- }
-
- internal void AddToList (Control c)
- {
- all_controls = null;
- list.Add (c);
- }
- internal virtual void AddImplicit (Control control)
- {
- if (impl_list == null)
- impl_list = new ArrayList ();
- if (AllContains (control)) {
- owner.PerformLayout ();
- return;
- }
- if (control.parent != null) {
- control.parent.Controls.Remove(control);
- }
- all_controls = null;
- impl_list.Add (control);
- control.ChangeParent (owner);
- control.InitLayout ();
- if (owner.Visible)
- owner.UpdateChildrenZOrder ();
-
- // If we are adding a new control that isn't
- // visible, don't trigger a layout
- if (control.VisibleInternal)
- owner.PerformLayout (control, "Parent");
- }
- [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
- public virtual void AddRange (Control[] controls)
- {
- if (controls == null)
- throw new ArgumentNullException ("controls");
- owner.SuspendLayout ();
- try {
- for (int i = 0; i < controls.Length; i++)
- Add (controls[i]);
- } finally {
- owner.ResumeLayout ();
- }
- }
- internal virtual void AddRangeImplicit (Control [] controls)
- {
- if (controls == null)
- throw new ArgumentNullException ("controls");
- owner.SuspendLayout ();
- try {
- for (int i = 0; i < controls.Length; i++)
- AddImplicit (controls [i]);
- } finally {
- owner.ResumeLayout (false);
- }
- }
- new
- public virtual void Clear ()
- {
- all_controls = null;
- // MS sends remove events in reverse order
- while (list.Count > 0) {
- Remove((Control)list[list.Count - 1]);
- }
- }
- internal virtual void ClearImplicit ()
- {
- if (impl_list == null)
- return;
- all_controls = null;
- impl_list.Clear ();
- }
- public bool Contains (Control control)
- {
- return list.Contains (control);
- }
- internal bool ImplicitContains (Control value) {
- if (impl_list == null)
- return false;
- return impl_list.Contains (value);
- }
- internal bool AllContains (Control value) {
- return Contains (value) || ImplicitContains (value);
- }
- public virtual bool ContainsKey (string key)
- {
- return IndexOfKey (key) >= 0;
- }
- // LAMESPEC: MSDN says AE, MS implementation throws ANE
- public Control[] Find (string key, bool searchAllChildren)
- {
- if (string.IsNullOrEmpty (key))
- throw new ArgumentNullException ("key");
-
- ArrayList al = new ArrayList ();
-
- foreach (Control c in list) {
- if (c.Name.Equals (key, StringComparison.CurrentCultureIgnoreCase))
- al.Add (c);
-
- if (searchAllChildren)
- al.AddRange (c.Controls.Find (key, true));
- }
-
- return (Control[])al.ToArray (typeof (Control));
- }
- public int GetChildIndex(Control child) {
- return GetChildIndex(child, false);
- }
- public virtual int GetChildIndex(Control child, bool throwException) {
- int index;
- index=list.IndexOf(child);
- if (index==-1 && throwException) {
- throw new ArgumentException("Not a child control", "child");
- }
- return index;
- }
- public override IEnumerator
- GetEnumerator () {
- return new ControlCollectionEnumerator (list);
- }
- internal IEnumerator GetAllEnumerator () {
- Control [] res = GetAllControls ();
- return res.GetEnumerator ();
- }
- internal ArrayList ImplicitControls {
- get { return impl_list; }
- }
-
- internal Control [] GetAllControls () {
- if (all_controls != null)
- return all_controls;
- if (impl_list == null) {
- all_controls = (Control []) list.ToArray (typeof (Control));
- return all_controls;
- }
-
- all_controls = new Control [list.Count + impl_list.Count];
- impl_list.CopyTo (all_controls);
- list.CopyTo (all_controls, impl_list.Count);
- return all_controls;
- }
- public int IndexOf (Control control)
- {
- return list.IndexOf (control);
- }
- public virtual int IndexOfKey (string key)
- {
- if (string.IsNullOrEmpty (key))
- return -1;
-
- for (int i = 0; i < list.Count; i++)
- if (((Control)list[i]).Name.Equals (key, StringComparison.CurrentCultureIgnoreCase))
- return i;
-
- return -1;
- }
- public virtual void Remove (Control value)
- {
- if (value == null)
- return;
- all_controls = null;
- list.Remove(value);
- owner.PerformLayout(value, "Parent");
- owner.OnControlRemoved(new ControlEventArgs(value));
- ContainerControl container = owner.InternalGetContainerControl ();
- if (container != null) {
- // Inform any container controls about the loss of a child control
- // so that they can update their active control
- container.ChildControlRemoved (value);
- }
- value.ChangeParent(null);
- owner.UpdateChildrenZOrder();
- }
- internal virtual void RemoveImplicit (Control control)
- {
- if (impl_list != null) {
- all_controls = null;
- impl_list.Remove (control);
- owner.PerformLayout (control, "Parent");
- owner.OnControlRemoved (new ControlEventArgs (control));
- }
- control.ChangeParent (null);
- owner.UpdateChildrenZOrder ();
- }
- public void RemoveAt (int index)
- {
- if (index < 0 || index >= list.Count)
- throw new ArgumentOutOfRangeException("index", index, "ControlCollection does not have that many controls");
- Remove ((Control) list [index]);
- }
- public virtual void RemoveByKey (string key)
- {
- int index = IndexOfKey (key);
-
- if (index >= 0)
- RemoveAt (index);
- }
- public virtual void SetChildIndex(Control child, int newIndex)
- {
- if (child == null)
- throw new ArgumentNullException ("child");
- int old_index;
- old_index=list.IndexOf(child);
- if (old_index==-1) {
- throw new ArgumentException("Not a child control", "child");
- }
- if (old_index==newIndex) {
- return;
- }
- all_controls = null;
- list.RemoveAt(old_index);
- if (newIndex>list.Count) {
- list.Add(child);
- } else {
- list.Insert(newIndex, child);
- }
- child.UpdateZOrder();
- owner.PerformLayout();
- }
- #endregion // ControlCollection Private Instance Methods
- #region ControlCollection Interface Properties
- #endregion // ControlCollection Interface Properties
- #region ControlCollection Interface Methods
- int IList.Add (object control)
- {
- if (!(control is Control))
- throw new ArgumentException ("Object of type Control required", "control");
- if (control == null)
- throw new ArgumentException ("control", "Cannot add null controls");
- this.Add ((Control)control);
- return this.IndexOf ((Control)control);
- }
- void IList.Remove (object control)
- {
- if (!(control is Control))
- throw new ArgumentException ("Object of type Control required", "control");
- this.Remove ((Control)control);
- }
- Object ICloneable.Clone ()
- {
- ControlCollection clone = new ControlCollection (this.owner);
- clone.list = (ArrayList)list.Clone (); // FIXME: Do we need this?
- return clone;
- }
- #endregion // ControlCollection Interface Methods
-
- internal class ControlCollectionEnumerator : IEnumerator
- {
- private ArrayList list;
- int position = -1;
-
- public ControlCollectionEnumerator (ArrayList collection)
- {
- list = collection;
- }
-
- #region IEnumerator Members
- public object Current {
- get {
- try {
- return list[position];
- } catch (IndexOutOfRangeException) {
- throw new InvalidOperationException ();
- }
- }
- }
- public bool MoveNext ()
- {
- position++;
- return (position < list.Count);
- }
- public void Reset ()
- {
- position = -1;
- }
- #endregion
- }
- }
- #endregion // ControlCollection Class
-
- #region Public Constructors
- public Control ()
- {
- if (WindowsFormsSynchronizationContext.AutoInstall)
- if (!(SynchronizationContext.Current is WindowsFormsSynchronizationContext))
- SynchronizationContext.SetSynchronizationContext (new WindowsFormsSynchronizationContext ());
- layout_type = LayoutType.Anchor;
- anchor_style = AnchorStyles.Top | AnchorStyles.Left;
- is_created = false;
- is_visible = true;
- is_captured = false;
- is_disposed = false;
- is_enabled = true;
- is_entered = false;
- layout_pending = false;
- is_toplevel = false;
- causes_validation = true;
- has_focus = false;
- layout_suspended = 0;
- mouse_clicks = 1;
- tab_index = -1;
- cursor = null;
- right_to_left = RightToLeft.Inherit;
- border_style = BorderStyle.None;
- background_color = Color.Empty;
- dist_right = 0;
- dist_bottom = 0;
- tab_stop = true;
- ime_mode = ImeMode.Inherit;
- use_compatible_text_rendering = true;
- show_keyboard_cues = false;
- show_focus_cues = SystemInformation.MenuAccessKeysUnderlined;
- use_wait_cursor = false;
- backgroundimage_layout = ImageLayout.Tile;
- use_compatible_text_rendering = Application.use_compatible_text_rendering;
- padding = this.DefaultPadding;
- maximum_size = new Size();
- minimum_size = new Size();
- margin = this.DefaultMargin;
- auto_size_mode = AutoSizeMode.GrowOnly;
- control_style = ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint |
- ControlStyles.Selectable | ControlStyles.StandardClick |
- ControlStyles.StandardDoubleClick;
- control_style |= ControlStyles.UseTextForAccessibility;
- parent = null;
- background_image = null;
- text = string.Empty;
- name = string.Empty;
- window_target = new ControlWindowTarget(this);
- window = new ControlNativeWindow(this);
- child_controls = CreateControlsInstance();
-
- bounds.Size = DefaultSize;
- client_size = ClientSizeFromSize (bounds.Size);
- client_rect = new Rectangle (Point.Empty, client_size);
- explicit_bounds = bounds;
- }
- public Control (Control parent, string text) : this()
- {
- Text=text;
- Parent=parent;
- }
- public Control (Control parent, string text, int left, int top, int width, int height) : this()
- {
- Parent=parent;
- SetBounds(left, top, width, height, BoundsSpecified.All);
- Text=text;
- }
- public Control (string text) : this()
- {
- Text=text;
- }
- public Control (string text, int left, int top, int width, int height) : this()
- {
- SetBounds(left, top, width, height, BoundsSpecified.All);
- Text=text;
- }
- private delegate void RemoveDelegate(object c);
- protected override void Dispose (bool disposing)
- {
- if (!is_disposed && disposing) {
- is_disposing = true;
- Capture = false;
- DisposeBackBuffer ();
- if (this.InvokeRequired) {
- if (Application.MessageLoop && IsHandleCreated) {
- this.BeginInvokeInternal(new MethodInvoker(DestroyHandle), null);
- }
- } else {
- DestroyHandle();
- }
- if (parent != null)
- parent.Controls.Remove(this);
- Control [] children = child_controls.GetAllControls ();
- for (int i=0; i<children.Length; i++) {
- children[i].parent = null; // Need to set to null or our child will try and remove from ourselves and crash
- children[i].Dispose();
- }
- }
- is_disposed = true;
- base.Dispose(disposing);
- }
- #endregion // Public Constructors
- #region Internal Properties
- internal Rectangle PaddingClientRectangle
- {
- get {
- return new Rectangle (
- ClientRectangle.Left + padding.Left,
- ClientRectangle.Top + padding.Top,
- ClientRectangle.Width - padding.Horizontal,
- ClientRectangle.Height - padding.Vertical);
- }
- }
- private MenuTracker active_tracker;
-
- internal MenuTracker ActiveTracker {
- get { return active_tracker; }
- set {
- if (value == active_tracker)
- return;
- Capture = value != null;
- active_tracker = value;
- }
- }
- // Control is currently selected, like Focused, except maintains state
- // when Form loses focus
- internal bool InternalSelected {
- get {
- IContainerControl container;
-
- container = GetContainerControl();
-
- if (container != null && container.ActiveControl == this)
- return true;
-
- return false;
- }
- }
- // Looks for focus in child controls
- // and also in the implicit ones
- internal bool InternalContainsFocus {
- get {
- IntPtr focused_window;
- focused_window = XplatUI.GetFocus();
- if (IsHandleCreated) {
- if (focused_window == Handle)
- return true;
- foreach (Control child_control in child_controls.GetAllControls ())
- if (child_control.InternalContainsFocus)
- return true;
- }
- return false;
- }
- }
-
- // Mouse is currently within the control's bounds
- internal bool Entered {
- get { return this.is_entered; }
- }
- internal bool VisibleInternal {
- get { return is_visible; }
- }
- internal LayoutType ControlLayoutType {
- get { return layout_type; }
- }
- internal BorderStyle InternalBorderStyle {
- get {
- return border_style;
- }
- set {
- if (!Enum.IsDefined (typeof (BorderStyle), value))
- throw new InvalidEnumArgumentException (string.Format("Enum argument value '{0}' is not valid for BorderStyle", value));
- if (border_style != value) {
- border_style = value;
- if (IsHandleCreated) {
- XplatUI.SetBorderStyle (window.Handle, (FormBorderStyle)border_style);
- RecreateHandle ();
- Refresh ();
- } else
- client_size = ClientSizeFromSize (bounds.Size);
- }
- }
- }
-
- internal Size InternalClientSize { set { this.client_size = value; } }
- internal virtual bool ActivateOnShow { get { return true; } }
- internal Rectangle ExplicitBounds { get { return this.explicit_bounds; } set { this.explicit_bounds = value; } }
- internal bool ValidationFailed {
- get {
- ContainerControl c = InternalGetContainerControl ();
- if (c != null)
- return c.validation_failed;
- return false;
- }
- set {
- ContainerControl c = InternalGetContainerControl ();
- if (c != null)
- c.validation_failed = value;
- }
- }
- #endregion // Internal Properties
- #region Private & Internal Methods
-
- void IDropTarget.OnDragDrop (DragEventArgs drgEvent)
- {
- OnDragDrop (drgEvent);
- }
-
- void IDropTarget.OnDragEnter (DragEventArgs drgEvent)
- {
- OnDragEnter (drgEvent);
- }
-
- void IDropTarget.OnDragLeave (EventArgs e)
- {
- OnDragLeave (e);
- }
- void IDropTarget.OnDragOver (DragEventArgs drgEvent)
- {
- OnDragOver (drgEvent);
- }
- internal IAsyncResult BeginInvokeInternal (Delegate method, object [] args) {
- return BeginInvokeInternal (method, args, FindControlToInvokeOn ());
- }
- internal IAsyncResult BeginInvokeInternal (Delegate method, object [] args, Control control) {
- AsyncMethodResult result;
- AsyncMethodData data;
- result = new AsyncMethodResult ();
- data = new AsyncMethodData ();
- data.Handle = control.GetInvokableHandle ();
- data.Method = method;
- data.Args = args;
- data.Result = result;
- if (!ExecutionContext.IsFlowSuppressed ()) {
- data.Context = ExecutionContext.Capture ();
- }
- XplatUI.SendAsyncMethod (data);
- return result;
- }
- // The CheckForIllegalCrossThreadCalls in the #if 2.0 of
- // Control.Handle throws an exception when we are trying
- // to get the Handle to properly invoke on. This avoids that.
- private IntPtr GetInvokableHandle ()
- {
- if (!IsHandleCreated)
- CreateHandle ();
- return window.Handle;
- }
- internal void PointToClient (ref int x, ref int y) {
- XplatUI.ScreenToClient (Handle, ref x, ref y);
- }
- internal void PointToScreen (ref int x, ref int y) {
- XplatUI.ClientToScreen (Handle, ref x, ref y);
- }
- internal bool IsRecreating {
- get {
- return is_recreating;
- }
- }
- internal Graphics DeviceContext {
- get { return Hwnd.GraphicsContext; }
- }
- // An internal way to have a fixed height
- // Basically for DataTimePicker 2.0
- internal virtual int OverrideHeight (int height)
- {
- return height;
- }
-
- private void ProcessActiveTracker (ref Message m)
- {
- bool is_up = ((Msg) m.Msg == Msg.WM_LBUTTONUP) ||
- ((Msg) m.Msg == Msg.WM_RBUTTONUP);
-
- MouseButtons mb = FromParamToMouseButtons ((int) m.WParam.ToInt32 ());
-
- // We add in the button that was released (not sent in WParam)
- if (is_up) {
- switch ((Msg)m.Msg) {
- case Msg.WM_LBUTTONUP:
- mb |= MouseButtons.Left;
- break;
- case Msg.WM_RBUTTONUP:
- mb |= MouseButtons.Right;
- break;
- }
- }
-
- MouseEventArgs args = new MouseEventArgs (
- mb,
- mouse_clicks,
- Control.MousePosition.X,
- Control.MousePosition.Y,
- 0);
- if (is_up) {
- active_tracker.OnMouseUp (args);
- mouse_clicks = 1;
- } else {
- if (!active_tracker.OnMouseDown (args)) {
- Control control = GetRealChildAtPoint (Cursor.Position);
- if (control != null) {
- Point pt = control.PointToClient (Cursor.Position);
- XplatUI.SendMessage (control.Handle,
- (Msg)m.Msg,
- m.WParam,
- MakeParam (pt.X, pt.Y));
- }
- }
- }
- }
- private Control FindControlToInvokeOn ()
- {
- Control p = this;
- do {
- if (p.IsHandleCreated)
- break;
- p = p.parent;
- } while (p != null);
- if (p == null || !p.IsHandleCreated)
- throw new InvalidOperationException ("Cannot call Invoke or BeginInvoke on a control until the window handle is created");
-
- return p;
- }
- private void InvalidateBackBuffer () {
- if (backbuffer != null)
- backbuffer.Invalidate ();
- }
- private DoubleBuffer GetBackBuffer () {
- if (backbuffer == null)
- backbuffer = new DoubleBuffer (this);
- return backbuffer;
- }
- private void DisposeBackBuffer () {
- if (backbuffer != null) {
- backbuffer.Dispose ();
- backbuffer = null;
- }
- }
- internal static void SetChildColor(Control parent) {
- Control child;
- for (int i=0; i < parent.child_controls.Count; i++) {
- child=parent.child_controls[i];
- if (child.child_controls.Count>0) {
- SetChildColor(child);
- }
- }
- }
- internal bool Select(Control control) {
- IContainerControl container;
- if (control == null) {
- return false;
- }
- container = GetContainerControl();
- if (container != null && (Control)container != control) {
- container.ActiveControl = control;
- if (container.ActiveControl == control && !control.has_focus && control.IsHandleCreated)
- XplatUI.SetFocus(control.window.Handle);
- }
- else if (control.IsHandleCreated) {
- XplatUI.SetFocus(control.window.Handle);
- }
- return true;
- }
- internal virtual void DoDefaultAction() {
- // Only here to be overriden by our actual controls; this is needed by the accessibility class
- }
- internal static IntPtr MakeParam (int low, int high){
- return new IntPtr (high << 16 | low & 0xffff);
- }
- internal static int LowOrder (int param) {
- return ((int)(short)(param & 0xffff));
- }
- internal static int HighOrder (long param) {
- return ((int)(short)(param >> 16));
- }
- // This method exists so controls overriding OnPaintBackground can have default background painting done
- internal virtual void PaintControlBackground (PaintEventArgs pevent) {
- bool tbstyle_flat = ((CreateParams.Style & (int) ToolBarStyles.TBSTYLE_FLAT) != 0);
- // If we have transparent background
- if (((BackColor.A != 0xff) && GetStyle(ControlStyles.SupportsTransparentBackColor)) || tbstyle_flat) {
- if (parent != null) {
- PaintEventArgs parent_pe;
- GraphicsState state;
- parent_pe = new PaintEventArgs(pevent.Graphics, new Rectangle(pevent.ClipRectangle.X + Left, pevent.ClipRectangle.Y + Top, pevent.ClipRectangle.Width, pevent.ClipRectangle.Height));
- state = parent_pe.Graphics.Save();
- parent_pe.Graphics.TranslateTransform(-Left, -Top);
- parent.OnPaintBackground(parent_pe);
- parent_pe.Graphics.Restore(state);
- state = parent_pe.Graphics.Save();
- parent_pe.Graphics.TranslateTransform(-Left, -Top);
- parent.OnPaint(parent_pe);
- parent_pe.Graphics.Restore(state);
- parent_pe.SetGraphics(null);
- }
- }
- if ((clip_region != null) && (XplatUI.UserClipWontExposeParent)) {
- if (parent != null) {
- PaintEventArgs parent_pe;
- Region region;
- GraphicsState state;
- Hwnd hwnd;
- hwnd = Hwnd.ObjectFromHandle(Handle);
- if (hwnd != null) {
- parent_pe = new PaintEventArgs(pevent.Graphics, new Rectangle(pevent.ClipRectangle.X + Left, pevent.ClipRectangle.Y + Top, pevent.ClipRectangle.Width, pevent.ClipRectangle.Height));
- region = new Region ();
- region.MakeEmpty();
- region.Union(ClientRectangle);
- foreach (Rectangle r in hwnd.ClipRectangles) {
- region.Union (r);
- }
- state = parent_pe.Graphics.Save();
- parent_pe.Graphics.Clip = region;
- parent_pe.Graphics.TranslateTransform(-Left, -Top);
- parent.OnPaintBackground(parent_pe);
- parent_pe.Graphics.Restore(state);
- state = parent_pe.Graphics.Save();
- parent_pe.Graphics.Clip = region;
- parent_pe.Graphics.TranslateTransform(-Left, -Top);
- parent.OnPaint(parent_pe);
- parent_pe.Graphics.Restore(state);
- parent_pe.SetGraphics(null);
- region.Intersect(clip_region);
- pevent.Graphics.Clip = region;
- }
- }
- }
- if (background_image == null) {
- if (!tbstyle_flat) {
- Rectangle paintRect = pevent.ClipRectangle;
- Brush pen = ThemeEngine.Current.ResPool.GetSolidBrush(BackColor);
- pevent.Graphics.FillRectangle(pen, paintRect);
- }
- return;
- }
- DrawBackgroundImage (pevent.Graphics);
- }
- void DrawBackgroundImage (Graphics g) {
- Rectangle drawing_rectangle = new Rectangle ();
- g.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush (BackColor), ClientRectangle);
-
- switch (backgroundimage_layout)
- {
- case ImageLayout.Tile:
- using (TextureBrush b = new TextureBrush (background_image, WrapMode.Tile)) {
- g.FillRectangle (b, ClientRectangle);
- }
- return;
- case ImageLayout.Center:
- drawing_rectangle.Location = new Point (ClientSize.Width / 2 - background_image.Width / 2, ClientSize.Height / 2 - background_image.Height / 2);
- drawing_rectangle.Size = background_image.Size;
- break;
- case ImageLayout.None:
- drawing_rectangle.Location = Point.Empty;
- drawing_rectangle.Size = background_image.Size;
- break;
- case ImageLayout.Stretch:
- drawing_rectangle = ClientRectangle;
- break;
- case ImageLayout.Zoom:
- drawing_rectangle = ClientRectangle;
- if ((float)background_image.Width / (float)background_image.Height < (float)drawing_rectangle.Width / (float) drawing_rectangle.Height) {
- drawing_rectangle.Width = (int) (background_image.Width * ((float)drawing_rectangle.Height / (float)background_image.Height));
- drawing_rectangle.X = (ClientRectangle.Width - drawing_rectangle.Width) / 2;
- } else {
- drawing_rectangle.Height = (int) (background_image.Height * ((float)drawing_rectangle.Width / (float)background_image.Width));
- drawing_rectangle.Y = (ClientRectangle.Height - drawing_rectangle.Height) / 2;
- }
- break;
- default:
- return;
- }
- g.DrawImage (background_image, drawing_rectangle);
- }
- internal virtual void DndEnter (DragEventArgs e) {
- try {
- OnDragEnter (e);
- } catch { }
- }
- internal virtual void DndOver (DragEventArgs e) {
- try {
- OnDragOver (e);
- } catch { }
- }
- internal virtual void DndDrop (DragEventArgs e) {
- try {
- OnDragDrop (e);
- } catch (Exception exc) {
- Console.Error.WriteLine ("MWF: Exception while dropping:");
- Console.Error.WriteLine (exc);
- }
- }
- internal virtual void DndLeave (EventArgs e) {
- try {
- OnDragLeave (e);
- } catch { }
- }
- internal virtual void DndFeedback(GiveFeedbackEventArgs e) {
- try {
- OnGiveFeedback(e);
- } catch { }
- }
- internal virtual void DndContinueDrag(QueryContinueDragEventArgs e) {
- try {
- OnQueryContinueDrag(e);
- } catch { }
- }
-
- internal static MouseButtons FromParamToMouseButtons (long param) {
- MouseButtons buttons = MouseButtons.None;
-
- if ((param & (long) MsgButtons.MK_LBUTTON) != 0)
- buttons |= MouseButtons.Left;
- if ((param & (long)MsgButtons.MK_MBUTTON) != 0)
- buttons |= MouseButtons.Middle;
- if ((param & (long)MsgButtons.MK_RBUTTON) != 0)
- buttons |= MouseButtons.Right;
-
- return buttons;
- }
- internal virtual void FireEnter () {
- OnEnter (EventArgs.Empty);
- }
- internal virtual void FireLeave () {
- OnLeave (EventArgs.Empty);
- }
- internal virtual void FireValidating (CancelEventArgs ce) {
- OnValidating (ce);
- }
- internal virtual void FireValidated () {
- OnValidated (EventArgs.Empty);
- }
- internal virtual bool ProcessControlMnemonic(char charCode) {
- return ProcessMnemonic(charCode);
- }
- private static Control FindFlatForward(Control container, Control start) {
- Control found;
- int index;
- int end;
- bool hit;
- found = null;
- end = container.child_controls.Count;
- hit = false;
- if (start != null) {
- index = start.tab_index;
- } else {
- index = -1;
- }
- for (int i = 0; i < end; i++) {
- if (start == container.child_controls[i]) {
- hit = true;
- continue;
- }
- if (found == null || found.tab_index > container.child_controls[i].tab_index) {
- if (container.child_controls[i].tab_index > index || (hit && container.child_controls[i].tab_index == index)) {
- found = container.child_controls[i];
- }
- }
- }
- return found;
- }
- private static Control FindControlForward(Control container, Control start) {
- Control found;
- found = null;
- if (start == null) {
- return FindFlatForward(container, start);
- }
- if (start.child_controls != null && start.child_controls.Count > 0 &&
- (start == container || !((start is IContainerControl) && start.GetStyle(ControlStyles.ContainerControl)))) {
- return FindControlForward(start, null);
- }
- else {
- while (start != container) {
- found = FindFlatForward(start.parent, start);
- if (found != null) {
- return found;
- }
- start = start.parent;
- }
- }
- return null;
- }
- private static Control FindFlatBackward(Control container, Control start) {
- Control found;
- int index;
- int end;
- bool hit;
- found = null;
- end = container.child_controls.Count;
- hit = false;
- if (start != null) {
- index = start.tab_index;
- } else {
- index = int.MaxValue;
- }
- for (int i = end - 1; i >= 0; i--) {
- if (start == container.child_controls[i]) {
- hit = true;
- continue;
- }
- if (found == null || found.tab_index < container.child_controls[i].tab_index) {
- if (container.child_controls[i].tab_index < index || (hit && container.child_controls[i].tab_index == index))
- found = container.child_controls[i];
- }
- }
- return found;
- }
- private static Control FindControlBackward(Control container, Control start) {
- Control found = null;
- if (start == null) {
- found = FindFlatBackward(container, start);
- }
- else if (start != container) {
- if (start.parent != null) {
- found = FindFlatBackward(start.parent, start);
- if (found == null) {
- if (start.parent != container)
- return start.parent;
- return null;
- }
- }
- }
-
- if (found == null || start.parent == null)
- found = start;
- while (found != null && (found == container || (!((found is IContainerControl) && found.GetStyle(ControlStyles.ContainerControl))) &&
- found.child_controls != null && found.child_controls.Count > 0)) {
- // while (ctl.child_controls != null && ctl.child_controls.Count > 0 &&
- // (ctl == this || (!((ctl is IContainerControl) && ctl.GetStyle(ControlStyles.ContainerControl))))) {
- found = FindFlatBackward(found, null);
- }
- return found;
- /*
- Control found;
- found = null;
- if (start != null) {
- found = FindFlatBackward(start.parent, start);
- if (found == null) {
- if (start.parent != container) {
- return start.parent;
- }
- }
- }
- if (found == null) {
- found = FindFlatBackward(container, start);
- }
- if (container != start) {
- while ((found != null) && (!found.Contains(start)) && found.child_controls != null && found.child_controls.Count > 0 && !(found is IContainerControl)) {// || found.GetStyle(ControlStyles.ContainerControl))) {
- found = FindControlBackward(found, null);
- if (found != null) {
- return found;
- }
- }
- }
- return found;
- */
- }
- internal virtual void HandleClick(int clicks, MouseEventArgs me) {
- bool standardclick = GetStyle (ControlStyles.StandardClick);
- bool standardclickclick = GetStyle (ControlStyles.StandardDoubleClick);
- if ((clicks > 1) && standardclick && standardclickclick) {
- OnDoubleClick (me);
- OnMouseDoubleClick (me);
- } else if (clicks == 1 && standardclick && !ValidationFailed) {
- OnClick (me);
- OnMouseClick (me);
- }
- }
-
- internal void CaptureWithConfine (Control ConfineWindow) {
- if (this.IsHandleCreated && !is_captured) {
- is_captured = true;
- XplatUI.GrabWindow (this.window.Handle, ConfineWindow.Handle);
- }
- }
- private void CheckDataBindings () {
- if (data_bindings == null)
- return;
- foreach (Binding binding in data_bindings) {
- binding.Check ();
- }
- }
- private void ChangeParent(Control new_parent) {
- bool pre_enabled;
- bool pre_visible;
- Font pre_font;
- Color pre_fore_color;
- Color pre_back_color;
- RightToLeft pre_rtl;
- // These properties are inherited from our parent
- // Get them pre parent-change and then send events
- // if they are changed after we have our new parent
- pre_enabled = Enabled;
- pre_visible = Visible;
- pre_font = Font;
- pre_fore_color = ForeColor;
- pre_back_color = BackColor;
- pre_rtl = RightToLeft;
- // MS doesn't seem to send a CursorChangedEvent
- parent = new_parent;
- Form frm = this as Form;
- if (frm != null) {
- frm.ChangingParent (new_parent);
- } else if (IsHandleCreated) {
- IntPtr parent_handle = IntPtr.Zero;
- if (new_parent != null && new_parent.IsHandleCreated)
- parent_handle = new_parent.Handle;
- XplatUI.SetParent (Handle, parent_handle);
- }
-
- OnParentChanged(EventArgs.Empty);
- if (pre_enabled != Enabled) {
- OnEnabledChanged(EventArgs.Empty);
- }
- if (pre_visible != Visible) {
- OnVisibleChanged(EventArgs.Empty);
- }
- if (pre_font != Font) {
- OnFontChanged(EventArgs.Empty);
- }
- if (pre_fore_color != ForeColor) {
- OnForeColorChanged(EventArgs.Empty);
- }
- if (pre_back_color != BackColor) {
- OnBackColorChanged(EventArgs.Empty);
- }
- if (pre_rtl != RightToLeft) {
- // MS sneaks a OnCreateControl and OnHandleCreated in here, I guess
- // because when RTL changes they have to recreate the win32 control
- // We don't really need that (until someone runs into compatibility issues)
- OnRightToLeftChanged(EventArgs.Empty);
- }
- if ((new_parent != null) && new_parent.Created && is_visible && !Created) {
- CreateControl();
- }
- if ((binding_context == null) && Created) {
- OnBindingContextChanged(EventArgs.Empty);
- }
- }
- // Sometimes we need to do this calculation without it being virtual (constructor)
- internal Size InternalSizeFromClientSize (Size clientSize)
- {
- Rectangle ClientRect;
- Rectangle WindowRect;
- CreateParams cp;
- ClientRect = new Rectangle (0, 0, clientSize.Width, clientSize.Height);
- cp = this.CreateParams;
- if (XplatUI.CalculateWindowRect (ref ClientRect, cp, null, out WindowRect))
- return new Size (WindowRect.Width, WindowRect.Height);
- return Size.Empty;
- }
-
- internal Size ClientSizeFromSize (Size size)
- {
- // Calling this gives us the difference in Size and ClientSize.
- // We just have to apply that difference to our given size.
- Size client_size = this.InternalSizeFromClientSize (size);
-
- if (client_size == Size.Empty)
- return Size.Empty;
-
- return new Size (size.Width - (client_size.Width - size.Width), size.Height - (client_size.Height - size.Height));
- }
-
- internal CreateParams GetCreateParams ()
- {
- return CreateParams;
- }
- internal virtual Size GetPreferredSizeCore (Size proposedSize)
- {
- return this.explicit_bounds.Size;
- }
- private void UpdateDistances() {
- if (parent != null) {
- if (bounds.Width >= 0)
- dist_right = parent.ClientSize.Width - bounds.X - bounds.Width;
- if (bounds.Height >= 0)
- dist_bottom = parent.ClientSize.Height - bounds.Y - bounds.Height;
- recalculate_distances = false;
- }
- }
-
- private Cursor GetAvailableCursor ()
- {
- if (Cursor != null && Enabled) {
- return Cursor;
- }
- if (Parent != null) {
- return Parent.GetAvailableCursor ();
- }
- return Cursors.Default;
- }
-
- private void UpdateCursor ()
- {
- if (!IsHandleCreated)
- return;
-
- if (!Enabled) {
- XplatUI.SetCursor (window.Handle, GetAvailableCursor ().handle);
- return;
- }
- Point pt = PointToClient (Cursor.Position);
- if (!bounds.Contains (pt) && !Capture)
- return;
- if (cursor != null || use_wait_cursor) {
- XplatUI.SetCursor (window.Handle, Cursor.handle);
- } else {
- XplatUI.SetCursor (window.Handle, GetAvailableCursor ().handle);
- }
- }
-
- private bool UseDoubleBuffering {
- get {
- if (!ThemeEngine.Current.DoubleBufferingSupported)
- return false;
- // Since many of .Net's controls are unmanaged, they are doublebuffered
- // even though their bits may not be set in managed land. This allows
- // us to doublebuffer as well without affecting public style bits.
- if (force_double_buffer)
- return true;
-
- if (DoubleBuffered)
- return true;
- return (control_style & ControlStyles.DoubleBuffer) != 0;
- }
- }
- internal void OnSizeInitializedOrChanged ()
- {
- Form form = this as Form;
- if (form != null && form.WindowManager != null)
- ThemeEngine.Current.ManagedWindowOnSizeInitializedOrChanged (form);
- }
- #endregion // Private & Internal Methods
- #region Public Static Properties
- public static Color DefaultBackColor {
- get {
- return ThemeEngine.Current.DefaultControlBackColor;
- }
- }
- public static Font DefaultFont {
- get {
- return ThemeEngine.Current.DefaultFont;
- }
- }
- public static Color De…
Large files files are truncated, but you can click here to view the full file