Example #1
0
        /// <summary> Called when the user moves the mouse over the hyperbolic tree.
        /// Used to signal the tree translation when the left button has been pressed over a node.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void MouseMoveHandler(object sender, MouseEventArgs e)
        {
            ScreenVector __p = this.GetPosition(sender, e);

            if (__p != null)
            {
                if (sender is Renderer)
                {
                    Renderer __htDraw = ((Renderer)sender);
                    __htDraw.ForEachNode(__p,
                                         delegate(NodeView node) { node.RenderIsMouseOver = true; },
                                         delegate(NodeView node) { node.RenderIsMouseOver = false; }
                                         );

                    if (_statusButtonDown == true)
                    {
                        if (_startPoint.IsValid)
                        {
                            _endPoint.ProjectionStoE(__p.X, __p.Y, _model.SOrigin, _model.SMax);
                            if (_endPoint.IsValid)
                            {
                                __htDraw.Translate(_startPoint, _endPoint);
                            }
                        }
                    }
                }
            }
        }
Example #2
0
        /// <summary> Called when a user pressed the mouse button on the hyperbolic tree.
        /// Used to get the starting point of the drag.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void MouseDownHandler(object sender, MouseButtonEventArgs e)
        {
            if (e.OriginalSource is System.Windows.Controls.TextBlock)
            {
                ScreenVector __p = GetPosition(sender, e);

                if (__p != null)
                {
                    if (sender is Renderer)
                    {
                        Renderer __htDraw = ((Renderer)sender);
                        NodeView __node   = __htDraw.FindNode(__p);

                        if (__node != null)
                        {
                            __node.RenderIsPressed = true;
                        }
                        else
                        {
                            foreach (NodeView __n in __htDraw.Children)
                            {
                                __n.RenderIsPressed = false;
                            }
                        }
                    }

                    _startPoint.ProjectionStoE(__p.X, __p.Y, _model.SOrigin, _model.SMax);

                    _clickPoint.X = __p.X;
                    _clickPoint.Y = __p.Y;

                    if (e.ClickCount > 1)
                    {
                        _statusButtonDown = false;
                        MouseClicked(sender, e);
                    }
                    else
                    {
                        _statusButtonDown = true;
                    }
                }
            }
        }