浏览代码

2006-12-19 Carlos Alberto Cortez <[email protected]>

	* ColumnHeader.cs: Add Tag, Name, ImageKey, ImageIndex,
	and Image List 2.0 members for ColummnHeader.
	* ListView.cs: Add key-related 2.0 methods for
	ColumnHeaderCollection.


svn path=/trunk/mcs/; revision=69778
Carlos Alberto Cortez 19 年之前
父节点
当前提交
baf40c1325

+ 7 - 0
mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog

@@ -1,3 +1,10 @@
+2006-12-19  Carlos Alberto Cortez <[email protected]>
+
+	* ColumnHeader.cs: Add Tag, Name, ImageKey, ImageIndex,
+	and Image List 2.0 members for ColummnHeader.
+	* ListView.cs: Add key-related 2.0 methods for
+	ColumnHeaderCollection.
+
 2006-12-19  Gert Driesen  <[email protected]>
 
 	* ListViewItem.cs: Changed AddRange overloads to match MS: throw

+ 85 - 0
mcs/class/Managed.Windows.Forms/System.Windows.Forms/ColumnHeader.cs

@@ -42,6 +42,12 @@ namespace System.Windows.Forms
 		private string text = "ColumnHeader";
 		private HorizontalAlignment text_alignment = HorizontalAlignment.Left;
 		private int width = ThemeEngine.Current.ListViewDefaultColumnWidth;
+#if NET_2_0
+		private int image_index = -1;
+		private string image_key = String.Empty;
+		private string name = String.Empty;
+		private object tag;
+#endif
 
 		// internal variables
 		internal Rectangle column_rect = Rectangle.Empty;
@@ -59,10 +65,33 @@ namespace System.Windows.Forms
 			this.text_alignment = alignment;
 			CalcColumnHeader ();
 		}
+
+#if NET_2_0
+		internal ColumnHeader (string key, string text, int width, HorizontalAlignment textAlign)
+		{
+			Name = key;
+			Text = text;
+			this.width = width;
+			this.text_alignment = textAlign;
+			CalcColumnHeader ();
+		}
+#endif
 		#endregion	// Internal Constructor
 
 		#region Public Constructors
 		public ColumnHeader () { }
+
+#if NET_2_0
+		public ColumnHeader (int imageIndex)
+		{
+			ImageIndex = imageIndex;
+		}
+
+		public ColumnHeader (string imageKey)
+		{
+			ImageKey = imageKey;
+		}
+#endif
 		#endregion	// Public Constructors
 
 		#region Private Internal Methods Properties
@@ -129,6 +158,40 @@ namespace System.Windows.Forms
 		#endregion	// Private Internal Methods Properties
 
 		#region Public Instance Properties
+#if NET_2_0
+		public int ImageIndex {
+			get {
+				return image_index;
+			}
+			set {
+				if (value < -1)
+					throw new ArgumentOutOfRangeException ("value");
+
+				image_index = value;
+				image_key = String.Empty;
+			}
+		}
+
+		public string ImageKey {
+			get {
+				return image_key;
+			}
+			set {
+				image_key = value == null ? String.Empty : value;
+				image_index = -1;
+			}
+		}
+
+		public ImageList ImageList {
+			get {
+				if (owner == null)
+					return null;
+
+				return owner.SmallImageList;
+			}
+		}
+#endif
+
 		[Browsable (false)]
 		public int Index {
 			get {
@@ -145,6 +208,28 @@ namespace System.Windows.Forms
 			get { return owner; }
 		}
 
+#if NET_2_0
+		public string Name {
+			get {
+				return name;
+			}
+			set {
+				name = value == null ? String.Empty : value;
+			}
+		}
+
+		[LocalizableAttribute (false)]
+		[BindableAttribute (true)]
+		public object Tag {
+			get {
+				return tag;
+			}
+			set {
+				tag = value;
+			}
+		}
+#endif
+
 		[Localizable (true)]
 		public string Text {
 			get { return text; }

+ 126 - 0
mcs/class/Managed.Windows.Forms/System.Windows.Forms/ListView.cs

@@ -2779,6 +2779,18 @@ namespace System.Windows.Forms
 				}
 			}
 
+#if NET_2_0
+			public virtual ColumnHeader this [string key] {
+				get {
+					int idx = IndexOfKey (key);
+					if (idx == -1)
+						return null;
+
+					return (ColumnHeader) list [idx];
+				}
+			}
+#endif
+
 			bool ICollection.IsSynchronized {
 				get { return true; }
 			}
@@ -2816,6 +2828,48 @@ namespace System.Windows.Forms
 				return colHeader;
 			}
 
+#if NET_2_0
+			public virtual ColumnHeader Add (string text)
+			{
+				return Add (String.Empty, text);
+			}
+
+			public virtual ColumnHeader Add (string text, int iwidth)
+			{
+				return Add (String.Empty, text, iwidth);
+			}
+
+			public virtual ColumnHeader Add (string key, string text)
+			{
+				ColumnHeader colHeader = new ColumnHeader ();
+				colHeader.Name = key;
+				colHeader.Text = text;
+				Add (colHeader);
+				return colHeader;
+			}
+
+			public virtual ColumnHeader Add (string key, string text, int iwidth)
+			{
+				return Add (key, text, iwidth, HorizontalAlignment.Left, -1);
+			}
+
+			public virtual ColumnHeader Add (string key, string text, int iwidth, HorizontalAlignment textAlign, int imageIndex)
+			{
+				ColumnHeader colHeader = new ColumnHeader (key, text, iwidth, textAlign);
+				colHeader.ImageIndex = imageIndex;
+				Add (colHeader);
+				return colHeader;
+			}
+
+			public virtual ColumnHeader Add (string key, string text, int iwidth, HorizontalAlignment textAlign, string imageKey)
+			{
+				ColumnHeader colHeader = new ColumnHeader (key, text, iwidth, textAlign);
+				colHeader.ImageKey = imageKey;
+				Add (colHeader);
+				return colHeader;
+			}
+#endif
+
 			public virtual void AddRange (ColumnHeader [] values)
 			{
 				foreach (ColumnHeader colHeader in values) {
@@ -2837,6 +2891,13 @@ namespace System.Windows.Forms
 				return list.Contains (value);
 			}
 
+#if NET_2_0
+			public virtual bool ContainsKey (string key)
+			{
+				return IndexOfKey (key) != -1;
+			}
+#endif
+
 			public IEnumerator GetEnumerator ()
 			{
 				return list.GetEnumerator ();
@@ -2897,6 +2958,22 @@ namespace System.Windows.Forms
 				return list.IndexOf (value);
 			}
 
+#if NET_2_0
+			public virtual int IndexOfKey (string key)
+			{
+				if (key == null || key.Length == 0)
+					return -1;
+
+				for (int i = 0; i < list.Count; i++) {
+					ColumnHeader col = (ColumnHeader) list [i];
+					if (String.Compare (key, col.Name, true) == 0)
+						return i;
+				}
+
+				return -1;
+			}
+#endif
+
 			public void Insert (int index, ColumnHeader value)
 			{
 				// LAMESPEC: MSDOCS say greater than or equal to the value of the Count property
@@ -2909,6 +2986,46 @@ namespace System.Windows.Forms
 				owner.Redraw (true);
 			}
 
+#if NET_2_0
+			public void Insert (int index, string text)
+			{
+				Insert (index, String.Empty, text);
+			}
+
+			public void Insert (int index, string text, int width)
+			{
+				Insert (index, String.Empty, text, width);
+			}
+
+			public void Insert (int index, string key, string text)
+			{
+				ColumnHeader colHeader = new ColumnHeader ();
+				colHeader.Name = key;
+				colHeader.Text = text;
+				Insert (index, colHeader);
+			}
+
+			public void Insert (int index, string key, string text, int width)
+			{
+				ColumnHeader colHeader = new ColumnHeader (key, text, width, HorizontalAlignment.Left);
+				Insert (index, colHeader);
+			}
+
+			public void Insert (int index, string key, string text, int width, HorizontalAlignment textAlign, int imageIndex)
+			{
+				ColumnHeader colHeader = new ColumnHeader (key, text, width, textAlign);
+				colHeader.ImageIndex = imageIndex;
+				Insert (index, colHeader);
+			}
+
+			public void Insert (int index, string key, string text, int width, HorizontalAlignment textAlign, string imageKey)
+			{
+				ColumnHeader colHeader = new ColumnHeader (key, text, width, textAlign);
+				colHeader.ImageKey = imageKey;
+				Insert (index, colHeader);
+			}
+#endif
+
 			public void Insert (int index, string str, int width, HorizontalAlignment textAlign)
 			{
 				ColumnHeader colHeader = new ColumnHeader (this.owner, str, textAlign, width);
@@ -2922,6 +3039,15 @@ namespace System.Windows.Forms
 				owner.Redraw (true);
 			}
 
+#if NET_2_0
+			public virtual void RemoveByKey (string key)
+			{
+				int idx = IndexOfKey (key);
+				if (idx != -1)
+					RemoveAt (idx);
+			}
+#endif
+
 			public virtual void RemoveAt (int index)
 			{
 				if (index < 0 || index >= list.Count)