mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2025-12-06 07:12:04 +01:00
Added MapControl.UiTools.MapLayerInfo
This commit is contained in:
parent
c31780a298
commit
d23bc99f3d
44
MapUiTools/Avalonia/MapLayerInfo.xaml
Normal file
44
MapUiTools/Avalonia/MapLayerInfo.xaml
Normal file
|
|
@ -0,0 +1,44 @@
|
||||||
|
<UserControl
|
||||||
|
xmlns="https://github.com/avaloniaui"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:md="clr-namespace:Markdown.Avalonia;assembly=Markdown.Avalonia"
|
||||||
|
xmlns:local="clr-namespace:MapControl.UiTools"
|
||||||
|
x:Class="MapControl.UiTools.MapLayerInfo"
|
||||||
|
x:Name="mapLayerInfo">
|
||||||
|
|
||||||
|
<UserControl.Styles>
|
||||||
|
<Style Selector="local|MapLayerInfo">
|
||||||
|
<Setter Property="Padding" Value="4,0"/>
|
||||||
|
<Setter Property="HorizontalAlignment" Value="Right"/>
|
||||||
|
<Setter Property="VerticalAlignment" Value="Bottom"/>
|
||||||
|
</Style>
|
||||||
|
</UserControl.Styles>
|
||||||
|
|
||||||
|
<StackPanel
|
||||||
|
Orientation="Horizontal"
|
||||||
|
Background="{Binding Background, ElementName=mapLayerInfo}"
|
||||||
|
DataContext="{Binding ElementName=mapLayerInfo}">
|
||||||
|
|
||||||
|
<ProgressBar
|
||||||
|
VerticalAlignment="Center" Margin="{Binding Padding}"
|
||||||
|
Maximum="1" Value="{Binding MapLayer.LoadingProgress}">
|
||||||
|
|
||||||
|
<ProgressBar.IsVisible>
|
||||||
|
<Binding Path="Value" RelativeSource="{RelativeSource Self}">
|
||||||
|
<Binding.Converter>
|
||||||
|
<local:ProgressVisibilityConverter/>
|
||||||
|
</Binding.Converter>
|
||||||
|
</Binding>
|
||||||
|
</ProgressBar.IsVisible>
|
||||||
|
</ProgressBar>
|
||||||
|
|
||||||
|
<LayoutTransformControl Margin="{Binding Padding}">
|
||||||
|
<LayoutTransformControl.LayoutTransform>
|
||||||
|
<ScaleTransform ScaleX="0.8" ScaleY="0.8"/>
|
||||||
|
</LayoutTransformControl.LayoutTransform>
|
||||||
|
|
||||||
|
<md:MarkdownScrollViewer Markdown="{Binding MapLayer.Description}"/>
|
||||||
|
</LayoutTransformControl>
|
||||||
|
</StackPanel>
|
||||||
|
</UserControl>
|
||||||
|
|
@ -10,11 +10,22 @@
|
||||||
<Compile Include="..\Shared\*.cs" />
|
<Compile Include="..\Shared\*.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Remove="..\Shared\HyperlinkText.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<AvaloniaXaml Include="MapLayerInfo.xaml">
|
||||||
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
</AvaloniaXaml>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\..\MapControl\Avalonia\MapControl.Avalonia.csproj" />
|
<ProjectReference Include="..\..\MapControl\Avalonia\MapControl.Avalonia.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Avalonia" Version="11.3.6" />
|
<PackageReference Include="Avalonia" Version="11.3.6" />
|
||||||
|
<PackageReference Include="Markdown.Avalonia.Tight" Version="11.0.2" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ using System.Windows.Controls;
|
||||||
using System.Windows.Documents;
|
using System.Windows.Documents;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace SampleApplication
|
namespace MapControl.UiTools
|
||||||
{
|
{
|
||||||
public static class HyperlinkText
|
public static class HyperlinkText
|
||||||
{
|
{
|
||||||
|
|
@ -43,7 +43,7 @@ namespace SampleApplication
|
||||||
|
|
||||||
var link = new Hyperlink { NavigateUri = uri };
|
var link = new Hyperlink { NavigateUri = uri };
|
||||||
link.Inlines.Add(new Run { Text = match.Groups[1].Value });
|
link.Inlines.Add(new Run { Text = match.Groups[1].Value });
|
||||||
#if !WINUI && !UWP
|
#if WPF
|
||||||
link.ToolTip = uri.ToString();
|
link.ToolTip = uri.ToString();
|
||||||
|
|
||||||
link.RequestNavigate += (s, e) =>
|
link.RequestNavigate += (s, e) =>
|
||||||
34
MapUiTools/Shared/MapLayerInfo.xaml.cs
Normal file
34
MapUiTools/Shared/MapLayerInfo.xaml.cs
Normal file
|
|
@ -0,0 +1,34 @@
|
||||||
|
#if WPF
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
#elif UWP
|
||||||
|
using Windows.UI.Xaml;
|
||||||
|
using Windows.UI.Xaml.Controls;
|
||||||
|
#elif WINUI
|
||||||
|
using Microsoft.UI.Xaml;
|
||||||
|
using Microsoft.UI.Xaml.Controls;
|
||||||
|
#else
|
||||||
|
using Avalonia.Controls;
|
||||||
|
using DependencyProperty = Avalonia.AvaloniaProperty;
|
||||||
|
using FrameworkElement = Avalonia.Controls.Control;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace MapControl.UiTools
|
||||||
|
{
|
||||||
|
public partial class MapLayerInfo : UserControl
|
||||||
|
{
|
||||||
|
public static readonly DependencyProperty MapLayerProperty =
|
||||||
|
DependencyPropertyHelper.Register<MapLayerInfo, FrameworkElement>(nameof(MapLayer), null);
|
||||||
|
|
||||||
|
public FrameworkElement MapLayer
|
||||||
|
{
|
||||||
|
get => (FrameworkElement)GetValue(MapLayerProperty);
|
||||||
|
set => SetValue(MapLayerProperty, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public MapLayerInfo()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
45
MapUiTools/Shared/ProgressVisibilityConverter.cs
Normal file
45
MapUiTools/Shared/ProgressVisibilityConverter.cs
Normal file
|
|
@ -0,0 +1,45 @@
|
||||||
|
using System;
|
||||||
|
using System.Globalization;
|
||||||
|
#if WPF
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Data;
|
||||||
|
#elif UWP
|
||||||
|
using Windows.UI.Xaml;
|
||||||
|
using Windows.UI.Xaml.Data;
|
||||||
|
#elif WINUI
|
||||||
|
using Microsoft.UI.Xaml;
|
||||||
|
using Microsoft.UI.Xaml.Data;
|
||||||
|
#else
|
||||||
|
using Avalonia.Data.Converters;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace MapControl.UiTools
|
||||||
|
{
|
||||||
|
internal partial class ProgressVisibilityConverter : IValueConverter
|
||||||
|
{
|
||||||
|
public object Convert(object value, Type targetType, object parameter, string language)
|
||||||
|
{
|
||||||
|
var visible = (double)value < 1d;
|
||||||
|
#if AVALONIA
|
||||||
|
return visible;
|
||||||
|
#else
|
||||||
|
return visible ? Visibility.Visible : Visibility.Collapsed;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||||
|
{
|
||||||
|
return Convert(value, targetType, parameter, culture.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
public object ConvertBack(object value, Type targetType, object parameter, string language)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
44
MapUiTools/UWP/MapLayerInfo.xaml
Normal file
44
MapUiTools/UWP/MapLayerInfo.xaml
Normal file
|
|
@ -0,0 +1,44 @@
|
||||||
|
<UserControl
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:local="using:MapControl.UiTools"
|
||||||
|
x:Class="MapControl.UiTools.MapLayerInfo"
|
||||||
|
x:Name="mapLayerInfo">
|
||||||
|
|
||||||
|
<UserControl.Resources>
|
||||||
|
<Style TargetType="local:MapLayerInfo">
|
||||||
|
<Setter Property="Padding" Value="6,3"/>
|
||||||
|
<Setter Property="HorizontalAlignment" Value="Right"/>
|
||||||
|
<Setter Property="VerticalAlignment" Value="Bottom"/>
|
||||||
|
</Style>
|
||||||
|
<Style TargetType="ProgressBar">
|
||||||
|
<Setter Property="Width" Value="100"/>
|
||||||
|
</Style>
|
||||||
|
<Style TargetType="TextBlock">
|
||||||
|
<Setter Property="FontSize" Value="10"/>
|
||||||
|
</Style>
|
||||||
|
</UserControl.Resources>
|
||||||
|
|
||||||
|
<StackPanel
|
||||||
|
Orientation="Horizontal"
|
||||||
|
Background="{Binding Background, ElementName=mapLayerInfo}"
|
||||||
|
DataContext="{Binding ElementName=mapLayerInfo}">
|
||||||
|
|
||||||
|
<ProgressBar
|
||||||
|
VerticalAlignment="Center" Margin="{Binding Padding}"
|
||||||
|
Maximum="1" Value="{Binding MapLayer.LoadingProgress}">
|
||||||
|
|
||||||
|
<ProgressBar.Visibility>
|
||||||
|
<Binding Path="Value" RelativeSource="{RelativeSource Self}">
|
||||||
|
<Binding.Converter>
|
||||||
|
<local:ProgressVisibilityConverter/>
|
||||||
|
</Binding.Converter>
|
||||||
|
</Binding>
|
||||||
|
</ProgressBar.Visibility>
|
||||||
|
</ProgressBar>
|
||||||
|
|
||||||
|
<TextBlock
|
||||||
|
VerticalAlignment="Center" Margin="{Binding Padding}"
|
||||||
|
local:HyperlinkText.InlinesSource="{Binding MapLayer.Description}"/>
|
||||||
|
</StackPanel>
|
||||||
|
</UserControl>
|
||||||
42
MapUiTools/WPF/MapLayerInfo.xaml
Normal file
42
MapUiTools/WPF/MapLayerInfo.xaml
Normal file
|
|
@ -0,0 +1,42 @@
|
||||||
|
<UserControl
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:local="clr-namespace:MapControl.UiTools"
|
||||||
|
x:Class="MapControl.UiTools.MapLayerInfo">
|
||||||
|
|
||||||
|
<UserControl.Resources>
|
||||||
|
<Style TargetType="local:MapLayerInfo">
|
||||||
|
<Setter Property="Padding" Value="4,2"/>
|
||||||
|
<Setter Property="HorizontalAlignment" Value="Right"/>
|
||||||
|
<Setter Property="VerticalAlignment" Value="Bottom"/>
|
||||||
|
</Style>
|
||||||
|
<Style TargetType="ProgressBar">
|
||||||
|
<Setter Property="Width" Value="100"/>
|
||||||
|
</Style>
|
||||||
|
<Style TargetType="TextBlock">
|
||||||
|
<Setter Property="FontSize" Value="10"/>
|
||||||
|
</Style>
|
||||||
|
</UserControl.Resources>
|
||||||
|
|
||||||
|
<StackPanel
|
||||||
|
Orientation="Horizontal"
|
||||||
|
DataContext="{Binding RelativeSource={RelativeSource AncestorType=UserControl}}">
|
||||||
|
|
||||||
|
<ProgressBar
|
||||||
|
VerticalAlignment="Center" Margin="{Binding Padding}"
|
||||||
|
Maximum="1" Value="{Binding MapLayer.LoadingProgress}">
|
||||||
|
|
||||||
|
<ProgressBar.Visibility>
|
||||||
|
<Binding Path="Value" RelativeSource="{RelativeSource Self}">
|
||||||
|
<Binding.Converter>
|
||||||
|
<local:ProgressVisibilityConverter/>
|
||||||
|
</Binding.Converter>
|
||||||
|
</Binding>
|
||||||
|
</ProgressBar.Visibility>
|
||||||
|
</ProgressBar>
|
||||||
|
|
||||||
|
<TextBlock
|
||||||
|
Margin="{Binding Padding}"
|
||||||
|
local:HyperlinkText.InlinesSource="{Binding MapLayer.Description}"/>
|
||||||
|
</StackPanel>
|
||||||
|
</UserControl>
|
||||||
44
MapUiTools/WinUI/MapLayerInfo.xaml
Normal file
44
MapUiTools/WinUI/MapLayerInfo.xaml
Normal file
|
|
@ -0,0 +1,44 @@
|
||||||
|
<UserControl
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:local="using:MapControl.UiTools"
|
||||||
|
x:Class="MapControl.UiTools.MapLayerInfo"
|
||||||
|
x:Name="mapLayerInfo">
|
||||||
|
|
||||||
|
<UserControl.Resources>
|
||||||
|
<Style TargetType="local:MapLayerInfo">
|
||||||
|
<Setter Property="Padding" Value="6,3"/>
|
||||||
|
<Setter Property="HorizontalAlignment" Value="Right"/>
|
||||||
|
<Setter Property="VerticalAlignment" Value="Bottom"/>
|
||||||
|
</Style>
|
||||||
|
<Style TargetType="ProgressBar">
|
||||||
|
<Setter Property="Width" Value="100"/>
|
||||||
|
</Style>
|
||||||
|
<Style TargetType="TextBlock">
|
||||||
|
<Setter Property="FontSize" Value="10"/>
|
||||||
|
</Style>
|
||||||
|
</UserControl.Resources>
|
||||||
|
|
||||||
|
<StackPanel
|
||||||
|
Orientation="Horizontal"
|
||||||
|
Background="{Binding Background, ElementName=mapLayerInfo}"
|
||||||
|
DataContext="{Binding ElementName=mapLayerInfo}">
|
||||||
|
|
||||||
|
<ProgressBar
|
||||||
|
VerticalAlignment="Center" Margin="{Binding Padding}"
|
||||||
|
Maximum="1" Value="{Binding MapLayer.LoadingProgress}">
|
||||||
|
|
||||||
|
<ProgressBar.Visibility>
|
||||||
|
<Binding Path="Value" RelativeSource="{RelativeSource Self}">
|
||||||
|
<Binding.Converter>
|
||||||
|
<local:ProgressVisibilityConverter/>
|
||||||
|
</Binding.Converter>
|
||||||
|
</Binding>
|
||||||
|
</ProgressBar.Visibility>
|
||||||
|
</ProgressBar>
|
||||||
|
|
||||||
|
<TextBlock
|
||||||
|
VerticalAlignment="Center" Margin="{Binding Padding}"
|
||||||
|
local:HyperlinkText.InlinesSource="{Binding MapLayer.Description}"/>
|
||||||
|
</StackPanel>
|
||||||
|
</UserControl>
|
||||||
|
|
@ -17,10 +17,6 @@
|
||||||
<Compile Include="..\Shared\*.cs" />
|
<Compile Include="..\Shared\*.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<Compile Remove="..\Shared\HyperlinkText.cs" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Content Include="..\Shared\etna.kml" Link="etna.kml">
|
<Content Include="..\Shared\etna.kml" Link="etna.kml">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
|
@ -37,7 +33,6 @@
|
||||||
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.3.6" />
|
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.3.6" />
|
||||||
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.3.6" />
|
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.3.6" />
|
||||||
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.3.6" />
|
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.3.6" />
|
||||||
<PackageReference Include="Markdown.Avalonia.Tight" Version="11.0.2" />
|
|
||||||
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="9.0.9" />
|
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="9.0.9" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
<Window xmlns="https://github.com/avaloniaui"
|
<Window xmlns="https://github.com/avaloniaui"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:md="clr-namespace:Markdown.Avalonia;assembly=Markdown.Avalonia"
|
|
||||||
xmlns:map="clr-namespace:MapControl;assembly=MapControl.Avalonia"
|
xmlns:map="clr-namespace:MapControl;assembly=MapControl.Avalonia"
|
||||||
xmlns:tools="clr-namespace:MapControl.UiTools;assembly=MapUiTools.Avalonia"
|
xmlns:tools="clr-namespace:MapControl.UiTools;assembly=MapUiTools.Avalonia"
|
||||||
xmlns:local="clr-namespace:SampleApplication"
|
xmlns:local="clr-namespace:SampleApplication"
|
||||||
|
|
@ -12,10 +11,6 @@
|
||||||
</Window.DataContext>
|
</Window.DataContext>
|
||||||
|
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.Resources>
|
|
||||||
<local:MapHeadingToVisibilityConverter x:Key="MapHeadingToVisibilityConverter" />
|
|
||||||
</Grid.Resources>
|
|
||||||
|
|
||||||
<map:Map x:Name="map"
|
<map:Map x:Name="map"
|
||||||
ZoomLevel="11" MinZoomLevel="3"
|
ZoomLevel="11" MinZoomLevel="3"
|
||||||
Center="53.5,8.2"
|
Center="53.5,8.2"
|
||||||
|
|
@ -117,25 +112,8 @@
|
||||||
</TextBlock.Background>
|
</TextBlock.Background>
|
||||||
</TextBlock>
|
</TextBlock>
|
||||||
|
|
||||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Bottom" Background="#7FFFFFFF"
|
<tools:MapLayerInfo MapLayer="{Binding MapLayer, ElementName=map}" Background="#AFFFFFFF"/>
|
||||||
DataContext="{Binding MapLayer, ElementName=map}">
|
|
||||||
<ProgressBar Width="100" Height="8" Margin="4,2" VerticalAlignment="Center"
|
|
||||||
Maximum="1" Value="{Binding LoadingProgress}">
|
|
||||||
<ProgressBar.Styles>
|
|
||||||
<Style Selector="ProgressBar[Value=1]">
|
|
||||||
<Setter Property="IsVisible" Value="False"/>
|
|
||||||
</Style>
|
|
||||||
</ProgressBar.Styles>
|
|
||||||
</ProgressBar>
|
|
||||||
|
|
||||||
<LayoutTransformControl Margin="4,2">
|
|
||||||
<LayoutTransformControl.LayoutTransform>
|
|
||||||
<ScaleTransform ScaleX="0.7" ScaleY="0.7"/>
|
|
||||||
</LayoutTransformControl.LayoutTransform>
|
|
||||||
<md:MarkdownScrollViewer Markdown="{Binding Description}"/>
|
|
||||||
</LayoutTransformControl>
|
|
||||||
</StackPanel>
|
|
||||||
|
|
||||||
<StackPanel HorizontalAlignment="Left" VerticalAlignment="Top" Margin="6" Background="#7FFFFFFF">
|
<StackPanel HorizontalAlignment="Left" VerticalAlignment="Top" Margin="6" Background="#7FFFFFFF">
|
||||||
<tools:MenuButton x:Name="mapLayersMenuButton"
|
<tools:MenuButton x:Name="mapLayersMenuButton"
|
||||||
Icon="" Margin="2" ToolTip.Tip="Map Layers and Overlays" Map="{Binding ElementName=map}">
|
Icon="" Margin="2" ToolTip.Tip="Map Layers and Overlays" Map="{Binding ElementName=map}">
|
||||||
|
|
@ -223,9 +201,14 @@
|
||||||
<Button Margin="2" Padding="8" ToolTip.Tip="Reset Heading" Click="ResetHeadingButtonClick"
|
<Button Margin="2" Padding="8" ToolTip.Tip="Reset Heading" Click="ResetHeadingButtonClick"
|
||||||
FontSize="20" FontFamily="Segoe MDL2 Assets" Content=""
|
FontSize="20" FontFamily="Segoe MDL2 Assets" Content=""
|
||||||
HorizontalAlignment="Stretch"
|
HorizontalAlignment="Stretch"
|
||||||
HorizontalContentAlignment="Center"
|
HorizontalContentAlignment="Center">
|
||||||
IsVisible="{Binding ElementName=map, Path=Heading,
|
<Button.IsVisible>
|
||||||
Converter={StaticResource MapHeadingToVisibilityConverter}}">
|
<Binding Path="Heading" ElementName="map">
|
||||||
|
<Binding.Converter>
|
||||||
|
<local:MapHeadingToVisibilityConverter/>
|
||||||
|
</Binding.Converter>
|
||||||
|
</Binding>
|
||||||
|
</Button.IsVisible>
|
||||||
</Button>
|
</Button>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
|
||||||
44
SampleApps/Shared/MapHeadingToVisibilityConverter.cs
Normal file
44
SampleApps/Shared/MapHeadingToVisibilityConverter.cs
Normal file
|
|
@ -0,0 +1,44 @@
|
||||||
|
using System;
|
||||||
|
using System.Globalization;
|
||||||
|
#if WPF
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Data;
|
||||||
|
#elif UWP
|
||||||
|
using Windows.UI.Xaml;
|
||||||
|
using Windows.UI.Xaml.Data;
|
||||||
|
#elif WINUI
|
||||||
|
using Microsoft.UI.Xaml;
|
||||||
|
using Microsoft.UI.Xaml.Data;
|
||||||
|
#else
|
||||||
|
using Avalonia.Data.Converters;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace SampleApplication
|
||||||
|
{
|
||||||
|
public class MapHeadingToVisibilityConverter : IValueConverter
|
||||||
|
{
|
||||||
|
public object Convert(object value, Type targetType, object parameter, string language)
|
||||||
|
{
|
||||||
|
#if AVALONIA
|
||||||
|
return (double)value != 0d;
|
||||||
|
#else
|
||||||
|
return (double)value != 0d ? Visibility.Visible : Visibility.Collapsed;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
public object ConvertBack(object value, Type targetType, object parameter, string language)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||||
|
{
|
||||||
|
return Convert(value, targetType, parameter, culture.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||||
|
{
|
||||||
|
return ConvertBack(value, targetType, parameter, culture.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,65 +0,0 @@
|
||||||
using System;
|
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Globalization;
|
|
||||||
#if WINUI
|
|
||||||
using Microsoft.UI.Xaml.Data;
|
|
||||||
#elif UWP
|
|
||||||
using Windows.UI.Xaml.Data;
|
|
||||||
#elif AVALONIA
|
|
||||||
using Avalonia.Data.Converters;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace SampleApplication
|
|
||||||
{
|
|
||||||
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)
|
|
||||||
{
|
|
||||||
var converter = TypeDescriptor.GetConverter(targetType);
|
|
||||||
|
|
||||||
return (double)value == Trigger ? converter.ConvertFrom(TriggerValue) : converter.ConvertFrom(DefaultValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
public object ConvertBack(object value, Type targetType, object parameter, string language)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
|
||||||
{
|
|
||||||
return Convert(value, targetType, parameter, "");
|
|
||||||
}
|
|
||||||
|
|
||||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
|
||||||
{
|
|
||||||
return ConvertBack(value, targetType, parameter, "");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class MapHeadingToVisibilityConverter : IValueConverter
|
|
||||||
{
|
|
||||||
public object Convert(object value, Type targetType, object parameter, string language)
|
|
||||||
{
|
|
||||||
return (double)value != 0d;
|
|
||||||
}
|
|
||||||
|
|
||||||
public object ConvertBack(object value, Type targetType, object parameter, string language)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
|
||||||
{
|
|
||||||
return Convert(value, targetType, parameter, "");
|
|
||||||
}
|
|
||||||
|
|
||||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
|
||||||
{
|
|
||||||
return ConvertBack(value, targetType, parameter, "");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -168,21 +168,7 @@
|
||||||
FontFamily="Consolas" Margin="4,2" Visibility="Collapsed"/>
|
FontFamily="Consolas" Margin="4,2" Visibility="Collapsed"/>
|
||||||
</Border>
|
</Border>
|
||||||
|
|
||||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Bottom" Background="#AFFFFFFF"
|
<tools:MapLayerInfo MapLayer="{Binding MapLayer, ElementName=map}" Background="#AFFFFFFF"/>
|
||||||
DataContext="{Binding MapLayer, ElementName=map}">
|
|
||||||
<ProgressBar Width="100" Height="8" Margin="4,2" VerticalAlignment="Center"
|
|
||||||
Maximum="1" Value="{Binding LoadingProgress}">
|
|
||||||
<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 Description}"/>
|
|
||||||
</StackPanel>
|
|
||||||
|
|
||||||
<StackPanel HorizontalAlignment="Left" VerticalAlignment="Top" Margin="6" Background="#7FFFFFFF">
|
<StackPanel HorizontalAlignment="Left" VerticalAlignment="Top" Margin="6" Background="#7FFFFFFF">
|
||||||
<tools:MenuButton x:Name="mapLayersMenuButton"
|
<tools:MenuButton x:Name="mapLayersMenuButton"
|
||||||
|
|
@ -271,7 +257,7 @@
|
||||||
<Button.Visibility>
|
<Button.Visibility>
|
||||||
<Binding Path="Heading" ElementName="map">
|
<Binding Path="Heading" ElementName="map">
|
||||||
<Binding.Converter>
|
<Binding.Converter>
|
||||||
<local:DoubleTriggerConverter Trigger="0" TriggerValue="Collapsed" DefaultValue="Visible"/>
|
<local:MapHeadingToVisibilityConverter/>
|
||||||
</Binding.Converter>
|
</Binding.Converter>
|
||||||
</Binding>
|
</Binding>
|
||||||
</Button.Visibility>
|
</Button.Visibility>
|
||||||
|
|
|
||||||
|
|
@ -193,21 +193,7 @@
|
||||||
FontFamily="Consolas" Margin="4,2" Visibility="Collapsed"/>
|
FontFamily="Consolas" Margin="4,2" Visibility="Collapsed"/>
|
||||||
</Border>
|
</Border>
|
||||||
|
|
||||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Bottom" Background="#AFFFFFFF"
|
<tools:MapLayerInfo MapLayer="{Binding MapLayer, ElementName=map}" Background="#AFFFFFFF"/>
|
||||||
DataContext="{Binding MapLayer, ElementName=map}">
|
|
||||||
<ProgressBar Width="100" Height="8" Margin="4,2" VerticalAlignment="Center"
|
|
||||||
Maximum="1" Value="{Binding LoadingProgress}">
|
|
||||||
<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,1,4,3" FontSize="10" local:HyperlinkText.InlinesSource="{Binding Description}"/>
|
|
||||||
</StackPanel>
|
|
||||||
|
|
||||||
<StackPanel HorizontalAlignment="Left" VerticalAlignment="Top" Margin="6">
|
<StackPanel HorizontalAlignment="Left" VerticalAlignment="Top" Margin="6">
|
||||||
<tools:MenuButton x:Name="mapLayersMenuButton"
|
<tools:MenuButton x:Name="mapLayersMenuButton"
|
||||||
|
|
@ -296,7 +282,7 @@
|
||||||
<Button.Visibility>
|
<Button.Visibility>
|
||||||
<Binding Path="Heading" ElementName="map">
|
<Binding Path="Heading" ElementName="map">
|
||||||
<Binding.Converter>
|
<Binding.Converter>
|
||||||
<local:DoubleTriggerConverter Trigger="0" TriggerValue="Collapsed" DefaultValue="Visible"/>
|
<local:MapHeadingToVisibilityConverter/>
|
||||||
</Binding.Converter>
|
</Binding.Converter>
|
||||||
</Binding>
|
</Binding>
|
||||||
</Button.Visibility>
|
</Button.Visibility>
|
||||||
|
|
|
||||||
|
|
@ -170,23 +170,7 @@
|
||||||
</TextBlock.Background>
|
</TextBlock.Background>
|
||||||
</TextBlock>
|
</TextBlock>
|
||||||
|
|
||||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Bottom" Background="#AFFFFFFF"
|
<tools:MapLayerInfo MapLayer="{Binding MapLayer, ElementName=map}" Background="#AFFFFFFF"/>
|
||||||
DataContext="{Binding MapLayer, ElementName=map}">
|
|
||||||
<ProgressBar Width="100" Height="8" Margin="4,2" VerticalAlignment="Center"
|
|
||||||
Maximum="1" Value="{Binding LoadingProgress}">
|
|
||||||
<ProgressBar.Style>
|
|
||||||
<Style TargetType="ProgressBar">
|
|
||||||
<Style.Triggers>
|
|
||||||
<Trigger Property="Value" Value="1">
|
|
||||||
<Setter Property="Visibility" Value="Collapsed"/>
|
|
||||||
</Trigger>
|
|
||||||
</Style.Triggers>
|
|
||||||
</Style>
|
|
||||||
</ProgressBar.Style>
|
|
||||||
</ProgressBar>
|
|
||||||
|
|
||||||
<TextBlock Margin="4,2" FontSize="10" local:HyperlinkText.InlinesSource="{Binding Description}"/>
|
|
||||||
</StackPanel>
|
|
||||||
|
|
||||||
<StackPanel HorizontalAlignment="Left" VerticalAlignment="Top" Margin="6">
|
<StackPanel HorizontalAlignment="Left" VerticalAlignment="Top" Margin="6">
|
||||||
<tools:MenuButton x:Name="mapLayersMenuButton"
|
<tools:MenuButton x:Name="mapLayersMenuButton"
|
||||||
|
|
@ -275,15 +259,13 @@
|
||||||
|
|
||||||
<Button Margin="2" Padding="8" ToolTip="Reset Heading" Click="ResetHeadingButtonClick"
|
<Button Margin="2" Padding="8" ToolTip="Reset Heading" Click="ResetHeadingButtonClick"
|
||||||
FontSize="20" FontFamily="Segoe MDL2 Assets" Content="">
|
FontSize="20" FontFamily="Segoe MDL2 Assets" Content="">
|
||||||
<Button.Style>
|
<Button.Visibility>
|
||||||
<Style TargetType="Button">
|
<Binding Path="Heading" ElementName="map">
|
||||||
<Style.Triggers>
|
<Binding.Converter>
|
||||||
<DataTrigger Binding="{Binding Heading, ElementName=map}" Value="0">
|
<local:MapHeadingToVisibilityConverter/>
|
||||||
<Setter Property="Visibility" Value="Collapsed"/>
|
</Binding.Converter>
|
||||||
</DataTrigger>
|
</Binding>
|
||||||
</Style.Triggers>
|
</Button.Visibility>
|
||||||
</Style>
|
|
||||||
</Button.Style>
|
|
||||||
</Button>
|
</Button>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
|
||||||
|
|
@ -12,10 +12,6 @@
|
||||||
<Compile Include="..\Shared\*.cs" />
|
<Compile Include="..\Shared\*.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<Compile Remove="..\Shared\ValueConverters.cs" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Content Include="..\Shared\10_535_330.jpg" Link="10_535_330.jpg">
|
<Content Include="..\Shared\10_535_330.jpg" Link="10_535_330.jpg">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue