public override object Clone() { TitleTreeNodeItem item = new TitleTreeNodeItem(); item.BackColor = this.BackColor; item.Checked = this.Checked; item.ContextMenu = this.ContextMenu; item.ContextMenuStrip = this.ContextMenuStrip; item.ForeColor = this.ForeColor; item.ImageIndex = this.ImageIndex; item.ImageKey = this.ImageKey; item.Name = this.Name; item.NodeFont = this.NodeFont; item.SelectedImageIndex = this.SelectedImageIndex; item.SelectedImageKey = this.SelectedImageKey; item.StateImageIndex = this.StateImageIndex; item.StateImageKey = this.StateImageKey; item.Tag = this.Tag; item.Text = this.Text; item.ToolTipText = this.ToolTipText; item.ShowLines = this.ShowLines; item.ShowPlusMinus = this.ShowPlusMinus; item.ShowStateImageOrCheckBox = this.ShowStateImageOrCheckBox; item.SystemColor = this.SystemColor; item.TitleBorder = this.TitleBorder; item.TitleBackgroundBegin = this.TitleBackgroundBegin; item.TitleBackgroundEnd = this.TitleBackgroundEnd; item.UsingNodeRegionStyle = this.UsingNodeRegionStyle; for (int i = 0; i < this.Nodes.Count; i++) { item.Nodes.Add((TreeNode)this.Nodes[i].Clone()); } return(item); }
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType) { if (destinationType == null) { throw new ArgumentNullException("destinationType"); } if ((destinationType == typeof(InstanceDescriptor)) && (value is TitleTreeNodeItem)) { TitleTreeNodeItem node = (TitleTreeNodeItem)value; System.Reflection.MemberInfo member = null; object[] arguments = null; if ((node.ImageIndex == -1) || (node.SelectedImageIndex == -1)) { if (node.Nodes.Count == 0) { member = typeof(TitleTreeNodeItem).GetConstructor(new Type[] { typeof(string) }); arguments = new object[] { node.Text }; } else { member = typeof(TitleTreeNodeItem).GetConstructor(new Type[] { typeof(string), typeof(TreeNode[]) }); TreeNode[] dest = new TreeNode[node.Nodes.Count]; node.Nodes.CopyTo(dest, 0); arguments = new object[] { node.Text, dest }; } } else if (node.Nodes.Count == 0) { member = typeof(TitleTreeNodeItem).GetConstructor(new Type[] { typeof(string), typeof(int), typeof(int) }); arguments = new object[] { node.Text, node.ImageIndex, node.SelectedImageIndex }; } else { member = typeof(TitleTreeNodeItem).GetConstructor(new Type[] { typeof(string), typeof(int), typeof(int), typeof(TreeNode[]) }); TreeNode[] nodeArray2 = new TreeNode[node.Nodes.Count]; node.Nodes.CopyTo(nodeArray2, 0); arguments = new object[] { node.Text, node.ImageIndex, node.SelectedImageIndex, nodeArray2 }; } if (member != null) { return(new InstanceDescriptor(member, arguments, false)); } } return(base.ConvertTo(context, culture, value, destinationType)); }