public static void OnMouseMove(MapTool mapTool, MouseEventArgs e) { if (e.Button != MouseButtons.None) return; RefreshCursor(mapTool); }
/// <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); }
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); }
/// <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; }
private static void SetCursor(MapTool mapTool, Cursor cursor) { if (!ReferenceEquals(mapTool.MapControl.Cursor, cursor)) mapTool.MapControl.Cursor = cursor; }
public static void OnIsActiveChanged(MapTool mapTool) { RefreshCursor(mapTool); }
public static void InitializeCursor(MapTool mapTool, Bitmap icon) { cursorsPerTool.Add(mapTool, icon != null ? CreateAddFeatureCursor(icon) : null); }