[Mono-dev] [Patch] TreeView, TreeNode, TreeNodeCollection
Alan McGovern
alan.mcgovern at gmail.com
Sat Jan 20 10:54:13 EST 2007
Heya,
I'm on holidays in italy right now, so i havent had a chance to work on
stuff for the last week. I'll be home again tomorrow, so there should be a
patch ready (including nunits) by next saturday, all going well.
Alan.
On 1/20/07, Jonathan Pobst <monkey at jpobst.com> wrote:
>
> Hey Alan, I haven't seen you around in a while and wanted to make sure
> TreeNode.Name got into 1.2.3 due to how high it appears on the moma
> reports, so I committed that part of your patch and wrote the relevant
> test.
>
> I'm not writing the tests for the collection part, so I'll need those
> before I commit the other stuff. :)
>
> Obviously, the performance concerns are valid, but I'll take an
> inefficient implementation over no implementation if you are unable to
> make it use something better than a linear search.
>
> Also, have you made any headway on the TreeNode ContextMenu(Strip)
> stuff? It also shows pretty high on moma, so if you don't have time to
> do that, I'll probably write it.
>
> Thanks!
> jpobst
>
>
> Alan McGovern wrote:
> > Hi,
> >
> > This is my first patch, so i want to make sure that everything is
> > alright before i go committing. I will provide NUnit tests for the new
> > functionality (i'll post the tests here) if everything looks good with
> > the patch.
> >
> > I just implemented some of the .NET 2.0 methods which are missing which
> > i would like to have. They're nothing major. Also, how would i go about
> > implementing the ContextMenu stuff. Is there an example of how i can do
> > this? I'm not 100% sure how to do it :p
> >
> >
> > ------------------------------------------------------------------------
> >
> > Index:
> C:/programming/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TreeNode.cs
> > ===================================================================
> > ---
> C:/programming/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TreeNode.cs
> (revision 69123)
> > +++
> C:/programming/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TreeNode.cs
> (working copy)
> > @@ -54,6 +54,9 @@
> >
> > internal IntPtr handle;
> >
> > +#if NET_2_0
> > + private string name = string.Empty;
> > +#endif
> > #endregion // Fields
> >
> > #region Internal Constructors
> > @@ -352,6 +355,18 @@
> > }
> > }
> >
> > +#if NET_2_0
> > + public string Name
> > + {
> > + get { return this.name; }
> > + set
> > + {
> > + // Value should never be null as per spec
> > + this.name = (value == null) ? string.Empty: value;
> > + }
> > + }
> > +#endif
> > +
> > public TreeNode NextNode {
> > get {
> > if (parent == null)
> > Index:
> C:/programming/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TreeNodeCollection.cs
> > ===================================================================
> > ---
> C:/programming/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TreeNodeCollection.cs
> (revision 69123)
> > +++
> C:/programming/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TreeNodeCollection.cs
> (working copy)
> > @@ -95,6 +95,20 @@
> > }
> > }
> >
> > + #if NET_2_0
> > + public virtual TreeNode this[string key]
> > + {
> > + get
> > + {
> > + if(string.IsNullOrEmpty(key))
> > + return null;
> > +
> > + int index = IndexOfKey(key);
> > + return (index == -1) ? null : this[index];
> > + }
> > + }
> > + #endif
> > +
> > public virtual TreeNode Add (string text)
> > {
> > TreeNode res = new TreeNode (text);
> > @@ -442,6 +456,43 @@
> > return (res == 0 ? l.Index - r.Index :
> res);
> > }
> > }
> > +
> > +#if NET_2_0
> > + public virtual int IndexOfKey(string key)
> > + {
> > + if (string.IsNullOrEmpty(key))
> > + return -1;
> > +
> > + // We do a case insensitive comparison to
> find the key
> > + for (int i = 0; i < nodes.Count; i++)
> > + if (string.Equals(nodes.Name, name,
> StringComparison.CurrentCultureIgnoreCase))
> > + return i;
> > +
> > + return -1;
> > + }
> > +
> > + public virtual bool ContainsKey(string name)
> > + {
> > + return (IndexOfKey(name) != -1);
> > + }
> > +
> > +
> > + public virtual void RemoveByKey(string key)
> > + {
> > + int index = -1;
> > + for (int i = 0; i < nodes.Count; i++)
> > + {
> > + if (!string.Equals(nodes[i].Name,key,
> StringComparison.CurrentCultureIgnoreCase))
> > + continue;
> > +
> > + index = i;
> > + break;
> > + }
> > +
> > + if (index != -1)
> > + RemoveAt(index);
> > + }
> > +#endif
> > }
> > }
> >
> > Index:
> C:/programming/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TreeView.cs
> > ===================================================================
> > ---
> C:/programming/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TreeView.cs
> (revision 69123)
> > +++
> C:/programming/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TreeView.cs
> (working copy)
> > @@ -549,6 +549,15 @@
> > return root_node.GetNodeCount (include_subtrees);
> > }
> >
> > + #if NET_2_0
> > + public void Sort()
> > + {
> > + // Just call the pre-existing methods to sort the
> treeview.
> > + // I assume it'll sort correctly.
> > + this.Sorted = true;
> > + }
> > + #endif
> > +
> > public override string ToString () {
> > int count = Nodes.Count;
> > if (count <= 0)
> > Index:
> C:/programming/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
> > ===================================================================
> > ---
> C:/programming/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
> (revision 69123)
> > +++
> C:/programming/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
> (working copy)
> > @@ -1,3 +1,9 @@
> > +2007-1-09 Alan McGovern <alan.mcgovern at gmail.com>
> > + * TreeNode.cs
> > + * TreeView.cs
> > + * TreeNodeCollection.cs
> > + - Added some new .NET 2.0 methods
> > +
> > 2006-12-06 Jackson Harper <jackson at ximian.com>
> >
> > * TextControl.cs: Make this operation undoable.
> >
> >
> > ------------------------------------------------------------------------
> >
> > _______________________________________________
> > Mono-devel-list mailing list
> > Mono-devel-list at lists.ximian.com
> > http://lists.ximian.com/mailman/listinfo/mono-devel-list
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20070120/c8b43f0b/attachment.html
More information about the Mono-devel-list
mailing list