Esempio n. 1
0
        void ITreeEvents.Collapse(KellTreeNode treeNode)
        {
            _treeState.Collapse(treeNode);
            _verticalPositioning.Collapse(treeNode);

            OnAfterCollapse(new TreeNodeEventArgs(treeNode));
        }
Esempio n. 2
0
        KellTreeNode[] ITreeInfo.GetVisibleNodes()
        {
            List <KellTreeNode> nodes = new List <KellTreeNode>();

            Utility.Collections.Set <KellTreeNode> disallowParents = new Utility.Collections.Set <KellTreeNode>();
            int top = ClientRectangle.Top, bottom = ClientRectangle.Bottom;

            top    -= AutoScrollPosition.Y;
            bottom -= AutoScrollPosition.Y;

            foreach (KellTreeNode treeNode in _verticalPositioning.GetNodesBetween(top, bottom))
            {
                KellTreeNode parent = treeNode.ParentCollection.ParentNode;

                if (parent != null && disallowParents.Contains(parent))
                {
                    if (!disallowParents.Contains(treeNode))
                    {
                        disallowParents.Add(treeNode);
                    }
                }
                else
                {
                    nodes.Add(treeNode);

                    if (!_treeState.IsExpanded(treeNode) && !disallowParents.Contains(treeNode))
                    {
                        disallowParents.Add(treeNode);
                    }
                }
            }

            return(nodes.ToArray());
        }
Esempio n. 3
0
        void ITreeEvents.Expand(KellTreeNode treeNode)
        {
            _treeState.Expand(treeNode);
            _verticalPositioning.Expand(treeNode);

            OnAfterExpand(new TreeNodeEventArgs(treeNode));
        }
Esempio n. 4
0
        void ITreeEvents.NodeInserted(KellTreeNode treeNode)
        {
            _treeState.NodeInserted(treeNode);
            _verticalPositioning.NodeInserted(treeNode);

            ApplyUpdate();
        }
Esempio n. 5
0
        protected override void OnMouseDown(MouseEventArgs e)
        {
            base.OnMouseDown(e);

            _gotDragClick = (e.Button == MouseButtons.Left);

            _mouseDownPosition = e.Location;

            int x = e.X - AutoScrollPosition.X;
            int y = e.Y - AutoScrollPosition.Y;

            KellTreeNode[] nodes = _verticalPositioning.GetNodesBetween(y, y);

            if (nodes.Length == 1)
            {
                KellTreeNode treeNode   = nodes[0];
                Rectangle    nodeBounds = _verticalPositioning.GetNodeBounds
                                              (treeNode, Internal.Coordinates.X | Internal.Coordinates.Y | Internal.Coordinates.Width | Internal.Coordinates.Height);
                Rectangle rowBounds = new Rectangle(0, nodeBounds.Y, AutoScrollMinSize.Width, nodeBounds.Height);

                if (rowBounds.Contains(x, y))
                {
                    _renderer.ProcessClick(CreateGraphics(), treeNode, nodeBounds, new Point(x, y), this, this);

                    OnNodeMouseClick(new TreeNodeMouseEventArgs(treeNode, e.Button));
                }
            }
        }
Esempio n. 6
0
        public void EnsureNodeVisible(KellTreeNode node)
        {
            if (node == null)
            {
                throw new ArgumentNullException("node");
            }

            using (SuspendUpdates())
            {
                KellTreeNode parent = node.ParentCollection.ParentNode;

                while (parent != null)
                {
                    if (!parent.IsExpanded)
                    {
                        ((ITreeEvents)this).ToggleNodeExpansion(parent);
                    }

                    parent = parent.ParentCollection.ParentNode;
                }
            }

            Rectangle bounds = _verticalPositioning.GetNodeBounds(node, Internal.Coordinates.Y | Internal.Coordinates.Height);

            bounds.Offset(AutoScrollPosition);

            if (bounds.Top < ClientRectangle.Top)
            {
                AutoScrollPosition = new Point(-AutoScrollPosition.X, -AutoScrollPosition.Y - (ClientRectangle.Top - bounds.Top) - 4);
            }
            else if (bounds.Bottom > ClientRectangle.Bottom)
            {
                AutoScrollPosition = new Point(-AutoScrollPosition.X, -AutoScrollPosition.Y + (bounds.Bottom - ClientRectangle.Bottom) + 4);
            }
        }
Esempio n. 7
0
        void ITreeInfo.GetMouseOver(out KellTreeNode treeNode, out Point nodeRelative)
        {
            if (!((ITreeInfo)this).IsMouseOverTree())
            {
                treeNode     = null;
                nodeRelative = Point.Empty;
                return;
            }

            Point p = PointToClient(Control.MousePosition);
            int   x = p.X - AutoScrollPosition.X;

            if (x < 0 || x > ClientRectangle.Width)
            {
                treeNode     = null;
                nodeRelative = Point.Empty;
                return;
            }

            int y = p.Y - AutoScrollPosition.Y;

            foreach (KellTreeNode tn in _verticalPositioning.GetNodesBetween(y, y))
            {
                Rectangle nodeBounds = _verticalPositioning.GetNodeBounds(tn, Internal.Coordinates.X | Internal.Coordinates.Y);

                treeNode     = tn;
                nodeRelative = new Point(x - nodeBounds.X, y - nodeBounds.Y);

                return;
            }

            treeNode     = null;
            nodeRelative = Point.Empty;
        }
Esempio n. 8
0
        void ITreeEvents.ToggleNodeExpansion(KellTreeNode treeNode)
        {
            _treeState.ToggleNodeExpansion(treeNode);
            _verticalPositioning.ToggleNodeExpansion(treeNode);

            ApplyUpdate();
        }
Esempio n. 9
0
        void ITreeEvents.NodeDeleted(KellTreeNode treeNode)
        {
            _animationRequests.EndAnimating(treeNode);
            _treeState.NodeDeleted(treeNode);
            _verticalPositioning.NodeDeleted(treeNode);

            ApplyUpdate();
        }
Esempio n. 10
0
        public void InvalidateNode(KellTreeNode node)
        {
            Rectangle nodeBounds = _verticalPositioning.GetNodeBounds(node, Internal.Coordinates.Y | Internal.Coordinates.Height);

            nodeBounds.Offset(0, AutoScrollPosition.Y);

            Rectangle rect = new Rectangle(0, nodeBounds.Y, Math.Max(Width, AutoScrollMinSize.Width), nodeBounds.Height);

            Invalidate(rect);
        }
Esempio n. 11
0
        void ITreeEvents.SelectNode(KellTreeNode treeNode)
        {
            if (treeNode == SelectedNode)
            {
                return;
            }

            _treeState.SelectNode(treeNode);
            _verticalPositioning.SelectNode(treeNode);

            OnAfterSelect(new TreeNodeEventArgs(treeNode));
        }
Esempio n. 12
0
        public void CollapseNode(KellTreeNode node)
        {
            if (node == null)
            {
                throw new ArgumentNullException("node");
            }

            if (_treeState.IsExpanded(node))
            {
                ((ITreeEvents)this).ToggleNodeExpansion(node);
            }
        }
Esempio n. 13
0
 public static void LoadTreeNodes(DirectoryNode dir, KellTreeNode treenode, List <KellNode> nodes, bool cycle)
 {
     foreach (DirectoryNode node in nodes)
     {
         KellTreeNode kellNode = treenode.ChildNodes.Add();
         kellNode.Name = node.ID;
         kellNode.Text = node.Name;
         kellNode.Tag  = node.Tag;
         if (cycle)
         {
             GetSubKellTreeNodes(node, kellNode, cycle);
         }
     }
 }
Esempio n. 14
0
        protected override void OnMouseMove(MouseEventArgs e)
        {
            base.OnMouseMove(e);

            Rectangle allowed = new Rectangle
                                    (_mouseDownPosition.X - SystemInformation.DoubleClickSize.Width / 2, _mouseDownPosition.Y - SystemInformation.DoubleClickSize.Height / 2
                                    , SystemInformation.DoubleClickSize.Width, SystemInformation.DoubleClickSize.Height);
            KellTreeNode node = GetNodeAt(_mouseDownPosition);

            if (_gotDragClick && node != null && e.Button != MouseButtons.None && !allowed.Contains(e.Location))
            {
                _gotDragClick = false;
                OnNodeDrag(new TreeNodeMouseEventArgs(node, e.Button));
            }
        }
Esempio n. 15
0
        public void MoveSelectionOne()
        {
            KellTreeNode node = SelectedNode;

            if (node == null)
            {
                return;
            }

            KellTreeNode next = _verticalPositioning.GetNodeAfter(node);

            if (next != null)
            {
                SelectedNode = next;
            }
        }
Esempio n. 16
0
        public static void GetSubKellTreeNodes(DirectoryNode dir, KellTreeNode kellNode, bool cycle)
        {
            List <KellNode> nodes = dir.GetSub();

            foreach (DirectoryNode node in nodes)
            {
                KellTreeNode ktn = kellNode.ChildNodes.Add();
                ktn.Name = node.ID;
                ktn.Text = node.Name;
                ktn.Tag  = node.Tag;
                if (cycle)
                {
                    GetSubKellTreeNodes(node, ktn, cycle);
                }
            }
        }
Esempio n. 17
0
        public static void LoadDirectory(DirectoryNode dir, KellTreeControl tree, bool cycle)
        {
            tree.RootNodes.Clear();
            KellTreeNode treenode = tree.RootNodes.Add();

            treenode.Text = dir.Name;
            if (cycle)
            {
                List <KellNode> sub = LoadDirectoryCycle(dir);
                LoadTreeNodes(dir, treenode, sub, cycle);
            }
            else
            {
                List <KellNode> nodes = dir.GetSub();
                LoadTreeNodes(dir, treenode, nodes, cycle);
            }
        }
Esempio n. 18
0
        private void _timer_Tick(object sender, EventArgs e)
        {
            Point newMousePosition = PointToClient(Control.MousePosition);

            Rectangle    clientRect = new Rectangle(-AutoScrollPosition.X, -AutoScrollPosition.Y, ClientRectangle.Width, ClientRectangle.Height);
            KellTreeNode node       = GetNodeAt(newMousePosition);

            newMousePosition.Offset(-AutoScrollPosition.X, -AutoScrollPosition.Y);

            Rectangle allowedRect = new Rectangle
                                        (newMousePosition.X - SystemInformation.MouseHoverSize.Width / 2, newMousePosition.Y - SystemInformation.MouseHoverSize.Height / 2
                                        , SystemInformation.MouseHoverSize.Width, SystemInformation.MouseHoverSize.Height);

            if (node == _hoverNode && allowedRect.Contains(newMousePosition) && clientRect.Contains(newMousePosition))
            {
                if (DateTime.Now.Subtract(_lastMouseTime).TotalMilliseconds > SystemInformation.MouseHoverTime && Form.ActiveForm == FindForm())
                {
                    if (node != null)
                    {
                        Rectangle nodeBounds = _verticalPositioning.GetNodeBounds
                                                   (node, Internal.Coordinates.X | Internal.Coordinates.Y | Internal.Coordinates.Width | Internal.Coordinates.Height);

                        nodeBounds = new Rectangle(nodeBounds.X + 20, nodeBounds.Y, nodeBounds.Width - 20, nodeBounds.Height);

                        if (!_hovering && nodeBounds.Contains(newMousePosition))
                        {
                            OnNodeMouseHover(new TreeNodeEventArgs(node));
                            _hovering = true;
                        }
                    }
                }
            }
            else
            {
                _lastMousePosition = newMousePosition;
                _lastMouseTime     = DateTime.Now;
                _hoverNode         = node;
                _hovering          = false;
            }
        }
Esempio n. 19
0
 Size ITreeInfo.GetNodeSize(KellTreeNode treeNode)
 {
     return(_verticalPositioning.GetNodeBounds(treeNode, Internal.Coordinates.Width | Internal.Coordinates.Height).Size);
 }
Esempio n. 20
0
        protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
        {
            KellTreeNode node = SelectedNode;

            switch (keyData)
            {
            case Keys.Multiply:
            {
                if (node != null)
                {
                    if (!node.IsExpanded)
                    {
                        ((ITreeEvents)this).ToggleNodeExpansion(node);
                    }

                    RecurseExpandAll(node.ChildNodes);
                }
                return(true);
            }

            case Keys.Subtract:
            {
                if (node != null)
                {
                    if (node.IsExpanded)
                    {
                        ((ITreeEvents)this).ToggleNodeExpansion(node);
                    }
                }
                return(true);
            }

            case Keys.Up:
            {
                if (node != null)
                {
                    KellTreeNode newNode = _verticalPositioning.GetNodeBefore(node);

                    if (newNode != null)
                    {
                        SelectedNode = newNode;
                    }
                }
                return(true);
            }

            case Keys.Down:
            {
                if (node != null)
                {
                    KellTreeNode newNode = _verticalPositioning.GetNodeAfter(node);

                    if (newNode != null)
                    {
                        SelectedNode = newNode;
                    }
                }
                return(true);
            }

            case Keys.Left:
            {
                while (node != null && (node.ChildNodes.Count == 0 || !_treeState.IsExpanded(node)))
                {
                    node = node.ParentCollection.ParentNode;
                }

                if (node != null)
                {
                    CollapseNode(node);
                }
                return(true);
            }

            case Keys.Right:
            {
                if (node != null)
                {
                    ExpandNode(node);
                }

                return(true);
            }

            case Keys.Up | Keys.Control:
            {
                AutoScrollPosition = new Point(-AutoScrollPosition.X, -AutoScrollPosition.Y - 16);
                return(true);
            }

            case Keys.Down | Keys.Control:
            {
                AutoScrollPosition = new Point(-AutoScrollPosition.X, -AutoScrollPosition.Y + 16);
                return(true);
            }

            case Keys.Left | Keys.Control:
            {
                AutoScrollPosition = new Point(-AutoScrollPosition.X - 16, -AutoScrollPosition.Y);
                return(true);
            }

            case Keys.Right | Keys.Control:
            {
                AutoScrollPosition = new Point(-AutoScrollPosition.X + 16, -AutoScrollPosition.Y);
                return(true);
            }

            default:
            {
                return(base.ProcessCmdKey(ref msg, keyData));
            }
            }
        }
Esempio n. 21
0
 double ITreeInfo.ExpansionAnimationPosition(KellTreeNode treeNode)
 {
     return(_verticalPositioning.ExpansionAnimationPosition(treeNode));
 }
Esempio n. 22
0
 bool ITreeInfo.IsExpanded(KellTreeNode treeNode)
 {
     return(_treeState.IsExpanded(treeNode));
 }
Esempio n. 23
0
 bool ITreeInfo.IsSelected(KellTreeNode treeNode)
 {
     return(_treeState.SelectedTreeNode == treeNode);
 }
Esempio n. 24
0
 void ITreeInfo.EndAnimating(KellTreeNode treeNode)
 {
     _animationRequests.EndAnimating(treeNode);
 }
Esempio n. 25
0
 void ITreeInfo.BeginAnimating(KellTreeNode treeNode, Rectangle subRect)
 {
     _animationRequests.BeginAnimating(treeNode, subRect);
 }