Ejemplo n.º 1
0
 void Node_StateChanged(object sender, EventArgs e)
 {
     if (treeView1.InvokeRequired)
     {
         OnValueCallback d = new OnValueCallback(Node_StateChanged);
         if (!this.Disposing)
         {
             this.Invoke(d, new object[] { sender, e });
         }
     }
     else
     {
         NodeBase b = (sender as NodeBase);
         if (b.Tag is TreeNode)
         {
             TreeNode tn        = (b.Tag as TreeNode);
             int      firsticon = 0;
             if (b.GetType() == typeof(NodeLN))
             {
                 firsticon = 5;
             }
             else if (b.GetType() == typeof(NodeFC))
             {
                 firsticon = 6;
             }
             else if (b.GetType() == typeof(NodeData))
             {
                 if (b.GetChildNodes().Length == 0)
                 { // Leaf
                     firsticon = 8;
                 }
                 else
                 {
                     firsticon = 7;
                 }
             }
             tn.ImageIndex         = firsticon + ((int)b.NodeState) * 4;
             tn.SelectedImageIndex = firsticon + ((int)b.NodeState) * 4;
             treeView1.Invalidate(tn.Bounds);
         }
     }
 }