Version 7.1.0: Added MapUiTools

This commit is contained in:
Clemens 2022-01-11 19:42:12 +01:00
parent 731158c22d
commit 2ac4985c47
37 changed files with 437 additions and 463 deletions

View file

@ -1,14 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
<UseWPF>true</UseWPF>
<Version>7.0.0</Version>
<RootNamespace>ProjectionDemo</RootNamespace>
<AssemblyTitle>XAML Map Control Projection Demo Application</AssemblyTitle>
<Product>XAML Map Control</Product>
<Version>7.1.0</Version>
<Authors>Clemens Fischer</Authors>
<Description>XAML Map Control Map Projection Demo Application</Description>
<Product>XAML Map Control</Product>
<Copyright>Copyright © 2021 Clemens Fischer</Copyright>
<Copyright>Copyright © 2022 Clemens Fischer</Copyright>
</PropertyGroup>
<ItemGroup>

View file

@ -1,158 +0,0 @@
using MapControl;
using System.Collections.Generic;
using System.Linq;
#if WINUI
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Media;
#elif UWP
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Media;
#else
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
#endif
namespace SampleApplication
{
public class MapLayersMenuButton : MenuButton
{
public MapLayersMenuButton()
{
#if WINUI || UWP
Content = new FontIcon
{
FontFamily = new FontFamily("Segoe MDL2 Assets"),
Glyph = "\uE81E"
};
#else
FontFamily = new FontFamily("Segoe MDL2 Assets");
Content = "\uE81E";
#endif
}
public static readonly DependencyProperty MapProperty = DependencyProperty.Register(
nameof(Map), typeof(MapBase), typeof(MapLayersMenuButton),
new PropertyMetadata(null, (o, e) => ((MapLayersMenuButton)o).InitializeMenu()));
public static readonly DependencyProperty MapLayersProperty = DependencyProperty.Register(
nameof(MapLayers), typeof(IDictionary<string, UIElement>), typeof(MapLayersMenuButton),
new PropertyMetadata(null, (o, e) => ((MapLayersMenuButton)o).InitializeMenu()));
public static readonly DependencyProperty MapOverlaysProperty = DependencyProperty.Register(
nameof(MapOverlays), typeof(IDictionary<string, UIElement>), typeof(MapLayersMenuButton),
new PropertyMetadata(null, (o, e) => ((MapLayersMenuButton)o).InitializeMenu()));
public MapBase Map
{
get { return (MapBase)GetValue(MapProperty); }
set { SetValue(MapProperty, value); }
}
public IDictionary<string, UIElement> MapLayers
{
get { return (IDictionary<string, UIElement>)GetValue(MapLayersProperty); }
set { SetValue(MapLayersProperty, value); }
}
public IDictionary<string, UIElement> MapOverlays
{
get { return (IDictionary<string, UIElement>)GetValue(MapOverlaysProperty); }
set { SetValue(MapOverlaysProperty, value); }
}
private void InitializeMenu()
{
if (Map != null && MapLayers != null)
{
var menu = CreateMenu();
foreach (var layer in MapLayers)
{
menu.Items.Add(CreateMenuItem(layer.Key, layer.Value, MapLayerClicked));
}
var initialLayer = MapLayers.Values.FirstOrDefault();
if (MapOverlays != null && MapOverlays.Any())
{
if (initialLayer != null)
{
menu.Items.Add(CreateSeparator());
}
foreach (var overlay in MapOverlays)
{
menu.Items.Add(CreateMenuItem(overlay.Key, overlay.Value, MapOverlayClicked));
}
}
if (initialLayer != null)
{
SetMapLayer(initialLayer);
}
}
}
private void MapLayerClicked(object sender, RoutedEventArgs e)
{
var item = (FrameworkElement)sender;
var layer = (UIElement)item.Tag;
SetMapLayer(layer);
}
private void MapOverlayClicked(object sender, RoutedEventArgs e)
{
var item = (FrameworkElement)sender;
var layer = (UIElement)item.Tag;
ToggleMapOverlay(layer);
}
private void SetMapLayer(UIElement layer)
{
Map.MapLayer = layer;
UpdateCheckedStates();
}
private void ToggleMapOverlay(UIElement layer)
{
if (Map.Children.Contains(layer))
{
Map.Children.Remove(layer);
}
else
{
int index = 1;
foreach (var overlay in MapOverlays.Values)
{
if (overlay == layer)
{
Map.Children.Insert(index, layer);
break;
}
if (Map.Children.Contains(overlay))
{
index++;
}
}
}
UpdateCheckedStates();
}
private void UpdateCheckedStates()
{
foreach (var item in GetMenuItems())
{
item.IsChecked = Map.Children.Contains((UIElement)item.Tag);
}
}
}
}

View file

@ -1,94 +0,0 @@
using MapControl;
using System.Collections.Generic;
using System.Linq;
#if WINUI
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Media;
#elif UWP
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Media;
#else
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
#endif
namespace SampleApplication
{
public class MapProjectionsMenuButton : MenuButton
{
public MapProjectionsMenuButton()
{
#if WINUI || UWP
Content = new FontIcon
{
FontFamily = new FontFamily("Segoe MDL2 Assets"),
Glyph = "\uE809"
};
#else
FontFamily = new FontFamily("Segoe MDL2 Assets");
Content = "\uE809";
#endif
}
public static readonly DependencyProperty MapProperty = DependencyProperty.Register(
nameof(Map), typeof(MapBase), typeof(MapProjectionsMenuButton),
new PropertyMetadata(null, (o, e) => ((MapProjectionsMenuButton)o).InitializeMenu()));
public static readonly DependencyProperty MapProjectionsProperty = DependencyProperty.Register(
nameof(MapProjections), typeof(IDictionary<string, MapProjection>), typeof(MapProjectionsMenuButton),
new PropertyMetadata(null, (o, e) => ((MapProjectionsMenuButton)o).InitializeMenu()));
public MapBase Map
{
get { return (MapBase)GetValue(MapProperty); }
set { SetValue(MapProperty, value); }
}
public IDictionary<string, MapProjection> MapProjections
{
get { return (IDictionary<string, MapProjection>)GetValue(MapProjectionsProperty); }
set { SetValue(MapProjectionsProperty, value); }
}
private void InitializeMenu()
{
if (Map != null && MapProjections != null)
{
var menu = CreateMenu();
foreach (var projection in MapProjections)
{
menu.Items.Add(CreateMenuItem(projection.Key, projection.Value, MapProjectionClicked));
}
var initialProjection = MapProjections.Values.FirstOrDefault();
if (initialProjection != null)
{
SetMapProjection(initialProjection);
}
}
}
private void MapProjectionClicked(object sender, RoutedEventArgs e)
{
var item = (FrameworkElement)sender;
var projection = (MapProjection)item.Tag;
SetMapProjection(projection);
}
private void SetMapProjection(MapProjection projection)
{
Map.MapProjection = projection;
foreach (var item in GetMenuItems())
{
item.IsChecked = Map.MapProjection == (MapProjection)item.Tag;
}
}
}
}

View file

@ -1,73 +0,0 @@
using System.Collections.Generic;
using System.Linq;
#if WINUI
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
#elif UWP
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
#else
using System.Windows;
using System.Windows.Controls;
#endif
namespace SampleApplication
{
public class MenuButton : Button
{
#if WINUI || UWP
protected MenuFlyout CreateMenu()
{
var menu = new MenuFlyout();
Flyout = menu;
return menu;
}
protected IEnumerable<ToggleMenuFlyoutItem> GetMenuItems()
{
return ((MenuFlyout)Flyout).Items.OfType<ToggleMenuFlyoutItem>();
}
protected static ToggleMenuFlyoutItem CreateMenuItem(string text, object item, RoutedEventHandler click)
{
var menuItem = new ToggleMenuFlyoutItem { Text = text, Tag = item };
menuItem.Click += click;
return menuItem;
}
protected static MenuFlyoutSeparator CreateSeparator()
{
return new MenuFlyoutSeparator();
}
#else
protected ContextMenu CreateMenu()
{
var menu = new ContextMenu();
ContextMenu = menu;
return menu;
}
protected IEnumerable<MenuItem> GetMenuItems()
{
return ContextMenu.Items.OfType<MenuItem>();
}
protected static MenuItem CreateMenuItem(string text, object item, RoutedEventHandler click)
{
var menuItem = new MenuItem { Header = text, Tag = item };
menuItem.Click += click;
return menuItem;
}
protected static Separator CreateSeparator()
{
return new Separator();
}
protected MenuButton()
{
Click += (s, e) => ContextMenu.IsOpen = true;
}
#endif
}
}

View file

@ -2,6 +2,7 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:map="using:MapControl"
xmlns:tools="using:MapControl.UiTools"
xmlns:local="using:SampleApplication">
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
@ -115,16 +116,16 @@
</Border>
<StackPanel HorizontalAlignment="Left" VerticalAlignment="Top" Margin="6" Background="#7FFFFFFF">
<local:MapLayersMenuButton
<tools:MapLayersMenuButton
Margin="2" Padding="8" ToolTipService.ToolTip="Map Layers"
Map="{Binding ElementName=map}"
MapLayers="{Binding MapLayers}"
MapOverlays="{Binding MapOverlays}"/>
<!--<local:MapProjectionsMenuButton
<tools:MapProjectionsMenuButton
Margin="2" Padding="8" ToolTipService.ToolTip="Map Projections"
Map="{Binding ElementName=map}"
MapProjections="{Binding MapProjections}"/>-->
MapProjections="{Binding MapProjections}"/>
<Slider Orientation="Vertical" Margin="4,8" Height="100"
Minimum="{Binding MinZoomLevel, ElementName=map}"
@ -139,7 +140,7 @@
</Binding.Converter>
</Binding>
</Button.Visibility>
<FontIcon FontFamily="Segoe MDL2 Assets" Glyph="&#xEBE6;"/>
<FontIcon FontFamily="Segoe Fluent Icons" Glyph="&#xEBE6;"/>
</Button>
</StackPanel>

View file

@ -1,14 +1,13 @@
using System.Reflection;
using System.Runtime.InteropServices;
[assembly: AssemblyTitle("Universal Windows Sample Application")]
[assembly: AssemblyDescription("XAML Map Control Universal Windows Sample Application")]
[assembly: AssemblyTitle("XAML Map Control UWP Sample Application")]
[assembly: AssemblyProduct("XAML Map Control")]
[assembly: AssemblyCompany("Clemens Fischer")]
[assembly: AssemblyCopyright("Copyright © 2021 Clemens Fischer")]
[assembly: AssemblyCopyright("Copyright © 2022 Clemens Fischer")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: AssemblyVersion("7.0.0")]
[assembly: AssemblyFileVersion("7.0.0")]
[assembly: AssemblyVersion("7.1.0")]
[assembly: AssemblyFileVersion("7.1.0")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]

View file

@ -51,18 +51,9 @@
<Compile Include="..\Shared\HyperlinkText.cs">
<Link>HyperlinkText.cs</Link>
</Compile>
<Compile Include="..\Shared\MapLayersMenuButton.cs">
<Link>MapLayersMenuButton.cs</Link>
</Compile>
<Compile Include="..\Shared\MapProjectionsMenuButton.cs">
<Link>MapProjectionsMenuButton.cs</Link>
</Compile>
<Compile Include="..\Shared\MapViewModel.cs">
<Link>MapViewModel.cs</Link>
</Compile>
<Compile Include="..\Shared\MenuButton.cs">
<Link>MenuButton.cs</Link>
</Compile>
<Compile Include="..\Shared\ValueConverters.cs">
<Link>ValueConverters.cs</Link>
</Compile>
@ -108,6 +99,10 @@
<Project>{951bc5d2-d653-42d9-9a91-21dc50de0182}</Project>
<Name>MapControl.UWP</Name>
</ProjectReference>
<ProjectReference Include="..\..\MapUiTools\UWP\MapUiTools.UWP.csproj">
<Project>{dffe8e49-aa07-457e-a459-99326b44f828}</Project>
<Name>MapUiTools.UWP</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform">

View file

@ -2,6 +2,7 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:map="using:MapControl"
xmlns:tools="using:MapControl.UiTools"
xmlns:local="using:SampleApplication">
<Grid>
@ -116,16 +117,16 @@
</Border>
<StackPanel HorizontalAlignment="Left" VerticalAlignment="Top" Margin="6">
<local:MapLayersMenuButton
<tools:MapLayersMenuButton
Margin="2" Padding="8" ToolTipService.ToolTip="Map Layers and Overlays"
Map="{Binding ElementName=map}"
MapLayers="{Binding MapLayers}"
MapOverlays="{Binding MapOverlays}"/>
<!--<local:MapProjectionsMenuButton
<tools:MapProjectionsMenuButton
Margin="2" Padding="8" ToolTipService.ToolTip="Map Projections"
Map="{Binding ElementName=map}"
MapProjections="{Binding MapProjections}"/>-->
MapProjections="{Binding MapProjections}"/>
<Slider Orientation="Vertical" Margin="4,8" Height="100"
Minimum="{Binding MinZoomLevel, ElementName=map}"
@ -140,7 +141,7 @@
</Binding.Converter>
</Binding>
</Button.Visibility>
<FontIcon FontFamily="Segoe MDL2 Assets" Glyph="&#xEBE6;"/>
<FontIcon FontFamily="Segoe Fluent Icons" Glyph="&#xEBE6;"/>
</Button>
</StackPanel>

View file

@ -3,17 +3,17 @@
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows10.0.19041.0</TargetFramework>
<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
<Platforms>x86;x64;arm64</Platforms>
<Platforms>x64</Platforms>
<RuntimeIdentifiers>win10-x86;win10-x64;win10-arm64</RuntimeIdentifiers>
<PublishProfile>win10-$(Platform).pubxml</PublishProfile>
<UseWinUI>true</UseWinUI>
<ApplicationManifest>app.manifest</ApplicationManifest>
<RootNamespace>SampleApplication</RootNamespace>
<AssemblyTitle>XAML Map Control WinUI Sample Application</AssemblyTitle>
<Product>XAML Map Control</Product>
<Version>7.0.0</Version>
<Description>XAML Map Control WinUI Sample Application</Description>
<Version>7.1.0</Version>
<Authors>Clemens Fischer</Authors>
<Copyright>Copyright © 2021 Clemens Fischer</Copyright>
<Copyright>Copyright © 2022 Clemens Fischer</Copyright>
<AnalysisLevel>none</AnalysisLevel>
<EnablePreviewMsixTooling>true</EnablePreviewMsixTooling>
<DefineConstants>WINUI</DefineConstants>
@ -24,7 +24,7 @@
</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" />
<Content Include="Assets\SplashScreen.scale-200.png" />
<Content Include="Assets\LockScreenLogo.scale-200.png" />
<Content Include="Assets\Square150x150Logo.scale-200.png" />
@ -42,6 +42,7 @@
<ItemGroup>
<ProjectReference Include="..\..\MapControl\WinUI\MapControl.WinUI.csproj" />
<ProjectReference Include="..\..\MapUiTools\WinUI\MapUiTools.WinUI.csproj" />
</ItemGroup>
<!-- Defining the "Msix" ProjectCapability here allows the Single-project MSIX Packaging

View file

@ -2,6 +2,7 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:map="clr-namespace:MapControl;assembly=MapControl.WPF"
xmlns:tools="clr-namespace:MapControl.UiTools;assembly=MapUiTools.WPF"
xmlns:local="clr-namespace:SampleApplication"
Title="XAML MapControl - WPF Sample Application" Height="600" Width="900"
Stylus.IsPressAndHoldEnabled="False">
@ -143,16 +144,16 @@
</Border>
<StackPanel HorizontalAlignment="Left" VerticalAlignment="Top" Margin="6">
<local:MapLayersMenuButton
<tools:MapLayersMenuButton
Margin="2" Padding="6" FontSize="16" ToolTip="Map Layers and Overlays"
Map="{Binding ElementName=map}"
MapLayers="{Binding MapLayers}"
MapOverlays="{Binding MapOverlays}"/>
<!--<local:MapProjectionsMenuButton
<tools:MapProjectionsMenuButton
Margin="2" Padding="6" FontSize="16" ToolTip="Map Projections"
Map="{Binding ElementName=map}"
MapProjections="{Binding MapProjections}"/>-->
MapProjections="{Binding MapProjections}"/>
<Slider Orientation="Vertical" Margin="8" Height="100"
Minimum="{Binding MinZoomLevel, ElementName=map}"

View file

@ -4,11 +4,11 @@
<TargetFrameworks>net6.0-windows;net48</TargetFrameworks>
<UseWPF>true</UseWPF>
<RootNamespace>SampleApplication</RootNamespace>
<AssemblyTitle>XAML Map Control WPF Sample Application</AssemblyTitle>
<Product>XAML Map Control</Product>
<Version>7.0.0</Version>
<Description>XAML Map Control WPF Sample Application</Description>
<Version>7.1.0</Version>
<Authors>Clemens Fischer</Authors>
<Copyright>Copyright © 2021 Clemens Fischer</Copyright>
<Copyright>Copyright © 2022 Clemens Fischer</Copyright>
<DefineConstants></DefineConstants>
</PropertyGroup>
@ -16,12 +16,9 @@
<Compile Include="..\Shared\*.cs" />
</ItemGroup>
<ItemGroup>
<Compile Remove="..\Shared\MapLayers.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\MapControl\WPF\MapControl.WPF.csproj" />
<ProjectReference Include="..\..\MapUiTools\WPF\MapUiTools.WPF.csproj" />
</ItemGroup>
<ItemGroup>