Esempio n. 1
0
        public void RecalcLayout()
        {
            if (m_firstVisibleNode == null)
            {
                m_firstVisibleNode = Nodes.FirstNode;
            }
            //if (Nodes.Count == 0)
            if (Nodes.VisibleNodeCount == 0)
            {
                m_firstVisibleNode = null;
            }

            UpdateScrollBars();
            int vscroll = VScrollValue();

            if (vscroll == 0)
            {
                m_firstVisibleNode = Nodes.FirstNode;
            }
            else
            {
                m_firstVisibleNode = NodeCollection.GetNextNode(Nodes.FirstNode, vscroll);
            }
            Invalidate();
        }
Esempio n. 2
0
        public Node CalcHitNode(Point mousepoint)
        {
            int hitrow = CalcHitRow(mousepoint);

            if (hitrow < 0)
            {
                return(null);
            }
            return(NodeCollection.GetNextNode(m_firstVisibleNode, hitrow));
        }
Esempio n. 3
0
        void OnVScroll(object sender, ScrollEventArgs e)
        {
            int diff = e.NewValue - e.OldValue;

            //assumedScrollPos += diff;
            if (e.NewValue == 0)
            {
                m_firstVisibleNode = Nodes.FirstNode;
                diff = 0;
            }
            m_firstVisibleNode = NodeCollection.GetNextNode(m_firstVisibleNode, diff);
            Invalidate();
        }
Esempio n. 4
0
        protected override void OnKeyDown(KeyEventArgs e)
        {
            Node newnode = null;

            if (e.KeyCode == Keys.PageUp)
            {
                int remainder = 0;
                int diff      = MaxVisibleRows(out remainder) - 1;
                newnode = NodeCollection.GetNextNode(FocusedNode, -diff);
                if (newnode == null)
                {
                    newnode = Nodes.FirstVisibleNode();
                }
            }
            if (e.KeyCode == Keys.PageDown)
            {
                int remainder = 0;
                int diff      = MaxVisibleRows(out remainder) - 1;
                newnode = NodeCollection.GetNextNode(FocusedNode, diff);
                if (newnode == null)
                {
                    newnode = Nodes.LastVisibleNode(true);
                }
            }

            if (e.KeyCode == Keys.Down)
            {
                newnode = NodeCollection.GetNextNode(FocusedNode, 1);
            }
            if (e.KeyCode == Keys.Up)
            {
                newnode = NodeCollection.GetNextNode(FocusedNode, -1);
            }
            if (e.KeyCode == Keys.Home)
            {
                newnode = Nodes.FirstNode;
            }
            if (e.KeyCode == Keys.End)
            {
                newnode = Nodes.LastVisibleNode(true);
            }
            if (e.KeyValue == 109) // Touche (-) numérique
            {
                if (FocusedNode != null)
                {
                    if (FocusedNode.Expanded)
                    {
                        FocusedNode.Collapse();
                        EnsureVisible(FocusedNode);
                        return;
                    }
                }
            }
            if (e.KeyCode == Keys.Left)
            {
                if (FocusedNode != null)
                {
                    if (FocusedNode.Expanded)
                    {
                        FocusedNode.Collapse();
                        EnsureVisible(FocusedNode);
                        return;
                    }
                    if (FocusedNode.Parent != null)
                    {
                        FocusedNode = FocusedNode.Parent;
                        EnsureVisible(FocusedNode);
                    }
                }
            }
            if (e.KeyValue == 107) // Touche (+) numérique
            {
                if (FocusedNode != null)
                {
                    if (FocusedNode.Expanded == false && FocusedNode.HasChildren)
                    {
                        FocusedNode.Expand();
                        EnsureVisible(FocusedNode);
                        return;
                    }
                }
            }
            if (e.KeyCode == Keys.Right)
            {
                if (FocusedNode != null)
                {
                    if (FocusedNode.Expanded == false && FocusedNode.HasChildren)
                    {
                        FocusedNode.Expand();
                        EnsureVisible(FocusedNode);
                        return;
                    }
                    if (FocusedNode.Expanded == true && FocusedNode.HasChildren)
                    {
                        FocusedNode = FocusedNode.Nodes.FirstNode;
                        EnsureVisible(FocusedNode);
                    }
                }
            }
            if (e.KeyValue == 106) // Touche (*) numérique
            {
                if (FocusedNode != null)
                {
                    if (FocusedNode.Expanded == false && FocusedNode.HasChildren)
                    {
                        FocusedNode.ExpandAll();
                        EnsureVisible(FocusedNode);
                        return;
                    }
                }
            }

            if (newnode != null)
            {
                if (MultiSelect)
                {
                    // tree behavior is
                    // keys none,		the selected node is added as the focused and selected node
                    // keys control,	only focused node is moved, the selected nodes collection is not modified
                    // keys shift,		selection from first selected node to current node is done
                    if (Control.ModifierKeys == Keys.Control)
                    {
                        FocusedNode = newnode;
                    }
                    else
                    {
                        MultiSelectAdd(newnode, Control.ModifierKeys);
                    }
                }
                else
                {
                    FocusedNode = newnode;
                }
                EnsureVisible(FocusedNode);
            }
            base.OnKeyDown(e);
        }