Beispiel #1
0
        public bool HandleMouseLeave()
        {
            if (_tooltip != null)
            {
                _tooltip.IsOpen     = false;
                _tooltip.Visibility = Visibility.Hidden;
            }

            if (_hitVisual == null)
            {
                return(false);
            }

            string itemName = SvgObject.GetName(_hitVisual);

            if (itemName == null)
            {
                _hitVisual = null;
                return(false);
            }
            if (_visualBrushes.ContainsKey(itemName) && (_hitVisual != _selectedVisual))
            {
                SolidColorBrush brush = _visualBrushes[itemName] as SolidColorBrush;
                if (brush != null)
                {
                    brush.Color = _colorLink;
                }
            }
            _hitVisual = null;

            return(true);
        }
Beispiel #2
0
        protected override void OnMouseLeave(MouseEventArgs e)
        {
            base.OnMouseLeave(e);

            if (_animationCanvas != null && _animationCanvas.HandleMouseLeave())
            {
                return;
            }

            if (_tooltip != null)
            {
                _tooltip.IsOpen     = false;
                _tooltip.Visibility = Visibility.Hidden;
            }

            if (_hitVisual == null)
            {
                return;
            }

            string itemName = SvgObject.GetName(_hitVisual);

            if (itemName == null)
            {
                _hitVisual = null;
                return;
            }
            //if (_visualBrushes.ContainsKey(itemName))
            //{
            //    Brush brush = _visualBrushes[itemName];
            //    brush.Opacity = 0;
            //}
            _hitVisual = null;

            this.Cursor = Cursors.Arrow;
        }
Beispiel #3
0
        protected override void OnMouseDown(MouseButtonEventArgs e)
        {
            base.OnMouseDown(e);

            if (_animationCanvas != null && _animationCanvas.HandleMouseDown(e))
            {
                return;
            }

            Point pt = e.GetPosition(this);

            Drawing visual = HitTest(pt);

            if (visual == null)
            {
                if (_tooltip != null)
                {
                    _tooltip.IsOpen     = false;
                    _tooltip.Visibility = Visibility.Hidden;
                }

                this.Cursor = Cursors.Arrow;
                return;
            }

            string itemName = SvgObject.GetName(visual);

            if (itemName == null)
            {
                if (_tooltip != null)
                {
                    _tooltip.IsOpen     = false;
                    _tooltip.Visibility = Visibility.Hidden;
                }

                return;
            }
            //Brush brush = null;
            //if (_visualBrushes.ContainsKey(itemName))
            //{
            //    brush = _visualBrushes[itemName];
            //}
            //if (brush == null)
            //{
            //    if (_tooltip != null)
            //    {
            //        _tooltip.IsOpen = false;
            //        _tooltip.Visibility = Visibility.Hidden;
            //    }

            //    return;
            //}

            //if (e.ChangedButton == MouseButton.Left)
            //{
            //    string brushName = SvgObject.GetName(visual);
            //    if (!string.IsNullOrWhiteSpace(brushName))
            //    {
            //        SvgLinkAction linkAction = SvgLink.GetLinkAction(visual);
            //        if (linkAction == SvgLinkAction.LinkHtml ||
            //            linkAction == SvgLinkAction.LinkPage)
            //        {
            //            _animator.Start(brushName, brush);
            //        }
            //    }
            //}
            //else if (e.ChangedButton == MouseButton.Right)
            //{
            //    _animator.Stop();
            //}
        }
Beispiel #4
0
        public bool HandleMouseDown(MouseButtonEventArgs e)
        {
            Point pt = e.GetPosition(_drawingCanvas);

            Drawing visual = HitTest(pt);

            if (visual == null)
            {
                if (_tooltip != null)
                {
                    _tooltip.IsOpen     = false;
                    _tooltip.Visibility = Visibility.Hidden;
                }

                return(false);
            }

            if (_selectedVisual != null && visual == _selectedVisual)
            {
                _drawingCanvas.Cursor = Cursors.Hand;

                return(true);
            }

            string itemName = SvgObject.GetName(visual);

            if (itemName == null)
            {
                if (_tooltip != null)
                {
                    _tooltip.IsOpen     = false;
                    _tooltip.Visibility = Visibility.Hidden;
                }

                return(false);
            }
            SolidColorBrush brush = null;

            if (_visualBrushes.ContainsKey(itemName))
            {
                brush = _visualBrushes[itemName] as SolidColorBrush;

                if (brush != null)
                {
                    brush.Color = _colorSelected;
                }
            }
            if (brush == null)
            {
                if (_tooltip != null)
                {
                    _tooltip.IsOpen     = false;
                    _tooltip.Visibility = Visibility.Hidden;
                }

                return(false);
            }
            if (_selectedVisual != null)
            {
                itemName = SvgObject.GetName(_selectedVisual);
                if (itemName == null)
                {
                    return(false);
                }
                if (_visualBrushes.ContainsKey(itemName))
                {
                    brush = _visualBrushes[itemName] as SolidColorBrush;

                    if (brush != null)
                    {
                        brush.Color = _colorLink;
                    }
                }
                else
                {
                    return(false);
                }
            }

            _selectedVisual = visual;

            if (e.ChangedButton == MouseButton.Left)
            {
                string brushName = SvgObject.GetName(brush);
                if (!string.IsNullOrWhiteSpace(brushName))
                {
                    SvgLinkAction linkAction = SvgLink.GetAction(visual);
                    if (linkAction == SvgLinkAction.LinkHtml ||
                        linkAction == SvgLinkAction.LinkPage)
                    {
                        _animator.Start(brushName, brush);
                    }
                }
            }
            else if (e.ChangedButton == MouseButton.Right)
            {
                _animator.Stop();
            }

            return(true);
        }
Beispiel #5
0
        public bool HandleMouseMove(MouseEventArgs e)
        {
            // Retrieve the coordinates of the mouse button event.
            Point pt = e.GetPosition(_drawingCanvas);

            Drawing hitVisual = HitTest(pt);

            if (_selectedVisual != null && hitVisual == _selectedVisual)
            {
                _drawingCanvas.Cursor = Cursors.Hand;

                return(true);
            }

            string itemName = null;

            if (hitVisual == null)
            {
                if (_hitVisual != null)
                {
                    itemName = SvgObject.GetName(_hitVisual);
                    if (itemName == null)
                    {
                        _hitVisual = null;
                        return(false);
                    }
                    if (_visualBrushes.ContainsKey(itemName) && (_hitVisual != _selectedVisual))
                    {
                        SolidColorBrush brush = _visualBrushes[itemName] as SolidColorBrush;
                        if (brush != null)
                        {
                            brush.Color = _colorLink;
                        }
                    }
                    _hitVisual = null;
                }

                if (_tooltip != null)
                {
                    _tooltip.IsOpen     = false;
                    _tooltip.Visibility = Visibility.Hidden;
                }

                return(false);
            }
            else
            {
                _drawingCanvas.Cursor = Cursors.Hand;

                if (hitVisual == _hitVisual)
                {
                    return(false);
                }

                if (_hitVisual != null)
                {
                    itemName = SvgObject.GetName(_hitVisual);
                    if (itemName == null)
                    {
                        _hitVisual = null;
                        return(false);
                    }
                    if (_visualBrushes.ContainsKey(itemName) && (_hitVisual != _selectedVisual))
                    {
                        SolidColorBrush brush = _visualBrushes[itemName] as SolidColorBrush;
                        if (brush != null)
                        {
                            brush.Color = _colorLink;
                        }
                    }
                    _hitVisual = null;
                }

                itemName = SvgObject.GetName(hitVisual);
                if (itemName == null)
                {
                    return(false);
                }
                if (_visualBrushes.ContainsKey(itemName))
                {
                    SolidColorBrush brush = _visualBrushes[itemName] as SolidColorBrush;
                    if (brush != null)
                    {
                        brush.Color = _colorHover;
                    }
                }
                _hitVisual = hitVisual;

                string        tooltipText = itemName;
                SvgLinkAction linkAction  = SvgLink.GetAction(hitVisual);
                if (linkAction == SvgLinkAction.LinkTooltip &&
                    _tooltip != null && !string.IsNullOrWhiteSpace(tooltipText))
                {
                    Rect rectBounds = hitVisual.Bounds;

                    _tooltip.PlacementRectangle = rectBounds;

                    _tooltipText.Text = tooltipText;

                    if (_tooltip.Visibility == Visibility.Hidden)
                    {
                        _tooltip.Visibility = Visibility.Visible;
                    }

                    _tooltip.IsOpen = true;
                }
                else
                {
                    if (_tooltip != null)
                    {
                        _tooltip.IsOpen     = false;
                        _tooltip.Visibility = Visibility.Hidden;
                    }
                }
            }

            return(true);
        }