Ejemplo n.º 1
0
        /// <summary>
        /// The mouse was moved.
        /// </summary>
        /// <param name="Sender">The sender of the event.</param>
        /// <param name="MouseButtonEventArgs">The mouse button event arguments.</param>
        public void ProcessMouseRightButtonDown(Object Sender, MouseButtonEventArgs MouseButtonEventArgs)
        {
            var MousePosition = MouseButtonEventArgs.GetPosition(this);

            var GeoPos = GeoCalculations.Mouse2GeoCoordinate(MousePosition.X - this.ScreenOffset.X,
                                                             MousePosition.Y - this.ScreenOffset.Y,
                                                             ZoomLevel);

            Clipboard.SetData(DataFormats.Text, (Object)(GeoPos.Latitude.Value.ToString().Replace(",", ".") + ", " + GeoPos.Longitude.Value.ToString().Replace(",", ".")));
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Zoom out of the map.
 /// </summary>
 /// <param name="ScreenX">The x-coordinate of the zoom center on the map.</param>
 /// <param name="ScreenY">The y-coordinate of the zoom center on the map.</param>
 public void ZoomOut(Double ScreenX, Double ScreenY)
 {
     if (this.ZoomLevel > MinZoomLevel)
     {
         ZoomTo(GeoCalculations.Mouse2GeoCoordinate(ScreenX - this.ScreenOffset.X,
                                                    ScreenY - this.ScreenOffset.Y,
                                                    this.ZoomLevel),
                this.ZoomLevel - 1);
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// The mouse was moved above all canvas.
        /// </summary>
        /// <param name="Sender">The sender of the event.</param>
        /// <param name="MouseEventArgs">The mouse event arguments.</param>
        public void ProcessMouseMove(Object Sender, MouseEventArgs MouseEventArgs)
        {
            Int64 MapSizeAtZoomLevel;
            var   MousePosition = MouseEventArgs.GetPosition(this);

            if (LastMousePositionDuringMovement.X != MousePosition.X ||
                LastMousePositionDuringMovement.Y != MousePosition.Y)
            {
                #region The left mouse button is pressed => drag the map!

                if (MouseEventArgs.LeftButton == MouseButtonState.Pressed)
                {
                    if (Sender == BackgroundLayer &&
                        LastMouseClickPosition.X != 0 &&
                        LastMouseClickPosition.Y != 0)
                    {
                        MapSizeAtZoomLevel = (Int64)(Math.Pow(2, ZoomLevel) * 256);

                        this.ScreenOffset_AtMovementStart = new Point(this.ScreenOffset_AtMovementStart.X % MapSizeAtZoomLevel,
                                                                      this.ScreenOffset_AtMovementStart.Y % MapSizeAtZoomLevel);

                        this.ScreenOffset = new Point((Math.Round(ScreenOffset_AtMovementStart.X + MousePosition.X - LastMouseClickPosition.X) % MapSizeAtZoomLevel),
                                                      (Math.Round(ScreenOffset_AtMovementStart.Y + MousePosition.Y - LastMouseClickPosition.Y) % MapSizeAtZoomLevel));

                        AvoidEndlessVerticalScrolling();

                        MapCenter = GeoCalculations.Mouse2GeoCoordinate(MousePosition.X - this.ScreenOffset.X,
                                                                        MousePosition.Y - this.ScreenOffset.Y,
                                                                        this.ZoomLevel);

                        MapLayers.Values.ForEach(MapLayer => MapLayer.Move(MousePosition.X - LastMousePositionDuringMovement.X,
                                                                           MousePosition.Y - LastMousePositionDuringMovement.Y));

                        MapLayers.Values.ForEach(MapLayer => MapLayer.Redraw());

                        #region Send MapViewChanged events

                        MapMovements++;

                        if (MapViewChanged != null)
                        {
                            MapViewChanged(this, ScreenOffset, this.MapMovements);
                        }

                        #endregion
                    }
                }

                else
                {
                    LastMouseClickPosition.X = 0;
                    LastMouseClickPosition.Y = 0;
                }

                #endregion

                #region Send current mouse position as geo position

                if (GeoPositionChanged != null)
                {
                    GeoPositionChanged(this, GeoCalculations.Mouse2GeoCoordinate(MousePosition.X - this.ScreenOffset.X,
                                                                                 MousePosition.Y - this.ScreenOffset.Y,
                                                                                 ZoomLevel));
                }

                #endregion

                LastMousePositionDuringMovement = MousePosition;
            }
        }