From dd3c467f9f82234f5f32d9c049d232169190e6be Mon Sep 17 00:00:00 2001 From: PeterZhong Date: Mon, 23 Sep 2024 10:00:31 +0800 Subject: [PATCH] Add project files. --- GisDevelop_Exp.sln | 25 ++++++++++++ GisDevelop_Exp/App.xaml | 10 +++++ GisDevelop_Exp/App.xaml.cs | 60 ++++++++++++++++++++++++++++ GisDevelop_Exp/GisDevelop_Exp.csproj | 18 +++++++++ GisDevelop_Exp/MainWindow.xaml | 16 ++++++++ GisDevelop_Exp/MainWindow.xaml.cs | 28 +++++++++++++ GisDevelop_Exp/MapViewModel.cs | 54 +++++++++++++++++++++++++ 7 files changed, 211 insertions(+) create mode 100644 GisDevelop_Exp.sln create mode 100644 GisDevelop_Exp/App.xaml create mode 100644 GisDevelop_Exp/App.xaml.cs create mode 100644 GisDevelop_Exp/GisDevelop_Exp.csproj create mode 100644 GisDevelop_Exp/MainWindow.xaml create mode 100644 GisDevelop_Exp/MainWindow.xaml.cs create mode 100644 GisDevelop_Exp/MapViewModel.cs diff --git a/GisDevelop_Exp.sln b/GisDevelop_Exp.sln new file mode 100644 index 0000000..4a0846a --- /dev/null +++ b/GisDevelop_Exp.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.11.35222.181 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GisDevelop_Exp", "GisDevelop_Exp\GisDevelop_Exp.csproj", "{D8D17B02-9E63-4EE1-BAE5-8910D754A5A2}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {D8D17B02-9E63-4EE1-BAE5-8910D754A5A2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D8D17B02-9E63-4EE1-BAE5-8910D754A5A2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D8D17B02-9E63-4EE1-BAE5-8910D754A5A2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D8D17B02-9E63-4EE1-BAE5-8910D754A5A2}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {3C956326-3633-4C7A-9B10-E944309FAD17} + EndGlobalSection +EndGlobal diff --git a/GisDevelop_Exp/App.xaml b/GisDevelop_Exp/App.xaml new file mode 100644 index 0000000..f7b302e --- /dev/null +++ b/GisDevelop_Exp/App.xaml @@ -0,0 +1,10 @@ + + + + + diff --git a/GisDevelop_Exp/App.xaml.cs b/GisDevelop_Exp/App.xaml.cs new file mode 100644 index 0000000..9a13bca --- /dev/null +++ b/GisDevelop_Exp/App.xaml.cs @@ -0,0 +1,60 @@ +using Esri.ArcGISRuntime; +using Esri.ArcGISRuntime.Http; +using Esri.ArcGISRuntime.Security; +using System; +using System.Collections.Generic; +using System.Configuration; +using System.Data; +using System.Linq; +using System.Threading.Tasks; +using System.Windows; + +namespace GisDevelop_Exp +{ + /// + /// Interaction logic for App.xaml + /// + public partial class App : Application + { + private void Application_Startup(object sender, StartupEventArgs e) + { + /* Authentication for ArcGIS location services: + * Use of ArcGIS location services, including basemaps and geocoding, requires either: + * 1) User authentication: Automatically generates a unique, short-lived access token when a user signs in to your application with their ArcGIS account + * giving your application permission to access the content and location services authorized to an existing ArcGIS user's account. + * 2) API key authentication: Uses a long-lived access token to authenticate requests to location services and private content. + * Go to https://links.esri.com/create-an-api-key to learn how to create and manage an API key using API key credentials, and then call + * .UseApiKey("Your ArcGIS location services API Key") + * in the initialize call below. */ + + /* Licensing: + * Production deployment of applications built with the ArcGIS Maps SDK requires you to license ArcGIS functionality. + * For more information see https://links.esri.com/arcgis-runtime-license-and-deploy. + * You can set the license string by calling .UseLicense(licenseString) in the initialize call below + * or retrieve a license dynamically after signing into a portal: + * ArcGISRuntimeEnvironment.SetLicense(await myArcGISPortal.GetLicenseInfoAsync()); */ + try + { + // Initialize the ArcGIS Maps SDK runtime before any components are created. + ArcGISRuntimeEnvironment.Initialize(config => config + // .UseLicense("[Your ArcGIS Maps SDK license string]") + // .UseApiKey("[Your ArcGIS location services API key]") + .ConfigureAuthentication(auth => auth + .UseDefaultChallengeHandler() // Use the default authentication dialog + // .UseOAuthAuthorizeHandler(myOauthAuthorizationHandler) // Configure a custom OAuth dialog + ) + ); + // Enable support for TimestampOffset fields, which also changes behavior of Date fields. + // For more information see https://links.esri.com/DotNetDateTime + ArcGISRuntimeEnvironment.EnableTimestampOffsetSupport = true; + } + catch (Exception ex) + { + MessageBox.Show(ex.ToString(), "ArcGIS Maps SDK runtime initialization failed."); + + // Exit application + this.Shutdown(); + } + } + } +} diff --git a/GisDevelop_Exp/GisDevelop_Exp.csproj b/GisDevelop_Exp/GisDevelop_Exp.csproj new file mode 100644 index 0000000..b3d850e --- /dev/null +++ b/GisDevelop_Exp/GisDevelop_Exp.csproj @@ -0,0 +1,18 @@ + + + + WinExe + net8.0-windows10.0.19041.0 + 10.0.19041.0 + enable + true + win-x86;win-x64;win-arm64 + + + + + 200.5.0 + + + + diff --git a/GisDevelop_Exp/MainWindow.xaml b/GisDevelop_Exp/MainWindow.xaml new file mode 100644 index 0000000..da2a3a4 --- /dev/null +++ b/GisDevelop_Exp/MainWindow.xaml @@ -0,0 +1,16 @@ + + + + + + + + diff --git a/GisDevelop_Exp/MainWindow.xaml.cs b/GisDevelop_Exp/MainWindow.xaml.cs new file mode 100644 index 0000000..f106ffe --- /dev/null +++ b/GisDevelop_Exp/MainWindow.xaml.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace GisDevelop_Exp +{ + /// + /// Interaction logic for MainWindow.xaml + /// + public partial class MainWindow : Window + { + public MainWindow() + { + InitializeComponent(); + } + } +} diff --git a/GisDevelop_Exp/MapViewModel.cs b/GisDevelop_Exp/MapViewModel.cs new file mode 100644 index 0000000..59b4757 --- /dev/null +++ b/GisDevelop_Exp/MapViewModel.cs @@ -0,0 +1,54 @@ +using Esri.ArcGISRuntime.Data; +using Esri.ArcGISRuntime.Geometry; +using Esri.ArcGISRuntime.Location; +using Esri.ArcGISRuntime.Mapping; +using Esri.ArcGISRuntime.Security; +using Esri.ArcGISRuntime.Symbology; +using Esri.ArcGISRuntime.Tasks; +using Esri.ArcGISRuntime.UI; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Text; +using System.Threading.Tasks; + +namespace GisDevelop_Exp +{ + /// + /// Provides map data to an application + /// + public class MapViewModel : INotifyPropertyChanged + { + public MapViewModel() + { + _map = new Map(SpatialReferences.WebMercator) + { + InitialViewpoint = new Viewpoint(new Envelope(-180, -85, 180, 85, SpatialReferences.Wgs84)), +#warning To use ArcGIS location services (including basemaps) specify your API Key access token or require the user to sign in using a valid ArcGIS account. + //Basemap = new Basemap(BasemapStyle.ArcGISStreets) + }; + } + + private Map _map; + + /// + /// Gets or sets the map + /// + public Map Map + { + get => _map; + set { _map = value; OnPropertyChanged(); } + } + + /// + /// Raises the event + /// + /// The name of the property that has changed + protected void OnPropertyChanged([CallerMemberName] string? propertyName = null) => + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); + + public event PropertyChangedEventHandler? PropertyChanged; + } +}