Version 7.3. Added tile and map image progress reporting.

This commit is contained in:
Clemens 2022-08-05 21:30:57 +02:00
parent 3119c0fc9b
commit 17fdd63ce9
6 changed files with 67 additions and 34 deletions

View file

@ -61,8 +61,7 @@ namespace MapControl
nameof(MapForeground), typeof(Brush), typeof(MapTileLayerBase), new PropertyMetadata(null));
public static readonly DependencyProperty LoadingProgressProperty = DependencyProperty.Register(
nameof(LoadingProgress), typeof(double), typeof(MapTileLayerBase), new PropertyMetadata(1d,
(o, e) => { System.Diagnostics.Debug.WriteLine("LoadingProgress = {0:P0}", e.NewValue); }));
nameof(LoadingProgress), typeof(double), typeof(MapTileLayerBase), new PropertyMetadata(1d));
private readonly DispatcherTimer updateTimer;
private MapBase parentMap;

View file

@ -45,25 +45,25 @@ namespace MapControl
path.SetBinding(Shape.FillProperty, new Binding
{
Path = new PropertyPath("Background"),
Path = new PropertyPath(nameof(Background)),
Source = this
});
path.SetBinding(Shape.StrokeProperty, new Binding
{
Path = new PropertyPath("BorderBrush"),
Path = new PropertyPath(nameof(BorderBrush)),
Source = this
});
path.SetBinding(Shape.StrokeThicknessProperty, new Binding
{
Path = new PropertyPath("BorderThickness"),
Path = new PropertyPath(nameof(BorderWidth)),
Source = this
});
border.SetBinding(PaddingProperty, new Binding
{
Path = new PropertyPath("Padding"),
Path = new PropertyPath(nameof(Padding)),
Source = this
});

View file

@ -1,30 +1,25 @@
using System;
using System.ComponentModel;
using System.Globalization;
#if WINUI
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Data;
#elif UWP
using Windows.UI.Xaml;
using Windows.UI.Xaml.Data;
#else
using System.Windows;
using System.Windows.Data;
#endif
namespace SampleApplication
{
public class DoubleToVisibilityConverter : IValueConverter
public class DoubleTriggerConverter : IValueConverter
{
public double Trigger { get; set; }
public object TriggerValue { get; set; }
public object DefaultValue { get; set; }
public object Convert(object value, Type targetType, object parameter, string language)
{
if (!(parameter is double p))
{
p = double.Parse(parameter.ToString());
}
var converter = TypeDescriptor.GetConverter(targetType);
//System.Diagnostics.Debug.WriteLine((double)value);
return (double)value != p ? Visibility.Visible : Visibility.Collapsed;
return (double)value == Trigger ? converter.ConvertFrom(TriggerValue) : converter.ConvertFrom(DefaultValue);
}
public object ConvertBack(object value, Type targetType, object parameter, string language)

View file

@ -80,8 +80,6 @@
</Setter.Value>
</Setter>
</Style>
<local:DoubleToVisibilityConverter x:Key="DoubleToVisibilityConverter"/>
</Grid.Resources>
<Grid.DataContext>
@ -113,10 +111,28 @@
</map:Pushpin>
</map:Map>
<Border HorizontalAlignment="Right" VerticalAlignment="Bottom" Background="#BFFFFFFF">
<TextBlock Margin="2" FontSize="10"
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Bottom" Background="#AFFFFFFF">
<ProgressBar Width="100" Height="10" Margin="4,2" Maximum="1"
Value="{Binding MapLayer.LoadingProgress, ElementName=map}">
<ProgressBar.IsIndeterminate>
<Binding Path="Value" RelativeSource="{RelativeSource Self}">
<Binding.Converter>
<local:DoubleTriggerConverter Trigger="0" TriggerValue="true" DefaultValue="false"/>
</Binding.Converter>
</Binding>
</ProgressBar.IsIndeterminate>
<ProgressBar.Visibility>
<Binding Path="Value" RelativeSource="{RelativeSource Self}">
<Binding.Converter>
<local:DoubleTriggerConverter Trigger="1" TriggerValue="Collapsed" DefaultValue="Visible"/>
</Binding.Converter>
</Binding>
</ProgressBar.Visibility>
</ProgressBar>
<TextBlock Margin="4,2" FontSize="10"
local:HyperlinkText.InlinesSource="{Binding MapLayer.Description, ElementName=map}"/>
</Border>
</StackPanel>
<Border HorizontalAlignment="Center" VerticalAlignment="Top" Margin="4"
Background="#AFFFFFFF" IsHitTestVisible="False">
@ -216,8 +232,14 @@
Maximum="{Binding MaxZoomLevel, ElementName=map}"
Value="{Binding TargetZoomLevel, ElementName=map, Mode=TwoWay}"/>
<Button Margin="2" Padding="8" ToolTipService.ToolTip="Reset Heading" Click="ResetHeadingButtonClick"
Visibility="{Binding Heading, ElementName=map, Converter={StaticResource DoubleToVisibilityConverter}, ConverterParameter=0}">
<Button Margin="2" Padding="8" ToolTipService.ToolTip="Reset Heading" Click="ResetHeadingButtonClick">
<Button.Visibility>
<Binding Path="Heading" ElementName="map">
<Binding.Converter>
<local:DoubleTriggerConverter Trigger="0" TriggerValue="Collapsed" DefaultValue="Visible"/>
</Binding.Converter>
</Binding>
</Button.Visibility>
<FontIcon Glyph="&#xEBE6;"/>
</Button>
</StackPanel>

View file

@ -80,8 +80,6 @@
</Setter.Value>
</Setter>
</Style>
<local:DoubleToVisibilityConverter x:Key="DoubleToVisibilityConverter"/>
</Grid.Resources>
<Grid.DataContext>
@ -113,11 +111,24 @@
</map:Pushpin>
</map:Map>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Bottom" Background="#AFFFFFFF">
<ProgressBar Width="100" Height="10" Margin="4,2" Maximum="1"
Value="{Binding MapLayer.LoadingProgress, ElementName=map}"
Visibility="{Binding Value, RelativeSource={RelativeSource Self}, Converter={StaticResource DoubleToVisibilityConverter}, ConverterParameter=1}"/>
Value="{Binding MapLayer.LoadingProgress, ElementName=map}">
<ProgressBar.IsIndeterminate>
<Binding Path="Value" RelativeSource="{RelativeSource Self}">
<Binding.Converter>
<local:DoubleTriggerConverter Trigger="0" TriggerValue="true" DefaultValue="false"/>
</Binding.Converter>
</Binding>
</ProgressBar.IsIndeterminate>
<ProgressBar.Visibility>
<Binding Path="Value" RelativeSource="{RelativeSource Self}">
<Binding.Converter>
<local:DoubleTriggerConverter Trigger="1" TriggerValue="Collapsed" DefaultValue="Visible"/>
</Binding.Converter>
</Binding>
</ProgressBar.Visibility>
</ProgressBar>
<TextBlock Margin="4,2" FontSize="10"
local:HyperlinkText.InlinesSource="{Binding MapLayer.Description, ElementName=map}"/>
@ -220,8 +231,14 @@
Maximum="{Binding MaxZoomLevel, ElementName=map}"
Value="{Binding TargetZoomLevel, ElementName=map, Mode=TwoWay}"/>
<Button Margin="2" Padding="8" ToolTipService.ToolTip="Reset Heading" Click="ResetHeadingButtonClick"
Visibility="{Binding Heading, ElementName=map, Converter={StaticResource DoubleToVisibilityConverter}, ConverterParameter=0}">
<Button Margin="2" Padding="8" ToolTipService.ToolTip="Reset Heading" Click="ResetHeadingButtonClick">
<Button.Visibility>
<Binding Path="Heading" ElementName="map">
<Binding.Converter>
<local:DoubleTriggerConverter Trigger="0" TriggerValue="Collapsed" DefaultValue="Visible"/>
</Binding.Converter>
</Binding>
</Button.Visibility>
<FontIcon Glyph="&#xEBE6;"/>
</Button>
</StackPanel>

View file

@ -17,7 +17,7 @@
</ItemGroup>
<ItemGroup>
<None Remove="BingMapsApiKey.txt" />
<Compile Remove="..\Shared\ValueConverters.cs" />
</ItemGroup>
<ItemGroup>