提交 869fd033 编写于 作者: M Miguel de Icaza

[winforms] Pass 4 of removing NET_2_0 from winforms

上级 60ca042c
......@@ -33,10 +33,8 @@ using System.Windows.Forms.Theming;
using System.Windows.Forms.VisualStyles;
namespace System.Windows.Forms {
#if NET_2_0
[ComVisibleAttribute (true)]
[ClassInterfaceAttribute (ClassInterfaceType.AutoDispatch)]
#endif
[DefaultEvent("SelectedIndexChanged")]
[DefaultProperty("TabPages")]
[Designer("System.Windows.Forms.Design.TabControlDesigner, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.IDesigner")]
......@@ -66,13 +64,10 @@ namespace System.Windows.Forms {
ToolTip.TipState tooltip_state = ToolTip.TipState.Down;
Timer tooltip_timer;
#if NET_2_0
private bool rightToLeftLayout;
#endif
#endregion // Fields
#region UIA Framework Events
#if NET_2_0
static object UIAHorizontallyScrollableChangedEvent = new object ();
internal event EventHandler UIAHorizontallyScrollableChanged {
......@@ -102,15 +97,12 @@ namespace System.Windows.Forms {
if (eh != null)
eh (this, e);
}
#endif
#endregion
#region UIA Framework Property
#if NET_2_0
internal double UIAHorizontalViewSize {
get { return LeftScrollButtonArea.Left * 100 / TabPages [TabCount - 1].TabBounds.Right; }
}
#endif
#endregion
#region Public Constructors
......@@ -171,14 +163,12 @@ namespace System.Windows.Forms {
set { base.BackgroundImage = value; }
}
#if NET_2_0
[Browsable (false)]
[EditorBrowsable (EditorBrowsableState.Never)]
public override ImageLayout BackgroundImageLayout {
get { return base.BackgroundImageLayout; }
set { base.BackgroundImageLayout = value; }
}
#endif
public override Rectangle DisplayRectangle {
get {
......@@ -186,13 +176,11 @@ namespace System.Windows.Forms {
}
}
#if NET_2_0
[EditorBrowsable (EditorBrowsableState.Never)]
protected override bool DoubleBuffered {
get { return base.DoubleBuffered; }
set { base.DoubleBuffered = value; }
}
#endif
[DefaultValue(TabDrawMode.Normal)]
public TabDrawMode DrawMode {
......@@ -223,9 +211,7 @@ namespace System.Windows.Forms {
}
}
#if NET_2_0
[RefreshProperties (RefreshProperties.Repaint)]
#endif
[DefaultValue(null)]
public ImageList ImageList {
get { return image_list; }
......@@ -279,9 +265,7 @@ namespace System.Windows.Forms {
[Localizable(true)]
public
#if NET_2_0
new
#endif
Point Padding {
get { return padding; }
set {
......@@ -295,7 +279,6 @@ namespace System.Windows.Forms {
}
#if NET_2_0
[MonoTODO ("RTL not supported")]
[Localizable (true)]
[DefaultValue (false)]
......@@ -308,7 +291,6 @@ namespace System.Windows.Forms {
}
}
}
#endif
[Browsable(false)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
......@@ -323,20 +305,12 @@ namespace System.Windows.Forms {
set {
if (value < -1) {
#if NET_2_0
throw new ArgumentOutOfRangeException ("SelectedIndex", "Value of '" + value + "' is valid for 'SelectedIndex'. " +
"'SelectedIndex' must be greater than or equal to -1.");
#else
throw new ArgumentException ("'" + value + "' is not a valid value for 'value'. " +
"'value' must be greater than or equal to -1.");
#endif
}
if (!this.IsHandleCreated) {
if (selected_index != value) {
selected_index = value;
#if !NET_2_0
OnSelectedIndexChanged (EventArgs.Empty);
#endif
}
return;
}
......@@ -353,27 +327,23 @@ namespace System.Windows.Forms {
return;
}
#if NET_2_0
TabControlCancelEventArgs ret = new TabControlCancelEventArgs (SelectedTab, selected_index, false, TabControlAction.Deselecting);
OnDeselecting (ret);
if (ret.Cancel)
return;
#endif
Focus ();
int old_index = selected_index;
int new_index = value;
selected_index = new_index;
#if NET_2_0
ret = new TabControlCancelEventArgs (SelectedTab, selected_index, false, TabControlAction.Selecting);
OnSelecting (ret);
if (ret.Cancel) {
selected_index = old_index;
return;
}
#endif
SuspendLayout ();
......@@ -492,11 +462,7 @@ namespace System.Windows.Forms {
}
}
#if NET_2_0
[Editor ("System.Windows.Forms.Design.TabPageCollectionEditor, " + Consts.AssemblySystem_Design, typeof (System.Drawing.Design.UITypeEditor))]
#else
[DefaultValue(null)]
#endif
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
[MergableProperty(false)]
public TabPageCollection TabPages {
......@@ -518,10 +484,8 @@ namespace System.Windows.Forms {
set {
show_slider = value;
#if NET_2_0
// UIA Framework Event: HorizontallyScrollable Changed
OnUIAHorizontallyScrollableChanged (EventArgs.Empty);
#endif
}
}
......@@ -613,7 +577,6 @@ namespace System.Windows.Forms {
return GetTab (index);
}
#if NET_2_0
public void SelectTab (TabPage tabPage)
{
if (tabPage == null)
......@@ -664,7 +627,6 @@ namespace System.Windows.Forms {
}
}
#endif
public override string ToString ()
{
......@@ -767,7 +729,6 @@ namespace System.Windows.Forms {
pe.Handled = true;
}
#if NET_2_0
protected override void OnEnter (EventArgs e)
{
base.OnEnter (e);
......@@ -835,7 +796,6 @@ namespace System.Windows.Forms {
if (this.SelectedTab != null)
this.SelectedTab.FireEnter ();
}
#endif
#endregion
......@@ -937,11 +897,7 @@ namespace System.Windows.Forms {
}
#endregion
#if NET_2_0
protected void UpdateTabSelection (bool updateFocus)
#else
protected void UpdateTabSelection (bool uiselected)
#endif
{
ResizeTabPages ();
}
......@@ -998,10 +954,8 @@ namespace System.Windows.Forms {
slider_pos++;
SizeTabs ();
#if NET_2_0
// UIA Framework Event: Horizontally Scrolled
OnUIAHorizontallyScrolled (EventArgs.Empty);
#endif
switch (this.Alignment) {
case TabAlignment.Top:
......@@ -1028,10 +982,8 @@ namespace System.Windows.Forms {
slider_pos--;
SizeTabs ();
#if NET_2_0
// UIA Framework Event: Horizontally Scrolled
OnUIAHorizontallyScrolled (EventArgs.Empty);
#endif
switch (this.Alignment) {
case TabAlignment.Top:
......@@ -1500,7 +1452,6 @@ namespace System.Windows.Forms {
this.Controls.SetChildIndex (value, index);
Redraw ();
}
#if NET_2_0
private void InsertTab (int index, TabPage value)
{
if (!tab_pages.Contains (value)) {
......@@ -1509,7 +1460,6 @@ namespace System.Windows.Forms {
this.Controls.SetChildIndex (value, index);
Redraw ();
}
#endif
internal void Redraw ()
{
if (!IsHandleCreated)
......@@ -1644,7 +1594,6 @@ namespace System.Windows.Forms {
remove { base.BackgroundImageChanged -= value; }
}
#if NET_2_0
[Browsable (false)]
[EditorBrowsable (EditorBrowsableState.Never)]
public new event EventHandler BackgroundImageLayoutChanged
......@@ -1652,7 +1601,6 @@ namespace System.Windows.Forms {
add { base.BackgroundImageLayoutChanged += value; }
remove { base.BackgroundImageLayoutChanged -= value; }
}
#endif
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
......@@ -1688,7 +1636,6 @@ namespace System.Windows.Forms {
remove { Events.RemoveHandler (SelectedIndexChangedEvent, value); }
}
#if NET_2_0
static object SelectedEvent = new object ();
public event TabControlEventHandler Selected {
......@@ -1726,14 +1673,11 @@ namespace System.Windows.Forms {
add { Events.AddHandler (RightToLeftLayoutChangedEvent, value); }
remove { Events.RemoveHandler (RightToLeftLayoutChangedEvent, value); }
}
#endif
#endregion // Events
#region Class TaControl.ControlCollection
#if NET_2_0
[ComVisible (false)]
#endif
public new class ControlCollection : System.Windows.Forms.Control.ControlCollection {
private TabControl owner;
......@@ -1821,7 +1765,6 @@ namespace System.Windows.Forms {
owner.SetTab (index, value);
}
}
#if NET_2_0
public virtual TabPage this [string key] {
get {
if (string.IsNullOrEmpty (key))
......@@ -1834,7 +1777,6 @@ namespace System.Windows.Forms {
return this[index];
}
}
#endif
internal int this[TabPage tabPage] {
get {
......@@ -1877,7 +1819,6 @@ namespace System.Windows.Forms {
owner.Controls.Add (value);
}
#if NET_2_0
public void Add (string text)
{
TabPage page = new TabPage (text);
......@@ -1907,7 +1848,6 @@ namespace System.Windows.Forms {
page.ImageKey = imageKey;
this.Add (page);
}
#endif
public void AddRange (TabPage [] pages)
{
......@@ -1929,13 +1869,11 @@ namespace System.Windows.Forms {
return owner.Controls.Contains (page);
}
#if NET_2_0
public virtual bool ContainsKey (string key)
{
int index = this.IndexOfKey (key);
return (index >= 0 && index < this.Count);
}
#endif
public IEnumerator GetEnumerator ()
{
......@@ -1947,7 +1885,6 @@ namespace System.Windows.Forms {
return owner.Controls.IndexOf (page);
}
#if NET_2_0
public virtual int IndexOfKey(string key)
{
if (string.IsNullOrEmpty (key))
......@@ -1962,7 +1899,6 @@ namespace System.Windows.Forms {
return -1;
}
#endif
public void Remove (TabPage value)
{
......@@ -1976,14 +1912,12 @@ namespace System.Windows.Forms {
owner.Invalidate ();
}
#if NET_2_0
public virtual void RemoveByKey (string key)
{
int index = this.IndexOfKey (key);
if (index >= 0 && index < this.Count)
this.RemoveAt (index);
}
#endif
void ICollection.CopyTo (Array dest, int index)
{
......@@ -2015,16 +1949,11 @@ namespace System.Windows.Forms {
return IndexOf (tabPage);
}
#if NET_2_0
void IList.Insert (int index, object tabPage)
#else
void IList.Insert (int index, object value)
#endif
{
throw new NotSupportedException ();
}
#if NET_2_0
public void Insert (int index, string text)
{
owner.InsertTab (index, new TabPage (text));
......@@ -2057,7 +1986,6 @@ namespace System.Windows.Forms {
owner.InsertTab (index, page);
page.ImageKey = imageKey;
}
#endif
void IList.Remove (object value)
{
TabPage page = value as TabPage;
......
......@@ -38,11 +38,9 @@ using System.Collections;
namespace System.Windows.Forms
{
#if NET_2_0
[ComVisible (true)]
[DefaultBindingProperty ("Text")]
[ClassInterface (ClassInterfaceType.AutoDispatch)]
#endif
[DefaultEvent("TextChanged")]
[Designer("System.Windows.Forms.Design.TextBoxBaseDesigner, " + Consts.AssemblySystem_Design)]
public abstract class TextBoxBase : Control
......@@ -154,11 +152,9 @@ namespace System.Windows.Forms
ResumeLayout ();
SetStyle(ControlStyles.UserPaint | ControlStyles.StandardClick, false);
#if NET_2_0
SetStyle(ControlStyles.UseTextForAccessibility, false);
base.SetAutoSizeMode (AutoSizeMode.GrowAndShrink);
#endif
canvas_width = ClientSize.Width;
canvas_height = ClientSize.Height;
......@@ -179,12 +175,10 @@ namespace System.Windows.Forms
return s.ToUpper();
}
#if NET_2_0
internal override Size GetPreferredSizeCore (Size proposedSize)
{
return new Size (Width, Height);
}
#endif
internal override void HandleClick (int clicks, MouseEventArgs me)
{
......@@ -228,21 +222,13 @@ namespace System.Windows.Forms
}
}
#if NET_2_0
[Browsable (false)]
[EditorBrowsable (EditorBrowsableState.Never)]
#endif
[DefaultValue(true)]
[Localizable(true)]
[RefreshProperties(RefreshProperties.Repaint)]
[MWFCategory("Behavior")]
public
#if NET_2_0
override
#else
virtual
#endif
bool AutoSize {
public override bool AutoSize {
get {
return auto_size;
}
......@@ -255,9 +241,6 @@ namespace System.Windows.Forms
ClientSize = new Size(ClientSize.Width, PreferredHeight);
}
}
#if NET_1_1
OnAutoSizeChanged(EventArgs.Empty);
#endif
}
}
}
......@@ -342,9 +325,7 @@ namespace System.Windows.Forms
}
}
#if NET_2_0
[MergableProperty (false)]
#endif
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
[Editor("System.Windows.Forms.Design.StringArrayEditor, " + Consts.AssemblySystem_Design, typeof(System.Drawing.Design.UITypeEditor))]
[Localizable(true)]
......@@ -496,9 +477,7 @@ namespace System.Windows.Forms
}
}
#if NET_2_0
[RefreshProperties (RefreshProperties.Repaint)]
#endif
[DefaultValue(false)]
[MWFCategory("Behavior")]
public bool ReadOnly {
......@@ -509,14 +488,12 @@ namespace System.Windows.Forms
set {
if (value != read_only) {
read_only = value;
#if NET_2_0
if (!backcolor_set) {
if (read_only)
background_color = SystemColors.Control;
else
background_color = SystemColors.Window;
}
#endif
OnReadOnlyChanged(EventArgs.Empty);
Invalidate ();
}
......@@ -529,10 +506,6 @@ namespace System.Windows.Forms
get {
string retval = document.GetSelection ();
#if ONLY_1_1
if (!IsHandleCreated && retval == string.Empty)
return null;
#endif
return retval;
}
......@@ -550,22 +523,13 @@ namespace System.Windows.Forms
get {
int res = document.SelectionLength ();
#if !NET_2_0
if (res == 0 && !IsHandleCreated)
res = -1;
#endif
return res;
}
set {
if (value < 0) {
string msg = String.Format ("'{0}' is not a valid value for 'SelectionLength'", value);
#if NET_2_0
throw new ArgumentOutOfRangeException ("SelectionLength", msg);
#else
throw new ArgumentException (msg);
#endif
}
document.InvalidateSelectionArea ();
......@@ -599,11 +563,7 @@ namespace System.Windows.Forms
set {
if (value < 0) {
string msg = String.Format ("'{0}' is not a valid value for 'SelectionStart'", value);
#if NET_2_0
throw new ArgumentOutOfRangeException ("SelectionStart", msg);
#else
throw new ArgumentException (msg);
#endif
}
// If SelectionStart has been used, we don't highlight on focus
......@@ -620,7 +580,6 @@ namespace System.Windows.Forms
}
}
#if NET_2_0
[DefaultValue (true)]
public virtual bool ShortcutsEnabled {
get { return shortcuts_enabled; }
......@@ -629,7 +588,6 @@ namespace System.Windows.Forms
[Editor ("System.ComponentModel.Design.MultilineStringEditor, " + Consts.AssemblySystem_Design,
"System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
#endif
[Localizable(true)]
public override string Text {
get {
......@@ -701,7 +659,6 @@ namespace System.Windows.Forms
}
}
#if NET_2_0
[Browsable (false)]
[EditorBrowsable (EditorBrowsableState.Never)]
public override ImageLayout BackgroundImageLayout {
......@@ -720,11 +677,9 @@ namespace System.Windows.Forms
protected override Cursor DefaultCursor {
get { return Cursors.IBeam; }
}
#endif
#endregion // Public Instance Properties
#region Protected Instance Properties
#if NET_2_0
protected override bool CanEnableIme {
get {
if (ReadOnly || password_char != '\0')
......@@ -733,7 +688,6 @@ namespace System.Windows.Forms
return true;
}
}
#endif
protected override CreateParams CreateParams {
get {
......@@ -747,14 +701,12 @@ namespace System.Windows.Forms
}
}
#if NET_2_0
// Currently our double buffering breaks our scrolling, so don't let people enable this
[EditorBrowsable (EditorBrowsableState.Never)]
protected override bool DoubleBuffered {
get { return false; }
set { }
}
#endif
#endregion // Protected Instance Properties
......@@ -882,7 +834,6 @@ namespace System.Windows.Forms
}
}
#if NET_2_0
public void DeselectAll ()
{
SelectionLength = 0;
......@@ -974,7 +925,6 @@ namespace System.Windows.Forms
{
return document.LineTagToCharIndex (document.caret.line, 0);
}
#endif
#endregion // Public Instance Methods
#region Protected Instance Methods
......@@ -1028,15 +978,6 @@ namespace System.Windows.Forms
eh (this, e);
}
#if ONLY_1_1
protected virtual void OnAutoSizeChanged (EventArgs e)
{
EventHandler eh = (EventHandler)(Events [AutoSizeChangedEvent]);
if (eh != null)
eh (this, e);
}
#endif
protected virtual void OnBorderStyleChanged (EventArgs e)
{
EventHandler eh = (EventHandler)(Events [BorderStyleChangedEvent]);
......@@ -1087,12 +1028,10 @@ namespace System.Windows.Forms
eh (this, e);
}
#if NET_2_0
protected override void OnPaddingChanged (EventArgs e)
{
base.OnPaddingChanged (e);
}
#endif
protected virtual void OnReadOnlyChanged (EventArgs e)
{
......@@ -1101,12 +1040,10 @@ namespace System.Windows.Forms
eh (this, e);
}
#if NET_2_0
protected override bool ProcessCmdKey (ref Message msg, Keys keyData)
{
return base.ProcessCmdKey (ref msg, keyData);
}
#endif
protected override bool ProcessDialogKey (Keys keyData)
{
// The user can use Ctrl-Tab or Ctrl-Shift-Tab to move control focus
......@@ -1588,9 +1525,7 @@ namespace System.Windows.Forms
if (document.Length < max_length) {
document.InsertCharAtCaret(c, true);
#if NET_2_0
OnTextUpdate ();
#endif
CaretMoved (this, null);
Modified = true;
OnTextChanged(EventArgs.Empty);
......@@ -1646,15 +1581,9 @@ namespace System.Windows.Forms
remove { Events.RemoveHandler (AcceptsTabChangedEvent, value); }
}
#if NET_2_0
[Browsable (false)]
[EditorBrowsable (EditorBrowsableState.Never)]
#endif
public
#if NET_2_0
new
#endif
event EventHandler AutoSizeChanged {
public new event EventHandler AutoSizeChanged {
add { Events.AddHandler (AutoSizeChangedEvent, value); }
remove { Events.RemoveHandler (AutoSizeChangedEvent, value); }
}
......@@ -1701,7 +1630,6 @@ namespace System.Windows.Forms
remove { base.BackgroundImageChanged -= value; }
}
#if NET_2_0
[Browsable (false)]
[EditorBrowsable (EditorBrowsableState.Never)]
public new event EventHandler BackgroundImageLayoutChanged {
......@@ -1726,10 +1654,6 @@ namespace System.Windows.Forms
[Browsable (true)]
[EditorBrowsable (EditorBrowsableState.Always)]
#else
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Advanced)]
#endif
public new event EventHandler Click {
add { base.Click += value; }
remove { base.Click -= value; }
......@@ -2297,11 +2221,7 @@ namespace System.Windows.Forms
}
if (found_link == false) {
#if NET_2_0
XplatUI.SetCursor (window.Handle, DefaultCursor.handle);
#else
XplatUI.SetCursor(window.Handle, Cursors.IBeam.handle);
#endif
current_link = null;
}
}
......@@ -2532,7 +2452,6 @@ namespace System.Windows.Forms
}
#endregion
#if NET_2_0
// This is called just before OnTextChanged is called.
internal virtual void OnTextUpdate ()
{
......@@ -2558,6 +2477,5 @@ namespace System.Windows.Forms
{
base.OnMouseUp (mevent);
}
#endif
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册