Add project files.

This commit is contained in:
PeterZhong 2024-09-23 10:00:31 +08:00
parent 782718490d
commit dd3c467f9f
7 changed files with 211 additions and 0 deletions

25
GisDevelop_Exp.sln Normal file
View File

@ -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

10
GisDevelop_Exp/App.xaml Normal file
View File

@ -0,0 +1,10 @@
<Application x:Class="GisDevelop_Exp.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:GisDevelop_Exp"
Startup="Application_Startup"
StartupUri="MainWindow.xaml">
<Application.Resources>
</Application.Resources>
</Application>

View File

@ -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
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
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();
}
}
}
}

View File

@ -0,0 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net8.0-windows10.0.19041.0</TargetFramework>
<SupportedOSPlatformVersion>10.0.19041.0</SupportedOSPlatformVersion>
<Nullable>enable</Nullable>
<UseWPF>true</UseWPF>
<RuntimeIdentifiers>win-x86;win-x64;win-arm64</RuntimeIdentifiers>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Esri.ArcGISRuntime.WPF">
<Version>200.5.0</Version>
</PackageReference>
</ItemGroup>
</Project>

View File

@ -0,0 +1,16 @@
<Window x:Class="GisDevelop_Exp.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:esri="http://schemas.esri.com/arcgis/runtime/2013"
xmlns:local="clr-namespace:GisDevelop_Exp"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Window.Resources>
<local:MapViewModel x:Key="MapViewModel" />
</Window.Resources>
<Grid>
<esri:MapView Map="{Binding Map, Source={StaticResource MapViewModel}}" />
</Grid>
</Window>

View File

@ -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
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
}
}

View File

@ -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
{
/// <summary>
/// Provides map data to an application
/// </summary>
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;
/// <summary>
/// Gets or sets the map
/// </summary>
public Map Map
{
get => _map;
set { _map = value; OnPropertyChanged(); }
}
/// <summary>
/// Raises the <see cref="MapViewModel.PropertyChanged" /> event
/// </summary>
/// <param name="propertyName">The name of the property that has changed</param>
protected void OnPropertyChanged([CallerMemberName] string? propertyName = null) =>
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
public event PropertyChangedEventHandler? PropertyChanged;
}
}