Пример #1
0
        public TestTreeView()
        {
            InitializeComponent();
            customTreeView1.AddImage("Root", Directory.GetCurrentDirectory() + "/root.png");
            customTreeView1.AddImage("EnemyCategory1", Directory.GetCurrentDirectory() + "/enemy.png");
            customTreeView1.AddImage("Enemy1", Directory.GetCurrentDirectory() + "/icon.png");
            customTreeView1.AddImage("Enemy2", Directory.GetCurrentDirectory() + "/icon1.png");
            customTreeView1.RootObject = new TreeViewObject(null, customTreeView1, this, "Demo Root", "Root");
            category1 = new TreeViewObject(customTreeView1.RootObject, customTreeView1, this,
                                           "enemy1", "EnemyCategory1");
            TreeViewObject item1 = new TreeViewObject(category1, customTreeView1, this,
                                                      "item1", "Enemy1");

            item2 = new TreeViewObject(category1, customTreeView1, this,
                                       "item2", "Enemy2");

            TreeViewObject category2 = new TreeViewObject(customTreeView1.RootObject, customTreeView1, this,
                                                          "enemy2", "EnemyCategory1");
            TreeViewObject item3 = new TreeViewObject(category2, customTreeView1, this,
                                                      "item3", "Enemy1");
            TreeViewObject item4 = new TreeViewObject(category2, customTreeView1, this,
                                                      "item4", "Enemy2");

            customTreeView1.TreeViewContainer = this;
        }
Пример #2
0
        void AccessTreeView(TreeViewObject parent, CustomTreeView treeView, object owner, string name, string imageKey)
        {
            Owner = owner;
            if (parent != null)
            {
                parent.Childs.Add(this);
                this.Parent = parent;
            }
            Id = DateTime.Now.Millisecond;
            TreeNodeCollection nodes = null;

            if (parent == null)
            {
                nodes = treeView.Nodes;
            }
            else
            {
                Parent = parent;
                nodes  = parent.Node.Nodes;
            }
            nodes.Add(Id.ToString(), name);
            nodes[Id.ToString()].ImageKey         = imageKey;
            nodes[Id.ToString()].SelectedImageKey = imageKey;
            Node          = nodes[Id.ToString()];
            Node.Tag      = this;
            this.Name     = name;
            this.ImageKey = imageKey;
        }
Пример #3
0
 public TreeViewObject(TreeViewObject parent, CustomTreeView treeView, object owner, string name, string imageKey)
 {
     AccessTreeView(parent, treeView, owner, name, imageKey);
     //if (treeView.Created)
     //{
     //    AccessTreeViewDelegate d = new AccessTreeViewDelegate(AccessTreeView);
     //    treeView.BeginInvoke(d, parent, treeView, owner, name, imageKey);
     //}
     //else
     //{
     //}
     //d.Invoke(parent, treeView, owner, name, imageKey);
 }
Пример #4
0
 public void OnDoubleClick(TreeViewObject obj, CustomTreeView treeView)
 {
     throw new NotImplementedException();
 }
Пример #5
0
 private void button4_Click(object sender, EventArgs e)
 {
     TreeViewObject viewObject = new TreeViewObject(customTreeView1.RootObject, customTreeView1,
                                                    this, "new", "EnemyCategory1"
                                                    );
 }
Пример #6
0
 public void OnFocus(TreeViewObject obj, CustomTreeView treeView)
 {
 }
Пример #7
0
 public void OnProperty(TreeViewObject obj, CustomTreeView treeView)
 {
     //  MessageBox.Show(obj.Name);
 }
Пример #8
0
 public void OnDelete(TreeViewObject obj, CustomTreeView treeView)
 {
 }
Пример #9
0
 public void OnSelectTreeViewObject(TreeViewObject obj, CustomTreeView treeView)
 {
     //MessageBox.Show(obj.Name);
 }