diff --git a/SampleApps/AvaloniaApp/App.axaml b/SampleApps/AvaloniaApp/App.axaml index 7547ad18..beeea381 100644 --- a/SampleApps/AvaloniaApp/App.axaml +++ b/SampleApps/AvaloniaApp/App.axaml @@ -1,7 +1,7 @@ + RequestedThemeVariant="Light"> diff --git a/SampleApps/AvaloniaApp/MainWindow.axaml.cs b/SampleApps/AvaloniaApp/MainWindow.axaml.cs index b72bf328..6e9fa49c 100644 --- a/SampleApps/AvaloniaApp/MainWindow.axaml.cs +++ b/SampleApps/AvaloniaApp/MainWindow.axaml.cs @@ -1,11 +1,7 @@ using Avalonia.Controls; using Avalonia.Input; -using Avalonia.Media; using MapControl; -using MapControl.UiTools; -using System; using System.Diagnostics; -using System.IO; using System.Linq; namespace SampleApplication @@ -15,63 +11,17 @@ namespace SampleApplication static MainWindow() { //TileImageLoader.Cache = new MapControl.Caching.ImageFileCache(TileImageLoader.DefaultCacheFolder); - - var bingMapsApiKeyPath = Path.Combine( - Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "MapControl", "BingMapsApiKey.txt"); - - if (File.Exists(bingMapsApiKeyPath)) - { - BingMapsTileLayer.ApiKey = File.ReadAllText(bingMapsApiKeyPath)?.Trim(); - } } public MainWindow() { InitializeComponent(); - if (!string.IsNullOrEmpty(BingMapsTileLayer.ApiKey)) - { - mapLayersMenuButton.MapLayers.Add(new MapLayerItem - { - Text = "Bing Maps Road", - Layer = new BingMapsTileLayer - { - Mode = BingMapsTileLayer.MapMode.Road, - SourceName = "Bing Maps Road", - Description = "© [Microsoft](http://www.bing.com/maps/)" - } - }); - - mapLayersMenuButton.MapLayers.Add(new MapLayerItem - { - Text = "Bing Maps Aerial", - Layer = new BingMapsTileLayer - { - Mode = BingMapsTileLayer.MapMode.Aerial, - SourceName = "Bing Maps Aerial", - Description = "© [Microsoft](http://www.bing.com/maps/)", - MapForeground = Brushes.White, - MapBackground = Brushes.Black - } - }); - - mapLayersMenuButton.MapLayers.Add(new MapLayerItem - { - Text = "Bing Maps Aerial with Labels", - Layer = new BingMapsTileLayer - { - Mode = BingMapsTileLayer.MapMode.AerialWithLabels, - SourceName = "Bing Maps Hybrid", - Description = "© [Microsoft](http://www.bing.com/maps/)", - MapForeground = Brushes.White, - MapBackground = Brushes.Black - } - }); - } - + AddBingMapsLayers(); AddTestLayers(); } + partial void AddBingMapsLayers(); partial void AddTestLayers(); private void MapItemsControlSelectionChanged(object sender, SelectionChangedEventArgs e) diff --git a/SampleApps/Shared/BingMapsLayers.cs b/SampleApps/Shared/BingMapsLayers.cs new file mode 100644 index 00000000..121ff41c --- /dev/null +++ b/SampleApps/Shared/BingMapsLayers.cs @@ -0,0 +1,76 @@ +using System; +using System.IO; +using MapControl; +using MapControl.UiTools; +#if WPF +using System.Windows.Media; +#elif WINUI +using Microsoft.UI; +using Microsoft.UI.Xaml.Media; +#elif UWP +using Windows.UI; +using Windows.UI.Xaml.Media; +#elif AVALONIA +using Avalonia.Media; +#endif + +namespace SampleApplication +{ +#if UWP + public partial class MainPage +#else + public partial class MainWindow +#endif + { + partial void AddBingMapsLayers() + { +#if UWP + var bingMapsApiKeyPath = "BingMapsApiKey.txt"; +#else + var bingMapsApiKeyPath = Path.Combine( + Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "MapControl", "BingMapsApiKey.txt"); +#endif + if (File.Exists(bingMapsApiKeyPath)) + { + BingMapsTileLayer.ApiKey = File.ReadAllText(bingMapsApiKeyPath)?.Trim(); + + mapLayersMenuButton.MapLayers.Add(new MapLayerItem + { + Text = "Bing Maps Road", + Layer = new BingMapsTileLayer + { + Mode = BingMapsTileLayer.MapMode.Road, + SourceName = "Bing Maps Road", + Description = "© [Microsoft](http://www.bing.com/maps/)" + } + }); + + mapLayersMenuButton.MapLayers.Add(new MapLayerItem + { + Text = "Bing Maps Aerial", + Layer = new BingMapsTileLayer + { + Mode = BingMapsTileLayer.MapMode.Aerial, + SourceName = "Bing Maps Aerial", + Description = "© [Microsoft](http://www.bing.com/maps/)", + MapForeground = new SolidColorBrush(Colors.White), + MapBackground = new SolidColorBrush(Colors.Black) + } + }); + + mapLayersMenuButton.MapLayers.Add(new MapLayerItem + { + Text = "Bing Maps Aerial with Labels", + Layer = new BingMapsTileLayer + { + Mode = BingMapsTileLayer.MapMode.AerialWithLabels, + SourceName = "Bing Maps Hybrid", + Description = "© [Microsoft](http://www.bing.com/maps/)", + MapForeground = new SolidColorBrush(Colors.White), + MapBackground = new SolidColorBrush(Colors.Black) + } + }); + } + } + } +} \ No newline at end of file diff --git a/SampleApps/UniversalApp/MainPage.xaml.cs b/SampleApps/UniversalApp/MainPage.xaml.cs index e25183cb..12ee83d8 100644 --- a/SampleApps/UniversalApp/MainPage.xaml.cs +++ b/SampleApps/UniversalApp/MainPage.xaml.cs @@ -1,17 +1,13 @@ using MapControl; -using MapControl.UiTools; using System; using System.Diagnostics; using System.Globalization; -using System.IO; using System.Linq; using Windows.Devices.Input; using Windows.System; -using Windows.UI; using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Input; -using Windows.UI.Xaml.Media; namespace SampleApplication { @@ -20,64 +16,17 @@ namespace SampleApplication static MainPage() { //TileImageLoader.Cache = new MapControl.Caching.ImageFileCache(TileImageLoader.DefaultCacheFolder); - //TileImageLoader.Cache = new MapControl.Caching.FileDbCache(TileImageLoader.DefaultCacheFolder); - //TileImageLoader.Cache = new MapControl.Caching.SQLiteCache(TileImageLoader.DefaultCacheFolder); - - var bingMapsApiKeyPath = "BingMapsApiKey.txt"; - - if (File.Exists(bingMapsApiKeyPath)) - { - BingMapsTileLayer.ApiKey = File.ReadAllText(bingMapsApiKeyPath)?.Trim(); - } } public MainPage() { InitializeComponent(); - if (!string.IsNullOrEmpty(BingMapsTileLayer.ApiKey)) - { - mapLayersMenuButton.MapLayers.Add(new MapLayerItem - { - Text = "Bing Maps Road", - Layer = new BingMapsTileLayer - { - Mode = BingMapsTileLayer.MapMode.Road, - SourceName = "Bing Maps Road", - Description = "© [Microsoft](http://www.bing.com/maps/)" - } - }); - - mapLayersMenuButton.MapLayers.Add(new MapLayerItem - { - Text = "Bing Maps Aerial", - Layer = new BingMapsTileLayer - { - Mode = BingMapsTileLayer.MapMode.Aerial, - SourceName = "Bing Maps Aerial", - Description = "© [Microsoft](http://www.bing.com/maps/)", - MapForeground = new SolidColorBrush(Colors.White), - MapBackground = new SolidColorBrush(Colors.Black) - } - }); - - mapLayersMenuButton.MapLayers.Add(new MapLayerItem - { - Text = "Bing Maps Aerial with Labels", - Layer = new BingMapsTileLayer - { - Mode = BingMapsTileLayer.MapMode.AerialWithLabels, - SourceName = "Bing Maps Hybrid", - Description = "© [Microsoft](http://www.bing.com/maps/)", - MapForeground = new SolidColorBrush(Colors.White), - MapBackground = new SolidColorBrush(Colors.Black) - } - }); - } - + AddBingMapsLayers(); AddTestLayers(); } + partial void AddBingMapsLayers(); partial void AddTestLayers(); private void MapItemsControlSelectionChanged(object sender, SelectionChangedEventArgs e) diff --git a/SampleApps/UniversalApp/UniversalApp.csproj b/SampleApps/UniversalApp/UniversalApp.csproj index 10a588ab..c3440fe5 100644 --- a/SampleApps/UniversalApp/UniversalApp.csproj +++ b/SampleApps/UniversalApp/UniversalApp.csproj @@ -48,6 +48,9 @@ false + + BingMapsLayers.cs + HyperlinkText.cs diff --git a/SampleApps/WinUiApp/MainWindow.xaml.cs b/SampleApps/WinUiApp/MainWindow.xaml.cs index 60c911d6..8cf65b0e 100644 --- a/SampleApps/WinUiApp/MainWindow.xaml.cs +++ b/SampleApps/WinUiApp/MainWindow.xaml.cs @@ -1,15 +1,11 @@ using MapControl; -using MapControl.UiTools; -using Microsoft.UI; using Microsoft.UI.Input; using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Controls; using Microsoft.UI.Xaml.Input; -using Microsoft.UI.Xaml.Media; using System; using System.Diagnostics; using System.Globalization; -using System.IO; using System.Linq; using Windows.System; @@ -20,16 +16,6 @@ namespace SampleApplication static MainWindow() { //TileImageLoader.Cache = new MapControl.Caching.ImageFileCache(TileImageLoader.DefaultCacheFolder); - //TileImageLoader.Cache = new MapControl.Caching.FileDbCache(TileImageLoader.DefaultCacheFolder); - //TileImageLoader.Cache = new MapControl.Caching.SQLiteCache(TileImageLoader.DefaultCacheFolder); - - var bingMapsApiKeyPath = Path.Combine( - Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "MapControl", "BingMapsApiKey.txt"); - - if (File.Exists(bingMapsApiKeyPath)) - { - BingMapsTileLayer.ApiKey = File.ReadAllText(bingMapsApiKeyPath)?.Trim(); - } } public MainWindow() @@ -38,49 +24,11 @@ namespace SampleApplication Title = "XAML Map Control - WinUI Sample Application"; - if (!string.IsNullOrEmpty(BingMapsTileLayer.ApiKey)) - { - mapLayersMenuButton.MapLayers.Add(new MapLayerItem - { - Text = "Bing Maps Road", - Layer = new BingMapsTileLayer - { - Mode = BingMapsTileLayer.MapMode.Road, - SourceName = "Bing Maps Road", - Description = "© [Microsoft](http://www.bing.com/maps/)" - } - }); - - mapLayersMenuButton.MapLayers.Add(new MapLayerItem - { - Text = "Bing Maps Aerial", - Layer = new BingMapsTileLayer - { - Mode = BingMapsTileLayer.MapMode.Aerial, - SourceName = "Bing Maps Aerial", - Description = "© [Microsoft](http://www.bing.com/maps/)", - MapForeground = new SolidColorBrush(Colors.White), - MapBackground = new SolidColorBrush(Colors.Black) - } - }); - - mapLayersMenuButton.MapLayers.Add(new MapLayerItem - { - Text = "Bing Maps Aerial with Labels", - Layer = new BingMapsTileLayer - { - Mode = BingMapsTileLayer.MapMode.AerialWithLabels, - SourceName = "Bing Maps Hybrid", - Description = "© [Microsoft](http://www.bing.com/maps/)", - MapForeground = new SolidColorBrush(Colors.White), - MapBackground = new SolidColorBrush(Colors.Black) - } - }); - } - + AddBingMapsLayers(); AddTestLayers(); } + partial void AddBingMapsLayers(); partial void AddTestLayers(); private void MapItemsControlSelectionChanged(object sender, SelectionChangedEventArgs e) diff --git a/SampleApps/WpfApplication/MainWindow.xaml.cs b/SampleApps/WpfApplication/MainWindow.xaml.cs index bb552c96..37bd3a3b 100644 --- a/SampleApps/WpfApplication/MainWindow.xaml.cs +++ b/SampleApps/WpfApplication/MainWindow.xaml.cs @@ -1,14 +1,11 @@ using MapControl; -using MapControl.UiTools; using System; using System.Diagnostics; using System.Globalization; -using System.IO; using System.Linq; using System.Windows; using System.Windows.Controls; using System.Windows.Input; -using System.Windows.Media; namespace SampleApplication { @@ -24,63 +21,17 @@ namespace SampleApplication // Configuration = "T400:6379", // InstanceName = "MapTileCache/" //})); - - var bingMapsApiKeyPath = Path.Combine( - Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "MapControl", "BingMapsApiKey.txt"); - - if (File.Exists(bingMapsApiKeyPath)) - { - BingMapsTileLayer.ApiKey = File.ReadAllText(bingMapsApiKeyPath)?.Trim(); - } } public MainWindow() { InitializeComponent(); - if (!string.IsNullOrEmpty(BingMapsTileLayer.ApiKey)) - { - mapLayersMenuButton.MapLayers.Add(new MapLayerItem - { - Text = "Bing Maps Road", - Layer = new BingMapsTileLayer - { - Mode = BingMapsTileLayer.MapMode.Road, - SourceName = "Bing Maps Road", - Description = "© [Microsoft](http://www.bing.com/maps/)" - } - }); - - mapLayersMenuButton.MapLayers.Add(new MapLayerItem - { - Text = "Bing Maps Aerial", - Layer = new BingMapsTileLayer - { - Mode = BingMapsTileLayer.MapMode.Aerial, - SourceName = "Bing Maps Aerial", - Description = "© [Microsoft](http://www.bing.com/maps/)", - MapForeground = Brushes.White, - MapBackground = Brushes.Black - } - }); - - mapLayersMenuButton.MapLayers.Add(new MapLayerItem - { - Text = "Bing Maps Aerial with Labels", - Layer = new BingMapsTileLayer - { - Mode = BingMapsTileLayer.MapMode.AerialWithLabels, - SourceName = "Bing Maps Hybrid", - Description = "© [Microsoft](http://www.bing.com/maps/)", - MapForeground = Brushes.White, - MapBackground = Brushes.Black - } - }); - } - + AddBingMapsLayers(); AddTestLayers(); } + partial void AddBingMapsLayers(); partial void AddTestLayers(); private void MapItemsControlSelectionChanged(object sender, SelectionChangedEventArgs e)