Author: gert
Date: 2006-12-11 14:27:43 -0500 (Mon, 11 Dec 2006)
New Revision: 69352
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ChangeLog
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ControlTest.cs
Log:
* Control.cs: Verify value set for Dock property. Code formatting
updates.
* ControlTest.cs: Added test for invalid Dock value.
Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
2006-12-11 19:06:23 UTC (rev 69351)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
2006-12-11 19:27:43 UTC (rev 69352)
@@ -1,3 +1,8 @@
+2006-12-11 Gert Driesen <[EMAIL PROTECTED]>
+
+ * Control.cs: Verify value set for Dock property. Code formatting
+ updates.
+
2006-12-11 Jackson Harper <[EMAIL PROTECTED]>
* TextControl.cs: Draw the caret and the selection when a flag is
Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs
2006-12-11 19:06:23 UTC (rev 69351)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs
2006-12-11 19:27:43 UTC (rev 69352)
@@ -56,7 +56,7 @@
[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
- {
+ {
#region Local Variables
// Basic
@@ -332,9 +332,9 @@
if (value == null)
return;
- if (Contains (value)) {
+ if (Contains (value)) {
owner.PerformLayout();
- return;
+ return;
}
if (value.tab_index == -1) {
@@ -695,8 +695,8 @@
#endregion // ControlCollection Class
#region Public Constructors
- public Control() {
-
+ public Control()
+ {
anchor_style = AnchorStyles.Top | AnchorStyles.Left;
is_created = false;
@@ -709,7 +709,7 @@
is_toplevel = false;
causes_validation = true;
has_focus = false;
- layout_suspended = 0;
+ layout_suspended = 0;
mouse_clicks = 1;
tab_index = -1;
cursor = null;
@@ -743,7 +743,7 @@
parent = null;
background_image = null;
text = string.Empty;
- name = string.Empty;
+ name = string.Empty;
window = new ControlNativeWindow(this);
child_controls = CreateControlsInstance();
@@ -804,7 +804,6 @@
DestroyHandle();
}
-
if (parent != null) {
parent.Controls.Remove(this);
}
@@ -849,9 +848,7 @@
AsyncMethodData data;
if (!disposing) {
- Control p;
-
- p = this;
+ Control p = this;
do {
if (!p.IsHandleCreated) {
throw new
InvalidOperationException("Cannot call Invoke or InvokeAsync on a control until
the window handle is created");
@@ -1122,7 +1119,7 @@
buttons |= MouseButtons.Middle;
if ((param & (int) MsgButtons.MK_RBUTTON) != 0)
- buttons |= MouseButtons.Right;
+ buttons |= MouseButtons.Right;
return buttons;
@@ -1166,7 +1163,6 @@
index = -1;
}
-
for (int i = 0, pos = -1; i < end; i++) {
if (start == container.child_controls[i]) {
pos = i;
@@ -1336,7 +1332,6 @@
}
}
-
private void ChangeParent(Control new_parent) {
bool pre_enabled;
bool pre_visible;
@@ -1810,7 +1805,7 @@
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public bool ContainsFocus {
get {
- IntPtr focused_window;
+ IntPtr focused_window;
focused_window = XplatUI.GetFocus();
if (IsHandleCreated) {
@@ -1877,7 +1872,7 @@
set {
if (cursor != value) {
- Point pt;
+ Point pt;
cursor = value;
@@ -1949,6 +1944,11 @@
return;
}
+ if (!Enum.IsDefined (typeof (DockStyle),
value)) {
+ throw new InvalidEnumArgumentException
("value", (int) value,
+ typeof (DockStyle));
+ }
+
dock_style = value;
if (dock_style == DockStyle.None) {
@@ -1990,12 +1990,12 @@
if (old_value != value && !value &&
this.has_focus)
SelectNextControl(this, true, true,
true, true);
- OnEnabledChanged (EventArgs.Empty);
+ OnEnabledChanged (EventArgs.Empty);
}
}
[EditorBrowsable(EditorBrowsableState.Advanced)]
- [Browsable(false)]
+ [Browsable(false)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public virtual bool Focused {
get {
@@ -2004,7 +2004,7 @@
}
[DispId(-512)]
- [AmbientValue(null)]
+ [AmbientValue(null)]
[Localizable(true)]
[MWFCategory("Appearance")]
public virtual Font Font {
@@ -2026,9 +2026,9 @@
return;
}
- font = value;
+ font = value;
Invalidate();
- OnFontChanged (EventArgs.Empty);
+ OnFontChanged (EventArgs.Empty);
}
}
@@ -2104,10 +2104,10 @@
public ImeMode ImeMode {
get {
if (ime_mode == ImeMode.Inherit) {
- if (parent != null)
- return parent.ImeMode;
- else
- return ImeMode.NoControl; //
default value
+ if (parent != null)
+ return parent.ImeMode;
+ else
+ return ImeMode.NoControl; //
default value
}
return ime_mode;
}
@@ -2122,7 +2122,7 @@
}
[EditorBrowsable(EditorBrowsableState.Advanced)]
- [Browsable(false)]
+ [Browsable(false)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public bool InvokeRequired {
// ISynchronizeInvoke
get {
@@ -2262,13 +2262,13 @@
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public string ProductName {
get {
- Type t = typeof (AssemblyProductAttribute);
- Assembly assembly = GetType().Module.Assembly;
- object [] attrs = assembly.GetCustomAttributes
(t, false);
- AssemblyProductAttribute a = null;
- // On MS we get a NullRefException if product
attribute is not
- // set.
- if (attrs != null && attrs.Length > 0)
+ Type t = typeof (AssemblyProductAttribute);
+ Assembly assembly = GetType().Module.Assembly;
+ object [] attrs = assembly.GetCustomAttributes
(t, false);
+ AssemblyProductAttribute a = null;
+ // On MS we get a NullRefException if product
attribute is not
+ // set.
+ if (attrs != null && attrs.Length > 0)
a = (AssemblyProductAttribute) attrs
[0];
return a.Product;
}
@@ -2679,7 +2679,7 @@
}
public static bool IsMnemonic(char charCode, string text) {
- int amp;
+ int amp;
amp = text.IndexOf('&');
@@ -3175,7 +3175,7 @@
BackColor = Color.Empty;
}
- [EditorBrowsable(EditorBrowsableState.Never)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
public void ResetBindings() {
data_bindings.Clear();
}
@@ -3282,7 +3282,7 @@
c.Select (true, true);
return true;
}
- } while (c != ctl); // If we wrap back to ourselves
we stop
+ } while (c != ctl); // If we wrap back to ourselves we
stop
return false;
}
@@ -4318,7 +4318,7 @@
}
default:
- DefWndProc(ref m);
+ DefWndProc(ref m);
return;
}
}
@@ -4996,7 +4996,7 @@
add { Events.AddHandler (DockChangedEvent, value); }
remove { Events.RemoveHandler (DockChangedEvent,
value); }
}
-
+
public event EventHandler DoubleClick {
add { Events.AddHandler (DoubleClickEvent, value); }
remove { Events.RemoveHandler (DoubleClickEvent,
value); }
@@ -5021,7 +5021,7 @@
add { Events.AddHandler (DragOverEvent, value); }
remove { Events.RemoveHandler (DragOverEvent, value); }
}
-
+
public event EventHandler EnabledChanged {
add { Events.AddHandler (EnabledChangedEvent, value); }
remove { Events.RemoveHandler (EnabledChangedEvent,
value); }
Modified:
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ChangeLog
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ChangeLog
2006-12-11 19:06:23 UTC (rev 69351)
+++ trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ChangeLog
2006-12-11 19:27:43 UTC (rev 69352)
@@ -1,3 +1,7 @@
+2006-12-11 Gert Driesen <[EMAIL PROTECTED]>
+
+ * ControlTest.cs: Added test for invalid Dock value.
+
2006-12-11 Andreia Gaita <[EMAIL PROTECTED]>
* TabControlTest.cs: add tests to check if SelectedIndex is
Modified:
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ControlTest.cs
===================================================================
---
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ControlTest.cs
2006-12-11 19:06:23 UTC (rev 69351)
+++
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ControlTest.cs
2006-12-11 19:27:43 UTC (rev 69352)
@@ -6,11 +6,12 @@
//
using System;
-using System.Windows.Forms;
+using InvalidEnumArgumentException =
System.ComponentModel.InvalidEnumArgumentException;
using System.Drawing;
-using System.Threading;
using System.Reflection;
using System.Runtime.Remoting;
+using System.Threading;
+using System.Windows.Forms;
using NUnit.Framework;
@@ -906,6 +907,22 @@
}
[Test]
+ public void Dock_Value_Invalid ()
+ {
+ Control c = new Control ();
+ try {
+ c.Dock = (DockStyle) 666;
+ Assert.Fail ("#1");
+ } catch (InvalidEnumArgumentException ex) {
+ Assert.AreEqual (typeof
(InvalidEnumArgumentException), ex.GetType (), "#2");
+ Assert.IsNotNull (ex.Message, "#3");
+ Assert.IsNotNull (ex.ParamName, "#4");
+ Assert.AreEqual ("value", ex.ParamName, "#5");
+ Assert.IsNull (ex.InnerException, "#6");
+ }
+ }
+
+ [Test]
public void EnabledTest1() {
Control child;
Control parent;
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches