Exemple #1
0
        public virtual object Clone()
        {
            TreeNode tn = (TreeNode)Activator.CreateInstance(GetType());

            tn.name                 = name;
            tn.text                 = text;
            tn.image_key            = image_key;
            tn.image_index          = image_index;
            tn.selected_image_index = selected_image_index;
            tn.selected_image_key   = selected_image_key;
            tn.state_image_index    = state_image_index;
            tn.state_image_key      = state_image_key;
            tn.tag                = tag;
            tn.check              = check;
            tn.tool_tip_text      = tool_tip_text;
            tn.context_menu_strip = context_menu_strip;
            if (nodes != null)
            {
                foreach (TreeNode child in nodes)
                {
                    tn.nodes.Add((TreeNode)child.Clone());
                }
            }
            if (prop_bag != null)
            {
                tn.prop_bag = OwnerDrawPropertyBag.Copy(prop_bag);
            }
            return(tn);
        }
Exemple #2
0
        TreeNode(SerializationInfo serializationInfo, StreamingContext context) : this()
        {
            SerializationInfoEnumerator en;
            SerializationEntry          e;
            int children;

            en       = serializationInfo.GetEnumerator();
            children = 0;
            while (en.MoveNext())
            {
                e = en.Current;
                switch (e.Name)
                {
                case "Text":
                    Text = (string)e.Value;
                    break;

                case "PropBag":
                    prop_bag = (OwnerDrawPropertyBag)e.Value;
                    break;

                case "ImageIndex":
                    image_index = (int)e.Value;
                    break;

                case "SelectedImageIndex":
                    selected_image_index = (int)e.Value;
                    break;

                case "Tag":
                    tag = e.Value;
                    break;

                case "IsChecked":
                    check = (bool)e.Value;
                    break;

                case "ChildCount":
                    children = (int)e.Value;
                    break;
                }
            }
            if (children > 0)
            {
                for (int i = 0; i < children; i++)
                {
                    TreeNode node = (TreeNode)serializationInfo.GetValue("children" + i, typeof(TreeNode));
                    Nodes.Add(node);
                }
            }
        }
Exemple #3
0
 public static OwnerDrawPropertyBag Copy(OwnerDrawPropertyBag value)
 {
     lock (typeof(OwnerDrawPropertyBag))
     {
         OwnerDrawPropertyBag newPropertyBag = new OwnerDrawPropertyBag();
         if (value != null)
         {
             newPropertyBag.backColor = value.backColor;
             newPropertyBag.foreColor = value.foreColor;
             newPropertyBag.Font      = value.font;
         }
         return(newPropertyBag);
     }
 }
 public static OwnerDrawPropertyBag Copy(OwnerDrawPropertyBag value)
 {
     lock (internalSyncObject)
     {
         OwnerDrawPropertyBag bag = new OwnerDrawPropertyBag();
         if (value != null)
         {
             bag.backColor = value.backColor;
             bag.foreColor = value.foreColor;
             bag.Font      = value.font;
         }
         return(bag);
     }
 }
 public static OwnerDrawPropertyBag Copy(OwnerDrawPropertyBag value)
 {
     lock (internalSyncObject)
     {
         OwnerDrawPropertyBag bag = new OwnerDrawPropertyBag();
         if (value != null)
         {
             bag.backColor = value.backColor;
             bag.foreColor = value.foreColor;
             bag.Font = value.font;
         }
         return bag;
     }
 }
 /// <include file='doc\OwnerDrawPropertyBag.uex' path='docs/doc[@for="OwnerDrawPropertyBag.Copy"]/*' />
 /// <devdoc>
 ///     Copies the bag. Always returns a valid ODPB object
 /// </devdoc>
 public static OwnerDrawPropertyBag Copy(OwnerDrawPropertyBag value)
 {
     lock (typeof(OwnerDrawPropertyBag)) {
         OwnerDrawPropertyBag ret = new OwnerDrawPropertyBag();
         if (value == null)
         {
             return(ret);
         }
         ret.backColor = value.backColor;
         ret.foreColor = value.foreColor;
         ret.Font      = value.font;
         return(ret);
     }
 }
Exemple #7
0
        protected virtual void Deserialize(SerializationInfo serializationInfo, StreamingContext context)
        {
            Text               = serializationInfo.GetString("Text");
            prop_bag           = (OwnerDrawPropertyBag)serializationInfo.GetValue("prop_bag", typeof(OwnerDrawPropertyBag));
            ImageIndex         = serializationInfo.GetInt32("ImageIndex");
            SelectedImageIndex = serializationInfo.GetInt32("SelectedImageIndex");
            Tag     = serializationInfo.GetValue("Tag", typeof(Object));
            Checked = serializationInfo.GetBoolean("Checked");

            int count = serializationInfo.GetInt32("NumberOfChildren");

            for (int i = 0; i < count; i++)
            {
                Nodes.Add((TreeNode)serializationInfo.GetValue("Child-" + i, typeof(TreeNode)));
            }
        }
Exemple #8
0
        /// <summary>
        /// Copies the bag. Always returns a valid ODPB object
        /// </summary>
        public static OwnerDrawPropertyBag Copy(OwnerDrawPropertyBag value)
        {
            lock (s_internalSyncObject)
            {
                var result = new OwnerDrawPropertyBag();
                if (value == null)
                {
                    return(result);
                }

                result.BackColor = value.BackColor;
                result.ForeColor = value.ForeColor;
                result.Font      = value.Font;
                return(result);
            }
        }
Exemple #9
0
        public virtual object Clone()
        {
            TreeNode tn = new TreeNode(text, image_index, selected_image_index);

            if (nodes != null)
            {
                foreach (TreeNode child in nodes)
                {
                    tn.Nodes.Add((TreeNode)child.Clone());
                }
            }
            tn.Tag     = tag;
            tn.Checked = Checked;
            if (prop_bag != null)
            {
                tn.prop_bag = OwnerDrawPropertyBag.Copy(prop_bag);
            }
            return(tn);
        }
Exemple #10
0
        /// <include file='doc\TreeNode.uex' path='docs/doc[@for="TreeNode.Deserialize"]/*' />
        /// <devdoc>
        ///    <para>[To be supplied.]</para>
        /// </devdoc>
        protected virtual void Deserialize(SerializationInfo serializationInfo, StreamingContext context) {

            int childCount = 0;
            int imageIndex = -1;
            string imageKey = null;

            int selectedImageIndex = -1;
            string selectedImageKey = null;

            int stateImageIndex = -1;
            string stateImageKey = null;
            
            foreach (SerializationEntry entry in serializationInfo) {
                switch (entry.Name) {
                    case "PropBag":
                        // SEC 
                        propBag = (OwnerDrawPropertyBag)serializationInfo.GetValue(entry.Name, typeof(OwnerDrawPropertyBag));
                        break;
                    case "Text":
                        Text = serializationInfo.GetString(entry.Name);
                        break;
                    case "ToolTipText":
                        ToolTipText = serializationInfo.GetString(entry.Name);
                        break;
                    case "Name":
                        Name = serializationInfo.GetString(entry.Name);
                        break;
                    case "IsChecked":
                        CheckedStateInternal = serializationInfo.GetBoolean(entry.Name);
                        break;
                    case "ImageIndex":
                        imageIndex = serializationInfo.GetInt32(entry.Name);
                        break;
                    case "SelectedImageIndex":
                        selectedImageIndex = serializationInfo.GetInt32(entry.Name);
                        break;
                    case "ImageKey":
                        imageKey = serializationInfo.GetString(entry.Name);
                        break;
                    case "SelectedImageKey":
                        selectedImageKey= serializationInfo.GetString(entry.Name);
                        break;                    
                    case "StateImageKey":
                        stateImageKey = serializationInfo.GetString(entry.Name);
                        break;                    
                    case "StateImageIndex":
                        stateImageIndex = serializationInfo.GetInt32(entry.Name);
                        break;
                    case "ChildCount":
                        childCount = serializationInfo.GetInt32(entry.Name);
                        break;
                    case "UserData":
                        userData = entry.Value;
                        break;
                }
            }

            // let imagekey take precidence
            if (imageKey != null) {
                ImageKey = imageKey;    
            } 
            else if (imageIndex != -1) {
                ImageIndex = imageIndex;
            }

            // let selectedimagekey take precidence
            if (selectedImageKey != null) {
                SelectedImageKey = selectedImageKey;    
            } 
            else if (selectedImageIndex != -1) {
                SelectedImageIndex = selectedImageIndex;
            }

            // let stateimagekey take precidence
            if (stateImageKey != null) {
                StateImageKey = stateImageKey;    
            } 
            else if (stateImageIndex != -1) {
                StateImageIndex = stateImageIndex;
            }

            if (childCount > 0) {
                TreeNode[] childNodes = new TreeNode[childCount];

                for (int i = 0; i < childCount; i++) {
                    // SEC 
                    childNodes[i] = (TreeNode)serializationInfo.GetValue("children" + i, typeof(TreeNode));
                }
                Nodes.AddRange(childNodes);
            }
        }
		public static OwnerDrawPropertyBag Copy(OwnerDrawPropertyBag value)
		{
			lock(typeof(OwnerDrawPropertyBag))
			{
				OwnerDrawPropertyBag newPropertyBag = new OwnerDrawPropertyBag();
				if (value != null)
				{
					newPropertyBag.backColor = value.backColor;
					newPropertyBag.foreColor = value.foreColor;
					newPropertyBag.Font = value.font;
				}
				return newPropertyBag;
			}
		}
        /// <include file='doc\TreeView.uex' path='docs/doc[@for="TreeView.GetItemRenderStyles"]/*' />
        /// <devdoc>
        ///     Generates colors for each item. This can be overridden to provide colors on a per state/per node
        ///     basis, rather than using the ForeColor/BackColor/NodeFont properties on TreeNode.
        ///
        /// </devdoc>
        /// <internalonly/>
        protected OwnerDrawPropertyBag GetItemRenderStyles(TreeNode node, int state) {
            OwnerDrawPropertyBag retval = new OwnerDrawPropertyBag();
            if (node == null || node.propBag == null) return retval;

            // we only change colors if we're displaying things normally
            if ((state & (NativeMethods.CDIS_SELECTED | NativeMethods.CDIS_GRAYED | NativeMethods.CDIS_HOT | NativeMethods.CDIS_DISABLED))==0) {
                retval.ForeColor = node.propBag.ForeColor;
                retval.BackColor = node.propBag.BackColor;
            }
            retval.Font = node.propBag.Font;
            return retval;
        }
 private void RemovePropBagIfEmpty()
 {
     if ((this.propBag != null) && this.propBag.IsEmpty())
     {
         this.propBag = null;
     }
 }
        protected virtual void Deserialize(SerializationInfo serializationInfo, StreamingContext context)
        {
            int num = 0;
            int num2 = -1;
            string str = null;
            int num3 = -1;
            string str2 = null;
            int num4 = -1;
            string str3 = null;
            SerializationInfoEnumerator enumerator = serializationInfo.GetEnumerator();
            while (enumerator.MoveNext())
            {
                SerializationEntry current = enumerator.Current;
                switch (current.Name)
                {
                    case "PropBag":
                        this.propBag = (OwnerDrawPropertyBag) serializationInfo.GetValue(current.Name, typeof(OwnerDrawPropertyBag));
                        break;

                    case "Text":
                        this.Text = serializationInfo.GetString(current.Name);
                        break;

                    case "Name":
                        this.Name = serializationInfo.GetString(current.Name);
                        break;

                    case "IsChecked":
                        this.CheckedStateInternal = serializationInfo.GetBoolean(current.Name);
                        break;

                    case "ImageIndex":
                        num2 = serializationInfo.GetInt32(current.Name);
                        break;

                    case "SelectedImageIndex":
                        num3 = serializationInfo.GetInt32(current.Name);
                        break;

                    case "ImageKey":
                        str = serializationInfo.GetString(current.Name);
                        break;

                    case "SelectedImageKey":
                        str2 = serializationInfo.GetString(current.Name);
                        break;

                    case "StateImageKey":
                        str3 = serializationInfo.GetString(current.Name);
                        break;

                    case "StateImageIndex":
                        num4 = serializationInfo.GetInt32(current.Name);
                        break;

                    case "ChildCount":
                        num = serializationInfo.GetInt32(current.Name);
                        break;

                    case "UserData":
                        this.userData = current.Value;
                        break;
                }
            }
            if (str != null)
            {
                this.ImageKey = str;
            }
            else if (num2 != -1)
            {
                this.ImageIndex = num2;
            }
            if (str2 != null)
            {
                this.SelectedImageKey = str2;
            }
            else if (num3 != -1)
            {
                this.SelectedImageIndex = num3;
            }
            if (str3 != null)
            {
                this.StateImageKey = str3;
            }
            else if (num4 != -1)
            {
                this.StateImageIndex = num4;
            }
            if (num > 0)
            {
                TreeNode[] nodes = new TreeNode[num];
                for (int i = 0; i < num; i++)
                {
                    nodes[i] = (TreeNode) serializationInfo.GetValue("children" + i, typeof(TreeNode));
                }
                this.Nodes.AddRange(nodes);
            }
        }
		public static OwnerDrawPropertyBag Copy (OwnerDrawPropertyBag value)
		{
			return new OwnerDrawPropertyBag (value.ForeColor, value.BackColor, value.Font);
		}
Exemple #16
0
 /// <include file='doc\OwnerDrawPropertyBag.uex' path='docs/doc[@for="OwnerDrawPropertyBag.Copy"]/*' />
 /// <devdoc>
 ///     Copies the bag. Always returns a valid ODPB object
 /// </devdoc>
 public static OwnerDrawPropertyBag Copy(OwnerDrawPropertyBag value) {
     lock(internalSyncObject) {
         OwnerDrawPropertyBag ret = new OwnerDrawPropertyBag();
         if (value == null) return ret;
         ret.backColor = value.backColor;
         ret.foreColor = value.foreColor;
         ret.Font = value.font;
         return ret;
     }
 }
Exemple #17
0
		protected TreeNode (SerializationInfo serializationInfo, StreamingContext context) : this ()
		{
			SerializationInfoEnumerator	en;
			SerializationEntry		e;
			int				children;

			en = serializationInfo.GetEnumerator();
			children = 0;
			while (en.MoveNext()) {
				e = en.Current;
				switch(e.Name) {
					case "Text": Text = (string)e.Value; break;
					case "PropBag": prop_bag = (OwnerDrawPropertyBag)e.Value; break;
					case "ImageIndex": image_index = (int)e.Value; break;
					case "SelectedImageIndex": selected_image_index = (int)e.Value; break;
					case "Tag": tag = e.Value; break;
					case "IsChecked": check = (bool)e.Value; break;
					case "ChildCount": children = (int)e.Value; break;
				}
			}
			if (children > 0) {
				for (int i = 0; i < children; i++) {
					TreeNode node = (TreeNode) serializationInfo.GetValue ("children" + i, typeof (TreeNode));
					Nodes.Add (node);
				}
			}
		}
Exemple #18
0
		protected virtual void Deserialize (SerializationInfo serializationInfo, StreamingContext context)
		{
			Text = serializationInfo.GetString ("Text");
			prop_bag = (OwnerDrawPropertyBag)serializationInfo.GetValue ("prop_bag", typeof (OwnerDrawPropertyBag));
			ImageIndex = serializationInfo.GetInt32 ("ImageIndex");
			SelectedImageIndex = serializationInfo.GetInt32 ("SelectedImageIndex");
			Tag = serializationInfo.GetValue ("Tag", typeof (Object));
			Checked = serializationInfo.GetBoolean ("Checked");
			
			int count = serializationInfo.GetInt32 ("NumberOfChildren");
			
			for (int i = 0; i < count; i++)
				Nodes.Add ((TreeNode)serializationInfo.GetValue ("Child-" + i, typeof (TreeNode)));
		}
Exemple #19
0
 public static OwnerDrawPropertyBag Copy(OwnerDrawPropertyBag value)
 {
     return(new OwnerDrawPropertyBag(value.ForeColor, value.BackColor, value.Font));
 }
 protected OwnerDrawPropertyBag GetItemRenderStyles(TreeNode node, int state)
 {
     OwnerDrawPropertyBag bag = new OwnerDrawPropertyBag();
     if ((node != null) && (node.propBag != null))
     {
         if ((state & 0x47) == 0)
         {
             bag.ForeColor = node.propBag.ForeColor;
             bag.BackColor = node.propBag.BackColor;
         }
         bag.Font = node.propBag.Font;
     }
     return bag;
 }
Exemple #21
0
 /// <include file='doc\TreeNode.uex' path='docs/doc[@for="TreeNode.RemovePropBagIfEmpty"]/*' />
 /// <devdoc>
 ///     Removes the propBag object if it's now devoid of useful data
 /// </devdoc>
 /// <internalonly/>
 private void RemovePropBagIfEmpty() {
     if (propBag==null) return;
     if (propBag.IsEmpty()) propBag = null;
     return;
 }
Exemple #22
0
 public static OwnerDrawPropertyBag Copy(OwnerDrawPropertyBag value)
 {
     throw null;
 }