Esempio n. 1
0
        protected override void OnMouseDown(MouseEventArgs e)
        {
            this.Focus();

            float x = e.X;
            float y = e.Y;
            x = (x - dx) / scale;
            y = (y - dy) / scale;

            this.lastX = e.X;
            this.lastY = e.Y;

            if (tree == null) return;

            Tree node = tree.Select(x, y);
            if ((node == null || node.State == TreeState.Current) && this.CurrentSelect != null)
            {
                this.CurrentSelect.State = TreeState.Normal;
                this.CurrentSelect = null;
                this.Refresh();
            }
            if (node != null && node != this.CurrentSelect)
            {
                if (node.State != TreeState.Current)
                {
                    if (this.CurrentSelect != null)
                    {
                        this.CurrentSelect.State = TreeState.Normal;
                    }
                    this.CurrentSelect = node;
                    this.CurrentSelect.State = TreeState.Selected;
                    this.CurrentHover = null;
                    this.Refresh();
                    if (this.NodeClick != null)
                    {
                        this.NodeClick.Invoke(node.Event);
                    }
                }
                else
                {
                    if (this.NodeClick != null)
                    {
                        this.NodeClick.Invoke(node.Event);
                    }
                }
            }
        }
Esempio n. 2
0
 public void SetTree(Tree tree)
 {
     this.tree = tree;
     this.Refresh();
 }
Esempio n. 3
0
 public void Add(Tree node)
 {
     this.Children.Add(node);
 }