mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2025-12-06 07:12:04 +01:00
Update comments
This commit is contained in:
parent
9db1987ee5
commit
754e185c5d
|
|
@ -94,7 +94,8 @@ namespace MapControl
|
||||||
|
|
||||||
image.RenderTransform = new RotateTransform { Angle = -rotation };
|
image.RenderTransform = new RotateTransform { Angle = -rotation };
|
||||||
|
|
||||||
// effective unrotated transform
|
// Calculate effective unrotated transform.
|
||||||
|
//
|
||||||
transform.M11 = Math.Sqrt(transform.M11 * transform.M11 + transform.M12 * transform.M12);
|
transform.M11 = Math.Sqrt(transform.M11 * transform.M11 + transform.M12 * transform.M12);
|
||||||
transform.M22 = -Math.Sqrt(transform.M22 * transform.M22 + transform.M21 * transform.M21);
|
transform.M22 = -Math.Sqrt(transform.M22 * transform.M22 + transform.M21 * transform.M21);
|
||||||
transform.M12 = 0;
|
transform.M12 = 0;
|
||||||
|
|
|
||||||
|
|
@ -114,7 +114,8 @@ namespace MapControl
|
||||||
overlay.RenderTransform = new RotateTransform { Angle = -imageOverlay.LatLonBox.Rotation };
|
overlay.RenderTransform = new RotateTransform { Angle = -imageOverlay.LatLonBox.Rotation };
|
||||||
overlay.RenderTransformOrigin = new Point(0.5, 0.5);
|
overlay.RenderTransformOrigin = new Point(0.5, 0.5);
|
||||||
|
|
||||||
// additional Panel for map rotation, see MapPanel.ArrangeElementWithBoundingBox
|
// Additional Panel for map rotation, see MapPanel.ArrangeElementWithBoundingBox.
|
||||||
|
//
|
||||||
var panel = new Grid { UseLayoutRounding = false };
|
var panel = new Grid { UseLayoutRounding = false };
|
||||||
panel.Children.Add(overlay);
|
panel.Children.Add(overlay);
|
||||||
overlay = panel;
|
overlay = panel;
|
||||||
|
|
|
||||||
|
|
@ -89,7 +89,7 @@ namespace MapControl
|
||||||
{
|
{
|
||||||
byte[] buffer = null;
|
byte[] buffer = null;
|
||||||
|
|
||||||
// check for possibly unavailable Bing Maps tile
|
// Check for possibly unavailable Bing Maps tile.
|
||||||
//
|
//
|
||||||
if (!responseMessage.Headers.TryGetValues("X-VE-Tile-Info", out IEnumerable<string> tileInfo) ||
|
if (!responseMessage.Headers.TryGetValues("X-VE-Tile-Info", out IEnumerable<string> tileInfo) ||
|
||||||
!tileInfo.Contains("no-tile"))
|
!tileInfo.Contains("no-tile"))
|
||||||
|
|
|
||||||
|
|
@ -343,7 +343,9 @@ namespace MapControl
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
TranslateMap(translation); // more precise
|
// More accurate than SetTransformCenter.
|
||||||
|
//
|
||||||
|
TranslateMap(translation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -764,7 +766,8 @@ namespace MapControl
|
||||||
|
|
||||||
if (resetTransformCenter)
|
if (resetTransformCenter)
|
||||||
{
|
{
|
||||||
// check if transform center moved across the dateline
|
// Check if transform center moved across the dateline.
|
||||||
|
//
|
||||||
transformCenterChanged = Math.Abs(center.Longitude - transformCenter.Longitude) > 180d;
|
transformCenterChanged = Math.Abs(center.Longitude - transformCenter.Longitude) > 180d;
|
||||||
|
|
||||||
ResetTransformCenter();
|
ResetTransformCenter();
|
||||||
|
|
@ -783,7 +786,8 @@ namespace MapControl
|
||||||
|
|
||||||
SetViewScale(ViewTransform.Scale);
|
SetViewScale(ViewTransform.Scale);
|
||||||
|
|
||||||
// check if view center moved across the dateline
|
// Check if view center moved across the dateline.
|
||||||
|
//
|
||||||
transformCenterChanged = transformCenterChanged || Math.Abs(Center.Longitude - centerLongitude) > 180d;
|
transformCenterChanged = transformCenterChanged || Math.Abs(Center.Longitude - centerLongitude) > 180d;
|
||||||
centerLongitude = Center.Longitude;
|
centerLongitude = Center.Longitude;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -114,7 +114,7 @@ namespace MapControl
|
||||||
{
|
{
|
||||||
if (!rotation.HasValue)
|
if (!rotation.HasValue)
|
||||||
{
|
{
|
||||||
// get rotation from second location with same latitude
|
// Get rotation from second location with same latitude.
|
||||||
//
|
//
|
||||||
var pos = ParentMap.LocationToView(
|
var pos = ParentMap.LocationToView(
|
||||||
new Location(location.Latitude, location.Longitude + 10d / PixelPerLongitudeDegree(location)));
|
new Location(location.Latitude, location.Longitude + 10d / PixelPerLongitudeDegree(location)));
|
||||||
|
|
|
||||||
|
|
@ -180,7 +180,7 @@ namespace MapControl
|
||||||
{
|
{
|
||||||
if (updateInProgress)
|
if (updateInProgress)
|
||||||
{
|
{
|
||||||
// update image on next tick, start timer if not running
|
// Update image on next tick, start timer if not running.
|
||||||
//
|
//
|
||||||
updateTimer.Run();
|
updateTimer.Run();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,9 @@ namespace MapControl
|
||||||
|
|
||||||
protected override Size ArrangeOverride(Size bounds)
|
protected override Size ArrangeOverride(Size bounds)
|
||||||
{
|
{
|
||||||
if (mapTransform != null) // property in use, e.g. as source of a Binding
|
// If MapTransform is used, update its Matrix property.
|
||||||
|
//
|
||||||
|
if (mapTransform != null)
|
||||||
{
|
{
|
||||||
var parentMap = (VisualTreeHelper.GetParent(this) as MapPanel)?.ParentMap;
|
var parentMap = (VisualTreeHelper.GetParent(this) as MapPanel)?.ParentMap;
|
||||||
|
|
||||||
|
|
@ -184,7 +186,7 @@ namespace MapControl
|
||||||
|
|
||||||
if (SelectionMode == SelectionMode.Single)
|
if (SelectionMode == SelectionMode.Single)
|
||||||
{
|
{
|
||||||
// Single -> set only SelectedItem
|
// Single -> set only SelectedItem.
|
||||||
|
|
||||||
if (SelectedItem != item)
|
if (SelectedItem != item)
|
||||||
{
|
{
|
||||||
|
|
@ -197,7 +199,7 @@ namespace MapControl
|
||||||
}
|
}
|
||||||
else if (SelectionMode == SelectionMode.Multiple || controlKey)
|
else if (SelectionMode == SelectionMode.Multiple || controlKey)
|
||||||
{
|
{
|
||||||
// Multiple or Extended with Ctrl -> toggle item in SelectedItems
|
// Multiple or Extended with Ctrl -> toggle item in SelectedItems.
|
||||||
|
|
||||||
if (SelectedItems.Contains(item))
|
if (SelectedItems.Contains(item))
|
||||||
{
|
{
|
||||||
|
|
@ -210,7 +212,7 @@ namespace MapControl
|
||||||
}
|
}
|
||||||
else if (shiftKey && SelectedItem != null)
|
else if (shiftKey && SelectedItem != null)
|
||||||
{
|
{
|
||||||
// Extended with Shift -> select items in view rectangle
|
// Extended with Shift -> select items in view rectangle.
|
||||||
|
|
||||||
var p1 = MapPanel.GetViewPosition(ContainerFromItem(SelectedItem));
|
var p1 = MapPanel.GetViewPosition(ContainerFromItem(SelectedItem));
|
||||||
var p2 = MapPanel.GetViewPosition(mapItem);
|
var p2 = MapPanel.GetViewPosition(mapItem);
|
||||||
|
|
@ -222,7 +224,7 @@ namespace MapControl
|
||||||
}
|
}
|
||||||
else if (SelectedItem != item)
|
else if (SelectedItem != item)
|
||||||
{
|
{
|
||||||
// Extended without Control or Shift -> set selected item
|
// Extended without Control or Shift -> set selected item.
|
||||||
|
|
||||||
SelectedItem = item;
|
SelectedItem = item;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -108,7 +108,7 @@ namespace MapControl
|
||||||
{
|
{
|
||||||
foreach (var tile in Tiles)
|
foreach (var tile in Tiles)
|
||||||
{
|
{
|
||||||
// arrange tiles relative to XMin/YMin
|
// Arrange tiles relative to XMin/YMin.
|
||||||
//
|
//
|
||||||
var tileSize = TileSize << (TileMatrix.ZoomLevel - tile.ZoomLevel);
|
var tileSize = TileSize << (TileMatrix.ZoomLevel - tile.ZoomLevel);
|
||||||
var x = tileSize * tile.X - TileSize * TileMatrix.XMin;
|
var x = tileSize * tile.X - TileSize * TileMatrix.XMin;
|
||||||
|
|
@ -162,7 +162,7 @@ namespace MapControl
|
||||||
{
|
{
|
||||||
if (TileMatrix != null)
|
if (TileMatrix != null)
|
||||||
{
|
{
|
||||||
// tile matrix origin in pixels
|
// Tile matrix origin in pixels.
|
||||||
//
|
//
|
||||||
var tileMatrixOrigin = new Point(TileSize * TileMatrix.XMin, TileSize * TileMatrix.YMin);
|
var tileMatrixOrigin = new Point(TileSize * TileMatrix.XMin, TileSize * TileMatrix.YMin);
|
||||||
|
|
||||||
|
|
@ -175,15 +175,17 @@ namespace MapControl
|
||||||
|
|
||||||
private bool SetTileMatrix()
|
private bool SetTileMatrix()
|
||||||
{
|
{
|
||||||
var tileMatrixZoomLevel = (int)Math.Floor(ParentMap.ZoomLevel - ZoomLevelOffset + 0.001); // avoid rounding issues
|
// Add 0.001 to avoid rounding issues.
|
||||||
|
//
|
||||||
|
var tileMatrixZoomLevel = (int)Math.Floor(ParentMap.ZoomLevel - ZoomLevelOffset + 0.001);
|
||||||
|
|
||||||
var tileMatrixScale = ViewTransform.ZoomLevelToScale(tileMatrixZoomLevel);
|
var tileMatrixScale = ViewTransform.ZoomLevelToScale(tileMatrixZoomLevel);
|
||||||
|
|
||||||
// bounds in tile pixels from view size
|
// Bounds in tile pixels from view size.
|
||||||
//
|
//
|
||||||
var bounds = ParentMap.ViewTransform.GetTileMatrixBounds(tileMatrixScale, MapTopLeft, ParentMap.RenderSize);
|
var bounds = ParentMap.ViewTransform.GetTileMatrixBounds(tileMatrixScale, MapTopLeft, ParentMap.RenderSize);
|
||||||
|
|
||||||
// tile X and Y bounds
|
// Tile X and Y bounds.
|
||||||
//
|
//
|
||||||
var xMin = (int)Math.Floor(bounds.X / TileSize);
|
var xMin = (int)Math.Floor(bounds.X / TileSize);
|
||||||
var yMin = (int)Math.Floor(bounds.Y / TileSize);
|
var yMin = (int)Math.Floor(bounds.Y / TileSize);
|
||||||
|
|
|
||||||
|
|
@ -93,13 +93,13 @@ namespace MapControl
|
||||||
|
|
||||||
transform.Rotate(Rotation);
|
transform.Rotate(Rotation);
|
||||||
|
|
||||||
// tile matrix origin in map coordinates
|
// Tile matrix origin in map coordinates.
|
||||||
//
|
//
|
||||||
var mapOrigin = new Point(
|
var mapOrigin = new Point(
|
||||||
tileMatrixTopLeft.X + tileMatrixOrigin.X / tileMatrixScale,
|
tileMatrixTopLeft.X + tileMatrixOrigin.X / tileMatrixScale,
|
||||||
tileMatrixTopLeft.Y - tileMatrixOrigin.Y / tileMatrixScale);
|
tileMatrixTopLeft.Y - tileMatrixOrigin.Y / tileMatrixScale);
|
||||||
|
|
||||||
// tile matrix origin in view coordinates
|
// Tile matrix origin in view coordinates.
|
||||||
//
|
//
|
||||||
var viewOrigin = MapToView(mapOrigin);
|
var viewOrigin = MapToView(mapOrigin);
|
||||||
|
|
||||||
|
|
@ -115,17 +115,17 @@ namespace MapControl
|
||||||
|
|
||||||
transform.Rotate(-Rotation);
|
transform.Rotate(-Rotation);
|
||||||
|
|
||||||
// view origin in map coordinates
|
// View origin in map coordinates.
|
||||||
//
|
//
|
||||||
var origin = ViewToMap(new Point());
|
var origin = ViewToMap(new Point());
|
||||||
|
|
||||||
// translate origin to tile matrix origin in pixels
|
// Translate origin to tile matrix origin in pixels.
|
||||||
//
|
//
|
||||||
transform.Translate(
|
transform.Translate(
|
||||||
tileMatrixScale * (origin.X - tileMatrixTopLeft.X),
|
tileMatrixScale * (origin.X - tileMatrixTopLeft.X),
|
||||||
tileMatrixScale * (tileMatrixTopLeft.Y - origin.Y));
|
tileMatrixScale * (tileMatrixTopLeft.Y - origin.Y));
|
||||||
|
|
||||||
// transform view bounds to tile pixel bounds
|
// Transform view bounds to tile pixel bounds.
|
||||||
//
|
//
|
||||||
return new MatrixTransform { Matrix = transform }
|
return new MatrixTransform { Matrix = transform }
|
||||||
.TransformBounds(new Rect(0d, 0d, viewSize.Width, viewSize.Height));
|
.TransformBounds(new Rect(0d, 0d, viewSize.Width, viewSize.Height));
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,9 @@ namespace MapControl
|
||||||
new PropertyMetadata(null,
|
new PropertyMetadata(null,
|
||||||
async (o, e) =>
|
async (o, e) =>
|
||||||
{
|
{
|
||||||
if (e.OldValue != null) // ignore property change from GetImageAsync
|
// Ignore property change from GetImageAsync, when Layers was null.
|
||||||
|
//
|
||||||
|
if (e.OldValue != null)
|
||||||
{
|
{
|
||||||
await ((WmsImageLayer)o).UpdateImageAsync();
|
await ((WmsImageLayer)o).UpdateImageAsync();
|
||||||
}
|
}
|
||||||
|
|
@ -176,7 +178,9 @@ namespace MapControl
|
||||||
if (Layers == null &&
|
if (Layers == null &&
|
||||||
ServiceUri.ToString().IndexOf("LAYERS=", StringComparison.OrdinalIgnoreCase) < 0)
|
ServiceUri.ToString().IndexOf("LAYERS=", StringComparison.OrdinalIgnoreCase) < 0)
|
||||||
{
|
{
|
||||||
Layers = (await GetLayerNamesAsync())?.FirstOrDefault() ?? ""; // get first Layer from Capabilities
|
// Get first Layer from a GetCapabilities response.
|
||||||
|
//
|
||||||
|
Layers = (await GetLayerNamesAsync())?.FirstOrDefault() ?? "";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (boundingBox.West >= -180d && boundingBox.East <= 180d ||
|
if (boundingBox.West >= -180d && boundingBox.East <= 180d ||
|
||||||
|
|
|
||||||
|
|
@ -112,20 +112,26 @@ namespace MapControl
|
||||||
|
|
||||||
private bool UpdateChildLayers(WmtsTileMatrixSet tileMatrixSet)
|
private bool UpdateChildLayers(WmtsTileMatrixSet tileMatrixSet)
|
||||||
{
|
{
|
||||||
var maxScale = 1.001 * ParentMap.ViewTransform.Scale; // avoid rounding issues
|
// Multiply scale by 1.001 to avoid rounding issues.
|
||||||
|
//
|
||||||
|
var maxScale = 1.001 * ParentMap.ViewTransform.Scale;
|
||||||
|
|
||||||
// show all WmtsTileMatrix layers with Scale <= maxScale, at least the first layer
|
// Show all WmtsTileMatrix layers with Scale <= maxScale, at least the first layer.
|
||||||
//
|
//
|
||||||
var currentMatrixes = tileMatrixSet.TileMatrixes
|
var currentMatrixes = tileMatrixSet.TileMatrixes
|
||||||
.Where((matrix, i) => i == 0 || matrix.Scale <= maxScale)
|
.Where((matrix, i) => i == 0 || matrix.Scale <= maxScale)
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
if (!IsBaseMapLayer) // show only the last layer
|
if (!IsBaseMapLayer)
|
||||||
{
|
{
|
||||||
|
// Show only the last layer.
|
||||||
|
//
|
||||||
currentMatrixes = currentMatrixes.Skip(currentMatrixes.Count - 1).ToList();
|
currentMatrixes = currentMatrixes.Skip(currentMatrixes.Count - 1).ToList();
|
||||||
}
|
}
|
||||||
else if (currentMatrixes.Count > MaxBackgroundLevels + 1)
|
else if (currentMatrixes.Count > MaxBackgroundLevels + 1)
|
||||||
{
|
{
|
||||||
|
// Show not more than MaxBackgroundLevels + 1 layers.
|
||||||
|
//
|
||||||
currentMatrixes = currentMatrixes.Skip(currentMatrixes.Count - MaxBackgroundLevels - 1).ToList();
|
currentMatrixes = currentMatrixes.Skip(currentMatrixes.Count - MaxBackgroundLevels - 1).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ namespace MapControl
|
||||||
{
|
{
|
||||||
public class WmtsTileMatrixLayer : Panel
|
public class WmtsTileMatrixLayer : Panel
|
||||||
{
|
{
|
||||||
// zoomLevel is index of tileMatrix in a WmtsTileMatrixSet.TileMatrixes list
|
// zoomLevel is index of tileMatrix in a WmtsTileMatrixSet.TileMatrixes list.
|
||||||
//
|
//
|
||||||
public WmtsTileMatrixLayer(WmtsTileMatrix tileMatrix, int zoomLevel)
|
public WmtsTileMatrixLayer(WmtsTileMatrix tileMatrix, int zoomLevel)
|
||||||
{
|
{
|
||||||
|
|
@ -38,7 +38,7 @@ namespace MapControl
|
||||||
|
|
||||||
public void SetRenderTransform(ViewTransform viewTransform)
|
public void SetRenderTransform(ViewTransform viewTransform)
|
||||||
{
|
{
|
||||||
// tile matrix origin in pixels
|
// Tile matrix origin in pixels.
|
||||||
//
|
//
|
||||||
var tileMatrixOrigin = new Point(WmtsTileMatrix.TileWidth * TileMatrix.XMin, WmtsTileMatrix.TileHeight * TileMatrix.YMin);
|
var tileMatrixOrigin = new Point(WmtsTileMatrix.TileWidth * TileMatrix.XMin, WmtsTileMatrix.TileHeight * TileMatrix.YMin);
|
||||||
|
|
||||||
|
|
@ -48,24 +48,24 @@ namespace MapControl
|
||||||
|
|
||||||
public bool UpdateTiles(ViewTransform viewTransform, Size viewSize)
|
public bool UpdateTiles(ViewTransform viewTransform, Size viewSize)
|
||||||
{
|
{
|
||||||
// bounds in tile pixels from view size
|
// Bounds in tile pixels from view size.
|
||||||
//
|
//
|
||||||
var bounds = viewTransform.GetTileMatrixBounds(WmtsTileMatrix.Scale, WmtsTileMatrix.TopLeft, viewSize);
|
var bounds = viewTransform.GetTileMatrixBounds(WmtsTileMatrix.Scale, WmtsTileMatrix.TopLeft, viewSize);
|
||||||
|
|
||||||
// tile X and Y bounds
|
// Tile X and Y bounds.
|
||||||
//
|
//
|
||||||
var xMin = (int)Math.Floor(bounds.X / WmtsTileMatrix.TileWidth);
|
var xMin = (int)Math.Floor(bounds.X / WmtsTileMatrix.TileWidth);
|
||||||
var yMin = (int)Math.Floor(bounds.Y / WmtsTileMatrix.TileHeight);
|
var yMin = (int)Math.Floor(bounds.Y / WmtsTileMatrix.TileHeight);
|
||||||
var xMax = (int)Math.Floor((bounds.X + bounds.Width) / WmtsTileMatrix.TileWidth);
|
var xMax = (int)Math.Floor((bounds.X + bounds.Width) / WmtsTileMatrix.TileWidth);
|
||||||
var yMax = (int)Math.Floor((bounds.Y + bounds.Height) / WmtsTileMatrix.TileHeight);
|
var yMax = (int)Math.Floor((bounds.Y + bounds.Height) / WmtsTileMatrix.TileHeight);
|
||||||
|
|
||||||
// total tile matrix width in meters
|
// Total tile matrix width in meters.
|
||||||
//
|
//
|
||||||
var totalWidth = WmtsTileMatrix.MatrixWidth * WmtsTileMatrix.TileWidth / WmtsTileMatrix.Scale;
|
var totalWidth = WmtsTileMatrix.MatrixWidth * WmtsTileMatrix.TileWidth / WmtsTileMatrix.Scale;
|
||||||
|
|
||||||
if (Math.Abs(totalWidth - 360d * MapProjection.Wgs84MeterPerDegree) > 1d)
|
if (Math.Abs(totalWidth - 360d * MapProjection.Wgs84MeterPerDegree) > 1d)
|
||||||
{
|
{
|
||||||
// no full longitudinal coverage, restrict x index
|
// No full longitudinal coverage, restrict x index.
|
||||||
//
|
//
|
||||||
xMin = Math.Max(xMin, 0);
|
xMin = Math.Max(xMin, 0);
|
||||||
xMax = Math.Min(Math.Max(xMax, 0), WmtsTileMatrix.MatrixWidth - 1);
|
xMax = Math.Min(Math.Max(xMax, 0), WmtsTileMatrix.MatrixWidth - 1);
|
||||||
|
|
@ -77,7 +77,7 @@ namespace MapControl
|
||||||
if (TileMatrix.XMin == xMin && TileMatrix.YMin == yMin &&
|
if (TileMatrix.XMin == xMin && TileMatrix.YMin == yMin &&
|
||||||
TileMatrix.XMax == xMax && TileMatrix.YMax == yMax)
|
TileMatrix.XMax == xMax && TileMatrix.YMax == yMax)
|
||||||
{
|
{
|
||||||
// no change of the TileMatrix and the Tiles collection
|
// No change of the TileMatrix and the Tiles collection.
|
||||||
//
|
//
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -122,7 +122,7 @@ namespace MapControl
|
||||||
{
|
{
|
||||||
foreach (var tile in Tiles)
|
foreach (var tile in Tiles)
|
||||||
{
|
{
|
||||||
// arrange tiles relative to XMin/YMin
|
// Arrange tiles relative to XMin/YMin.
|
||||||
//
|
//
|
||||||
var x = WmtsTileMatrix.TileWidth * (tile.X - TileMatrix.XMin);
|
var x = WmtsTileMatrix.TileWidth * (tile.X - TileMatrix.XMin);
|
||||||
var y = WmtsTileMatrix.TileHeight * (tile.Y - TileMatrix.YMin);
|
var y = WmtsTileMatrix.TileHeight * (tile.Y - TileMatrix.YMin);
|
||||||
|
|
|
||||||
|
|
@ -101,7 +101,9 @@ namespace MapControl
|
||||||
|
|
||||||
private void OnMouseWheel(object sender, MouseWheelEventArgs e)
|
private void OnMouseWheel(object sender, MouseWheelEventArgs e)
|
||||||
{
|
{
|
||||||
mouseWheelDelta += e.Delta / 120d; // standard mouse wheel delta
|
// Standard mouse wheel delta value is 120.
|
||||||
|
//
|
||||||
|
mouseWheelDelta += e.Delta / 120d;
|
||||||
|
|
||||||
if (Math.Abs(mouseWheelDelta) >= 1d)
|
if (Math.Abs(mouseWheelDelta) >= 1d)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,8 @@ namespace MapControl
|
||||||
{
|
{
|
||||||
base.OnInitialized(e);
|
base.OnInitialized(e);
|
||||||
|
|
||||||
// If this.Stroke is not explicitly set, bind it to this.Foreground
|
// If this.Stroke is not explicitly set, bind it to this.Foreground.
|
||||||
|
//
|
||||||
this.SetBindingOnUnsetProperty(StrokeProperty, this, ForegroundProperty, nameof(Foreground));
|
this.SetBindingOnUnsetProperty(StrokeProperty, this, ForegroundProperty, nameof(Foreground));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,9 @@ namespace MapControl
|
||||||
|
|
||||||
private static void DataPropertyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
|
private static void DataPropertyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
|
||||||
{
|
{
|
||||||
if (e.NewValue != null && !ReferenceEquals(e.NewValue, e.OldValue)) // Data is actually a new Geometry
|
// Check if Data is actually a new Geometry.
|
||||||
|
//
|
||||||
|
if (e.NewValue != null && !ReferenceEquals(e.NewValue, e.OldValue))
|
||||||
{
|
{
|
||||||
var path = (MapPath)obj;
|
var path = (MapPath)obj;
|
||||||
var data = (Geometry)e.NewValue;
|
var data = (Geometry)e.NewValue;
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,9 @@ namespace MapControl
|
||||||
{
|
{
|
||||||
using (var stream = new MemoryStream(buffer))
|
using (var stream = new MemoryStream(buffer))
|
||||||
{
|
{
|
||||||
return await LoadImageAsync(stream); // await before closing stream
|
// Must await method before closing the stream.
|
||||||
|
//
|
||||||
|
return await LoadImageAsync(stream);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,9 @@ namespace MapControl
|
||||||
{
|
{
|
||||||
var point = e.GetCurrentPoint(this);
|
var point = e.GetCurrentPoint(this);
|
||||||
|
|
||||||
mouseWheelDelta += point.Properties.MouseWheelDelta / 120d; // standard mouse wheel delta
|
// Standard mouse wheel delta value is 120.
|
||||||
|
//
|
||||||
|
mouseWheelDelta += point.Properties.MouseWheelDelta / 120d;
|
||||||
|
|
||||||
if (Math.Abs(mouseWheelDelta) >= 1d)
|
if (Math.Abs(mouseWheelDelta) >= 1d)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,8 @@ namespace MapControl
|
||||||
|
|
||||||
public MapBase()
|
public MapBase()
|
||||||
{
|
{
|
||||||
// set Background by Style to enable resetting by ClearValue in MapLayerPropertyChanged
|
// Set Background by Style to enable resetting by ClearValue in MapLayerPropertyChanged.
|
||||||
|
//
|
||||||
var style = new Style(typeof(MapBase));
|
var style = new Style(typeof(MapBase));
|
||||||
style.Setters.Add(new Setter(BackgroundProperty, new SolidColorBrush(Colors.White)));
|
style.Setters.Add(new Setter(BackgroundProperty, new SolidColorBrush(Colors.White)));
|
||||||
Style = style;
|
Style = style;
|
||||||
|
|
|
||||||
|
|
@ -57,13 +57,16 @@ namespace MapControl
|
||||||
|
|
||||||
if (parentMap != null)
|
if (parentMap != null)
|
||||||
{
|
{
|
||||||
// If this.Background is not explicitly set, bind it to parentMap.Background
|
// If this.Background is not explicitly set, bind it to parentMap.Background.
|
||||||
|
//
|
||||||
this.SetBindingOnUnsetProperty(BackgroundProperty, parentMap, Panel.BackgroundProperty, nameof(Background));
|
this.SetBindingOnUnsetProperty(BackgroundProperty, parentMap, Panel.BackgroundProperty, nameof(Background));
|
||||||
|
|
||||||
// If this.Foreground is not explicitly set, bind it to parentMap.Foreground
|
// If this.Foreground is not explicitly set, bind it to parentMap.Foreground.
|
||||||
|
//
|
||||||
this.SetBindingOnUnsetProperty(ForegroundProperty, parentMap, MapBase.ForegroundProperty, nameof(Foreground));
|
this.SetBindingOnUnsetProperty(ForegroundProperty, parentMap, MapBase.ForegroundProperty, nameof(Foreground));
|
||||||
|
|
||||||
// If this.BorderBrush is not explicitly set, bind it to parentMap.Foreground
|
// If this.BorderBrush is not explicitly set, bind it to parentMap.Foreground.
|
||||||
|
//
|
||||||
this.SetBindingOnUnsetProperty(BorderBrushProperty, parentMap, MapBase.ForegroundProperty, nameof(Foreground));
|
this.SetBindingOnUnsetProperty(BorderBrushProperty, parentMap, MapBase.ForegroundProperty, nameof(Foreground));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -66,10 +66,12 @@ namespace MapControl
|
||||||
{
|
{
|
||||||
if (map != null)
|
if (map != null)
|
||||||
{
|
{
|
||||||
// If this.Forground is not explicitly set, bind it to map.Foreground
|
// If this.Forground is not explicitly set, bind it to map.Foreground.
|
||||||
|
//
|
||||||
this.SetBindingOnUnsetProperty(ForegroundProperty, map, MapBase.ForegroundProperty, nameof(Foreground));
|
this.SetBindingOnUnsetProperty(ForegroundProperty, map, MapBase.ForegroundProperty, nameof(Foreground));
|
||||||
|
|
||||||
// If this.Stroke is not explicitly set, bind it to this.Foreground
|
// If this.Stroke is not explicitly set, bind it to this.Foreground.
|
||||||
|
//
|
||||||
this.SetBindingOnUnsetProperty(StrokeProperty, this, ForegroundProperty, nameof(Foreground));
|
this.SetBindingOnUnsetProperty(StrokeProperty, this, ForegroundProperty, nameof(Foreground));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue