Static MapBase.TileFadeDuration property

This commit is contained in:
ClemensF 2020-04-19 10:53:25 +02:00
parent 395ece8c62
commit c915860eff
7 changed files with 26 additions and 24 deletions

View file

@ -33,6 +33,8 @@ namespace MapControl
{
private const double MaximumZoomLevel = 22d;
public static TimeSpan TileFadeDuration { get; set; } = TimeSpan.FromSeconds(0.1);
public static readonly DependencyProperty MapLayerProperty = DependencyProperty.Register(
nameof(MapLayer), typeof(UIElement), typeof(MapBase),
new PropertyMetadata(null, (o, e) => ((MapBase)o).MapLayerPropertyChanged((UIElement)e.OldValue, (UIElement)e.NewValue)));
@ -61,10 +63,6 @@ namespace MapControl
nameof(AnimationEasingFunction), typeof(EasingFunctionBase), typeof(MapBase),
new PropertyMetadata(new QuadraticEase { EasingMode = EasingMode.EaseOut }));
public static readonly DependencyProperty TileFadeDurationProperty = DependencyProperty.Register(
nameof(TileFadeDuration), typeof(TimeSpan), typeof(MapBase),
new PropertyMetadata(Tile.FadeDuration, (o, e) => Tile.FadeDuration = (TimeSpan)e.NewValue));
private PointAnimation centerAnimation;
private DoubleAnimation zoomLevelAnimation;
private DoubleAnimation headingAnimation;
@ -213,16 +211,6 @@ namespace MapControl
set { SetValue(AnimationEasingFunctionProperty, value); }
}
/// <summary>
/// Gets or sets the Duration of the Tile Opacity animation.
/// The default value is 0.2 seconds.
/// </summary>
public TimeSpan TileFadeDuration
{
get { return (TimeSpan)GetValue(TileFadeDurationProperty); }
set { SetValue(TileFadeDurationProperty, value); }
}
/// <summary>
/// Gets the scaling factor from cartesian map coordinates to view coordinates,
/// i.e. pixels per meter, as a read-only dependency property.

View file

@ -23,8 +23,8 @@ using System.Windows.Threading;
namespace MapControl
{
/// <summary>
/// Map image layer. Fills the viewport with a single map image, e.g. provided by a Web Map Service.
/// The image must be provided by the abstract GetImageAsync method.
/// Displays a single map image, e.g. from a Web Map Service (WMS).
/// The image must be provided by the abstract GetImageAsync() method.
/// </summary>
public abstract class MapImageLayer : MapPanel, IMapLayer
{
@ -335,13 +335,13 @@ namespace MapControl
topImage.BeginAnimation(OpacityProperty, new DoubleAnimation
{
To = 1d,
Duration = Tile.FadeDuration
Duration = MapBase.TileFadeDuration
});
bottomImage.BeginAnimation(OpacityProperty, new DoubleAnimation
{
To = 0d,
BeginTime = Tile.FadeDuration,
BeginTime = MapBase.TileFadeDuration,
Duration = TimeSpan.Zero
});
}

View file

@ -17,7 +17,7 @@ using System.Windows.Media;
namespace MapControl
{
/// <summary>
/// Fills the viewport with map tiles from a TileSource.
/// Displays web mercator map tiles.
/// </summary>
public class MapTileLayer : MapTileLayerBase
{

View file

@ -19,8 +19,6 @@ namespace MapControl
{
public partial class Tile
{
public static TimeSpan FadeDuration { get; set; } = TimeSpan.FromSeconds(0.15);
public readonly int ZoomLevel;
public readonly int X;
public readonly int Y;
@ -46,7 +44,14 @@ namespace MapControl
private void FadeIn()
{
Image.BeginAnimation(UIElement.OpacityProperty, new DoubleAnimation { From = 0d, To = 1d, Duration = FadeDuration, FillBehavior = FillBehavior.Stop });
Image.BeginAnimation(UIElement.OpacityProperty, new DoubleAnimation
{
From = 0d,
To = 1d,
Duration = MapBase.TileFadeDuration,
FillBehavior = FillBehavior.Stop
});
Image.Opacity = 1d;
}
}

View file

@ -15,6 +15,9 @@ using System.Windows;
namespace MapControl
{
/// <summary>
/// Displays map tiles from a Web Map Tile Service (WMTS).
/// </summary>
public class WmtsTileLayer : MapTileLayerBase
{
public static readonly DependencyProperty CapabilitiesUriProperty = DependencyProperty.Register(
@ -37,12 +40,18 @@ namespace MapControl
Loaded += OnLoaded;
}
/// <summary>
/// The Uri of a XML file or web response that contains the service capabilities.
/// </summary>
public Uri CapabilitiesUri
{
get { return (Uri)GetValue(CapabilitiesUriProperty); }
set { SetValue(CapabilitiesUriProperty, value); }
}
/// <summary>
/// The ows:Identifier of the Layer that should be displayed. If not set, the first Layer is displayed.
/// </summary>
public string LayerIdentifier
{
get { return (string)GetValue(LayerIdentifierProperty); }

View file

@ -16,7 +16,7 @@ namespace MapControl
{
Pending = false;
if (fadeIn && FadeDuration > TimeSpan.Zero)
if (fadeIn && MapBase.TileFadeDuration > TimeSpan.Zero)
{
if (image is BitmapImage bitmap && bitmap.UriSource != null)
{

View file

@ -15,7 +15,7 @@ namespace MapControl
{
Pending = false;
if (fadeIn && FadeDuration > TimeSpan.Zero)
if (fadeIn && MapBase.TileFadeDuration > TimeSpan.Zero)
{
if (image is BitmapSource bitmap && !bitmap.IsFrozen && bitmap.IsDownloading)
{