Example #1
0
        public static void OnMouseMove(MapTool mapTool, MouseEventArgs e)
        {
            if (e.Button != MouseButtons.None)
                return;

            RefreshCursor(mapTool);
        }
Example #2
0
        /// <summary>
        /// Converts a coordinate as clicked on the map (so in the maps coordinate system) to coordinates
        /// in the layer's coordinate system.
        /// </summary>
        /// <param name="mapTool"></param>
        /// <param name="mapCoordinate"></param>
        /// <returns></returns>
        protected static ICoordinate ConvertFromMapToLayer(MapTool mapTool, ICoordinate mapCoordinate)
        {
            var layer = mapTool.Layers.FirstOrDefault();

            if (layer == null)
            {
                return(mapCoordinate);
            }

            if (layer.CoordinateTransformation != null)
            {
                var xy = layer.CoordinateTransformation.MathTransform.Inverse()
                         .Transform(new[] { mapCoordinate.X, mapCoordinate.Y });
                return(new Coordinate(xy[0], xy[1]));
            }
            return(mapCoordinate);
        }
Example #3
0
 private static void RefreshCursor(MapTool mapTool)
 {
     if (mapTool.IsActive)
     {
         var targetLayer = mapTool.Layers.FirstOrDefault();
         if (targetLayer != null)
         {
             var cursor = cursorsPerTool[mapTool];
             if (cursor != null)
             {
                 SetCursor(mapTool, cursor);
                 return;
             }
         }
     }
     SetCursor(mapTool, Cursors.Default);
 }
Example #4
0
        /// <summary>
        /// Converts a coordinate as clicked on the map (so in the maps coordinate system) to coordinates 
        /// in the layer's coordinate system.
        /// </summary>
        /// <param name="mapTool"></param>
        /// <param name="mapCoordinate"></param>
        /// <returns></returns>
        protected static ICoordinate ConvertFromMapToLayer(MapTool mapTool, ICoordinate mapCoordinate)
        {
            var layer = mapTool.Layers.FirstOrDefault();
            if (layer == null)
                return mapCoordinate;

            if (layer.CoordinateTransformation != null)
            {
                var xy = layer.CoordinateTransformation.MathTransform.Inverse()
                              .Transform(new[] {mapCoordinate.X, mapCoordinate.Y});
                return new Coordinate(xy[0], xy[1]);
            }
            return mapCoordinate;
        }
Example #5
0
 private static void SetCursor(MapTool mapTool, Cursor cursor)
 {
     if (!ReferenceEquals(mapTool.MapControl.Cursor, cursor))
         mapTool.MapControl.Cursor = cursor;
 }
Example #6
0
 public static void OnIsActiveChanged(MapTool mapTool)
 {
     RefreshCursor(mapTool);
 }
Example #7
0
 public static void InitializeCursor(MapTool mapTool, Bitmap icon)
 {
     cursorsPerTool.Add(mapTool, icon != null ? CreateAddFeatureCursor(icon) : null);
 }