Exemplo n.º 1
0
        protected void control_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            if (IsMapLoaded)
            {
                //Get keyboard focus
                Keyboard.Focus(this);

                //Save starting point, used later when determining how much to scroll
                startPosition = e.GetPosition(this);
                startOffset   = new Point(translateTransform.X, translateTransform.Y);

                var shiftPressed = Keyboard.IsKeyDown(Key.LeftShift) || Keyboard.IsKeyDown(Key.RightShift);

                if (!shiftPressed)
                {
                    CaptureMouse();
                    Cursor = Cursors.ScrollAll;
                }
                else
                {
                    lastDistance = new DistanceOverlay(FromLocalToMap(startPosition), FromLocalToMap(startPosition), "0m")
                    {
                        Tag = "distance"
                    };
                    AddOverlay(lastDistance);
                }
            }
        }
Exemplo n.º 2
0
        protected void control_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            if (IsMouseCaptured)
            {
                //Reset the cursor and release the mouse pointer
                Cursor = Cursors.Arrow;
                ReleaseMouseCapture();
            }
            else
            {
                var shiftPressed = Keyboard.IsKeyDown(Key.LeftShift) || Keyboard.IsKeyDown(Key.RightShift);

                if (shiftPressed)
                {
                    lastDistance = null;
                }
            }
        }
Exemplo n.º 3
0
        protected void control_MouseMove(object sender, MouseEventArgs e)
        {
            if (IsMapLoaded)
            {
                var position = e.GetPosition(this);

                if (IsMouseCaptured)
                {
                    //Move the content
                    var displacement = new Vector(position.X - startPosition.X + startOffset.X, position.Y - startPosition.Y + startOffset.Y);
                    LocalPanTo(displacement);
                }
                else
                {
                    MousePointerPosition = FromLocalToMap(position);

                    var shiftPressed = Keyboard.IsKeyDown(Key.LeftShift) || Keyboard.IsKeyDown(Key.RightShift);

                    if (shiftPressed && lastDistance != null)
                    {
                        var a        = FromLocalToMap(startPosition);
                        var b        = FromLocalToMap(e.GetPosition(this));
                        var distance = Math.Sqrt((a.X - b.X) * (a.X - b.X) + (a.Y - b.Y) * (a.Y - b.Y));
                        RemoveOverlay(lastDistance);
                        lastDistance = new DistanceOverlay(a, b, string.Format("{0:0}m", distance))
                        {
                            Tag = "distance"
                        };
                        AddOverlay(lastDistance);
                    }
                }
            }
            else
            {
                MousePointerPosition = ORIGIN;
            }
        }