+2004-11-29 Marek Safar <marek.safar@seznam.cz>
+
+ * System.Windows.Forms.dll.sources: Added\r
+ TreeNode.cs, TreeNodeCollection.cs, TreeView.cs,\r
+ TreeViewAction.cs, TreeViewEventArgs.cs\r
+\r
+ * System.Windows.Forms_test.dll.sources: Added\r
+ TreeNodeTest.cs
+\r
2004-11-24 Ravindra <rkumar@novell.com>
* SWF.csproj: Updated project.
OutputType = "Library"\r
PreBuildEvent = ""\r
PostBuildEvent = ""\r
- RootNamespace = "System.Windows.Forms"\r
+ RootNamespace = ""\r
RunPostBuildEvent = "OnBuildSuccess"\r
StartupObject = ""\r
>\r
SubType = "Component"\r
BuildAction = "Compile"\r
/>\r
+ <File\r
+ RelPath = "System.Windows.Forms\TreeNode.cs"\r
+ SubType = "Code"\r
+ BuildAction = "Compile"\r
+ />\r
+ <File\r
+ RelPath = "System.Windows.Forms\TreeNodeCollection.cs"\r
+ SubType = "Code"\r
+ BuildAction = "Compile"\r
+ />\r
+ <File\r
+ RelPath = "System.Windows.Forms\TreeView.cs"\r
+ SubType = "Component"\r
+ BuildAction = "Compile"\r
+ />\r
+ <File\r
+ RelPath = "System.Windows.Forms\TreeViewAction.cs"\r
+ SubType = "Code"\r
+ BuildAction = "Compile"\r
+ />\r
+ <File\r
+ RelPath = "System.Windows.Forms\TreeViewEventArgs.cs"\r
+ SubType = "Code"\r
+ BuildAction = "Compile"\r
+ />\r
<File\r
RelPath = "System.Windows.Forms\TreeViewImageIndexConverter.cs"\r
SubType = "Code"\r
System.Windows.Forms/ToolBar.cs
System.Windows.Forms/ToolBarTextAlign.cs
System.Windows.Forms/ToolTip.cs
-System.Windows.Forms/TrackBar.cs
+System.Windows.Forms/TrackBar.cs\r
+System.Windows.Forms/TreeNode.cs\r
+System.Windows.Forms/TreeNodeCollection.cs\r
+System.Windows.Forms/TreeView.cs\r
+System.Windows.Forms/TreeViewAction.cs\r
+System.Windows.Forms/TreeViewEventArgs.cs\r
System.Windows.Forms/TreeViewImageIndexConverter.cs
System.Windows.Forms/UICues.cs
System.Windows.Forms/UICuesEventArgs.cs
}
}
- while (!exiting && XplatUI.GetMessage(ref msg, IntPtr.Zero, 0, 0)) {
- if (form.end_modal) {
- break;
- }
-
+ while (!exiting && !form.end_modal && XplatUI.GetMessage(ref msg, IntPtr.Zero, 0, 0)) {
XplatUI.TranslateMessage(ref msg);
XplatUI.DispatchMessage(ref msg);
+2004-11-29 Marek Safar <marek.safar@seznam.cz>
+
+ * Application.cs (ModalRun): Don't hang after exit.\r
+\r
+ * Theme.cs: New TreeViewDefaultSize property.\r
+\r
+ * ThemeWin32Classic.cs: Replaced hardcoded defaultWindowBackColor\r
+ with less hardcoded SystemColors constant.\r
+ Implemented TreeViewDefaultSize.\r
+\r
+ * TreeNode.cs, TreeNodeCollection.cs, TreeView.cs,\r
+ TreeViewAction.cs, TreeViewEventArgs.cs: New files.\r
+\r
2004-11-29 John BouAntoun <jba-mono@optusnet.com.au>
* MonthCalendar.cs:
public abstract Size VScrollBarDefaultSize{get;} // Default size of the scrollbar
#endregion // VScrollBar
+ #region TreeView
+ public abstract Size TreeViewDefaultSize { get; }
+ #endregion
#region ControlPaint Methods
public abstract void CPDrawBorder (Graphics graphics, Rectangle bounds, Color leftColor, int leftWidth,
pen_arrow = new Pen (Color.Black);
br_progressbarblock = new SolidBrush (Color.FromArgb (255, 0, 0, 128));
- defaultWindowBackColor = Color.FromArgb (255, 10, 10, 10);
+ defaultWindowBackColor = SystemColors.Window;
defaultWindowForeColor = ColorButtonText;
default_font = new Font (FontFamily.GenericSansSerif, 8.25f);
}
}
#endregion // VScrollBar
+ #region TreeView
+ public override Size TreeViewDefaultSize {\r
+ get {\r
+ return new Size (121, 97);\r
+ }\r
+ }\r
+
+ #endregion
+
#region ControlPaint
private enum DrawFrameControlStates {
ButtonCheck = 0x0000,
public override void CPDrawBorderStyle (Graphics dc, Rectangle area, BorderStyle border_style) {
switch (border_style){
- case BorderStyle.Fixed3D:
+ case BorderStyle.Fixed3D:
dc.DrawLine (ResPool.GetPen (ColorButtonShadow), area.X, area.Y, area.X +area.Width, area.Y);
dc.DrawLine (ResPool.GetPen (ColorButtonShadow), area.X, area.Y, area.X, area.Y + area.Height);
dc.DrawLine (ResPool.GetPen (ColorButtonHilight), area.X , area.Y + area.Height - 1, area.X + area.Width ,
area.Y + area.Height - 1);
dc.DrawLine (ResPool.GetPen (ColorButtonHilight), area.X + area.Width -1 , area.Y, area.X + area.Width -1,
area.Y + area.Height);
+
+ // FIXME: These colors are not correct. Microsoft uses different ones but I didn't find them.
+ dc.DrawLine (ResPool.GetPen (ColorButtonLight), area.X + 1, area.Bottom - 2, area.Right - 2, area.Bottom - 2);
+ dc.DrawLine (ResPool.GetPen (ColorButtonLight), area.Right - 2, area.Top + 1, area.Right - 2, area.Bottom - 2);
+ dc.DrawLine (ResPool.GetPen (ColorButtonDkShadow), area.X + 1, area.Top + 1, area.X + 1, area.Bottom - 3);
+ dc.DrawLine (ResPool.GetPen (ColorButtonDkShadow), area.X + 1, area.Top + 1, area.Right - 3, area.Top + 1);
break;
case BorderStyle.FixedSingle:
dc.DrawRectangle (ResPool.GetPen (ColorWindowFrame), area.X, area.Y, area.Width - 1, area.Height - 1);
--- /dev/null
+//
+// System.Windows.Forms.TreeNode.cs
+//
+// 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.
+//
+// Autors:
+// Marek Safar marek.safar@seznam.cz
+//
+//
+//
+//
+
+// NOT COMPLETE
+
+using System;
+using System.Runtime.Serialization;
+
+namespace System.Windows.Forms
+{
+ [Serializable]
+ public class TreeNode: MarshalByRefObject, ICloneable, ISerializable
+ {
+ [Flags]
+ enum Flags {
+ HasCheck = 0x01,
+ IsSelected = 0x02,
+ IsExpanded = 0x04
+ }
+
+ Flags flags;
+ int index;
+ int imageIndex = -1;
+ TreeNodeCollection nodes;
+ TreeNode parent;
+ int selectedImageIndex = -1;
+ object tag;
+ string text = "";
+ TreeView treeView;
+
+ public TreeNode() {
+ }
+
+ public TreeNode (string text)
+ {
+ if (text != null)
+ this.text = text;
+ }
+
+ public TreeNode (string text, TreeNode[] children):
+ this (text)
+ {
+ Nodes.AddRange (children);
+ }
+
+
+ public TreeNode (string text, int imageIndex, int selectedImageIndex):
+ this (text)
+ {
+ this.imageIndex = imageIndex;
+ this.selectedImageIndex = selectedImageIndex;
+ }
+
+ public TreeNode (string text, int imageIndex, int selectedImageIndex, TreeNode[] children):
+ this (text, imageIndex, selectedImageIndex)
+ {
+ Nodes.AddRange (children);
+ }
+
+
+ #region Properties
+
+ public bool Checked {
+ get {
+ return (flags & Flags.HasCheck) != 0;
+ }
+ set {
+ flags |= Flags.HasCheck;
+ }
+ }
+
+ public TreeNode FirstNode {
+ get {
+ return (nodes == null || nodes.Count == 0) ? null : nodes [0];
+ }
+ }
+
+ public string FullPath {
+ get {
+ if (treeView == null)
+ throw new Exception ("No TreeView associated");
+
+ return "";
+ }
+ }
+
+ public int Index {
+ get {
+ return index;
+ }
+ }
+
+ public int ImageIndex {
+ get {
+ return imageIndex;
+ }
+ set {
+ imageIndex = value;
+ }
+ }
+
+ public bool IsExpanded {
+ get {
+ return (flags & Flags.IsExpanded) != 0;
+ }
+ }
+
+ public bool IsSelected {
+ get {
+ return (flags & Flags.IsSelected) != 0;
+ }
+ }
+
+ [MonoTODO]
+ public bool IsVisible {
+ get {
+ throw new NotImplementedException ();
+ }
+ }
+
+ public TreeNode LastNode {
+ get {
+ return (nodes == null || nodes.Count == 0) ? null : nodes [nodes.Count - 1];
+ }
+ }
+
+ public TreeNode NextNode {
+ get {
+ if (parent.nodes == null || index == parent.nodes.Count - 1)
+ return null;
+
+ return parent.nodes [index + 1];
+ }
+ }
+
+ public TreeNodeCollection Nodes {
+ get {
+ if (nodes == null)
+ nodes = new TreeNodeCollection (this);
+ return nodes;
+ }
+ }
+
+ public TreeNode Parent {
+ get {
+ return parent;
+ }
+ }
+
+ public TreeNode PrevNode {
+ get {
+ if (parent.nodes == null || index == 0)
+ return null;
+
+ return parent.nodes [index - 1];
+ }
+ }
+
+ public int SelectedImageIndex {
+ get {
+ return selectedImageIndex;
+ }
+ set {
+ selectedImageIndex = value;
+ }
+ }
+
+ public object Tag {
+ get {
+ return tag;
+ }
+ set {
+ tag = value;
+ }
+ }
+
+ public string Text {
+ get {
+ return text;
+ }
+ set {
+ this.text = (value == null) ? "" : value;
+ }
+ }
+
+ #endregion
+
+ #region ICloneable Members
+
+ [MonoTODO ("Copy drawing fields")]
+ public object Clone()
+ {
+ TreeNode tn = new TreeNode (text, imageIndex, selectedImageIndex);
+ if (nodes != null) {
+ foreach (TreeNode child in nodes)
+ tn.Nodes.Add ((TreeNode)child.Clone ());
+ }
+ tn.Tag = tag;
+ tn.Checked = Checked;
+ return tn;
+ }
+
+ #endregion
+
+ #region ISerializable Members
+
+ [MonoTODO]
+ void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context)
+ {
+ throw new NotImplementedException ();
+ }
+
+ #endregion
+
+ // Internal
+
+ internal void SetParent (TreeNode parent)
+ {
+ this.parent = parent;
+ }
+
+ internal void SetIndex (int index)
+ {
+ this.index = index;
+ }
+
+ }
+}
--- /dev/null
+//
+// System.Windows.Forms.TreeNode.cs
+//
+// 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.
+//
+// Autors:
+// Marek Safar marek.safar@seznam.cz
+//
+//
+//
+//
+
+// NOT COMPLETE
+
+using System;
+using System.Collections;
+
+namespace System.Windows.Forms
+{
+ public class TreeNodeCollection: ICollection, IEnumerable, IList
+ {
+ TreeNode owner;
+
+ ArrayList collection = new ArrayList ();
+
+ internal TreeNodeCollection (TreeNode owner)
+ {
+ this.owner = owner;
+ }
+
+ [MonoTODO ("Check implementation")]
+ public virtual int Add (TreeNode node)
+ {
+ if (node == null)
+ throw new ArgumentNullException("value");
+
+ if (node.Parent != null)
+ throw new ArgumentException("Object already has a parent", "node");
+
+ node.SetParent (owner);
+ int index = collection.Add (node);
+ node.SetIndex (index);
+ return index;
+ }
+
+ public virtual void AddRange (TreeNode[] nodes)
+ {
+ if (nodes == null)
+ throw new ArgumentNullException("nodes");
+
+ foreach (TreeNode node in nodes) {
+ Add (node);
+ }
+ }
+
+ public int Count {
+ get {
+ return collection.Count;
+ }
+ }
+
+ [MonoTODO ("set")]
+ public virtual TreeNode this [int index] {
+ get {
+ return (TreeNode)collection [index];
+ }
+ set {
+ throw new NotImplementedException ();
+ }
+ }
+
+ #region IEnumerable Members
+
+ public IEnumerator GetEnumerator ()
+ {
+ return collection.GetEnumerator ();
+ }
+
+ #endregion
+
+ #region ICollection Members
+
+ bool ICollection.IsSynchronized {
+ get {
+ return false;
+ }
+ }
+
+ public void CopyTo(Array array, int index)
+ {
+ collection.CopyTo (array, index);
+ }
+
+ object ICollection.SyncRoot {
+ get {
+ return this;
+ }
+ }
+
+ #endregion
+
+ #region IList Members
+
+ public bool IsReadOnly {
+ get {
+ return false;
+ }
+ }
+
+ [MonoTODO]
+ object IList.this[int index] {
+ get {
+ return null;
+ }
+ set {
+ }
+ }
+
+ public void RemoveAt (int index)
+ {
+ collection.RemoveAt (index);
+ }
+
+ [MonoTODO]
+ void IList.Insert(int index, object value)
+ {
+ }
+
+ [MonoTODO]
+ void IList.Remove(object value)
+ {
+ }
+
+ [MonoTODO]
+ bool IList.Contains(object value)
+ {
+ return false;
+ }
+
+ public void Clear()
+ {
+ collection.Clear ();
+ }
+
+ [MonoTODO]
+ int IList.IndexOf(object value)
+ {
+ return 0;
+ }
+
+ [MonoTODO]
+ int IList.Add(object value)
+ {
+ return 0;
+ }
+
+ public bool IsFixedSize {
+ get {
+ return false;
+ }
+ }
+
+ #endregion
+ }
+}
--- /dev/null
+//
+// System.Windows.Forms.TreeNode.cs
+//
+// 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.
+//
+// Autors:
+// Marek Safar marek.safar@seznam.cz
+//
+//
+//
+//
+
+// NOT COMPLETE
+
+using System;
+using System.Drawing;
+using System.ComponentModel;
+
+namespace System.Windows.Forms
+{
+ public class TreeView: Control
+ {
+ BorderStyle border_style = BorderStyle.Fixed3D;
+
+ public TreeView()
+ {
+ background_color = ThemeEngine.Current.DefaultWindowBackColor;
+
+ base.Paint += new PaintEventHandler (TreeView_Paint);
+
+ SetStyle (ControlStyles.ResizeRedraw, true);
+ }
+
+ #region Properties
+
+ public override Color BackColor {
+ get {
+ return background_color;
+ }
+ set {
+ if (value == background_color)
+ return;
+
+ background_color = value;
+// if (BackColorChanged != null)
+// BackColorChanged (this, new EventArgs ());
+// Redraw (false);
+ }
+ }
+
+ [DefaultValue (BorderStyle.Fixed3D)]
+ public BorderStyle BorderStyle {
+ get {
+ return border_style;
+ }
+ set {
+ if (border_style != value) {
+ border_style = value;
+ //this.Redraw (false);
+ }
+ }
+ }
+
+ protected override System.Drawing.Size DefaultSize {
+ get {
+ return ThemeEngine.Current.TreeViewDefaultSize;
+ }
+ }
+
+ #endregion
+
+ void TreeView_Paint (object sender, PaintEventArgs pe)
+ {
+ if (this.Width <= 0 || this.Height <= 0 ||
+ this.Visible == false)
+ return;
+
+ DrawTreeView (pe.Graphics, this);
+ ThemeEngine.Current.CPDrawBorderStyle (pe.Graphics, this.ClientRectangle, border_style);
+ }
+
+ void DrawTreeView (Graphics dc, Control control)
+ {
+ dc.Clear (control.BackColor);
+ }
+ }
+}
--- /dev/null
+//
+// System.Windows.Forms.TreeViewAction.cs
+//
+// 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.
+//
+// Autors:
+// Marek Safar marek.safar@seznam.cz
+//
+// Copyright (C) Novell Inc., 2004
+//
+//
+//
+
+// COMPLETE
+
+namespace System.Windows.Forms
+{
+ public enum TreeViewAction
+ {
+ Unknown = 0,
+ ByKeyboard = 1,
+ ByMouse = 2,
+ Collapse = 3,
+ Expand = 4
+ }
+}
--- /dev/null
+//
+// System.Windows.Forms.TreeViewEventArgs.cs
+//
+// 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.
+//
+// Autors:
+// Marek Safar marek.safar@seznam.cz
+//
+// Copyright (C) Novell Inc., 2004
+//
+//
+//
+
+// COMPLETE
+
+namespace System.Windows.Forms
+{
+ public class TreeViewEventArgs: EventArgs
+ {
+ TreeViewAction action;
+ TreeNode node;
+
+ public TreeViewEventArgs (TreeNode node):
+ this (node, TreeViewAction.Unknown)
+ {
+ }
+
+ public TreeViewEventArgs (TreeNode node, TreeViewAction action)
+ {
+ this.node = node;
+ this.action = action;
+ }
+
+ public TreeViewAction Action {
+ get {
+ return action;
+ }
+ }
+
+ public TreeNode Node {
+ get {
+ return node;
+ }
+ }
+ }
+}
+
System.Windows.Forms/TestImageIndexConverter.cs
+System.Windows.Forms/TreeNodeTest.cs
--- /dev/null
+using System;
+using NUnit.Framework;
+using System.Windows.Forms;
+
+[TestFixture]
+public class TreeNodeTest {
+
+ [Test]
+ public void EmptyCtorTest ()
+ {
+ TreeNode tn = new TreeNode ();
+ Assert.AreEqual ("", tn.Text, "#1");
+ Assert.AreEqual (0, tn.Nodes.Count, "#2");
+ Assert.AreEqual (-1, tn.ImageIndex, "#3");
+ Assert.AreEqual (-1, tn.SelectedImageIndex, "#4");
+
+ // Set simple properties
+ tn.Text = null;
+ Assert.AreEqual ("", tn.Text, "#5");
+ tn.ImageIndex = 67;
+ Assert.AreEqual (67, tn.ImageIndex, "#6");
+ tn.SelectedImageIndex = 99;
+ Assert.AreEqual (99, tn.SelectedImageIndex, "#7");
+ }
+
+ [Test]
+ public void CtorTest () {
+ TreeNode tn = new TreeNode ("label1");
+
+ Assert.AreEqual ("label1", tn.Text);
+ Assert.AreEqual (0, tn.Nodes.Count);
+ Assert.AreEqual (-1, tn.ImageIndex, "II");
+ Assert.AreEqual (-1, tn.SelectedImageIndex, "SI");
+
+ Assert.IsNull (tn.FirstNode);
+ Assert.IsNull (tn.LastNode);
+ Assert.AreEqual ("", new TreeNode (null).Text);
+ }
+
+ [Test]
+ public void CtorTest2 ()
+ {
+ TreeNode tn = new TreeNode ("a1", new TreeNode[] { new TreeNode ("aa1"), new TreeNode ("aa2") } );
+
+ Assert.AreEqual ("a1", tn.Text);
+ Assert.AreEqual (-1, tn.ImageIndex, "II");
+ Assert.AreEqual (-1, tn.SelectedImageIndex, "SI");
+
+ Assert.AreEqual ("aa1", tn.Nodes [0].Text, "#1");
+ Assert.AreEqual ("aa2", tn.Nodes [1].Text, "#2");
+ Assert.AreSame (tn.FirstNode, tn.Nodes [0], "#3");
+ Assert.AreSame (tn.LastNode, tn.Nodes [1], "#4");
+ }
+
+ [Test]
+ public void CtorTest3 ()
+ {
+ TreeNode tn = new TreeNode ("a", 5, 9);
+
+ Assert.AreEqual ("a", tn.Text);
+ Assert.IsNotNull (tn.Nodes);
+ Assert.AreEqual (5, tn.ImageIndex);
+ Assert.AreEqual (9, tn.SelectedImageIndex);
+ Assert.AreEqual ("", new TreeNode (null, 0, 0).Text);
+ }
+
+ [Test, ExpectedException (typeof (ArgumentNullException))]
+ public void CtorException1 ()
+ {
+ new TreeNode ("", 1, 1, null);
+ }
+
+ [Test, ExpectedException (typeof (ArgumentNullException))]
+ public void CtorException2 () {
+ new TreeNode ("tt", null);
+ }
+
+ [Test]
+ public void Traverse ()
+ {
+ TreeNode tn_1 = new TreeNode ("1");
+ TreeNode tn_2 = new TreeNode ("2");
+ TreeNode tn_3 = new TreeNode ("3");
+ TreeNode tn = new TreeNode ("lev1");
+ tn.Nodes.Add (tn_1);
+ Assert.AreSame (tn, tn_1.Parent, "#1");
+ Assert.IsNull (tn_1.NextNode, "#2");
+ Assert.AreEqual (0, tn_1.Parent.Index, "#3");
+ tn.Nodes.Add (tn_2);
+ Assert.IsNull (tn_1.NextNode.NextNode, "#33");
+ tn.Nodes.Add (tn_3);
+ Assert.AreEqual (2, tn_3.Index, "#4");
+
+ Assert.AreEqual (3, tn.Nodes.Count, "#5");
+ Assert.AreSame (tn_2, tn_2.NextNode.PrevNode, "#6");
+ Assert.IsNull (tn_1.PrevNode, "#7");
+ }
+
+ [Test, ExpectedException (typeof (Exception))]
+ public void FullPathException ()
+ {
+ string s = new TreeNode ("").FullPath;
+ }
+
+ [Test, Ignore ("TODO")]
+ public void FullPathTest ()
+ {
+ TreeNode tn_1 = new TreeNode ("A");
+ TreeNode tn_2 = new TreeNode ("B");
+ tn_2.Nodes.Add (tn_1);
+ Assert.AreEqual (@"A\B", tn_1.FullPath);
+
+ }
+
+ [Test]
+ public void CloneTest ()
+ {
+ // TODO: Add draw oriented fields will be implemented
+
+ TreeNode orig = new TreeNode ("text", 2, 3, new TreeNode [] { new TreeNode ("child", 22, 33) });
+ orig.Tag = FlatStyle.Flat;
+ orig.Checked = true;
+ TreeNode clone = (TreeNode)orig.Clone ();
+ Assert.AreEqual ("text", clone.Text, "#1");
+ Assert.AreEqual (2, clone.ImageIndex, "#2");
+ Assert.AreEqual (3, clone.SelectedImageIndex, "#3");
+ Assert.AreEqual (1, clone.Nodes.Count, "#4");
+ Assert.AreEqual (FlatStyle.Flat, clone.Tag, "#5");
+ Assert.IsTrue (clone.Checked, "#6");
+ Assert.AreEqual ("child", clone.Nodes [0].Text, "#10");
+ Assert.AreEqual (22, clone.Nodes [0].ImageIndex, "#11");
+ }
+
+}
\ No newline at end of file