init commit
@@ -0,0 +1,60 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 11.00
|
||||||
|
# Visual Studio 2010
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GpsEmulator", "GpsEmulator\GpsEmulator.csproj", "{566AEE14-134C-4EE4-93B5-1FFB021DE678}"
|
||||||
|
EndProject
|
||||||
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{736B4E0E-21AD-4357-A730-917438B61875}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GpsEmulatorClient", "GpsEmulatorClient\GpsEmulatorClient.csproj", "{A128812A-1249-4562-BDF4-5E17951B8434}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GpsEmulatorPhoneTestClient", "GpsEmulatorPhoneTestClient\GpsEmulatorPhoneTestClient.csproj", "{BF7316A8-A2C5-4176-8D7F-672AD12F474D}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Debug|Mixed Platforms = Debug|Mixed Platforms
|
||||||
|
Debug|x86 = Debug|x86
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
Release|Mixed Platforms = Release|Mixed Platforms
|
||||||
|
Release|x86 = Release|x86
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{566AEE14-134C-4EE4-93B5-1FFB021DE678}.Debug|Any CPU.ActiveCfg = Debug|x86
|
||||||
|
{566AEE14-134C-4EE4-93B5-1FFB021DE678}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
|
||||||
|
{566AEE14-134C-4EE4-93B5-1FFB021DE678}.Debug|Mixed Platforms.Build.0 = Debug|x86
|
||||||
|
{566AEE14-134C-4EE4-93B5-1FFB021DE678}.Debug|x86.ActiveCfg = Debug|x86
|
||||||
|
{566AEE14-134C-4EE4-93B5-1FFB021DE678}.Debug|x86.Build.0 = Debug|x86
|
||||||
|
{566AEE14-134C-4EE4-93B5-1FFB021DE678}.Release|Any CPU.ActiveCfg = Release|x86
|
||||||
|
{566AEE14-134C-4EE4-93B5-1FFB021DE678}.Release|Mixed Platforms.ActiveCfg = Release|x86
|
||||||
|
{566AEE14-134C-4EE4-93B5-1FFB021DE678}.Release|Mixed Platforms.Build.0 = Release|x86
|
||||||
|
{566AEE14-134C-4EE4-93B5-1FFB021DE678}.Release|x86.ActiveCfg = Release|x86
|
||||||
|
{566AEE14-134C-4EE4-93B5-1FFB021DE678}.Release|x86.Build.0 = Release|x86
|
||||||
|
{A128812A-1249-4562-BDF4-5E17951B8434}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{A128812A-1249-4562-BDF4-5E17951B8434}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{A128812A-1249-4562-BDF4-5E17951B8434}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||||
|
{A128812A-1249-4562-BDF4-5E17951B8434}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||||
|
{A128812A-1249-4562-BDF4-5E17951B8434}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||||
|
{A128812A-1249-4562-BDF4-5E17951B8434}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{A128812A-1249-4562-BDF4-5E17951B8434}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{A128812A-1249-4562-BDF4-5E17951B8434}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||||
|
{A128812A-1249-4562-BDF4-5E17951B8434}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||||
|
{A128812A-1249-4562-BDF4-5E17951B8434}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
|
{BF7316A8-A2C5-4176-8D7F-672AD12F474D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{BF7316A8-A2C5-4176-8D7F-672AD12F474D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{BF7316A8-A2C5-4176-8D7F-672AD12F474D}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
|
||||||
|
{BF7316A8-A2C5-4176-8D7F-672AD12F474D}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||||
|
{BF7316A8-A2C5-4176-8D7F-672AD12F474D}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||||
|
{BF7316A8-A2C5-4176-8D7F-672AD12F474D}.Debug|Mixed Platforms.Deploy.0 = Debug|Any CPU
|
||||||
|
{BF7316A8-A2C5-4176-8D7F-672AD12F474D}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||||
|
{BF7316A8-A2C5-4176-8D7F-672AD12F474D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{BF7316A8-A2C5-4176-8D7F-672AD12F474D}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{BF7316A8-A2C5-4176-8D7F-672AD12F474D}.Release|Any CPU.Deploy.0 = Release|Any CPU
|
||||||
|
{BF7316A8-A2C5-4176-8D7F-672AD12F474D}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||||
|
{BF7316A8-A2C5-4176-8D7F-672AD12F474D}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||||
|
{BF7316A8-A2C5-4176-8D7F-672AD12F474D}.Release|Mixed Platforms.Deploy.0 = Release|Any CPU
|
||||||
|
{BF7316A8-A2C5-4176-8D7F-672AD12F474D}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
||||||
@@ -0,0 +1,155 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<configuration>
|
||||||
|
<appSettings>
|
||||||
|
<add key="BingApiKey" value="Create Your Own Key and Place it here"/>
|
||||||
|
</appSettings>
|
||||||
|
<system.serviceModel>
|
||||||
|
<bindings>
|
||||||
|
<basicHttpBinding>
|
||||||
|
<binding name="BasicHttpBinding_ISearchService" closeTimeout="00:01:00"
|
||||||
|
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
|
||||||
|
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
|
||||||
|
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
|
||||||
|
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
|
||||||
|
useDefaultWebProxy="true">
|
||||||
|
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
|
||||||
|
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
|
||||||
|
<security mode="None">
|
||||||
|
<transport clientCredentialType="None" proxyCredentialType="None"
|
||||||
|
realm="" />
|
||||||
|
<message clientCredentialType="UserName" algorithmSuite="Default" />
|
||||||
|
</security>
|
||||||
|
</binding>
|
||||||
|
<binding name="BasicHttpBinding_IGeocodeService" closeTimeout="00:01:00"
|
||||||
|
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
|
||||||
|
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
|
||||||
|
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
|
||||||
|
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
|
||||||
|
useDefaultWebProxy="true">
|
||||||
|
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
|
||||||
|
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
|
||||||
|
<security mode="None">
|
||||||
|
<transport clientCredentialType="None" proxyCredentialType="None"
|
||||||
|
realm="" />
|
||||||
|
<message clientCredentialType="UserName" algorithmSuite="Default" />
|
||||||
|
</security>
|
||||||
|
</binding>
|
||||||
|
<binding name="BasicHttpBinding_IImageryService" closeTimeout="00:01:00"
|
||||||
|
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
|
||||||
|
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
|
||||||
|
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
|
||||||
|
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
|
||||||
|
useDefaultWebProxy="true">
|
||||||
|
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
|
||||||
|
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
|
||||||
|
<security mode="None">
|
||||||
|
<transport clientCredentialType="None" proxyCredentialType="None"
|
||||||
|
realm="" />
|
||||||
|
<message clientCredentialType="UserName" algorithmSuite="Default" />
|
||||||
|
</security>
|
||||||
|
</binding>
|
||||||
|
<binding name="BasicHttpBinding_IRouteService" closeTimeout="00:01:00"
|
||||||
|
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
|
||||||
|
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
|
||||||
|
maxBufferSize="655360" maxBufferPoolSize="524288" maxReceivedMessageSize="655360"
|
||||||
|
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
|
||||||
|
useDefaultWebProxy="true">
|
||||||
|
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
|
||||||
|
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
|
||||||
|
<security mode="None">
|
||||||
|
<transport clientCredentialType="None" proxyCredentialType="None"
|
||||||
|
realm="" />
|
||||||
|
<message clientCredentialType="UserName" algorithmSuite="Default" />
|
||||||
|
</security>
|
||||||
|
</binding>
|
||||||
|
</basicHttpBinding>
|
||||||
|
<customBinding>
|
||||||
|
<binding name="CustomBinding_ISearchService">
|
||||||
|
<textMessageEncoding maxReadPoolSize="64" maxWritePoolSize="16"
|
||||||
|
messageVersion="Soap12" writeEncoding="utf-8">
|
||||||
|
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
|
||||||
|
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
|
||||||
|
</textMessageEncoding>
|
||||||
|
<httpTransport manualAddressing="false" maxBufferPoolSize="524288"
|
||||||
|
maxReceivedMessageSize="65536" allowCookies="false" authenticationScheme="Anonymous"
|
||||||
|
bypassProxyOnLocal="false" decompressionEnabled="true" hostNameComparisonMode="StrongWildcard"
|
||||||
|
keepAliveEnabled="true" maxBufferSize="65536" proxyAuthenticationScheme="Anonymous"
|
||||||
|
realm="" transferMode="Buffered" unsafeConnectionNtlmAuthentication="false"
|
||||||
|
useDefaultWebProxy="true" />
|
||||||
|
</binding>
|
||||||
|
<binding name="CustomBinding_IGeocodeService">
|
||||||
|
<binaryMessageEncoding maxReadPoolSize="64" maxWritePoolSize="16"
|
||||||
|
maxSessionSize="2048">
|
||||||
|
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
|
||||||
|
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
|
||||||
|
</binaryMessageEncoding>
|
||||||
|
<httpTransport manualAddressing="false" maxBufferPoolSize="524288"
|
||||||
|
maxReceivedMessageSize="65536" allowCookies="false" authenticationScheme="Anonymous"
|
||||||
|
bypassProxyOnLocal="false" decompressionEnabled="true" hostNameComparisonMode="StrongWildcard"
|
||||||
|
keepAliveEnabled="true" maxBufferSize="65536" proxyAuthenticationScheme="Anonymous"
|
||||||
|
realm="" transferMode="Buffered" unsafeConnectionNtlmAuthentication="false"
|
||||||
|
useDefaultWebProxy="true" />
|
||||||
|
</binding>
|
||||||
|
<binding name="CustomBinding_IImageryService">
|
||||||
|
<binaryMessageEncoding maxReadPoolSize="64" maxWritePoolSize="16"
|
||||||
|
maxSessionSize="2048">
|
||||||
|
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
|
||||||
|
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
|
||||||
|
</binaryMessageEncoding>
|
||||||
|
<httpTransport manualAddressing="false" maxBufferPoolSize="524288"
|
||||||
|
maxReceivedMessageSize="65536" allowCookies="false" authenticationScheme="Anonymous"
|
||||||
|
bypassProxyOnLocal="false" decompressionEnabled="true" hostNameComparisonMode="StrongWildcard"
|
||||||
|
keepAliveEnabled="true" maxBufferSize="65536" proxyAuthenticationScheme="Anonymous"
|
||||||
|
realm="" transferMode="Buffered" unsafeConnectionNtlmAuthentication="false"
|
||||||
|
useDefaultWebProxy="true" />
|
||||||
|
</binding>
|
||||||
|
<binding name="CustomBinding_IRouteService">
|
||||||
|
<binaryMessageEncoding maxReadPoolSize="64" maxWritePoolSize="16"
|
||||||
|
maxSessionSize="2048">
|
||||||
|
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
|
||||||
|
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
|
||||||
|
</binaryMessageEncoding>
|
||||||
|
<httpTransport manualAddressing="false" maxBufferPoolSize="524288"
|
||||||
|
maxReceivedMessageSize="655360" allowCookies="false" authenticationScheme="Anonymous"
|
||||||
|
bypassProxyOnLocal="false" decompressionEnabled="true" hostNameComparisonMode="StrongWildcard"
|
||||||
|
keepAliveEnabled="true" maxBufferSize="655360" proxyAuthenticationScheme="Anonymous"
|
||||||
|
realm="" transferMode="Buffered" unsafeConnectionNtlmAuthentication="false"
|
||||||
|
useDefaultWebProxy="true" />
|
||||||
|
</binding>
|
||||||
|
</customBinding>
|
||||||
|
</bindings>
|
||||||
|
<client>
|
||||||
|
<endpoint address="http://dev.virtualearth.net/webservices/v1/searchservice/searchservice.svc"
|
||||||
|
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ISearchService"
|
||||||
|
contract="ISearchService" name="BasicHttpBinding_ISearchService" />
|
||||||
|
<endpoint address="http://dev.virtualearth.net/webservices/v1/searchservice/searchservice.svc/binaryHttp"
|
||||||
|
binding="customBinding" bindingConfiguration="CustomBinding_ISearchService"
|
||||||
|
contract="ISearchService" name="CustomBinding_ISearchService" />
|
||||||
|
<endpoint address="http://dev.virtualearth.net/webservices/v1/geocodeservice/GeocodeService.svc"
|
||||||
|
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IGeocodeService"
|
||||||
|
contract="IGeocodeService" name="BasicHttpBinding_IGeocodeService" />
|
||||||
|
<endpoint address="http://dev.virtualearth.net/webservices/v1/geocodeservice/GeocodeService.svc/binaryHttp"
|
||||||
|
binding="customBinding" bindingConfiguration="CustomBinding_IGeocodeService"
|
||||||
|
contract="IGeocodeService" name="CustomBinding_IGeocodeService" />
|
||||||
|
<endpoint address="http://dev.virtualearth.net/webservices/v1/imageryservice/imageryservice.svc"
|
||||||
|
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IImageryService"
|
||||||
|
contract="IImageryService" name="BasicHttpBinding_IImageryService" />
|
||||||
|
<endpoint address="http://dev.virtualearth.net/webservices/v1/imageryservice/imageryservice.svc/binaryHttp"
|
||||||
|
binding="customBinding" bindingConfiguration="CustomBinding_IImageryService"
|
||||||
|
contract="IImageryService" name="CustomBinding_IImageryService" />
|
||||||
|
<endpoint address="http://dev.virtualearth.net/webservices/v1/routeservice/routeservice.svc"
|
||||||
|
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IRouteService"
|
||||||
|
contract="IRouteService" name="BasicHttpBinding_IRouteService" />
|
||||||
|
<endpoint address="http://dev.virtualearth.net/webservices/v1/routeservice/routeservice.svc/binaryHttp"
|
||||||
|
binding="customBinding" bindingConfiguration="CustomBinding_IRouteService"
|
||||||
|
contract="IRouteService" name="CustomBinding_IRouteService" />
|
||||||
|
</client>
|
||||||
|
<behaviors>
|
||||||
|
<serviceBehaviors>
|
||||||
|
<behavior>
|
||||||
|
<serviceMetadata httpGetEnabled="True" />
|
||||||
|
</behavior>
|
||||||
|
</serviceBehaviors>
|
||||||
|
</behaviors>
|
||||||
|
</system.serviceModel>
|
||||||
|
</configuration>
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
<Application x:Class="GpsEmulator.App"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
StartupUri="MainWindow.xaml">
|
||||||
|
<Application.Resources>
|
||||||
|
|
||||||
|
</Application.Resources>
|
||||||
|
</Application>
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
using System.Windows;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Security.Principal;
|
||||||
|
|
||||||
|
namespace GpsEmulator
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Interaction logic for App.xaml
|
||||||
|
/// </summary>
|
||||||
|
public partial class App : Application
|
||||||
|
{
|
||||||
|
App()
|
||||||
|
{
|
||||||
|
WindowsPrincipal pricipal = new WindowsPrincipal(WindowsIdentity.GetCurrent());
|
||||||
|
if (!pricipal.IsInRole(WindowsBuiltInRole.Administrator))
|
||||||
|
{
|
||||||
|
ProcessStartInfo processInfo = new ProcessStartInfo();
|
||||||
|
processInfo.Verb = "runas";
|
||||||
|
string appStartPath = System.IO.Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName);
|
||||||
|
Process p = Process.GetCurrentProcess();
|
||||||
|
processInfo.FileName = appStartPath + "\\" + p.ProcessName + ".exe";
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Process.Start(processInfo);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
//Do nothing. Probably the user canceled the UAC window
|
||||||
|
}
|
||||||
|
Application.Current.Shutdown();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,252 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Net;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Media.Imaging;
|
||||||
|
using dev.virtualearth.net.webservices.v1.common;
|
||||||
|
using dev.virtualearth.net.webservices.v1.geocode;
|
||||||
|
using dev.virtualearth.net.webservices.v1.route;
|
||||||
|
using GpsEmulator.Utilities;
|
||||||
|
|
||||||
|
namespace GpsEmulator.BingApis
|
||||||
|
{
|
||||||
|
public class BingMapsClient
|
||||||
|
{
|
||||||
|
Credentials creds = new Credentials();
|
||||||
|
RouteServiceClient routeService = new RouteServiceClient("CustomBinding_IRouteService");
|
||||||
|
ImageryServiceClient imageryService = new ImageryServiceClient("CustomBinding_IImageryService");
|
||||||
|
|
||||||
|
#region Properties
|
||||||
|
|
||||||
|
string apiKey = null;
|
||||||
|
public string ApiKey
|
||||||
|
{
|
||||||
|
get { return apiKey; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
apiKey = value;
|
||||||
|
creds.ApplicationId = apiKey;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int MaxServiceRetries = 5;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
public BingMapsClient(string bingApiKey)
|
||||||
|
{
|
||||||
|
creds.ApplicationId = bingApiKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool QueryLocation(string queryString, out double lat, out double lng)
|
||||||
|
{
|
||||||
|
lat = 0;
|
||||||
|
lng = 0;
|
||||||
|
|
||||||
|
GeocodeRequest geocodeRequest = new GeocodeRequest();
|
||||||
|
geocodeRequest.Query = queryString;
|
||||||
|
geocodeRequest.Options = new GeocodeOptions() { Filters = new FilterBase[] { new ConfidenceFilter() { MinimumConfidence = Confidence.High } }, Count = 1 };
|
||||||
|
geocodeRequest.Credentials = creds;
|
||||||
|
|
||||||
|
GeocodeServiceClient geocodeServiceClient = new GeocodeServiceClient("CustomBinding_IGeocodeService");
|
||||||
|
GeocodeResponse geocodeResponse = geocodeServiceClient.Geocode(geocodeRequest);
|
||||||
|
|
||||||
|
bool locationFound = geocodeResponse.Results.Count() > 0;
|
||||||
|
if (locationFound)
|
||||||
|
{
|
||||||
|
lat = geocodeResponse.Results[0].Locations[0].Latitude;
|
||||||
|
lng = geocodeResponse.Results[0].Locations[0].Longitude;
|
||||||
|
}
|
||||||
|
return locationFound;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<TimedPosition> GetRoute(TimeSpan startTime, double startLat, double startLong, double endLat, double endLong)
|
||||||
|
{
|
||||||
|
RouteRequest routeRequest = new RouteRequest();
|
||||||
|
routeRequest.Credentials = creds;
|
||||||
|
routeRequest.Options = new RouteOptions() { RoutePathType = RoutePathType.Points };
|
||||||
|
|
||||||
|
Waypoint wp1 = new Waypoint()
|
||||||
|
{
|
||||||
|
Description = "Start",
|
||||||
|
Location = new Location() { Latitude = startLat, Longitude = startLong }
|
||||||
|
};
|
||||||
|
Waypoint wp2 = new Waypoint()
|
||||||
|
{
|
||||||
|
Description = "End",
|
||||||
|
Location = new Location() { Latitude = endLat, Longitude = endLong }
|
||||||
|
};
|
||||||
|
routeRequest.Waypoints = new Waypoint[] { wp1, wp2 };
|
||||||
|
|
||||||
|
// Make the calculate route request
|
||||||
|
int attempts = 0;
|
||||||
|
RouteResponse routeResponse = null;
|
||||||
|
while (routeResponse == null && attempts < MaxServiceRetries)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
routeResponse = routeService.CalculateRoute(routeRequest);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
attempts++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (attempts == MaxServiceRetries | routeResponse.Result.RoutePath.Points.Length < 2) return null;
|
||||||
|
|
||||||
|
List<TimedPosition> path = new List<TimedPosition>();
|
||||||
|
|
||||||
|
for (int i = 0; i < routeResponse.Result.RoutePath.Points.Length; i++)
|
||||||
|
{
|
||||||
|
if (i > 0)
|
||||||
|
{
|
||||||
|
routeRequest.Waypoints = new Waypoint[] {
|
||||||
|
new Waypoint() {
|
||||||
|
Location = new Location() {
|
||||||
|
Longitude = routeResponse.Result.RoutePath.Points[i-1].Longitude,
|
||||||
|
Latitude= routeResponse.Result.RoutePath.Points[i-1].Latitude
|
||||||
|
}
|
||||||
|
},
|
||||||
|
new Waypoint() {
|
||||||
|
Location = new Location() {
|
||||||
|
Longitude = routeResponse.Result.RoutePath.Points[i].Longitude,
|
||||||
|
Latitude= routeResponse.Result.RoutePath.Points[i].Latitude
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
RouteResponse subRouteResponse = routeService.CalculateRoute(routeRequest);
|
||||||
|
startTime = startTime.Add(TimeSpan.FromSeconds(subRouteResponse.Result.Summary.TimeInSeconds));
|
||||||
|
}
|
||||||
|
path.Add(new TimedPosition(startTime, routeResponse.Result.RoutePath.Points[i].Latitude, routeResponse.Result.RoutePath.Points[i].Longitude));
|
||||||
|
}
|
||||||
|
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<TimedPosition> GetRoute(TimeSpan startTime, double startLat, double startLong, double endLat, double endLong, double speedOfTravel)
|
||||||
|
{
|
||||||
|
RouteRequest routeRequest = new RouteRequest();
|
||||||
|
routeRequest.Credentials = creds;
|
||||||
|
routeRequest.Options = new RouteOptions() { RoutePathType = RoutePathType.Points };
|
||||||
|
|
||||||
|
Waypoint wp1 = new Waypoint()
|
||||||
|
{
|
||||||
|
Description = "Start",
|
||||||
|
Location = new Location() { Latitude = startLat, Longitude = startLong }
|
||||||
|
};
|
||||||
|
Waypoint wp2 = new Waypoint()
|
||||||
|
{
|
||||||
|
Description = "End",
|
||||||
|
Location = new Location() { Latitude = endLat, Longitude = endLong }
|
||||||
|
};
|
||||||
|
routeRequest.Waypoints = new Waypoint[] { wp1, wp2 };
|
||||||
|
|
||||||
|
// Make the calculate route request
|
||||||
|
int attempts = 0;
|
||||||
|
RouteResponse routeResponse = null;
|
||||||
|
while (routeResponse == null && attempts < MaxServiceRetries)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
routeResponse = routeService.CalculateRoute(routeRequest);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
attempts++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (attempts == MaxServiceRetries | routeResponse.Result.RoutePath.Points.Length <2) return null;
|
||||||
|
|
||||||
|
List<TimedPosition> path = new List<TimedPosition>(routeResponse.Result.RoutePath.Points.Length);
|
||||||
|
System.Windows.Point startPoint, endPoint;
|
||||||
|
|
||||||
|
startPoint = new System.Windows.Point(
|
||||||
|
routeResponse.Result.RoutePath.Points[0].Longitude,
|
||||||
|
routeResponse.Result.RoutePath.Points[0].Latitude);
|
||||||
|
TimeSpan time = startTime;
|
||||||
|
|
||||||
|
for (int i = 1; i < routeResponse.Result.RoutePath.Points.Length; i++)
|
||||||
|
{
|
||||||
|
endPoint = new System.Windows.Point(
|
||||||
|
routeResponse.Result.RoutePath.Points[i].Longitude,
|
||||||
|
routeResponse.Result.RoutePath.Points[i].Latitude);
|
||||||
|
double distance = MapUtils.GetDistance(startPoint, endPoint);
|
||||||
|
time = time.Add(TimeSpan.FromMilliseconds(100 * distance / speedOfTravel));
|
||||||
|
path.Add(new TimedPosition(time, routeResponse.Result.RoutePath.Points[i].Latitude, routeResponse.Result.RoutePath.Points[i].Longitude));
|
||||||
|
startPoint = endPoint;
|
||||||
|
}
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal BitmapImage GetTile(int zoom, int tileX, int tileY, MapType type)
|
||||||
|
{
|
||||||
|
string tileUrl = GetTileUrl(zoom, tileX, tileY, type);
|
||||||
|
BitmapImage image = new BitmapImage();
|
||||||
|
|
||||||
|
// Make the image request on a different thread, but create the actual image on the current one
|
||||||
|
Task.Factory.StartNew<MemoryStream>(delegate()
|
||||||
|
{
|
||||||
|
WebClient client = new WebClient();
|
||||||
|
int attempts = 0;
|
||||||
|
byte[] tileBytes = null;
|
||||||
|
while (attempts < MaxServiceRetries)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
tileBytes = client.DownloadData(tileUrl);
|
||||||
|
return new MemoryStream(tileBytes);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
attempts++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
})
|
||||||
|
.ContinueWith((t) =>
|
||||||
|
{
|
||||||
|
if (!t.IsFaulted && t.Result!=null)
|
||||||
|
{
|
||||||
|
image.BeginInit();
|
||||||
|
image.CacheOption = BitmapCacheOption.OnLoad;
|
||||||
|
image.StreamSource = t.Result;
|
||||||
|
image.EndInit();
|
||||||
|
t.Result.Close();
|
||||||
|
}
|
||||||
|
}, TaskScheduler.FromCurrentSynchronizationContext());
|
||||||
|
return image;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal string GetTileUrl(int zoom, int tileX, int tileY, MapType type, string language="en-US")
|
||||||
|
{
|
||||||
|
const string VersionBingMaps = "517";
|
||||||
|
|
||||||
|
string key = MapUtils.TileXYToQuadKey(tileX, tileY, zoom);
|
||||||
|
|
||||||
|
int serverNum = ((int) (tileX + 2 * tileY)) % 4;
|
||||||
|
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case MapType.Road:
|
||||||
|
{
|
||||||
|
return string.Format("http://ecn.t{0}.tiles.virtualearth.net/tiles/r{1}.png?g={2}&mkt={3}{4}", serverNum, key, VersionBingMaps, language, (!string.IsNullOrEmpty(creds.ApplicationId) ? "&token=" + creds.ApplicationId : string.Empty));
|
||||||
|
// If you want lower image quality, change this to: return string.Format("http://ecn.t{0}.tiles.virtualearth.net/tiles/r{1}.png?g={2}&mkt={3}{4}", serverNum, key, VersionBingMaps, language, (!string.IsNullOrEmpty(creds.ApplicationId) ? "&token=" + creds.ApplicationId : string.Empty));
|
||||||
|
}
|
||||||
|
|
||||||
|
case MapType.Aerial:
|
||||||
|
{
|
||||||
|
return string.Format("http://ecn.t{0}.tiles.virtualearth.net/tiles/a{1}.jpeg?g={2}&mkt={3}{4}", serverNum, key, VersionBingMaps, language, (!string.IsNullOrEmpty(creds.ApplicationId) ? "&token=" + creds.ApplicationId : string.Empty));
|
||||||
|
}
|
||||||
|
|
||||||
|
case MapType.Hybrid:
|
||||||
|
{
|
||||||
|
return string.Format("http://ecn.t{0}.tiles.virtualearth.net/tiles/h{1}.jpeg?g={2}&mkt={3}{4}", serverNum, key, VersionBingMaps, language, (!string.IsNullOrEmpty(creds.ApplicationId) ? "&token=" + creds.ApplicationId : string.Empty));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
using System;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
|
using System.Windows;
|
||||||
|
using GpsEmulator.MapControl;
|
||||||
|
|
||||||
|
namespace GpsEmulator.BingApis
|
||||||
|
{
|
||||||
|
[DataContract]
|
||||||
|
public class TimedPosition
|
||||||
|
{
|
||||||
|
[DataMember]
|
||||||
|
public TimeSpan Time { get; set; }
|
||||||
|
[DataMember]
|
||||||
|
public Point Position { get; set; }
|
||||||
|
public MapMarker MapMarker { get; set; }
|
||||||
|
|
||||||
|
public TimedPosition(TimeSpan time, double lat, double lng)
|
||||||
|
{
|
||||||
|
this.Time = time;
|
||||||
|
this.Position = new Point(lat, lng);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
<Window x:Class="GpsEmulator.DialogWindows.AboutDialog"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
Title="About Windows Phone GPS Emulator" Icon="/Resources/GpsEmulator.ico" Height="470" Width="320" ResizeMode="NoResize" WindowStartupLocation="CenterOwner" WindowStyle="ThreeDBorderWindow">
|
||||||
|
<DockPanel>
|
||||||
|
<Image DockPanel.Dock="Top" Source="/Resources/GpsEmulator.png" Height="280"/>
|
||||||
|
<Button DockPanel.Dock="Bottom" Width="80" Click="Button_Click" IsDefault="True" Margin="0,0,0,8">Close</Button>
|
||||||
|
<TextBlock DockPanel.Dock="Top" VerticalAlignment="Center" HorizontalAlignment="Center" TextAlignment="Center">
|
||||||
|
<LineBreak/>
|
||||||
|
<Run FontSize="18">Windows® Phone 7 GPS Emulator</Run>
|
||||||
|
<LineBreak/>
|
||||||
|
<Run FontSize="14" Foreground="Purple" FontWeight="SemiBold">Community Edition</Run>
|
||||||
|
<LineBreak/>
|
||||||
|
<LineBreak/>
|
||||||
|
<Run>Shy Cohen Consulting</Run>
|
||||||
|
<LineBreak/>
|
||||||
|
<Hyperlink NavigateUri="http://www.ShyCohen.com" RequestNavigate="Hyperlink_RequestNavigate">www.ShyCohen.com</Hyperlink>
|
||||||
|
</TextBlock>
|
||||||
|
</DockPanel>
|
||||||
|
</Window>
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
using System.Diagnostics;
|
||||||
|
using System.Windows;
|
||||||
|
|
||||||
|
namespace GpsEmulator.DialogWindows
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Interaction logic for About.xaml
|
||||||
|
/// </summary>
|
||||||
|
public partial class AboutDialog : Window
|
||||||
|
{
|
||||||
|
public AboutDialog()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Button_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
this.Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Hyperlink_RequestNavigate(object sender, System.Windows.Navigation.RequestNavigateEventArgs e)
|
||||||
|
{
|
||||||
|
Process.Start(new ProcessStartInfo(e.Uri.AbsoluteUri));
|
||||||
|
e.Handled = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
<Window x:Class="GpsEmulator.DialogWindows.BingApiKeyDialog"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
Title="Edit Bing Maps Key" Height="139" Width="600" Icon="/Resources/GpsEmulator.ico" ResizeMode="NoResize" WindowStartupLocation="CenterOwner" WindowStyle="ThreeDBorderWindow">
|
||||||
|
<DockPanel>
|
||||||
|
<Image DockPanel.Dock="Left" Source="/Resources/Key.png"/>
|
||||||
|
<StackPanel VerticalAlignment="Center">
|
||||||
|
<TextBlock TextAlignment="Center">
|
||||||
|
<Run FontSize="16">Enter your Bing Maps API Key</Run>
|
||||||
|
<LineBreak/>
|
||||||
|
<Run>(If you don't have a key, click</Run>
|
||||||
|
<Hyperlink NavigateUri="http://www.bingmapsportal.com/" RequestNavigate="Hyperlink_RequestNavigate">here</Hyperlink> to obtain one)
|
||||||
|
</TextBlock>
|
||||||
|
<TextBox Name="tbKey" Margin="3,5,3,5" Background="LightGray" TextAlignment="Center"/>
|
||||||
|
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
|
||||||
|
<Button Name="btnOk" Width="50" Margin="0,0,10,0" Click="btnOk_Click">OK</Button>
|
||||||
|
<Button Name="btnCancel" Width="50" Click="btnCancel_Click">Cancel</Button>
|
||||||
|
</StackPanel>
|
||||||
|
</StackPanel>
|
||||||
|
</DockPanel>
|
||||||
|
</Window>
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
using System.Diagnostics;
|
||||||
|
using System.Windows;
|
||||||
|
|
||||||
|
namespace GpsEmulator.DialogWindows
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Interaction logic for BingApiKeyDialog.xaml
|
||||||
|
/// </summary>
|
||||||
|
public partial class BingApiKeyDialog : Window
|
||||||
|
{
|
||||||
|
public bool cancelled = true;
|
||||||
|
public bool Cancelled
|
||||||
|
{
|
||||||
|
get { return cancelled; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public BingApiKeyDialog()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Hyperlink_RequestNavigate(object sender, System.Windows.Navigation.RequestNavigateEventArgs e)
|
||||||
|
{
|
||||||
|
Process.Start(new ProcessStartInfo(e.Uri.AbsoluteUri));
|
||||||
|
e.Handled = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void btnOk_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
cancelled = false;
|
||||||
|
this.Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void btnCancel_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
this.Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
<Window x:Class="GpsEmulator.DialogWindows.OptionsDialog"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
Title="Windows Phone 7 GPS Emulator Options" Height="210" Width="500" Icon="/Resources/GpsEmulator.ico" ResizeMode="NoResize" WindowStartupLocation="CenterOwner" WindowStyle="ThreeDBorderWindow">
|
||||||
|
<DockPanel>
|
||||||
|
<Image Source="/Resources/Settings.png"/>
|
||||||
|
<Grid Margin="15,0,10,0">
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
<RowDefinition Height="5" />
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
<RowDefinition Height="5" />
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
<RowDefinition Height="5" />
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
<RowDefinition Height="5" />
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="Auto"/>
|
||||||
|
<ColumnDefinition Width="12"/>
|
||||||
|
<ColumnDefinition Width="60"/>
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<TextBlock Grid.Row="0" Grid.ColumnSpan="4" FontSize="16" FontWeight="Bold" Margin="0,10,0,10">Default Settings</TextBlock>
|
||||||
|
<TextBlock Grid.Row="2" Grid.Column="0">Path Color</TextBlock>
|
||||||
|
<ComboBox Grid.Row="2" Grid.Column="2" Name="cmbPathColor"/>
|
||||||
|
<TextBlock Grid.Row="4" Grid.Column="0">Speed (in m/sec) of Travel to a New Point</TextBlock>
|
||||||
|
<TextBox Grid.Row="4" Grid.Column="2" Name="tbSpeed" Text="60" Background="LightGray"/>
|
||||||
|
<CheckBox Grid.Row="6" Grid.ColumnSpan="2" Name="cbUseRealTimeTrafficData">Use real-time traffic data</CheckBox>
|
||||||
|
<StackPanel Grid.Row="8" Grid.ColumnSpan="3" Orientation="Horizontal" HorizontalAlignment="Center" Margin="10">
|
||||||
|
<Button Name="btnOk" Width="50" Margin="0,0,10,0" Click="btnOk_Click">OK</Button>
|
||||||
|
<Button Name="btnCancel" Width="50" Click="btnCancel_Click">Cancel</Button>
|
||||||
|
</StackPanel>
|
||||||
|
</Grid>
|
||||||
|
</DockPanel>
|
||||||
|
</Window>
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
using System;
|
||||||
|
using System.Windows;
|
||||||
|
|
||||||
|
namespace GpsEmulator.DialogWindows
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Interaction logic for OptionsDialog.xaml
|
||||||
|
/// </summary>
|
||||||
|
public partial class OptionsDialog : Window
|
||||||
|
{
|
||||||
|
bool cancelled = false;
|
||||||
|
|
||||||
|
public bool Cancelled
|
||||||
|
{
|
||||||
|
get { return cancelled; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public OptionsDialog()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
cmbPathColor.ItemsSource = new string[] { "Red", "Blue", "Green" };
|
||||||
|
}
|
||||||
|
|
||||||
|
private void btnOk_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
cancelled = false;
|
||||||
|
this.Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void btnCancel_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
this.Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,224 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
|
||||||
|
<ProductVersion>8.0.30703</ProductVersion>
|
||||||
|
<SchemaVersion>2.0</SchemaVersion>
|
||||||
|
<ProjectGuid>{566AEE14-134C-4EE4-93B5-1FFB021DE678}</ProjectGuid>
|
||||||
|
<OutputType>WinExe</OutputType>
|
||||||
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
|
<RootNamespace>GpsEmulator</RootNamespace>
|
||||||
|
<AssemblyName>GpsEmulator</AssemblyName>
|
||||||
|
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||||
|
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
|
||||||
|
<FileAlignment>512</FileAlignment>
|
||||||
|
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
|
||||||
|
<PlatformTarget>x86</PlatformTarget>
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
<OutputPath>bin\Debug\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
|
||||||
|
<PlatformTarget>x86</PlatformTarget>
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>bin\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup>
|
||||||
|
<ApplicationIcon>Resources\GpsEmulator.ico</ApplicationIcon>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Tests|x86'">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<OutputPath>bin\x86\Tests\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<PlatformTarget>x86</PlatformTarget>
|
||||||
|
<CodeAnalysisLogFile>bin\Debug\GpsEmulator.exe.CodeAnalysisLog.xml</CodeAnalysisLogFile>
|
||||||
|
<CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
|
||||||
|
<CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||||
|
<CodeAnalysisRuleSetDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets</CodeAnalysisRuleSetDirectories>
|
||||||
|
<CodeAnalysisRuleDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules</CodeAnalysisRuleDirectories>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.configuration" />
|
||||||
|
<Reference Include="System.Data" />
|
||||||
|
<Reference Include="System.Drawing" />
|
||||||
|
<Reference Include="System.Runtime.Serialization" />
|
||||||
|
<Reference Include="System.ServiceModel" />
|
||||||
|
<Reference Include="System.Xml" />
|
||||||
|
<Reference Include="Microsoft.CSharp" />
|
||||||
|
<Reference Include="System.Core" />
|
||||||
|
<Reference Include="System.Xml.Linq" />
|
||||||
|
<Reference Include="System.Data.DataSetExtensions" />
|
||||||
|
<Reference Include="System.Xaml">
|
||||||
|
<RequiredTargetFramework>4.0</RequiredTargetFramework>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="WindowsBase" />
|
||||||
|
<Reference Include="PresentationCore" />
|
||||||
|
<Reference Include="PresentationFramework" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ApplicationDefinition Include="App.xaml">
|
||||||
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
</ApplicationDefinition>
|
||||||
|
<Compile Include="BingApis\BingMapsClient.cs" />
|
||||||
|
<Compile Include="DialogWindows\BingApiKeyDialog.xaml.cs">
|
||||||
|
<DependentUpon>BingApiKeyDialog.xaml</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="DialogWindows\OptionsDialog.xaml.cs">
|
||||||
|
<DependentUpon>OptionsDialog.xaml</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="GpsService\IGpsEmulatorService.cs" />
|
||||||
|
<Compile Include="MapControl\MapMarker.cs" />
|
||||||
|
<Compile Include="Markers\RouteMarker.cs" />
|
||||||
|
<Compile Include="Markers\SelectionMarker.xaml.cs">
|
||||||
|
<DependentUpon>SelectionMarker.xaml</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="Markers\DirectionalMarker.xaml.cs">
|
||||||
|
<DependentUpon>DirectionalMarker.xaml</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="DialogWindows\AboutDialog.xaml.cs">
|
||||||
|
<DependentUpon>AboutDialog.xaml</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="Utilities\MapTypes.cs" />
|
||||||
|
<Compile Include="Utilities\InternetConnectivityChecker.cs" />
|
||||||
|
<Compile Include="MapControl\InMemoryCacheMapTileFactory.cs" />
|
||||||
|
<Compile Include="MapControl\MapControl.xaml.cs">
|
||||||
|
<DependentUpon>MapControl.xaml</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="MapControl\MapTile.xaml.cs">
|
||||||
|
<DependentUpon>MapTile.xaml</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="MapControl\IMapTileFactory.cs" />
|
||||||
|
<Compile Include="Utilities\MapUtils.cs" />
|
||||||
|
<Compile Include="MapControl\WebMapTileFactory.cs" />
|
||||||
|
<Compile Include="Markers\WaypointMarker.xaml.cs">
|
||||||
|
<DependentUpon>WaypointMarker.xaml</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="BingApis\TimedPosition.cs" />
|
||||||
|
<Compile Include="BingApis\VirtualEarthWebServices.cs" />
|
||||||
|
<Page Include="DialogWindows\BingApiKeyDialog.xaml">
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
</Page>
|
||||||
|
<Page Include="DialogWindows\OptionsDialog.xaml">
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
</Page>
|
||||||
|
<Page Include="MapControl\MapControl.xaml">
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
</Page>
|
||||||
|
<Page Include="MapControl\MapTile.xaml">
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
</Page>
|
||||||
|
<Page Include="Markers\SelectionMarker.xaml">
|
||||||
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
</Page>
|
||||||
|
<Page Include="Markers\DirectionalMarker.xaml">
|
||||||
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
</Page>
|
||||||
|
<Page Include="Markers\WaypointMarker.xaml">
|
||||||
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
</Page>
|
||||||
|
<Page Include="MainWindow.xaml">
|
||||||
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
</Page>
|
||||||
|
<Compile Include="App.xaml.cs">
|
||||||
|
<DependentUpon>App.xaml</DependentUpon>
|
||||||
|
<SubType>Code</SubType>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="MainWindow.xaml.cs">
|
||||||
|
<DependentUpon>MainWindow.xaml</DependentUpon>
|
||||||
|
<SubType>Code</SubType>
|
||||||
|
</Compile>
|
||||||
|
<Page Include="DialogWindows\AboutDialog.xaml">
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
</Page>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="Properties\AssemblyInfo.cs">
|
||||||
|
<SubType>Code</SubType>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="Properties\Resources.Designer.cs">
|
||||||
|
<AutoGen>True</AutoGen>
|
||||||
|
<DesignTime>True</DesignTime>
|
||||||
|
<DependentUpon>Resources.resx</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="Properties\Settings.Designer.cs">
|
||||||
|
<AutoGen>True</AutoGen>
|
||||||
|
<DependentUpon>Settings.settings</DependentUpon>
|
||||||
|
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||||
|
</Compile>
|
||||||
|
<EmbeddedResource Include="Properties\Resources.resx">
|
||||||
|
<Generator>ResXFileCodeGenerator</Generator>
|
||||||
|
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||||
|
</EmbeddedResource>
|
||||||
|
<None Include="App.config">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
</None>
|
||||||
|
<None Include="Properties\Settings.settings">
|
||||||
|
<Generator>SettingsSingleFileGenerator</Generator>
|
||||||
|
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||||
|
</None>
|
||||||
|
<AppDesigner Include="Properties\" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<WCFMetadata Include="Service References\" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Resource Include="Resources\ZoomIn.png" />
|
||||||
|
<Resource Include="Resources\ZoomOut.png" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Resource Include="Markers\WaypointMarker.png" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Resource Include="Markers\DirectionalMarker.png" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Resource Include="Markers\SelectionMarker.png" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Resource Include="Resources\GpsEmulator.ico" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Resource Include="Resources\GpsEmulator.png" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Resource Include="Resources\Key.png" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Resource Include="Resources\Settings.png" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
|
<Target Name="BeforeBuild">
|
||||||
|
</Target>
|
||||||
|
<Target Name="AfterBuild">
|
||||||
|
</Target>
|
||||||
|
-->
|
||||||
|
</Project>
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
using System.ServiceModel;
|
||||||
|
|
||||||
|
namespace GpsEmulator.GpsService
|
||||||
|
{
|
||||||
|
[ServiceContract]
|
||||||
|
interface IGpsEmulatorService
|
||||||
|
{
|
||||||
|
[OperationContract]
|
||||||
|
string GetCurrentPosition();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,201 @@
|
|||||||
|
<Window x:Class="GpsEmulator.MainWindow"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:src="clr-namespace:GpsEmulator"
|
||||||
|
xmlns:map="clr-namespace:GpsEmulator.MapControl"
|
||||||
|
Icon="Resources\GpsEmulator.ico"
|
||||||
|
Title="Windows Phone GPS Emulator" Height="600" Width="800">
|
||||||
|
<Window.Resources>
|
||||||
|
<Style x:Key="ZoomInButton" TargetType="Button">
|
||||||
|
<Setter Property="Width" Value="20" />
|
||||||
|
<Setter Property="Height" Value="20" />
|
||||||
|
<Setter Property="Template">
|
||||||
|
<Setter.Value>
|
||||||
|
<ControlTemplate TargetType="Button">
|
||||||
|
<Grid Width="20" Height="20">
|
||||||
|
<Image Source="/Resources/ZoomIn.png" Stretch="Fill" />
|
||||||
|
<ContentPresenter HorizontalAlignment="Center" />
|
||||||
|
</Grid>
|
||||||
|
<ControlTemplate.Triggers>
|
||||||
|
<Trigger Property="IsMouseOver" Value="True">
|
||||||
|
<Setter Property="Effect">
|
||||||
|
<Setter.Value>
|
||||||
|
<DropShadowEffect ShadowDepth="2" />
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
|
</Trigger>
|
||||||
|
</ControlTemplate.Triggers>
|
||||||
|
</ControlTemplate>
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
|
</Style>
|
||||||
|
<Style x:Key="ZoomOutButton" TargetType="Button">
|
||||||
|
<Setter Property="Width" Value="20" />
|
||||||
|
<Setter Property="Height" Value="20" />
|
||||||
|
<Setter Property="Template">
|
||||||
|
<Setter.Value>
|
||||||
|
<ControlTemplate TargetType="Button">
|
||||||
|
<Grid Width="20" Height="20">
|
||||||
|
<Image Source="/Resources/ZoomOut.png" Stretch="Fill" />
|
||||||
|
<ContentPresenter HorizontalAlignment="Center" />
|
||||||
|
</Grid>
|
||||||
|
<ControlTemplate.Triggers>
|
||||||
|
<Trigger Property="IsMouseOver" Value="True">
|
||||||
|
<Setter Property="Effect">
|
||||||
|
<Setter.Value>
|
||||||
|
<DropShadowEffect ShadowDepth="2" />
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
|
</Trigger>
|
||||||
|
</ControlTemplate.Triggers>
|
||||||
|
</ControlTemplate>
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
|
</Style>
|
||||||
|
</Window.Resources>
|
||||||
|
<Grid x:Name="LayoutRoot">
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="20"/>
|
||||||
|
<RowDefinition Height="*"/>
|
||||||
|
<RowDefinition Height="22"/>
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<Menu Name="menu" Grid.Row="0" HorizontalAlignment="Stretch">
|
||||||
|
<MenuItem Header="_File">
|
||||||
|
<MenuItem Header="_New" InputGestureText="Ctrl+N" Command="New" />
|
||||||
|
<MenuItem Header="_Open" InputGestureText="Ctrl+O" Command="Open" />
|
||||||
|
<MenuItem Header="_Recent">
|
||||||
|
<MenuItem Header="..."/>
|
||||||
|
</MenuItem>
|
||||||
|
<MenuItem Header="_Save" InputGestureText="Ctrl+S" Command="Save" />
|
||||||
|
<MenuItem Header="_Save As" Click="mnuSaveAs_Click" />
|
||||||
|
<Separator/>
|
||||||
|
<MenuItem Header="E_xit" InputGestureText="Alt+F4" Command="Close"/>
|
||||||
|
</MenuItem>
|
||||||
|
<MenuItem Header="_Tools">
|
||||||
|
<MenuItem Header="_Set API Key ..." Click="mnuSetApiKey_Click"/>
|
||||||
|
<MenuItem Header="_Options ..." Click="mnuOptions_Click" />
|
||||||
|
</MenuItem>
|
||||||
|
<MenuItem Header="_Help">
|
||||||
|
<MenuItem Header="_About" Click="mnuAbout_Click"/>
|
||||||
|
</MenuItem>
|
||||||
|
</Menu>
|
||||||
|
<Grid Grid.Row="1" >
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="230" MinWidth="230"/>
|
||||||
|
<ColumnDefinition Width="Auto" />
|
||||||
|
<ColumnDefinition Width="*"/>
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<DockPanel VerticalAlignment="Stretch" Grid.Column="0">
|
||||||
|
<DockPanel DockPanel.Dock="Top" HorizontalAlignment="Stretch" Height="130px">
|
||||||
|
<Label DockPanel.Dock="Top" FontWeight="Bold" Background="AliceBlue">Waypoint</Label>
|
||||||
|
<DockPanel DockPanel.Dock="Top" Margin="2,2,5,2">
|
||||||
|
<Button Name="btnSearch" DockPanel.Dock="Right" Width="80" Margin="5,0,0,0" Click="btnSearch_Click">Search</Button>
|
||||||
|
<TextBox Name="tbSearchString" KeyUp="tbSearchString_KeyUp"/>
|
||||||
|
</DockPanel>
|
||||||
|
<Grid DockPanel.Dock="Right" Width="80" Margin="0,3,5,2">
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition/>
|
||||||
|
<RowDefinition Height="5" />
|
||||||
|
<RowDefinition/>
|
||||||
|
<RowDefinition Height="5" />
|
||||||
|
<RowDefinition/>
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<Button Name="btnAddPoint" Grid.Row="0" Click="btnAddPoint_Click">Add Point</Button>
|
||||||
|
<Button Name="btnAddRoute" Grid.Row="2" Click="btnAddRoute_Click">Add Route</Button>
|
||||||
|
<Button Name="btnUpdatePoint" Grid.Row="4" Click="btnUpdatePoint_Click" ToolTip="Replaces the currently selected point in the route">Update Point</Button>
|
||||||
|
</Grid>
|
||||||
|
<Border BorderBrush="LightSkyBlue" BorderThickness="1" Margin="2,0,5,0" >
|
||||||
|
<Grid>
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="55"/>
|
||||||
|
<ColumnDefinition/>
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition/>
|
||||||
|
<RowDefinition/>
|
||||||
|
<RowDefinition/>
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<Label Grid.Row="0" Grid.Column="0" DockPanel.Dock="Left">Lat:</Label>
|
||||||
|
<TextBox Name="tbPositionLat" Grid.Row="0" Grid.Column="1" Height="20" HorizontalAlignment="Stretch" Margin="0,0,5,0" TextChanged="positionTextChanged">47.6395454</TextBox>
|
||||||
|
<Label Grid.Row="1" Grid.Column="0" DockPanel.Dock="Left">Long:</Label>
|
||||||
|
<TextBox Name="tbPositionLng" Grid.Row="1" Grid.Column="1" Height="20" HorizontalAlignment="Stretch" Margin="0,0,5,0" TextChanged="positionTextChanged">-122.130699</TextBox>
|
||||||
|
<Label Grid.Row="2" Grid.Column="0" DockPanel.Dock="Left">Time:</Label>
|
||||||
|
<TextBox Name="tbTime" Grid.Row="2" Grid.Column="1" Height="20" HorizontalAlignment="Stretch" Margin="0,0,5,0" TextChanged="timeTextChanged" Text="00:00:00.00"/>
|
||||||
|
</Grid>
|
||||||
|
</Border>
|
||||||
|
</DockPanel>
|
||||||
|
<DockPanel DockPanel.Dock="Bottom" HorizontalAlignment="Stretch" Height="76px">
|
||||||
|
<Grid DockPanel.Dock="Top">
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition/>
|
||||||
|
<RowDefinition/>
|
||||||
|
<RowDefinition/>
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="72" />
|
||||||
|
<ColumnDefinition/>
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<Rectangle Grid.Row="0" Grid.ColumnSpan="2" HorizontalAlignment="Stretch" Height="3" Fill="LightGray" Margin="0,0 ,0,0" />
|
||||||
|
<TextBlock Grid.Row="1" Grid.ColumnSpan="2" Background="AliceBlue" FontWeight="Bold" Padding="5,2,0,2" Height="26">Simulation</TextBlock>
|
||||||
|
<TextBlock Grid.Row="2" Grid.Column="0" Name="tbSpeed" Margin="5,0,5,0" VerticalAlignment="Center">Speed : x1</TextBlock>
|
||||||
|
<Slider Grid.Row="2" Grid.Column="1" HorizontalAlignment="Stretch" Name="sldSimulationSpeed" Minimum="0" Maximum="6" IsSnapToTickEnabled="True" SmallChange="1" TickPlacement="BottomRight" ToolTip="Simulation Speed" ValueChanged="sldSimulationSpeed_ValueChanged"/>
|
||||||
|
</Grid>
|
||||||
|
<Button DockPanel.Dock="Left" Name="btnStart" Margin="5,2,5,2" Click="btnStart_Click">Start</Button>
|
||||||
|
<Button DockPanel.Dock="Left" Name="btnReset" Margin="0,2,0,2" Click="btnReset_Click">Reset</Button>
|
||||||
|
<TextBlock Name="tbCurrentPosition" HorizontalAlignment="Center" VerticalAlignment="Center"></TextBlock>
|
||||||
|
</DockPanel>
|
||||||
|
<DockPanel>
|
||||||
|
<Rectangle DockPanel.Dock="Top" HorizontalAlignment="Stretch" Height="3" Fill="LightGray" Margin="0,2,0,0" />
|
||||||
|
<Label DockPanel.Dock="Top" FontWeight="Bold" Background="AliceBlue">Route</Label>
|
||||||
|
<ListView Name="lvRoute">
|
||||||
|
<ListView.View>
|
||||||
|
<GridView ColumnHeaderToolTip="Route Information">
|
||||||
|
<GridViewColumn Header="Time" DisplayMemberBinding="{Binding Path=Time}" />
|
||||||
|
<GridViewColumn Header="Lat" DisplayMemberBinding="{Binding Path=Position.X}" />
|
||||||
|
<GridViewColumn Header="Long" DisplayMemberBinding="{Binding Path=Position.Y}" />
|
||||||
|
</GridView>
|
||||||
|
</ListView.View>
|
||||||
|
</ListView>
|
||||||
|
</DockPanel>
|
||||||
|
</DockPanel>
|
||||||
|
<GridSplitter Grid.Column="1" Background="LightGray" ShowsPreview="True" Width="5" HorizontalAlignment="Stretch" />
|
||||||
|
<Grid Grid.Column="2">
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="25"/>
|
||||||
|
<RowDefinition Height="*" />
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="*" />
|
||||||
|
<ColumnDefinition Width="Auto" />
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<Label Grid.Row="0" Grid.Column="0" FontWeight="Bold" Background="AliceBlue">Map</Label>
|
||||||
|
<StackPanel Grid.Row="0" Grid.Column="1" Grid.ColumnSpan="1" Orientation="Horizontal" Background="AliceBlue">
|
||||||
|
<Label>Map Type</Label>
|
||||||
|
<ComboBox SelectedItem="{Binding ElementName=MapControl, Path=MapType}" FontSize="12" Name="cmbMapType" Margin="0,2,5,2" Height="27" Width="80" SelectionChanged="cmbMapType_SelectionChanged" />
|
||||||
|
</StackPanel>
|
||||||
|
<map:MapControl x:Name="MapControl" Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2"/>
|
||||||
|
<StackPanel Orientation="Horizontal" Grid.Row="1" Grid.Column="0" VerticalAlignment="Top" Margin="5,5,0,0">
|
||||||
|
<Button Name="btnZoomIn" Style="{StaticResource ZoomInButton}" Width="20" Height="20" Click="btnZoomIn_Click" />
|
||||||
|
<Label></Label>
|
||||||
|
<Button Name="btnZoomOut" Style="{StaticResource ZoomOutButton}" Width="20" Height="20" Click="btnZoomOut_Click"/>
|
||||||
|
</StackPanel>
|
||||||
|
</Grid>
|
||||||
|
</Grid>
|
||||||
|
<StatusBar Grid.Row="2" BorderBrush="Black" BorderThickness="0,1,0,0">
|
||||||
|
<StatusBarItem HorizontalAlignment="Left" Width="180">
|
||||||
|
<TextBlock Name="tbOnlineStatus">Not Connected to the Internet</TextBlock>
|
||||||
|
</StatusBarItem>
|
||||||
|
<Separator/>
|
||||||
|
<StatusBarItem>
|
||||||
|
<TextBlock Name="tbFileName">No file loaded</TextBlock>
|
||||||
|
</StatusBarItem>
|
||||||
|
<Separator/>
|
||||||
|
<StatusBarItem HorizontalAlignment="Right" Width="140">
|
||||||
|
<DockPanel>
|
||||||
|
<Ellipse DockPanel.Dock="Left" Name="elClientIndicator" Fill="Red" Stroke="Black" Width="14" Height="14"/>
|
||||||
|
<TextBlock DockPanel.Dock="Right" Name="tbClientIndicator" Margin="10,0,0,0">No client connected</TextBlock>
|
||||||
|
</DockPanel>
|
||||||
|
</StatusBarItem>
|
||||||
|
</StatusBar>
|
||||||
|
</Grid>
|
||||||
|
</Window>
|
||||||
@@ -0,0 +1,784 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
|
using System.Configuration;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.IO;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
using System.Windows.Input;
|
||||||
|
using System.Windows.Media;
|
||||||
|
using GpsEmulator.BingApis;
|
||||||
|
using GpsEmulator.MapControl;
|
||||||
|
using GpsEmulator.Markers;
|
||||||
|
using GpsEmulator.Utilities;
|
||||||
|
using GpsEmulator.GpsService;
|
||||||
|
using Microsoft.Win32;
|
||||||
|
using System.ServiceModel;
|
||||||
|
using System.Windows.Ink;
|
||||||
|
|
||||||
|
namespace GpsEmulator
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Interaction logic for MainWindow.xaml
|
||||||
|
/// </summary>
|
||||||
|
[ServiceBehavior(InstanceContextMode=InstanceContextMode.Single)]
|
||||||
|
public partial class MainWindow : Window, IGpsEmulatorService
|
||||||
|
{
|
||||||
|
ObservableCollection<TimedPosition> route = new ObservableCollection<TimedPosition>();
|
||||||
|
static string MSG_BOX_CAPTION = "Windows Phone 7 GPS Emulator";
|
||||||
|
string bingApiKey;
|
||||||
|
BingApis.BingMapsClient bingMapsClient;
|
||||||
|
double defaultSpeed; // In meters per second
|
||||||
|
bool useRealTimeData = false;
|
||||||
|
string transmittedLocation = "Not Started";
|
||||||
|
bool clientCallDetected = false;
|
||||||
|
ServiceHost host;
|
||||||
|
|
||||||
|
public MainWindow()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// setup the GPS host service
|
||||||
|
host = new ServiceHost(this, new Uri("http://localhost:8192/"));
|
||||||
|
host.AddServiceEndpoint(typeof(IGpsEmulatorService), new BasicHttpBinding(BasicHttpSecurityMode.None), "GpsEmulator");
|
||||||
|
host.Open();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Failed to start the GPS Emulator!\nPlease make sure the application has Administrator privilages.\n\nError details: " + ex.Message, MSG_BOX_CAPTION, MessageBoxButton.OK);
|
||||||
|
Application.Current.Shutdown() ;
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Read application settings from configuration file
|
||||||
|
double lastLat, lastLng;
|
||||||
|
int lastZoom, lastMapType;
|
||||||
|
int windowTop, windowLeft, windowHeight, windowWidth;
|
||||||
|
bingApiKey = ConfigurationManager.AppSettings["BingApiKey"];
|
||||||
|
bingMapsClient = new BingApis.BingMapsClient(bingApiKey);
|
||||||
|
if (!Double.TryParse(ConfigurationManager.AppSettings["DefaultSpeed"], out defaultSpeed)) defaultSpeed = 16.6666;
|
||||||
|
if (!Boolean.TryParse(ConfigurationManager.AppSettings["UseRealTimeData"], out useRealTimeData)) useRealTimeData = false;
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
InitializeComponent();
|
||||||
|
|
||||||
|
#region BindMenuCommends
|
||||||
|
|
||||||
|
this.CommandBindings.Add(new CommandBinding(ApplicationCommands.Open, OpenCommandHandler, null));
|
||||||
|
this.CommandBindings.Add(new CommandBinding(ApplicationCommands.New, NewCommendHandler, null));
|
||||||
|
this.CommandBindings.Add(new CommandBinding(ApplicationCommands.Save, SaveCommandHandler, null));
|
||||||
|
this.CommandBindings.Add(new CommandBinding(ApplicationCommands.Close, CloseCommandHandler, null));
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Restore main window settings from the last session
|
||||||
|
if (ConfigurationManager.AppSettings["windowMaximized"] != null && ConfigurationManager.AppSettings["windowMaximized"] == "True") this.WindowState = System.Windows.WindowState.Maximized;
|
||||||
|
if (Int32.TryParse(ConfigurationManager.AppSettings["windowTop"], out windowTop)) this.Top = windowTop;
|
||||||
|
if (Int32.TryParse(ConfigurationManager.AppSettings["windowLeft"], out windowLeft)) this.Left = windowLeft;
|
||||||
|
if (Int32.TryParse(ConfigurationManager.AppSettings["windowHeight"], out windowHeight)) this.Height = windowHeight > 400 ? windowHeight : 400;
|
||||||
|
if (Int32.TryParse(ConfigurationManager.AppSettings["windowWidth"], out windowWidth)) this.Width = windowWidth > 450 ? windowWidth : 450;
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Restore map control settings from the last session
|
||||||
|
if (!Double.TryParse(ConfigurationManager.AppSettings["LastLocationLat"], out lastLat)) lastLat = 47.6395454;
|
||||||
|
if (!Double.TryParse(ConfigurationManager.AppSettings["LastLocationLng"], out lastLng)) lastLng = -122.130699;
|
||||||
|
if (!Int32.TryParse(ConfigurationManager.AppSettings["LastZoom"], out lastZoom)) lastZoom = 17;
|
||||||
|
if (!Int32.TryParse(ConfigurationManager.AppSettings["LastMapType"], out lastMapType)) lastMapType = 1;
|
||||||
|
MapControl.ZoomLevel = lastZoom;
|
||||||
|
MapControl.MapCenter = new Point(lastLat, lastLng);
|
||||||
|
MapControl.MapType = (MapType) lastMapType;
|
||||||
|
if (ConfigurationManager.AppSettings["PathColor"] != null)
|
||||||
|
{
|
||||||
|
Brush brush;
|
||||||
|
switch (ConfigurationManager.AppSettings["PathColor"])
|
||||||
|
{
|
||||||
|
case "Green":
|
||||||
|
brush = Brushes.ForestGreen;
|
||||||
|
break;
|
||||||
|
case "Blue":
|
||||||
|
brush = Brushes.RoyalBlue;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
brush = Brushes.Red;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
MapControl.PathColor = brush;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
MapControl.MapTileFactory = new InMemoryCacheMapTileFactory( new WebMapTileFactory(bingMapsClient) );
|
||||||
|
|
||||||
|
// Attach map control event handlers
|
||||||
|
MapControl.MouseMove += new System.Windows.Input.MouseEventHandler(MapControl_MouseMove);
|
||||||
|
MapControl.MouseLeftButtonDown += new MouseButtonEventHandler(MapControl_MouseLeftButtonDown);
|
||||||
|
MapControl.MouseLeftButtonUp += new MouseButtonEventHandler(MapControl_MouseLeftButtonUp);
|
||||||
|
MapControl.MouseDoubleClick += new System.Windows.Input.MouseButtonEventHandler(MapControl_MouseDoubleClick);
|
||||||
|
MapControl.MouseWheel += new MouseWheelEventHandler(MapControl_MouseWheel);
|
||||||
|
|
||||||
|
// Bind map type drop down
|
||||||
|
cmbMapType.ItemsSource = Enum.GetValues(typeof(Utilities.MapType));
|
||||||
|
|
||||||
|
// route
|
||||||
|
lvRoute.ItemsSource = route;
|
||||||
|
lvRoute.SizeChanged += lvRoute_SizeChanged;
|
||||||
|
lvRoute.SelectionChanged += lvRoute_SelectionChanged;
|
||||||
|
lvRoute.KeyUp += new KeyEventHandler(lvRoute_KeyUp);
|
||||||
|
|
||||||
|
#region Internet Connectivity Checking
|
||||||
|
// check internet connectivity
|
||||||
|
Task t = Task.Factory.StartNew(() =>
|
||||||
|
{
|
||||||
|
//bool previouslyConnectedToTheInternet = true;
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
((InMemoryCacheMapTileFactory)MapControl.MapTileFactory).CleanupCache();
|
||||||
|
tbOnlineStatus.Dispatcher.Invoke((Action)(() => {
|
||||||
|
tbOnlineStatus.Text = InternetConnectivityChecker.IsConnectedToInternet() ? "Connected to the Internet" : "Not Connected to the Internet";
|
||||||
|
if (clientCallDetected)
|
||||||
|
{
|
||||||
|
elClientIndicator.Fill = Brushes.Green;
|
||||||
|
tbClientIndicator.Text = "Client connected";
|
||||||
|
clientCallDetected = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
elClientIndicator.Fill = Brushes.Red;
|
||||||
|
tbClientIndicator.Text = "No client connected";
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
// Refresh the display if connected
|
||||||
|
//bool connectedToTheInternet = InternetConnectivityChecker.IsConnectedToInternet();
|
||||||
|
//if (!previouslyConnectedToTheInternet && connectedToTheInternet)
|
||||||
|
//{
|
||||||
|
// MapControl.InvalidateVisual();
|
||||||
|
//}
|
||||||
|
//previouslyConnectedToTheInternet = connectedToTheInternet;
|
||||||
|
System.Threading.Thread.Sleep(2000);
|
||||||
|
}
|
||||||
|
}, TaskCreationOptions.LongRunning);
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
host.Close(TimeSpan.FromSeconds(1));
|
||||||
|
}
|
||||||
|
catch {}
|
||||||
|
|
||||||
|
Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
|
||||||
|
|
||||||
|
AddOrCreateConfigSection(config, "LastLocationLat", MapControl.MapCenter.X.ToString());
|
||||||
|
AddOrCreateConfigSection(config, "LastLocationLng", MapControl.MapCenter.Y.ToString());
|
||||||
|
AddOrCreateConfigSection(config, "LastZoom", MapControl.ZoomLevel.ToString());
|
||||||
|
AddOrCreateConfigSection(config, "windowTop", this.Top.ToString());
|
||||||
|
AddOrCreateConfigSection(config, "windowLeft", this.Left.ToString());
|
||||||
|
AddOrCreateConfigSection(config, "windowHeight", this.ActualHeight.ToString());
|
||||||
|
AddOrCreateConfigSection(config, "windowWidth", this.ActualWidth.ToString());
|
||||||
|
AddOrCreateConfigSection(config, "windowMaximized", this.WindowState==System.Windows.WindowState.Maximized ? "True" : "False");
|
||||||
|
AddOrCreateConfigSection(config, "LastMapType", ((int)MapControl.MapType).ToString());
|
||||||
|
|
||||||
|
config.Save(ConfigurationSaveMode.Modified); base.OnClosing(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void AddOrCreateConfigSection(Configuration config, string key, string value)
|
||||||
|
{
|
||||||
|
if (config.AppSettings.Settings[key] == null)
|
||||||
|
config.AppSettings.Settings.Add(key, value);
|
||||||
|
else
|
||||||
|
config.AppSettings.Settings[key].Value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Map Event Handlers
|
||||||
|
|
||||||
|
void MapControl_MouseDoubleClick(object sender, System.Windows.Input.MouseButtonEventArgs e)
|
||||||
|
{
|
||||||
|
Point endPoint = e.GetPosition(MapControl);
|
||||||
|
endPoint = MapControl.LatLongFromLocal((int)endPoint.X, (int)endPoint.Y);
|
||||||
|
tbPositionLat.Text = endPoint.X.ToString();
|
||||||
|
tbPositionLng.Text = endPoint.Y.ToString();
|
||||||
|
if (Keyboard.IsKeyDown(Key.LeftCtrl))
|
||||||
|
{
|
||||||
|
// Add a path
|
||||||
|
ExtendRouteFromLastPosition();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Add a single point
|
||||||
|
if (lvRoute.Items.Count > 0)
|
||||||
|
{
|
||||||
|
// Update the time based on the location of the new point
|
||||||
|
TimedPosition tmp = lvRoute.Items[lvRoute.Items.Count - 1] as TimedPosition;
|
||||||
|
Point startPoint = new Point(tmp.Position.X, tmp.Position.Y);
|
||||||
|
double distance = MapUtils.GetDistance(startPoint, endPoint);
|
||||||
|
tbTime.Text = tmp.Time.Add(TimeSpan.FromMilliseconds(100 * distance / defaultSpeed)).ToString();
|
||||||
|
}
|
||||||
|
AddWaypointAtCurrentPosition();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Point mapMouseDownPoint = new Point();
|
||||||
|
void MapControl_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
||||||
|
{
|
||||||
|
mapMouseDownPoint = e.GetPosition(MapControl);
|
||||||
|
Mouse.Capture(MapControl);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool dragDetected = false;
|
||||||
|
void MapControl_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
|
||||||
|
{
|
||||||
|
Mouse.Capture(null);
|
||||||
|
Point p = e.GetPosition(MapControl);
|
||||||
|
if (!dragDetected)
|
||||||
|
{
|
||||||
|
Point clickLatLong = MapControl.LatLongFromLocal(p.X, p.Y);
|
||||||
|
MapControl.SetSelectedPoint(clickLatLong.X, clickLatLong.Y);
|
||||||
|
tbPositionLat.Text = clickLatLong.X.ToString();
|
||||||
|
tbPositionLng.Text = clickLatLong.Y.ToString();
|
||||||
|
transmittedLocation = String.Format("{0}, {1}", tbPositionLat.Text, tbPositionLng.Text);
|
||||||
|
}
|
||||||
|
dragDetected = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void MapControl_MouseMove(object sender, System.Windows.Input.MouseEventArgs e)
|
||||||
|
{
|
||||||
|
if (mapMouseDownPoint == e.GetPosition(MapControl)) return;
|
||||||
|
if (e.LeftButton == System.Windows.Input.MouseButtonState.Pressed)
|
||||||
|
{
|
||||||
|
dragDetected = true;
|
||||||
|
Mouse.SetCursor(Cursors.SizeAll);
|
||||||
|
Point p = e.GetPosition(MapControl);
|
||||||
|
double dX = (mapMouseDownPoint.X - p.X) / 2;
|
||||||
|
double dY = (mapMouseDownPoint.Y - p.Y) / 2;
|
||||||
|
MapControl.MoveCenter(dX, dY);
|
||||||
|
mapMouseDownPoint = p;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void MapControl_MouseWheel(object sender, MouseWheelEventArgs e)
|
||||||
|
{
|
||||||
|
int oldZoom = MapControl.ZoomLevel;
|
||||||
|
Point uiPoint = Mouse.GetPosition(MapControl);
|
||||||
|
Point uiLatLng = MapControl.LatLongFromLocal(uiPoint.X, uiPoint.Y);
|
||||||
|
Point latLngDelta = new Point(uiLatLng.X - MapControl.MapCenter.X, uiLatLng.Y - MapControl.MapCenter.Y);
|
||||||
|
Point newCenter;
|
||||||
|
if (e.Delta < 0)
|
||||||
|
{
|
||||||
|
MapControl.ZoomLevel -= 1;
|
||||||
|
newCenter = new Point(MapControl.MapCenter.X - latLngDelta.X, MapControl.MapCenter.Y - latLngDelta.Y);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MapControl.ZoomLevel += 1;
|
||||||
|
newCenter = new Point(MapControl.MapCenter.X + latLngDelta.X/2, MapControl.MapCenter.Y + latLngDelta.Y/2);
|
||||||
|
}
|
||||||
|
if (oldZoom != MapControl.ZoomLevel)
|
||||||
|
{
|
||||||
|
MapControl.MapCenter = newCenter;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Event handlers for buttons, lists, etc.
|
||||||
|
private void btnAddPoint_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
AddWaypointAtCurrentPosition();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void btnAddRoute_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
ExtendRouteFromLastPosition();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void btnUpdatePoint_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
int index = lvRoute.SelectedIndex;
|
||||||
|
if (index == -1) return;
|
||||||
|
|
||||||
|
double lat, lng;
|
||||||
|
TimeSpan time;
|
||||||
|
if (!Double.TryParse(tbPositionLat.Text, out lat) || !Double.TryParse(tbPositionLng.Text, out lng)) return;
|
||||||
|
if (!TimeSpan.TryParse(tbTime.Text, out time)) return;
|
||||||
|
|
||||||
|
TimedPosition waypoint = new TimedPosition(time, lat, lng);
|
||||||
|
WaypointMarker newMarker = new WaypointMarker(this, String.Format("Lat : {0}\nLong : {1}", waypoint.Position.X, waypoint.Position.Y));
|
||||||
|
MapMarker mm = MapControl.ReplaceMarker(route[index].MapMarker, newMarker, waypoint.Position.X, waypoint.Position.Y);
|
||||||
|
waypoint.MapMarker = mm;
|
||||||
|
route[index] = waypoint;
|
||||||
|
|
||||||
|
lvRoute.SelectedIndex = index;
|
||||||
|
MapControl.RegenerateRouteShape();
|
||||||
|
return;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void btnSearch_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
UpdateLocationUsingSearchString();
|
||||||
|
}
|
||||||
|
|
||||||
|
int simulationSpeed = 1;
|
||||||
|
Task currentNavigationTask = null;
|
||||||
|
static CancellationTokenSource cancellationTokenSource;
|
||||||
|
static CancellationToken canellationToken;
|
||||||
|
|
||||||
|
private void btnStart_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
if (currentNavigationTask != null)
|
||||||
|
{
|
||||||
|
cancellationTokenSource.Cancel();
|
||||||
|
currentNavigationTask = null;
|
||||||
|
btnStart.Content = "Start";
|
||||||
|
btnReset.IsEnabled = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const int DELAY = 32;
|
||||||
|
if (lvRoute.Items.Count < 2)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Please add 2 or more waypoints to the route", MSG_BOX_CAPTION, MessageBoxButton.OK, MessageBoxImage.Exclamation);
|
||||||
|
}
|
||||||
|
if (lvRoute.SelectedIndex == -1)
|
||||||
|
{
|
||||||
|
lvRoute.SelectedIndex = 0;
|
||||||
|
}
|
||||||
|
int index = lvRoute.SelectedIndex;
|
||||||
|
TimeSpan currentTime = (lvRoute.Items[index] as TimedPosition).Time.Add(new TimeSpan());
|
||||||
|
|
||||||
|
Point p = (lvRoute.Items[index] as TimedPosition).Position;
|
||||||
|
DirectionalMarker dm = new DirectionalMarker();
|
||||||
|
MapMarker directionalMarker = MapControl.AddMarker(dm, p.X, p.Y);
|
||||||
|
directionalMarker.SetVisualLocation(MapControl.ZoomLevel);
|
||||||
|
|
||||||
|
cancellationTokenSource = new CancellationTokenSource();
|
||||||
|
canellationToken = cancellationTokenSource.Token;
|
||||||
|
btnStart.Content = "Stop";
|
||||||
|
btnReset.IsEnabled = false;
|
||||||
|
|
||||||
|
currentNavigationTask = Task.Factory.StartNew(() =>
|
||||||
|
{
|
||||||
|
while (index < lvRoute.Items.Count - 1)
|
||||||
|
{
|
||||||
|
if (canellationToken.IsCancellationRequested)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
TimedPosition w1 = lvRoute.Items[index] as TimedPosition;
|
||||||
|
TimedPosition w2 = lvRoute.Items[index + 1] as TimedPosition;
|
||||||
|
double numOfStepsOnLeg = (w2.Time - w1.Time).TotalMilliseconds / DELAY;
|
||||||
|
double dLat = (w2.Position.X - w1.Position.X) / numOfStepsOnLeg;
|
||||||
|
double dLng = (w2.Position.Y - w1.Position.Y) / numOfStepsOnLeg;
|
||||||
|
Point currentPosition = new Point(w1.Position.X, w1.Position.Y);
|
||||||
|
Point directionalMarkerCurrentLocation = new Point(w1.Position.X, w1.Position.Y);
|
||||||
|
this.Dispatcher.Invoke((Action)(() => { dm.SetHeading(dLat, dLng); }));
|
||||||
|
|
||||||
|
while (currentTime < w2.Time)
|
||||||
|
{
|
||||||
|
if (canellationToken.IsCancellationRequested) break;
|
||||||
|
Thread.Sleep(DELAY);
|
||||||
|
currentTime = currentTime.Add(new TimeSpan(0, 0, 0, 0, (int) ((double)DELAY * simulationSpeed)));
|
||||||
|
currentPosition.X += dLat * simulationSpeed;
|
||||||
|
currentPosition.Y += dLng * simulationSpeed;
|
||||||
|
directionalMarkerCurrentLocation.X += dLat * simulationSpeed;
|
||||||
|
directionalMarkerCurrentLocation.Y += dLng * simulationSpeed;
|
||||||
|
this.Dispatcher.Invoke((Action)(() =>
|
||||||
|
{
|
||||||
|
transmittedLocation = String.Format("{0}, {1}", currentPosition.X, currentPosition.Y);
|
||||||
|
tbCurrentPosition.Text = String.Format("{0} : {1}", currentTime, transmittedLocation);
|
||||||
|
directionalMarker.Location = directionalMarkerCurrentLocation;
|
||||||
|
directionalMarker.SetVisualLocation(MapControl.ZoomLevel);
|
||||||
|
MapControl.MapCenter = directionalMarkerCurrentLocation;
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
index++;
|
||||||
|
this.Dispatcher.Invoke((Action)(() => lvRoute.SelectedIndex = index));
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.ContinueWith(_ => this.Dispatcher.Invoke((Action)(() =>
|
||||||
|
{
|
||||||
|
MapControl.RemoveMarker(directionalMarker);
|
||||||
|
currentNavigationTask = null;
|
||||||
|
btnStart.Content = "Start";
|
||||||
|
btnReset.IsEnabled = true;
|
||||||
|
})));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void btnReset_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
lvRoute.SelectedIndex = 0;
|
||||||
|
tbCurrentPosition.Text = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
private void btnZoomIn_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
MapControl.ZoomLevel += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void btnZoomOut_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
MapControl.ZoomLevel -= 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void cmbMapType_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||||
|
{
|
||||||
|
MapControl.MapType = (GpsEmulator.Utilities.MapType)cmbMapType.SelectedValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void sldSimulationSpeed_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
|
||||||
|
{
|
||||||
|
simulationSpeed = (int)Math.Pow(2, (int)e.NewValue);
|
||||||
|
tbSpeed.Text = String.Format("Speed : x{0}", simulationSpeed);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void tbSearchString_KeyUp(object sender, KeyEventArgs e)
|
||||||
|
{
|
||||||
|
if (e.Key == Key.Enter) UpdateLocationUsingSearchString();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Text box validators
|
||||||
|
/// <summary>
|
||||||
|
/// Ensured that a text box contains a valid Double number
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
private void positionTextChanged(object sender, TextChangedEventArgs e)
|
||||||
|
{
|
||||||
|
TextBox tb = e.Source as TextBox;
|
||||||
|
Debug.Assert(tb!=null);
|
||||||
|
double notUsed;
|
||||||
|
if (Double.TryParse(tb.Text, out notUsed)) tb.Background = Brushes.White;
|
||||||
|
else tb.Background = Brushes.LightPink;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void timeTextChanged(object sender, TextChangedEventArgs e)
|
||||||
|
{
|
||||||
|
TextBox tb = e.Source as TextBox;
|
||||||
|
Debug.Assert(tb != null);
|
||||||
|
TimeSpan notUsed;
|
||||||
|
if (TimeSpan.TryParse(tb.Text, out notUsed)) tb.Background = Brushes.White;
|
||||||
|
else tb.Background = Brushes.LightPink;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Route list event handlers
|
||||||
|
private void lvRoute_SizeChanged(object sender, SizeChangedEventArgs e)
|
||||||
|
{
|
||||||
|
GridView view = lvRoute.View as GridView;
|
||||||
|
view.Columns[0].Width = lvRoute.ActualWidth / 3;
|
||||||
|
view.Columns[1].Width = lvRoute.ActualWidth / 3;
|
||||||
|
view.Columns[2].Width = lvRoute.ActualWidth / 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void lvRoute_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||||
|
{
|
||||||
|
TimedPosition tp = lvRoute.SelectedItem as TimedPosition;
|
||||||
|
if (tp == null) return;
|
||||||
|
tbPositionLat.Text = tp.Position.X.ToString();
|
||||||
|
tbPositionLng.Text = tp.Position.Y.ToString();
|
||||||
|
tbTime.Text = tp.Time.ToString();
|
||||||
|
MapControl.MapCenter = new Point(tp.Position.X, tp.Position.Y);
|
||||||
|
MapControl.SetSelectedPoint(tp.Position.X, tp.Position.Y);
|
||||||
|
transmittedLocation = String.Format("{0}, {1}", tbPositionLat.Text, tbPositionLng.Text);
|
||||||
|
}
|
||||||
|
|
||||||
|
void lvRoute_KeyUp(object sender, KeyEventArgs e)
|
||||||
|
{
|
||||||
|
if (e.Key == Key.Delete && lvRoute.SelectedItems.Count>0)
|
||||||
|
{
|
||||||
|
TimedPosition tp = lvRoute.SelectedItem as TimedPosition;
|
||||||
|
while( tp != null)
|
||||||
|
{
|
||||||
|
MapControl.RemoveMarker(tp.MapMarker);
|
||||||
|
MapControl.RegenerateRouteShape();
|
||||||
|
MapControl.InvalidateVisual();
|
||||||
|
route.Remove(tp);
|
||||||
|
tp = lvRoute.SelectedItem as TimedPosition;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Menu commands
|
||||||
|
|
||||||
|
private void CloseCommandHandler(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
Application.Current.Shutdown();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OpenCommandHandler(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
OpenFileDialog openFileDialog = new OpenFileDialog();
|
||||||
|
openFileDialog.Filter = "Route Files|*.route";
|
||||||
|
openFileDialog.Title = "Open a Route File";
|
||||||
|
openFileDialog.ShowDialog();
|
||||||
|
|
||||||
|
if (openFileDialog.FileName != "")
|
||||||
|
{
|
||||||
|
FileSaveFormat fileData;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using (FileStream fs = (System.IO.FileStream)openFileDialog.OpenFile())
|
||||||
|
{
|
||||||
|
DataContractSerializer x = new DataContractSerializer(typeof(FileSaveFormat));
|
||||||
|
fileData = (FileSaveFormat)x.ReadObject(fs);
|
||||||
|
}
|
||||||
|
if (!ClearPath()) return;
|
||||||
|
route.Clear();
|
||||||
|
MapControl.ZoomLevel = fileData.zoom;
|
||||||
|
MapControl.MapCenter = fileData.center;
|
||||||
|
route = fileData.route;
|
||||||
|
lvRoute.ItemsSource = route;
|
||||||
|
foreach (TimedPosition waypoint in route)
|
||||||
|
{
|
||||||
|
AddWaypointMarkerToMap(waypoint);
|
||||||
|
}
|
||||||
|
MapControl.RegenerateRouteShape();
|
||||||
|
tbFileName.Text = openFileDialog.FileName;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(String.Format("Error while loading file: \n{0}", ex.Message), MSG_BOX_CAPTION, MessageBoxButton.OK, MessageBoxImage.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void NewCommendHandler(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
ClearPath();
|
||||||
|
tbTime.Text = "00:00:00";
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SaveCommandHandler(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
SaveToFile(tbFileName.Text);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void mnuAbout_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
DialogWindows.AboutDialog aboutDialog = new DialogWindows.AboutDialog();
|
||||||
|
aboutDialog.Owner = this;
|
||||||
|
aboutDialog.ShowDialog();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void mnuSaveAs_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
SaveFileDialog saveFileDialog = new SaveFileDialog();
|
||||||
|
saveFileDialog.Filter = "Route Files|*.route";
|
||||||
|
saveFileDialog.Title = "Save a Route File";
|
||||||
|
saveFileDialog.FileName = tbFileName.Text;
|
||||||
|
saveFileDialog.ShowDialog();
|
||||||
|
|
||||||
|
SaveToFile(saveFileDialog.FileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void mnuSetApiKey_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
DialogWindows.BingApiKeyDialog keyDialog = new DialogWindows.BingApiKeyDialog();
|
||||||
|
keyDialog.tbKey.Text = bingApiKey;
|
||||||
|
keyDialog.Owner = this;
|
||||||
|
keyDialog.ShowDialog();
|
||||||
|
if (!keyDialog.Cancelled)
|
||||||
|
{
|
||||||
|
bingApiKey = keyDialog.tbKey.Text;
|
||||||
|
bingMapsClient.ApiKey = bingApiKey;
|
||||||
|
|
||||||
|
System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
|
||||||
|
config.AppSettings.Settings["BingApiKey"].Value = bingApiKey;
|
||||||
|
config.Save(ConfigurationSaveMode.Modified);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void mnuOptions_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
DialogWindows.OptionsDialog optionsDialog = new DialogWindows.OptionsDialog();
|
||||||
|
switch (MapControl.PathColor.ToString())
|
||||||
|
{
|
||||||
|
case "#FF228B22":
|
||||||
|
optionsDialog.cmbPathColor.SelectedValue = "Green";
|
||||||
|
break;
|
||||||
|
case "#FFFF0000":
|
||||||
|
optionsDialog.cmbPathColor.SelectedValue = "Red";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
optionsDialog.cmbPathColor.SelectedValue = "Blue";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
optionsDialog.tbSpeed.Text = defaultSpeed.ToString();
|
||||||
|
optionsDialog.cbUseRealTimeTrafficData.IsChecked = useRealTimeData;
|
||||||
|
optionsDialog.Owner = this;
|
||||||
|
optionsDialog.ShowDialog();
|
||||||
|
if (!optionsDialog.Cancelled)
|
||||||
|
{
|
||||||
|
switch ((string)optionsDialog.cmbPathColor.SelectedValue)
|
||||||
|
{
|
||||||
|
case "Green":
|
||||||
|
MapControl.PathColor = Brushes.ForestGreen;
|
||||||
|
break;
|
||||||
|
case "Blue":
|
||||||
|
MapControl.PathColor = Brushes.RoyalBlue;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
MapControl.PathColor = Brushes.Red;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
MapControl.RegenerateRouteShape();
|
||||||
|
System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
|
||||||
|
AddOrCreateConfigSection(config, "PathColor", (string)optionsDialog.cmbPathColor.SelectedValue);
|
||||||
|
AddOrCreateConfigSection(config, "DefaultSpeed", optionsDialog.tbSpeed.Text);
|
||||||
|
AddOrCreateConfigSection(config, "UseRealTimeData", optionsDialog.cbUseRealTimeTrafficData.IsChecked.Value.ToString());
|
||||||
|
defaultSpeed = Double.Parse(optionsDialog.tbSpeed.Text);
|
||||||
|
useRealTimeData = optionsDialog.cbUseRealTimeTrafficData.IsChecked.Value;
|
||||||
|
config.Save(ConfigurationSaveMode.Modified);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Menu command helpers
|
||||||
|
[DataContract]
|
||||||
|
private struct FileSaveFormat
|
||||||
|
{
|
||||||
|
[DataMember]
|
||||||
|
public ObservableCollection<TimedPosition> route;
|
||||||
|
[DataMember]
|
||||||
|
public Point center;
|
||||||
|
[DataMember]
|
||||||
|
public int zoom;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SaveToFile(string fileName)
|
||||||
|
{
|
||||||
|
if (!String.IsNullOrEmpty(fileName))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using (FileStream fs = new FileStream(fileName, FileMode.Create))
|
||||||
|
{
|
||||||
|
DataContractSerializer x = new DataContractSerializer(typeof(FileSaveFormat));
|
||||||
|
FileSaveFormat fileData = new FileSaveFormat();
|
||||||
|
fileData.route = route;
|
||||||
|
fileData.center = MapControl.MapCenter;
|
||||||
|
fileData.zoom = MapControl.ZoomLevel;
|
||||||
|
x.WriteObject(fs, fileData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(String.Format("Error while saving to file: \n{0}", ex.Message), MSG_BOX_CAPTION, MessageBoxButton.OK, MessageBoxImage.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool ClearPath()
|
||||||
|
{
|
||||||
|
if (route.Count > 0)
|
||||||
|
{
|
||||||
|
MessageBoxResult result = MessageBox.Show("This operation will clear all the current waypoints!\nWould you like to proceed?\n(This operation cannot be undone.)", MSG_BOX_CAPTION, MessageBoxButton.YesNo, MessageBoxImage.Question);
|
||||||
|
if (result != MessageBoxResult.Yes) return false;
|
||||||
|
route.Clear();
|
||||||
|
MapControl.RemoveAllMarkers();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Helper methods
|
||||||
|
|
||||||
|
private bool AddWaypointAtCurrentPosition()
|
||||||
|
{
|
||||||
|
double lat, lng;
|
||||||
|
TimeSpan time;
|
||||||
|
if (!Double.TryParse(tbPositionLat.Text, out lat) || !Double.TryParse(tbPositionLng.Text, out lng)) return false;
|
||||||
|
if (!TimeSpan.TryParse(tbTime.Text, out time)) return false;
|
||||||
|
// Find the right location to insert the new stop at
|
||||||
|
int i = 0;
|
||||||
|
for (; i < route.Count; i++)
|
||||||
|
{
|
||||||
|
if (route[i].Time > time) break;
|
||||||
|
if (route[i].Time == time)
|
||||||
|
{
|
||||||
|
MessageBox.Show(String.Format("Can't be in two places at the same time.\nThere's already a waypoint at time {0}.\nPlease select a different time for the new waypoint.", time), MSG_BOX_CAPTION, MessageBoxButton.OK, MessageBoxImage.Exclamation);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
TimedPosition waypoint = new TimedPosition(time, lat, lng);
|
||||||
|
route.Insert(i, waypoint);
|
||||||
|
AddWaypointMarkerToMap(waypoint);
|
||||||
|
MapControl.RegenerateRouteShape();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UpdateLocationUsingSearchString()
|
||||||
|
{
|
||||||
|
double lat, lng;
|
||||||
|
bool found = bingMapsClient.QueryLocation(tbSearchString.Text, out lat, out lng);
|
||||||
|
|
||||||
|
if (!found)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Can't find: " + tbSearchString.Text, MSG_BOX_CAPTION, MessageBoxButton.OK, MessageBoxImage.Exclamation);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
tbPositionLat.Text = lat.ToString();
|
||||||
|
tbPositionLng.Text = lng.ToString();
|
||||||
|
MapControl.MapCenter = new Point(lat, lng);
|
||||||
|
MapControl.SetSelectedPoint(lat, lng);
|
||||||
|
transmittedLocation = String.Format("{0}, {1}", tbPositionLat.Text, tbPositionLng.Text);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void AddWaypointMarkerToMap(TimedPosition waypoint)
|
||||||
|
{
|
||||||
|
WaypointMarker actualMarker = new WaypointMarker(this, String.Format("Lat : {0}\nLong : {1}", waypoint.Position.X, waypoint.Position.Y));
|
||||||
|
MapMarker mm = MapControl.AddMarker(actualMarker, waypoint.Position.X, waypoint.Position.Y);
|
||||||
|
waypoint.MapMarker = mm;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ExtendRouteFromLastPosition()
|
||||||
|
{
|
||||||
|
if (lvRoute.Items.Count == 0)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Please add a start point to the route", MSG_BOX_CAPTION, MessageBoxButton.OK, MessageBoxImage.Exclamation);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
double endLat, endLng;
|
||||||
|
if (!Double.TryParse(tbPositionLat.Text, out endLat) || !Double.TryParse(tbPositionLng.Text, out endLng)) return;
|
||||||
|
|
||||||
|
TimeSpan time = (lvRoute.Items[lvRoute.Items.Count - 1] as TimedPosition).Time;
|
||||||
|
Point startPoint = (lvRoute.Items[lvRoute.Items.Count - 1] as TimedPosition).Position;
|
||||||
|
|
||||||
|
Mouse.SetCursor(Cursors.Wait);
|
||||||
|
|
||||||
|
List<TimedPosition> results;
|
||||||
|
if (useRealTimeData) results = bingMapsClient.GetRoute(time, startPoint.X, startPoint.Y, endLat, endLng);
|
||||||
|
else results = bingMapsClient.GetRoute(time, startPoint.X, startPoint.Y, endLat, endLng, defaultSpeed);
|
||||||
|
|
||||||
|
Mouse.SetCursor(Cursors.Arrow);
|
||||||
|
if (results == null) return;
|
||||||
|
|
||||||
|
foreach (TimedPosition waypoint in results)
|
||||||
|
{
|
||||||
|
route.Add(waypoint);
|
||||||
|
AddWaypointMarkerToMap(waypoint);
|
||||||
|
}
|
||||||
|
MapControl.RegenerateRouteShape();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region IGpsEmulatorService Members
|
||||||
|
|
||||||
|
public string GetCurrentPosition()
|
||||||
|
{
|
||||||
|
clientCallDetected = true;
|
||||||
|
return transmittedLocation;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
using GpsEmulator.Utilities;
|
||||||
|
|
||||||
|
namespace GpsEmulator.MapControl
|
||||||
|
{
|
||||||
|
public interface IMapTileFactory
|
||||||
|
{
|
||||||
|
MapTile GetTile(int zoom, int tileX, int tileY, MapType type);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,87 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Threading;
|
||||||
|
using GpsEmulator.Utilities;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
namespace GpsEmulator.MapControl
|
||||||
|
{
|
||||||
|
class InMemoryCacheMapTileFactory : IMapTileFactory
|
||||||
|
{
|
||||||
|
Dictionary<string, MapTile> cache;
|
||||||
|
Dictionary<string, long> cacheAccessCounter;
|
||||||
|
ReaderWriterLockSlim cacheLock = new ReaderWriterLockSlim();
|
||||||
|
IMapTileFactory innerFactory;
|
||||||
|
|
||||||
|
public InMemoryCacheMapTileFactory(IMapTileFactory innerFactory)
|
||||||
|
{
|
||||||
|
this.innerFactory = innerFactory;
|
||||||
|
cache = new Dictionary<string, MapTile>();
|
||||||
|
cacheAccessCounter = new Dictionary<string, long>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public MapTile GetTile(int zoom, int tileX, int tileY, MapType type)
|
||||||
|
{
|
||||||
|
string key = String.Format("{0},{1},{2},{3}", zoom, tileX, tileY, type);
|
||||||
|
cacheLock.EnterUpgradeableReadLock();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (cache.ContainsKey(key))
|
||||||
|
{
|
||||||
|
cacheAccessCounter[key] = DateTime.Now.Ticks;
|
||||||
|
return cache[key];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MapTile tile = innerFactory.GetTile(zoom, tileX, tileY, type);
|
||||||
|
cacheLock.EnterWriteLock();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (tile != null)
|
||||||
|
{
|
||||||
|
cache[key] = tile;
|
||||||
|
cacheAccessCounter[key] = DateTime.Now.Ticks;
|
||||||
|
}
|
||||||
|
return tile;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
cacheLock.ExitWriteLock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
cacheLock.ExitUpgradeableReadLock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Cleans the cache, keeping only the 1000 tiles that were accessed most recently.
|
||||||
|
/// </summary>
|
||||||
|
public void CleanupCache()
|
||||||
|
{
|
||||||
|
List<string> deletionList = new List<string>();
|
||||||
|
cacheLock.EnterWriteLock();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var tmp = from string key in cacheAccessCounter.Keys
|
||||||
|
orderby cacheAccessCounter[key] descending
|
||||||
|
select key;
|
||||||
|
var keys = tmp.ToArray();
|
||||||
|
if (keys.Length < 500) return;
|
||||||
|
|
||||||
|
for (int i = 500; i < keys.Length; i++)
|
||||||
|
{
|
||||||
|
cacheAccessCounter.Remove(keys[i]);
|
||||||
|
cache.Remove(keys[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
cacheLock.ExitWriteLock();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
<UserControl x:Class="GpsEmulator.MapControl.MapControl"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
mc:Ignorable="d"
|
||||||
|
d:DesignHeight="300" d:DesignWidth="300">
|
||||||
|
<Grid>
|
||||||
|
<Border BorderBrush="Blue" BorderThickness="1" ClipToBounds="True" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" >
|
||||||
|
<Canvas Name="MapLayer"/>
|
||||||
|
</Border>
|
||||||
|
<Border BorderBrush="Blue" BorderThickness="1" ClipToBounds="True" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" >
|
||||||
|
<Canvas Name="MarkerLayer"/>
|
||||||
|
</Border>
|
||||||
|
<TextBlock Name="tbMapInfo" Foreground="RoyalBlue" FontSize="40" HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||||
|
</Grid>
|
||||||
|
</UserControl>
|
||||||
@@ -0,0 +1,352 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
using System.Windows.Media;
|
||||||
|
using System.Windows.Media.Effects;
|
||||||
|
using System.Windows.Shapes;
|
||||||
|
using GpsEmulator.Utilities;
|
||||||
|
|
||||||
|
namespace GpsEmulator.MapControl
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Interaction logic for MapControl.xaml
|
||||||
|
/// </summary>
|
||||||
|
public partial class MapControl : UserControl
|
||||||
|
{
|
||||||
|
private List<List<MapTile>> tiles = new List<List<MapTile>>();
|
||||||
|
private TranslateTransform translateTransform = new TranslateTransform();
|
||||||
|
private MapMarker selectionMarker;
|
||||||
|
private List<MapMarker> Markers = new List<MapMarker>();
|
||||||
|
private Path routePath;
|
||||||
|
|
||||||
|
#region DependencyProperties
|
||||||
|
|
||||||
|
public static readonly DependencyProperty MapTypeProperty = DependencyProperty.Register("MapType", typeof(MapType), typeof(MapControl), new UIPropertyMetadata(MapType.Road, new PropertyChangedCallback(MapTypePropertyChanged)));
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// type of map
|
||||||
|
/// </summary>
|
||||||
|
[Category("MapControl")]
|
||||||
|
public MapType MapType
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return (MapType)(GetValue(MapTypeProperty));
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
SetValue(MapTypeProperty, value);
|
||||||
|
ResetView();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void MapTypePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||||
|
{
|
||||||
|
MapControl map = (MapControl)d;
|
||||||
|
if (map != null)
|
||||||
|
{
|
||||||
|
map.MapType = (MapType)e.NewValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region properties
|
||||||
|
private Point mapCenter;
|
||||||
|
public Point MapCenter
|
||||||
|
{
|
||||||
|
get { return mapCenter; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
mapCenter = value;
|
||||||
|
|
||||||
|
int centerXpixel, centerYpixel;
|
||||||
|
MapUtils.LatLongToPixelXY(mapCenter.X, mapCenter.Y, zoomLevel, out centerXpixel, out centerYpixel);
|
||||||
|
|
||||||
|
translateTransform.X = (this.ActualWidth / 2)- centerXpixel;
|
||||||
|
translateTransform.Y = (this.ActualHeight / 2) -centerYpixel;
|
||||||
|
InvalidateVisual();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private int zoomLevel = 10;
|
||||||
|
public int ZoomLevel
|
||||||
|
{
|
||||||
|
get { return zoomLevel; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (value < 1 || value > 21) return;
|
||||||
|
if (zoomLevel != value)
|
||||||
|
{
|
||||||
|
zoomLevel = value;
|
||||||
|
ResetView();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
IMapTileFactory mapTileFactory;
|
||||||
|
public IMapTileFactory MapTileFactory
|
||||||
|
{
|
||||||
|
get { return mapTileFactory; }
|
||||||
|
set { mapTileFactory = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public Brush PathColor = Brushes.Red;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
public MapControl() : this(47.65, -122.24)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public MapControl(double lat, double lng)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
MapLayer.RenderTransformOrigin = new Point(0.5, 0.5);
|
||||||
|
MapLayer.RenderTransform = translateTransform;
|
||||||
|
MarkerLayer.RenderTransformOrigin = new Point(0.5, 0.5);
|
||||||
|
MarkerLayer.RenderTransform = translateTransform;
|
||||||
|
MapCenter = new Point(lat, lng);
|
||||||
|
MapLayer.SetValue(Canvas.ZIndexProperty, 100);
|
||||||
|
MarkerLayer.SetValue(Canvas.ZIndexProperty, 200);
|
||||||
|
selectionMarker = AddMarker(new Markers.SelectionMarker(),lat, lng);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Moves the center by the specified amount of pixels
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="dX">Pixels to move horizontally</param>
|
||||||
|
/// <param name="dY">Pixels to move vertically</param>
|
||||||
|
public void MoveCenter(double dX, double dY)
|
||||||
|
{
|
||||||
|
Point transformPoint = translateTransform.Inverse.Transform(new System.Windows.Point(dX, dY));
|
||||||
|
int centerXpixel, centerYpixel;
|
||||||
|
centerXpixel = (int)(transformPoint.X + ActualWidth / 2 + dX);
|
||||||
|
centerYpixel = (int)(transformPoint.Y + ActualHeight / 2 + dY);
|
||||||
|
double lat, lng;
|
||||||
|
MapUtils.PixelXYToLatLong(centerXpixel, centerYpixel, zoomLevel, out lat, out lng);
|
||||||
|
MapCenter = new Point(lat, lng);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Point LatLongFromLocal(double imageX, double imageY)
|
||||||
|
{
|
||||||
|
Point localPoint = translateTransform.Inverse.Transform(new System.Windows.Point(imageX, imageY));
|
||||||
|
double lat, lng;
|
||||||
|
MapUtils.PixelXYToLatLong((int)(localPoint.X), (int)(localPoint.Y), zoomLevel, out lat, out lng);
|
||||||
|
return new Point(lat, lng);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Markers
|
||||||
|
public MapMarker AddMarker(UserControl marker, double lat, double lng)
|
||||||
|
{
|
||||||
|
if (!MapLayer.Children.Contains(marker))
|
||||||
|
{
|
||||||
|
MapMarker m = new MapMarker(new Point(lat, lng), marker);
|
||||||
|
m.SetVisualLocation(zoomLevel);
|
||||||
|
Markers.Add(m);
|
||||||
|
MarkerLayer.Children.Add(marker);
|
||||||
|
return m;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool RemoveMarker(MapMarker marker)
|
||||||
|
{
|
||||||
|
if (!MapLayer.Children.Contains(marker.MarkerControl))
|
||||||
|
{
|
||||||
|
foreach (MapMarker mapMarker in Markers)
|
||||||
|
{
|
||||||
|
if (mapMarker == marker)
|
||||||
|
{
|
||||||
|
Markers.Remove(mapMarker);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
MarkerLayer.Children.Remove(marker.MarkerControl);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MapMarker ReplaceMarker(MapMarker oldMarker, UserControl newMarker, double lat, double lng)
|
||||||
|
{
|
||||||
|
MapMarker m = new MapMarker(new Point(lat, lng), newMarker);
|
||||||
|
m.SetVisualLocation(zoomLevel);
|
||||||
|
int i = 0;
|
||||||
|
for (; i<Markers.Count; i++)
|
||||||
|
{
|
||||||
|
if (Markers[i] == oldMarker)
|
||||||
|
{
|
||||||
|
Markers[i]=m;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (i==Markers.Count) return null;
|
||||||
|
|
||||||
|
for (i = 0; i < MarkerLayer.Children.Count; i++)
|
||||||
|
{
|
||||||
|
if (MarkerLayer.Children[i] == oldMarker.MarkerControl)
|
||||||
|
{
|
||||||
|
MarkerLayer.Children.RemoveAt(i);
|
||||||
|
MarkerLayer.Children.Insert(i, newMarker);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return m;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void RemoveAllMarkers()
|
||||||
|
{
|
||||||
|
Markers.Clear();
|
||||||
|
MarkerLayer.Children.Clear();
|
||||||
|
Markers.Add(selectionMarker);
|
||||||
|
MarkerLayer.Children.Add(selectionMarker.MarkerControl);
|
||||||
|
RegenerateRouteShape();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetSelectedPoint(double lat, double lng)
|
||||||
|
{
|
||||||
|
if (selectionMarker == null)
|
||||||
|
{
|
||||||
|
selectionMarker = AddMarker(new Markers.SelectionMarker(), lat, lng);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
selectionMarker.Location = new Point(lat, lng);
|
||||||
|
selectionMarker.SetVisualLocation(zoomLevel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RegenerateRouteShape()
|
||||||
|
{
|
||||||
|
const int MAX_DISTANCE_BEFORE_DISTORTION = 5000; // 5km
|
||||||
|
var visualPath = new List<System.Windows.Point>();
|
||||||
|
Point? previousPoint = null;
|
||||||
|
int x, y;
|
||||||
|
|
||||||
|
// TODO (Shy, 9/14/2010): Need to make sure that the markers are sorted according to time. This means that I'll have to store the time there, or switch to TimedPosition.
|
||||||
|
foreach (var marker in Markers)
|
||||||
|
{
|
||||||
|
if (!(marker.MarkerControl is Markers.WaypointMarker)) continue;
|
||||||
|
|
||||||
|
int lengthInSegments = 0;
|
||||||
|
if (previousPoint.HasValue)
|
||||||
|
{
|
||||||
|
double distanceInMeters = MapUtils.GetDistance(marker.Location, previousPoint.Value);
|
||||||
|
lengthInSegments = (int)(distanceInMeters / MAX_DISTANCE_BEFORE_DISTORTION);
|
||||||
|
if (lengthInSegments > 0)
|
||||||
|
{
|
||||||
|
double dX = (marker.Location.X - previousPoint.Value.X) / (lengthInSegments + 1);
|
||||||
|
double dY = (marker.Location.Y - previousPoint.Value.Y) / (lengthInSegments + 1);
|
||||||
|
double currX = previousPoint.Value.X;
|
||||||
|
double currY = previousPoint.Value.Y;
|
||||||
|
Point currentPoint = previousPoint.Value;
|
||||||
|
for (int i = 0; i < lengthInSegments; i++)
|
||||||
|
{
|
||||||
|
currX += dX;
|
||||||
|
currY += dY;
|
||||||
|
MapUtils.LatLongToPixelXY(currX, currY, zoomLevel, out x, out y);
|
||||||
|
visualPath.Add(new System.Windows.Point(x, y));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
MapUtils.LatLongToPixelXY(marker.Location.X, marker.Location.Y, zoomLevel, out x, out y);
|
||||||
|
visualPath.Add(new Point(x, y));
|
||||||
|
|
||||||
|
previousPoint = marker.Location;
|
||||||
|
}
|
||||||
|
|
||||||
|
MarkerLayer.Children.Remove(routePath);
|
||||||
|
if (visualPath.Count < 2) return;
|
||||||
|
|
||||||
|
// Create a StreamGeometry to use to specify myPath.
|
||||||
|
StreamGeometry geometry = new StreamGeometry();
|
||||||
|
|
||||||
|
using (StreamGeometryContext ctx = geometry.Open())
|
||||||
|
{
|
||||||
|
ctx.BeginFigure(visualPath[0], false, false);
|
||||||
|
ctx.PolyLineTo(visualPath, true, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Freeze the geometry for performance reasons
|
||||||
|
geometry.Freeze();
|
||||||
|
|
||||||
|
routePath = new Path()
|
||||||
|
{
|
||||||
|
Data = geometry,
|
||||||
|
Effect = new BlurEffect()
|
||||||
|
{
|
||||||
|
KernelType = KernelType.Gaussian,
|
||||||
|
Radius = 2.0,
|
||||||
|
RenderingBias = RenderingBias.Quality
|
||||||
|
},
|
||||||
|
Stroke = PathColor,
|
||||||
|
StrokeThickness = 3,
|
||||||
|
StrokeLineJoin = PenLineJoin.Round,
|
||||||
|
StrokeStartLineCap = PenLineCap.Round,
|
||||||
|
StrokeEndLineCap = PenLineCap.Round,
|
||||||
|
Opacity = 0.6,
|
||||||
|
IsHitTestVisible = false,
|
||||||
|
};
|
||||||
|
MarkerLayer.Children.Add(routePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
protected override void OnRender(DrawingContext drawingContext)
|
||||||
|
{
|
||||||
|
if (System.ComponentModel.DesignerProperties.GetIsInDesignMode(this))
|
||||||
|
{
|
||||||
|
tbMapInfo.Text = "Bing Maps Control";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mapTileFactory == null) throw new Exception("MapControl cannot render without a map tile factory");
|
||||||
|
|
||||||
|
int centerTileX, centerTileY;
|
||||||
|
MapUtils.LatLongToPixelXY(mapCenter.X, mapCenter.Y, zoomLevel, out centerTileX, out centerTileY);
|
||||||
|
centerTileX /= 256;
|
||||||
|
centerTileY /= 256;
|
||||||
|
int widthInTiles = (int)(ActualWidth / 256) +1;
|
||||||
|
int heightInTiles = (int)(ActualHeight / 256) +1 ;
|
||||||
|
int minHorizontalTile = (int) MapUtils.Clip(centerTileX - widthInTiles, 0, MapUtils.MapSize(zoomLevel)/256);
|
||||||
|
int maxHorizontalTile = (int)MapUtils.Clip(centerTileX + widthInTiles, 0, MapUtils.MapSize(zoomLevel) / 256);
|
||||||
|
int minVerticalTile = (int)MapUtils.Clip(centerTileY - heightInTiles, 0, MapUtils.MapSize(zoomLevel) / 256);
|
||||||
|
int maxVerticalTile = (int)MapUtils.Clip(centerTileY + heightInTiles, 0, MapUtils.MapSize(zoomLevel) / 256);
|
||||||
|
|
||||||
|
// TODO (Shy, 9/14/2010): Cancel previous tile requests (on the tile factory) to make zooming go faster (i.e. stop getting tiles for a view that we're not going to present)
|
||||||
|
MapLayer.Children.Clear();
|
||||||
|
for (int x = minHorizontalTile; x <= maxHorizontalTile; x++)
|
||||||
|
{
|
||||||
|
for (int y = minVerticalTile; y <= maxVerticalTile; y++)
|
||||||
|
{
|
||||||
|
MapTile tile = mapTileFactory.GetTile(zoomLevel, x, y, MapType);
|
||||||
|
|
||||||
|
if (!MapLayer.Children.Contains(tile))
|
||||||
|
{
|
||||||
|
// Position tile in the map area
|
||||||
|
tile.Margin = new Thickness(x * 256, y * 256, 0, 0);
|
||||||
|
MapLayer.Children.Add(tile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ResetView()
|
||||||
|
{
|
||||||
|
MapLayer.Children.Clear();
|
||||||
|
MapCenter = mapCenter;
|
||||||
|
MarkerLayer.Children.Clear();
|
||||||
|
foreach (MapMarker marker in Markers)
|
||||||
|
{
|
||||||
|
marker.SetVisualLocation(zoomLevel);
|
||||||
|
MarkerLayer.Children.Add(marker.MarkerControl);
|
||||||
|
}
|
||||||
|
RegenerateRouteShape();
|
||||||
|
InvalidateVisual();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
using GpsEmulator.Utilities;
|
||||||
|
|
||||||
|
namespace GpsEmulator.MapControl
|
||||||
|
{
|
||||||
|
public class MapMarker
|
||||||
|
{
|
||||||
|
public Point Location;
|
||||||
|
public UserControl MarkerControl;
|
||||||
|
|
||||||
|
public MapMarker(Point location, UserControl markerControl)
|
||||||
|
{
|
||||||
|
Location = location;
|
||||||
|
MarkerControl = markerControl;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetVisualLocation(int zoomLevel)
|
||||||
|
{
|
||||||
|
int x, y;
|
||||||
|
MapUtils.LatLongToPixelXY(Location.X, Location.Y, zoomLevel, out x, out y);
|
||||||
|
MarkerControl.Margin = new Thickness(x-MarkerControl.Width/2, y-MarkerControl.Height/2, 0, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
<UserControl x:Class="GpsEmulator.MapControl.MapTile"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
mc:Ignorable="d">
|
||||||
|
<Grid Height="256" Width="256">
|
||||||
|
<TextBlock Name="tbDescription" HorizontalAlignment="Center" VerticalAlignment="Center" Text="Loading Image..." Foreground="Gray" FontSize="24" />
|
||||||
|
<Image Name="imgTileImage" Stretch="None" RenderOptions.EdgeMode="Aliased" />
|
||||||
|
</Grid>
|
||||||
|
</UserControl>
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
using System;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
using System.Windows.Media.Imaging;
|
||||||
|
using System.Windows.Threading;
|
||||||
|
|
||||||
|
namespace GpsEmulator.MapControl
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Interaction logic for MapTile.xaml
|
||||||
|
/// </summary>
|
||||||
|
public partial class MapTile : UserControl
|
||||||
|
{
|
||||||
|
public BitmapImage Image;
|
||||||
|
|
||||||
|
public MapTile()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetImage(BitmapImage image)
|
||||||
|
{
|
||||||
|
this.Dispatcher.BeginInvoke(new Action(() =>
|
||||||
|
{
|
||||||
|
imgTileImage.Source = image;
|
||||||
|
}), DispatcherPriority.Render);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetDescription(string description)
|
||||||
|
{
|
||||||
|
this.Dispatcher.BeginInvoke(new Action(() =>
|
||||||
|
{
|
||||||
|
tbDescription.Text = description;
|
||||||
|
}), DispatcherPriority.Render);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
using System;
|
||||||
|
using System.Windows.Media.Imaging;
|
||||||
|
using GpsEmulator.BingApis;
|
||||||
|
using GpsEmulator.Utilities;
|
||||||
|
|
||||||
|
namespace GpsEmulator.MapControl
|
||||||
|
{
|
||||||
|
public class WebMapTileFactory : IMapTileFactory
|
||||||
|
{
|
||||||
|
BingMapsClient bingMapsClient;
|
||||||
|
|
||||||
|
public WebMapTileFactory(BingMapsClient bingMapsClient)
|
||||||
|
{
|
||||||
|
this.bingMapsClient = bingMapsClient;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MapTile GetTile(int zoom, int tileX, int tileY, MapType type)
|
||||||
|
{
|
||||||
|
MapTile tile = new MapTile();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
BitmapImage img = bingMapsClient.GetTile(zoom, tileX, tileY, type);
|
||||||
|
img.Changed += ((a, b) => { tile.SetImage(img); });
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
tile.SetDescription(ex.Message);
|
||||||
|
}
|
||||||
|
return tile;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
After Width: | Height: | Size: 698 B |
@@ -0,0 +1,9 @@
|
|||||||
|
<UserControl x:Class="GpsEmulator.Markers.DirectionalMarker"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
mc:Ignorable="d" Opacity="10"
|
||||||
|
Height="20" Width="20">
|
||||||
|
<Image Name="icon" Source="DirectionalMarker.png" VerticalAlignment="Center" HorizontalAlignment="Center" />
|
||||||
|
</UserControl>
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
using System;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
using System.Windows.Media;
|
||||||
|
|
||||||
|
namespace GpsEmulator.Markers
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Interaction logic for PositionMarker.xaml
|
||||||
|
/// </summary>
|
||||||
|
public partial class DirectionalMarker : UserControl
|
||||||
|
{
|
||||||
|
RotateTransform rotateTransform = new RotateTransform(0);
|
||||||
|
|
||||||
|
public DirectionalMarker()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
this.RenderTransformOrigin = new Point(0.5, 0.5);
|
||||||
|
this.RenderTransform = rotateTransform;
|
||||||
|
SetValue(Canvas.ZIndexProperty, 300);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetHeading(double x, double y)
|
||||||
|
{
|
||||||
|
rotateTransform.Angle = Math.Atan2(y,x) * 180 / Math.PI ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
using System.Windows.Media;
|
||||||
|
using System.Windows.Media.Effects;
|
||||||
|
using System.Windows.Shapes;
|
||||||
|
using GpsEmulator.Utilities;
|
||||||
|
|
||||||
|
namespace GpsEmulator.Markers
|
||||||
|
{
|
||||||
|
public class RouteMarker : UserControl
|
||||||
|
{
|
||||||
|
GpsEmulator.MapControl.MapControl mapControl;
|
||||||
|
|
||||||
|
public RouteMarker(GpsEmulator.MapControl.MapControl mapControl)
|
||||||
|
{
|
||||||
|
this.mapControl = mapControl;
|
||||||
|
this.Width = 1;
|
||||||
|
this.Height = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
After Width: | Height: | Size: 3.2 KiB |
@@ -0,0 +1,9 @@
|
|||||||
|
<UserControl x:Class="GpsEmulator.Markers.SelectionMarker"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
mc:Ignorable="d" Opacity="10"
|
||||||
|
Height="40" Width="40">
|
||||||
|
<Image Name="icon" Source="SelectionMarker.png" VerticalAlignment="Center" HorizontalAlignment="Center" />
|
||||||
|
</UserControl>
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
using System.Windows.Controls;
|
||||||
|
|
||||||
|
namespace GpsEmulator.Markers
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Interaction logic for PositionMarker.xaml
|
||||||
|
/// </summary>
|
||||||
|
public partial class SelectionMarker : UserControl
|
||||||
|
{
|
||||||
|
public SelectionMarker()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
SetValue(Canvas.ZIndexProperty, 300);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
After Width: | Height: | Size: 980 B |
@@ -0,0 +1,9 @@
|
|||||||
|
<UserControl x:Class="GpsEmulator.Markers.WaypointMarker"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
mc:Ignorable="d" Opacity="10"
|
||||||
|
Height="20" Width="20">
|
||||||
|
<Image Name="icon" Source="WaypointMarker.png" VerticalAlignment="Center" HorizontalAlignment="Center" />
|
||||||
|
</UserControl>
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
using System.Windows.Controls.Primitives;
|
||||||
|
using System.Windows.Input;
|
||||||
|
using System.Windows.Media;
|
||||||
|
using GpsEmulator.Utilities;
|
||||||
|
|
||||||
|
namespace GpsEmulator.Markers
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Interaction logic for WaypointMarker.xaml
|
||||||
|
/// </summary>
|
||||||
|
public partial class WaypointMarker : UserControl
|
||||||
|
{
|
||||||
|
Popup Popup;
|
||||||
|
Label Label;
|
||||||
|
MainWindow MainWindow;
|
||||||
|
|
||||||
|
public WaypointMarker(MainWindow window, string title)
|
||||||
|
{
|
||||||
|
this.InitializeComponent();
|
||||||
|
|
||||||
|
this.MainWindow = window;
|
||||||
|
|
||||||
|
Popup = new Popup();
|
||||||
|
Popup.SetValue(Canvas.ZIndexProperty, 900);
|
||||||
|
Label = new Label();
|
||||||
|
|
||||||
|
this.Loaded += new RoutedEventHandler(WaypointMarker_Loaded);
|
||||||
|
this.MouseEnter += new MouseEventHandler(WaypointMarker_MouseEnter);
|
||||||
|
this.MouseLeave += new MouseEventHandler(WaypointMarker_MouseLeave);
|
||||||
|
|
||||||
|
Popup.Placement = PlacementMode.Mouse;
|
||||||
|
Label.Background = Brushes.Blue;
|
||||||
|
Label.Foreground = Brushes.White;
|
||||||
|
Label.BorderBrush = Brushes.WhiteSmoke;
|
||||||
|
Label.BorderThickness = new Thickness(1);
|
||||||
|
Label.Padding = new Thickness(5);
|
||||||
|
Label.FontSize = 14;
|
||||||
|
Label.Content = title;
|
||||||
|
Popup.Child = Label;
|
||||||
|
}
|
||||||
|
|
||||||
|
void WaypointMarker_Loaded(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
if (icon.Source.CanFreeze)
|
||||||
|
{
|
||||||
|
icon.Source.Freeze();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void WaypointMarker_MouseLeave(object sender, MouseEventArgs e)
|
||||||
|
{
|
||||||
|
Popup.SetValue(Canvas.ZIndexProperty, 900);
|
||||||
|
Popup.IsOpen = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void WaypointMarker_MouseEnter(object sender, MouseEventArgs e)
|
||||||
|
{
|
||||||
|
Popup.SetValue(Canvas.ZIndexProperty, 9000);
|
||||||
|
Popup.IsOpen = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
using System.Reflection;
|
||||||
|
using System.Resources;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Windows;
|
||||||
|
|
||||||
|
// General Information about an assembly is controlled through the following
|
||||||
|
// set of attributes. Change these attribute values to modify the information
|
||||||
|
// associated with an assembly.
|
||||||
|
[assembly: AssemblyTitle("GpsEmulator")]
|
||||||
|
[assembly: AssemblyDescription("Windows Phone 7 Series Device Emulator")]
|
||||||
|
[assembly: AssemblyConfiguration("")]
|
||||||
|
[assembly: AssemblyCompany("Microsoft Corp.")]
|
||||||
|
[assembly: AssemblyProduct("GpsEmulator")]
|
||||||
|
[assembly: AssemblyCopyright("Copyright © Microsoft 2010")]
|
||||||
|
[assembly: AssemblyTrademark("")]
|
||||||
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
|
// Setting ComVisible to false makes the types in this assembly not visible
|
||||||
|
// to COM components. If you need to access a type in this assembly from
|
||||||
|
// COM, set the ComVisible attribute to true on that type.
|
||||||
|
[assembly: ComVisible(false)]
|
||||||
|
|
||||||
|
//In order to begin building localizable applications, set
|
||||||
|
//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file
|
||||||
|
//inside a <PropertyGroup>. For example, if you are using US english
|
||||||
|
//in your source files, set the <UICulture> to en-US. Then uncomment
|
||||||
|
//the NeutralResourceLanguage attribute below. Update the "en-US" in
|
||||||
|
//the line below to match the UICulture setting in the project file.
|
||||||
|
|
||||||
|
//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
|
||||||
|
|
||||||
|
|
||||||
|
[assembly: ThemeInfo(
|
||||||
|
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
|
||||||
|
//(used if a resource is not found in the page,
|
||||||
|
// or application resource dictionaries)
|
||||||
|
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
|
||||||
|
//(used if a resource is not found in the page,
|
||||||
|
// app, or any theme specific resource dictionaries)
|
||||||
|
)]
|
||||||
|
|
||||||
|
|
||||||
|
// Version information for an assembly consists of the following four values:
|
||||||
|
//
|
||||||
|
// Major Version
|
||||||
|
// Minor Version
|
||||||
|
// Build Number
|
||||||
|
// Revision
|
||||||
|
//
|
||||||
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||||
|
// by using the '*' as shown below:
|
||||||
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
|
[assembly: AssemblyVersion("1.0.0.0")]
|
||||||
|
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||||
@@ -0,0 +1,71 @@
|
|||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// <auto-generated>
|
||||||
|
// This code was generated by a tool.
|
||||||
|
// Runtime Version:4.0.30319.1
|
||||||
|
//
|
||||||
|
// Changes to this file may cause incorrect behavior and will be lost if
|
||||||
|
// the code is regenerated.
|
||||||
|
// </auto-generated>
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace GpsEmulator.Properties
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||||
|
/// </summary>
|
||||||
|
// This class was auto-generated by the StronglyTypedResourceBuilder
|
||||||
|
// class via a tool like ResGen or Visual Studio.
|
||||||
|
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||||
|
// with the /str option, or rebuild your VS project.
|
||||||
|
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
||||||
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||||
|
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||||
|
internal class Resources
|
||||||
|
{
|
||||||
|
|
||||||
|
private static global::System.Resources.ResourceManager resourceMan;
|
||||||
|
|
||||||
|
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||||
|
|
||||||
|
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||||
|
internal Resources()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the cached ResourceManager instance used by this class.
|
||||||
|
/// </summary>
|
||||||
|
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||||
|
internal static global::System.Resources.ResourceManager ResourceManager
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if ((resourceMan == null))
|
||||||
|
{
|
||||||
|
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("GpsEmulator.Properties.Resources", typeof(Resources).Assembly);
|
||||||
|
resourceMan = temp;
|
||||||
|
}
|
||||||
|
return resourceMan;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Overrides the current thread's CurrentUICulture property for all
|
||||||
|
/// resource lookups using this strongly typed resource class.
|
||||||
|
/// </summary>
|
||||||
|
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||||
|
internal static global::System.Globalization.CultureInfo Culture
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return resourceCulture;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
resourceCulture = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,117 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// <auto-generated>
|
||||||
|
// This code was generated by a tool.
|
||||||
|
// Runtime Version:4.0.30319.1
|
||||||
|
//
|
||||||
|
// Changes to this file may cause incorrect behavior and will be lost if
|
||||||
|
// the code is regenerated.
|
||||||
|
// </auto-generated>
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace GpsEmulator.Properties
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||||
|
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")]
|
||||||
|
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
|
||||||
|
{
|
||||||
|
|
||||||
|
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||||
|
|
||||||
|
public static Settings Default
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return defaultInstance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
<?xml version='1.0' encoding='utf-8'?>
|
||||||
|
<SettingsFile xmlns="uri:settings" CurrentProfile="(Default)">
|
||||||
|
<Profiles>
|
||||||
|
<Profile Name="(Default)" />
|
||||||
|
</Profiles>
|
||||||
|
<Settings />
|
||||||
|
</SettingsFile>
|
||||||
|
After Width: | Height: | Size: 27 KiB |
|
After Width: | Height: | Size: 20 KiB |
|
After Width: | Height: | Size: 82 KiB |
|
After Width: | Height: | Size: 1.1 KiB |
|
After Width: | Height: | Size: 26 KiB |
|
After Width: | Height: | Size: 97 KiB |
|
After Width: | Height: | Size: 122 KiB |
|
After Width: | Height: | Size: 2.5 KiB |
|
After Width: | Height: | Size: 113 KiB |
|
After Width: | Height: | Size: 40 KiB |
|
After Width: | Height: | Size: 112 KiB |
|
After Width: | Height: | Size: 766 B |
|
After Width: | Height: | Size: 757 B |
@@ -0,0 +1,32 @@
|
|||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
namespace GpsEmulator.Utilities
|
||||||
|
{
|
||||||
|
public class InternetConnectivityChecker
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
[Flags]
|
||||||
|
enum InternetConnectionState : int
|
||||||
|
{
|
||||||
|
INTERNET_CONNECTION_MODEM = 0x1,
|
||||||
|
INTERNET_CONNECTION_LAN = 0x2,
|
||||||
|
INTERNET_CONNECTION_PROXY = 0x4,
|
||||||
|
INTERNET_RAS_INSTALLED = 0x10,
|
||||||
|
INTERNET_CONNECTION_OFFLINE = 0x20,
|
||||||
|
INTERNET_CONNECTION_CONFIGURED = 0x40
|
||||||
|
};
|
||||||
|
*/
|
||||||
|
|
||||||
|
//Creating the extern function…
|
||||||
|
[DllImport("wininet.dll")]
|
||||||
|
private extern static bool InternetGetConnectedState(out int Description, int ReservedValue);
|
||||||
|
|
||||||
|
//Creating a function that uses the API function…
|
||||||
|
public static bool IsConnectedToInternet()
|
||||||
|
{
|
||||||
|
int Desc;
|
||||||
|
return InternetGetConnectedState(out Desc, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
namespace GpsEmulator.Utilities
|
||||||
|
{
|
||||||
|
public enum MapType
|
||||||
|
{
|
||||||
|
Road = 1,
|
||||||
|
Aerial = 2,
|
||||||
|
Hybrid = 3
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,143 @@
|
|||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// Code source adopted from: http://msdn.microsoft.com/en-us/library/bb259689.aspx
|
||||||
|
//
|
||||||
|
// <copyright company="Microsoft">
|
||||||
|
// Copyright (c) 2006-2009 Microsoft Corporation. All rights reserved.
|
||||||
|
// </copyright>
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Text;
|
||||||
|
using System.Windows;
|
||||||
|
|
||||||
|
namespace GpsEmulator.Utilities
|
||||||
|
{
|
||||||
|
static class MapUtils
|
||||||
|
{
|
||||||
|
private const double EarthRadius = 6378137;
|
||||||
|
private const double MinLatitude = -85.05112878;
|
||||||
|
private const double MaxLatitude = 85.05112878;
|
||||||
|
private const double MinLongitude = -180;
|
||||||
|
private const double MaxLongitude = 180;
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clips a number to the specified minimum and maximum values.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="n">The number to clip.</param>
|
||||||
|
/// <param name="minValue">Minimum allowable value.</param>
|
||||||
|
/// <param name="maxValue">Maximum allowable value.</param>
|
||||||
|
/// <returns>The clipped value.</returns>
|
||||||
|
public static double Clip(double n, double minValue, double maxValue)
|
||||||
|
{
|
||||||
|
return Math.Min(Math.Max(n, minValue), maxValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Determines the map width and height (in pixels) at a specified level
|
||||||
|
/// of detail.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="levelOfDetail">Level of detail, from 1 (lowest detail)
|
||||||
|
/// to 23 (highest detail).</param>
|
||||||
|
/// <returns>The map width and height in pixels.</returns>
|
||||||
|
public static uint MapSize(int levelOfDetail)
|
||||||
|
{
|
||||||
|
return (uint) 256 << levelOfDetail;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the distance (in meters) between two points using the
|
||||||
|
/// Haversine formula.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="point1"></param>
|
||||||
|
/// <param name="point2"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static double GetDistance(Point point1, Point point2)
|
||||||
|
{
|
||||||
|
double dLat1InRad = point1.X * (Math.PI / 180);
|
||||||
|
double dLong1InRad = point1.Y * (Math.PI / 180);
|
||||||
|
double dLat2InRad = point2.X * (Math.PI / 180);
|
||||||
|
double dLong2InRad = point2.Y * (Math.PI / 180);
|
||||||
|
double dLongitude = dLong2InRad - dLong1InRad;
|
||||||
|
double dLatitude = dLat2InRad - dLat1InRad;
|
||||||
|
double a = Math.Pow(Math.Sin(dLatitude / 2), 2) + Math.Cos(dLat1InRad) * Math.Cos(dLat2InRad) * Math.Pow(Math.Sin(dLongitude / 2), 2);
|
||||||
|
double c = 2 * Math.Atan2(Math.Sqrt(a), Math.Sqrt(1 - a));
|
||||||
|
double dDistance = EarthRadius * c;
|
||||||
|
return dDistance;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Converts a point from latitude/longitude WGS-84 coordinates (in degrees)
|
||||||
|
/// into pixel XY coordinates at a specified level of detail.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="latitude">Latitude of the point, in degrees.</param>
|
||||||
|
/// <param name="longitude">Longitude of the point, in degrees.</param>
|
||||||
|
/// <param name="levelOfDetail">Level of detail, from 1 (lowest detail)
|
||||||
|
/// to 23 (highest detail).</param>
|
||||||
|
/// <param name="pixelX">Output parameter receiving the X coordinate in pixels.</param>
|
||||||
|
/// <param name="pixelY">Output parameter receiving the Y coordinate in pixels.</param>
|
||||||
|
public static void LatLongToPixelXY(double latitude, double longitude, int levelOfDetail, out int pixelX, out int pixelY)
|
||||||
|
{
|
||||||
|
latitude = Clip(latitude, MinLatitude, MaxLatitude);
|
||||||
|
longitude = Clip(longitude, MinLongitude, MaxLongitude);
|
||||||
|
|
||||||
|
double x = (longitude + 180) / 360;
|
||||||
|
double sinLatitude = Math.Sin(latitude * Math.PI / 180);
|
||||||
|
double y = 0.5 - Math.Log((1 + sinLatitude) / (1 - sinLatitude)) / (4 * Math.PI);
|
||||||
|
|
||||||
|
uint mapSize = MapSize(levelOfDetail);
|
||||||
|
pixelX = (int) Clip(x * mapSize + 0.5, 0, mapSize - 1);
|
||||||
|
pixelY = (int) Clip(y * mapSize + 0.5, 0, mapSize - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Converts a pixel from pixel XY coordinates at a specified level of detail
|
||||||
|
/// into latitude/longitude WGS-84 coordinates (in degrees).
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="pixelX">X coordinate of the point, in pixels.</param>
|
||||||
|
/// <param name="pixelY">Y coordinates of the point, in pixels.</param>
|
||||||
|
/// <param name="levelOfDetail">Level of detail, from 1 (lowest detail)
|
||||||
|
/// to 23 (highest detail).</param>
|
||||||
|
/// <param name="latitude">Output parameter receiving the latitude in degrees.</param>
|
||||||
|
/// <param name="longitude">Output parameter receiving the longitude in degrees.</param>
|
||||||
|
public static void PixelXYToLatLong(int pixelX, int pixelY, int levelOfDetail, out double latitude, out double longitude)
|
||||||
|
{
|
||||||
|
double mapSize = MapSize(levelOfDetail);
|
||||||
|
double x = (Clip(pixelX, 0, mapSize - 1) / mapSize) - 0.5;
|
||||||
|
double y = 0.5 - (Clip(pixelY, 0, mapSize - 1) / mapSize);
|
||||||
|
|
||||||
|
latitude = 90 - 360 * Math.Atan(Math.Exp(-y * 2 * Math.PI)) / Math.PI;
|
||||||
|
longitude = 360 * x;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Converts tile XY coordinates into a QuadKey at a specified level of detail.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="tileX">Tile X coordinate.</param>
|
||||||
|
/// <param name="tileY">Tile Y coordinate.</param>
|
||||||
|
/// <param name="levelOfDetail">Level of detail, from 1 (lowest detail)
|
||||||
|
/// to 23 (highest detail).</param>
|
||||||
|
/// <returns>A string containing the QuadKey.</returns>
|
||||||
|
public static string TileXYToQuadKey(int tileX, int tileY, int levelOfDetail)
|
||||||
|
{
|
||||||
|
StringBuilder quadKey = new StringBuilder();
|
||||||
|
for (int i = levelOfDetail; i > 0; i--)
|
||||||
|
{
|
||||||
|
char digit = '0';
|
||||||
|
int mask = 1 << (i - 1);
|
||||||
|
if ((tileX & mask) != 0)
|
||||||
|
{
|
||||||
|
digit++;
|
||||||
|
}
|
||||||
|
if ((tileY & mask) != 0)
|
||||||
|
{
|
||||||
|
digit++;
|
||||||
|
digit++;
|
||||||
|
}
|
||||||
|
quadKey.Append(digit);
|
||||||
|
}
|
||||||
|
return quadKey.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,277 @@
|
|||||||
|
using System;
|
||||||
|
using System.Net;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
using System.Windows.Documents;
|
||||||
|
using System.Windows.Ink;
|
||||||
|
using System.Windows.Input;
|
||||||
|
using System.Windows.Media;
|
||||||
|
using System.Windows.Media.Animation;
|
||||||
|
using System.Windows.Shapes;
|
||||||
|
using System.ServiceModel;
|
||||||
|
using System.Device.Location;
|
||||||
|
using System.Security;
|
||||||
|
using System.Threading;
|
||||||
|
using GpsEmulatorClient.ServiceReference1;
|
||||||
|
using System.Net.Browser;
|
||||||
|
|
||||||
|
namespace GpsEmulatorClient
|
||||||
|
{
|
||||||
|
public class GeoCoordinateWatcher : IGeoPositionWatcher<GeoCoordinate>
|
||||||
|
{
|
||||||
|
GpsEmulatorServiceClient client;
|
||||||
|
GeoPosition<GeoCoordinate> currentLocation;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Instantiates a new instance of the GeoCoordinateWatcher
|
||||||
|
/// class with the DesiredAccuracy value of System.Device.Location.GeoPositionAccuracy.Default.
|
||||||
|
/// </summary>
|
||||||
|
public GeoCoordinateWatcher() : this(GeoPositionAccuracy.Default)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Instantiates a new instance of the GeoCoordinateWatcher class with the provided
|
||||||
|
/// System.Device.Location.GeoCoordinateWatcher.DesiredAccuracy value.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="desiredAccuracy">
|
||||||
|
/// A member of the System.Device.Location.GeoPositionAccuracy enumeration specifying
|
||||||
|
/// the DesiredAccuracy value for the GpsEmulatorClient.GeoCoordinateWatcher.
|
||||||
|
/// </param>
|
||||||
|
public GeoCoordinateWatcher(GeoPositionAccuracy desiredAccuracy)
|
||||||
|
{
|
||||||
|
this.desiredAccuracy = desiredAccuracy;
|
||||||
|
}
|
||||||
|
|
||||||
|
GeoPositionAccuracy desiredAccuracy;
|
||||||
|
/// <summary>
|
||||||
|
/// The desired accuracy for data returned from the location service.
|
||||||
|
/// </summary>
|
||||||
|
public GeoPositionAccuracy DesiredAccuracy
|
||||||
|
{
|
||||||
|
get { return desiredAccuracy; }
|
||||||
|
}
|
||||||
|
|
||||||
|
double momementThreshold = 1;
|
||||||
|
/// <summary>
|
||||||
|
/// The minimum distance that must be travelled between successive PositionChanged events.
|
||||||
|
/// </summary>
|
||||||
|
public double MovementThreshold
|
||||||
|
{
|
||||||
|
get { return momementThreshold; }
|
||||||
|
set {
|
||||||
|
if (momementThreshold < 0) throw new ArgumentException("MovementThreshold value must be greater than zero");
|
||||||
|
momementThreshold = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The application’s level of access to the location service.
|
||||||
|
/// In the case of the Emulator, this always returns GeoPositionPermission.Granted.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>Note this is specific Emulator behaivor</remarks>
|
||||||
|
public GeoPositionPermission Permission
|
||||||
|
{
|
||||||
|
get { return GeoPositionPermission.Granted; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The most recent position obtained from the location service.
|
||||||
|
/// </summary>
|
||||||
|
public GeoPosition<GeoCoordinate> Position
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return currentLocation;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
GeoPositionStatus status = GeoPositionStatus.Disabled;
|
||||||
|
/// <summary>
|
||||||
|
/// The status of the location service, determined by the abuility to connect to the GPS Emulator.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>In real WP this is determined by the ability to find location</remarks>
|
||||||
|
public GeoPositionStatus Status
|
||||||
|
{
|
||||||
|
get { return status; }
|
||||||
|
private set
|
||||||
|
{
|
||||||
|
if (status != value)
|
||||||
|
{
|
||||||
|
this.status = value;
|
||||||
|
OnStatusChanged(new GeoPositionStatusChangedEventArgs(status));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Occurs when the location service detects a change in position, in accordance with the limits specified by the MovementThreshold value.
|
||||||
|
/// </summary>
|
||||||
|
public event EventHandler<GeoPositionChangedEventArgs<GeoCoordinate>> PositionChanged;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Occurs when the status of the location service changes.
|
||||||
|
/// </summary>
|
||||||
|
public event EventHandler<GeoPositionStatusChangedEventArgs> StatusChanged;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Releases resources used by the GeoCoordinateWatcher and stops the acquisition of data from the GPS Emulator.
|
||||||
|
/// </summary>
|
||||||
|
[SecuritySafeCritical]
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
if (client != null)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (client.State != CommunicationState.Faulted) client.CloseAsync(TimeSpan.FromSeconds(5));
|
||||||
|
Status = GeoPositionStatus.Disabled;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
client = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Raises the PositionChanged event.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="e">The event data</param>
|
||||||
|
protected void OnPositionChanged(GeoPositionChangedEventArgs<GeoCoordinate> e)
|
||||||
|
{
|
||||||
|
if (PositionChanged != null) PositionChanged(this, e);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Raises the StatusChanged event.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="e">The event data</param>
|
||||||
|
protected void OnStatusChanged(GeoPositionStatusChangedEventArgs e)
|
||||||
|
{
|
||||||
|
if (StatusChanged != null) StatusChanged(this, e);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Starts the acquisition of data from the GPS Emulator.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks></remarks>
|
||||||
|
[SecuritySafeCritical]
|
||||||
|
public void Start()
|
||||||
|
{
|
||||||
|
if (client == null)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
status = GeoPositionStatus.Initializing;
|
||||||
|
client = new GpsEmulatorServiceClient(
|
||||||
|
new BasicHttpBinding(BasicHttpSecurityMode.None),
|
||||||
|
new EndpointAddress("http://localhost:8192/GpsEmulator")); // change end point to real IP when testing on a real device
|
||||||
|
client.OpenCompleted += new EventHandler<System.ComponentModel.AsyncCompletedEventArgs>(client_OpenCompleted);
|
||||||
|
client.GetCurrentPositionCompleted +=new EventHandler<GetCurrentPositionCompletedEventArgs>(client_GetCurrentPositionCompleted);
|
||||||
|
ICommunicationObject commObject = client as ICommunicationObject;
|
||||||
|
if (commObject != null)
|
||||||
|
{
|
||||||
|
commObject.Faulted += new EventHandler((a,b) => { Stop(); });
|
||||||
|
}
|
||||||
|
client.GetCurrentPositionAsync();
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
client = null;
|
||||||
|
Status = GeoPositionStatus.Disabled;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void client_OpenCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e)
|
||||||
|
{
|
||||||
|
Status = GeoPositionStatus.Ready;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Starts the acquisition of data from the GPS Emulator.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="suppressPermissionPrompt">This parameter is not used.</param>
|
||||||
|
[SecuritySafeCritical]
|
||||||
|
public void Start(bool suppressPermissionPrompt)
|
||||||
|
{
|
||||||
|
Start();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Stops the acquisition of data from the GPS Emulator.
|
||||||
|
/// </summary>
|
||||||
|
[SecuritySafeCritical]
|
||||||
|
public void Stop()
|
||||||
|
{
|
||||||
|
Dispose();
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// Summary:
|
||||||
|
// Attempts to start the acquisition of data from the location service. If the
|
||||||
|
// provided timeout interval is exceeded before the location service responds,
|
||||||
|
// the request for location is stopped and the method returns false.
|
||||||
|
//
|
||||||
|
// Parameters:
|
||||||
|
// suppressPermissionPrompt:
|
||||||
|
// This parameter is not used.
|
||||||
|
//
|
||||||
|
// timeout:
|
||||||
|
// A TimeSpan object specifying the amount of time to wait for location data
|
||||||
|
// acquisition to begin.
|
||||||
|
//
|
||||||
|
// Returns:
|
||||||
|
// Returns System.Boolean . true if the location service responds within the
|
||||||
|
// timeout window. Otherwise, false.
|
||||||
|
[SecuritySafeCritical]
|
||||||
|
public bool TryStart(bool suppressPermissionPrompt, TimeSpan timeout)
|
||||||
|
{
|
||||||
|
Start();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static char[] latLngSeparator = new char[] { ',' };
|
||||||
|
static GeoCoordinate _PrevGc = null;
|
||||||
|
|
||||||
|
void client_GetCurrentPositionCompleted(object sender, GetCurrentPositionCompletedEventArgs e)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (client == null) return;
|
||||||
|
if (e.Error != null)
|
||||||
|
{
|
||||||
|
Status = GeoPositionStatus.Disabled;
|
||||||
|
client = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
string[] coordinates = e.Result.Split(latLngSeparator);
|
||||||
|
if (coordinates.Length == 2)
|
||||||
|
{
|
||||||
|
double lat, lng;
|
||||||
|
if (Double.TryParse(coordinates[0], out lat) && double.TryParse(coordinates[1], out lng))
|
||||||
|
{
|
||||||
|
GeoCoordinate gc = new GeoCoordinate(lat, lng);
|
||||||
|
if (_PrevGc == null || !_PrevGc.Equals(gc))
|
||||||
|
{
|
||||||
|
_PrevGc = gc;
|
||||||
|
currentLocation = new GeoPosition<GeoCoordinate>(DateTimeOffset.Now, gc);
|
||||||
|
GeoPositionChangedEventArgs<GeoCoordinate> gpcea = new GeoPositionChangedEventArgs<GeoCoordinate>(currentLocation);
|
||||||
|
Status = GeoPositionStatus.Ready;
|
||||||
|
OnPositionChanged(gpcea);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Status = GeoPositionStatus.NoData;
|
||||||
|
}
|
||||||
|
client.GetCurrentPositionAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,119 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
|
<ProductVersion>10.0.20506</ProductVersion>
|
||||||
|
<SchemaVersion>2.0</SchemaVersion>
|
||||||
|
<ProjectGuid>{A128812A-1249-4562-BDF4-5E17951B8434}</ProjectGuid>
|
||||||
|
<ProjectTypeGuids>{C089C8C0-30E0-4E22-80C0-CE093F111A43};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
|
||||||
|
<OutputType>Library</OutputType>
|
||||||
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
|
<RootNamespace>GpsEmulatorClient</RootNamespace>
|
||||||
|
<AssemblyName>GpsEmulatorClient</AssemblyName>
|
||||||
|
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||||
|
<SilverlightVersion>$(TargetFrameworkVersion)</SilverlightVersion>
|
||||||
|
<TargetFrameworkProfile>WindowsPhone</TargetFrameworkProfile>
|
||||||
|
<TargetFrameworkIdentifier>Silverlight</TargetFrameworkIdentifier>
|
||||||
|
<SilverlightApplication>false</SilverlightApplication>
|
||||||
|
<ValidateXaml>true</ValidateXaml>
|
||||||
|
<ThrowErrorsInValidation>true</ThrowErrorsInValidation>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
<OutputPath>Bin\Debug</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE;SILVERLIGHT;WINDOWS_PHONE</DefineConstants>
|
||||||
|
<NoStdLib>true</NoStdLib>
|
||||||
|
<NoConfig>true</NoConfig>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>Bin\Release</OutputPath>
|
||||||
|
<DefineConstants>TRACE;SILVERLIGHT;WINDOWS_PHONE</DefineConstants>
|
||||||
|
<NoStdLib>true</NoStdLib>
|
||||||
|
<NoConfig>true</NoConfig>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Tests|AnyCPU'">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<OutputPath>bin\Tests\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE;SILVERLIGHT;WINDOWS_PHONE</DefineConstants>
|
||||||
|
<NoStdLib>true</NoStdLib>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
|
<CodeAnalysisLogFile>Bin\Debug\GpsEmulatorClient.dll.CodeAnalysisLog.xml</CodeAnalysisLogFile>
|
||||||
|
<CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
|
||||||
|
<CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||||
|
<CodeAnalysisRuleSetDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets</CodeAnalysisRuleSetDirectories>
|
||||||
|
<CodeAnalysisRuleDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules</CodeAnalysisRuleDirectories>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="System.Device" />
|
||||||
|
<Reference Include="System.Runtime.Serialization" />
|
||||||
|
<Reference Include="System.Servicemodel" />
|
||||||
|
<Reference Include="System.Windows" />
|
||||||
|
<Reference Include="system" />
|
||||||
|
<Reference Include="System.Core" />
|
||||||
|
<Reference Include="System.Xml" />
|
||||||
|
<Reference Include="System.Net" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="GeoCoordinateWatcher.cs" />
|
||||||
|
<Compile Include="IGpsEmulatorService.cs" />
|
||||||
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
<Compile Include="Service References\ServiceReference1\Reference.cs">
|
||||||
|
<AutoGen>True</AutoGen>
|
||||||
|
<DesignTime>True</DesignTime>
|
||||||
|
<DependentUpon>Reference.svcmap</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<WCFMetadata Include="Service References\" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="Service References\ServiceReference1\item.xsd">
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
</None>
|
||||||
|
<None Include="Service References\ServiceReference1\item1.xsd">
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
</None>
|
||||||
|
<None Include="Service References\ServiceReference1\MainWindow.wsdl" />
|
||||||
|
<Content Include="ServiceReferences.ClientConfig" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<WCFMetadataStorage Include="Service References\ServiceReference1\" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="Service References\ServiceReference1\item.disco" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="Service References\ServiceReference1\configuration91.svcinfo" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="Service References\ServiceReference1\configuration.svcinfo" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="Service References\ServiceReference1\Reference.svcmap">
|
||||||
|
<Generator>WCF Proxy Generator</Generator>
|
||||||
|
<LastGenOutput>Reference.cs</LastGenOutput>
|
||||||
|
</None>
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(MSBuildExtensionsPath)\Microsoft\Silverlight for Phone\$(TargetFrameworkVersion)\Microsoft.Silverlight.$(TargetFrameworkProfile).Overrides.targets" />
|
||||||
|
<Import Project="$(MSBuildExtensionsPath)\Microsoft\Silverlight for Phone\$(TargetFrameworkVersion)\Microsoft.Silverlight.CSharp.targets" />
|
||||||
|
<ProjectExtensions />
|
||||||
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
|
<Target Name="BeforeBuild">
|
||||||
|
</Target>
|
||||||
|
<Target Name="AfterBuild">
|
||||||
|
</Target>
|
||||||
|
-->
|
||||||
|
</Project>
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
using System.ServiceModel;
|
||||||
|
|
||||||
|
namespace GpsEmulatorClient
|
||||||
|
{
|
||||||
|
[ServiceContract]
|
||||||
|
interface IGpsEmulatorService
|
||||||
|
{
|
||||||
|
[OperationContract]
|
||||||
|
string GetCurrentPosition();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
// General Information about an assembly is controlled through the following
|
||||||
|
// set of attributes. Change these attribute values to modify the information
|
||||||
|
// associated with an assembly.
|
||||||
|
[assembly: AssemblyTitle("GpsEmulatorClient")]
|
||||||
|
[assembly: AssemblyDescription("")]
|
||||||
|
[assembly: AssemblyConfiguration("")]
|
||||||
|
[assembly: AssemblyCompany("Microsoft")]
|
||||||
|
[assembly: AssemblyProduct("GpsEmulatorClient")]
|
||||||
|
[assembly: AssemblyCopyright("Copyright © Microsoft 2010")]
|
||||||
|
[assembly: AssemblyTrademark("")]
|
||||||
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
|
// Setting ComVisible to false makes the types in this assembly not visible
|
||||||
|
// to COM components. If you need to access a type in this assembly from
|
||||||
|
// COM, set the ComVisible attribute to true on that type.
|
||||||
|
[assembly: ComVisible(false)]
|
||||||
|
|
||||||
|
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||||
|
[assembly: Guid("0b356c09-b849-4c48-8e61-57e048820027")]
|
||||||
|
|
||||||
|
// Version information for an assembly consists of the following four values:
|
||||||
|
//
|
||||||
|
// Major Version
|
||||||
|
// Minor Version
|
||||||
|
// Build Number
|
||||||
|
// Revision
|
||||||
|
//
|
||||||
|
// You can specify all the values or you can default the Revision and Build Numbers
|
||||||
|
// by using the '*' as shown below:
|
||||||
|
[assembly: AssemblyVersion("1.0.0.0")]
|
||||||
|
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<wsdl:definitions xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy" xmlns:wsa10="http://www.w3.org/2005/08/addressing" xmlns:tns="http://tempuri.org/" xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="MainWindow" targetNamespace="http://tempuri.org/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
|
||||||
|
<wsdl:types>
|
||||||
|
<xsd:schema targetNamespace="http://tempuri.org/Imports">
|
||||||
|
<xsd:import schemaLocation="http://localhost:8192/?xsd=xsd0" namespace="http://tempuri.org/" />
|
||||||
|
<xsd:import schemaLocation="http://localhost:8192/?xsd=xsd1" namespace="http://schemas.microsoft.com/2003/10/Serialization/" />
|
||||||
|
</xsd:schema>
|
||||||
|
</wsdl:types>
|
||||||
|
<wsdl:message name="IGpsEmulatorService_GetCurrentPosition_InputMessage">
|
||||||
|
<wsdl:part name="parameters" element="tns:GetCurrentPosition" />
|
||||||
|
</wsdl:message>
|
||||||
|
<wsdl:message name="IGpsEmulatorService_GetCurrentPosition_OutputMessage">
|
||||||
|
<wsdl:part name="parameters" element="tns:GetCurrentPositionResponse" />
|
||||||
|
</wsdl:message>
|
||||||
|
<wsdl:portType name="IGpsEmulatorService">
|
||||||
|
<wsdl:operation name="GetCurrentPosition">
|
||||||
|
<wsdl:input wsaw:Action="http://tempuri.org/IGpsEmulatorService/GetCurrentPosition" message="tns:IGpsEmulatorService_GetCurrentPosition_InputMessage" />
|
||||||
|
<wsdl:output wsaw:Action="http://tempuri.org/IGpsEmulatorService/GetCurrentPositionResponse" message="tns:IGpsEmulatorService_GetCurrentPosition_OutputMessage" />
|
||||||
|
</wsdl:operation>
|
||||||
|
</wsdl:portType>
|
||||||
|
<wsdl:binding name="BasicHttpBinding_IGpsEmulatorService" type="tns:IGpsEmulatorService">
|
||||||
|
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
|
||||||
|
<wsdl:operation name="GetCurrentPosition">
|
||||||
|
<soap:operation soapAction="http://tempuri.org/IGpsEmulatorService/GetCurrentPosition" style="document" />
|
||||||
|
<wsdl:input>
|
||||||
|
<soap:body use="literal" />
|
||||||
|
</wsdl:input>
|
||||||
|
<wsdl:output>
|
||||||
|
<soap:body use="literal" />
|
||||||
|
</wsdl:output>
|
||||||
|
</wsdl:operation>
|
||||||
|
</wsdl:binding>
|
||||||
|
<wsdl:service name="MainWindow">
|
||||||
|
<wsdl:port name="BasicHttpBinding_IGpsEmulatorService" binding="tns:BasicHttpBinding_IGpsEmulatorService">
|
||||||
|
<soap:address location="http://localhost:8192/GpsEmulator" />
|
||||||
|
</wsdl:port>
|
||||||
|
</wsdl:service>
|
||||||
|
</wsdl:definitions>
|
||||||
@@ -0,0 +1,252 @@
|
|||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// <auto-generated>
|
||||||
|
// This code was generated by a tool.
|
||||||
|
// Runtime Version:4.0.30319.1
|
||||||
|
//
|
||||||
|
// Changes to this file may cause incorrect behavior and will be lost if
|
||||||
|
// the code is regenerated.
|
||||||
|
// </auto-generated>
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
//
|
||||||
|
// This code was auto-generated by Microsoft.Silverlight.Phone.ServiceReference, version 3.7.0.0
|
||||||
|
//
|
||||||
|
namespace GpsEmulatorClient.ServiceReference1 {
|
||||||
|
|
||||||
|
|
||||||
|
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
|
||||||
|
[System.ServiceModel.ServiceContractAttribute(ConfigurationName="ServiceReference1.IGpsEmulatorService")]
|
||||||
|
public interface IGpsEmulatorService {
|
||||||
|
|
||||||
|
[System.ServiceModel.OperationContractAttribute(AsyncPattern=true, Action="http://tempuri.org/IGpsEmulatorService/GetCurrentPosition", ReplyAction="http://tempuri.org/IGpsEmulatorService/GetCurrentPositionResponse")]
|
||||||
|
System.IAsyncResult BeginGetCurrentPosition(System.AsyncCallback callback, object asyncState);
|
||||||
|
|
||||||
|
string EndGetCurrentPosition(System.IAsyncResult result);
|
||||||
|
}
|
||||||
|
|
||||||
|
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
|
||||||
|
public interface IGpsEmulatorServiceChannel : GpsEmulatorClient.ServiceReference1.IGpsEmulatorService, System.ServiceModel.IClientChannel {
|
||||||
|
}
|
||||||
|
|
||||||
|
[System.Diagnostics.DebuggerStepThroughAttribute()]
|
||||||
|
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
|
||||||
|
public partial class GetCurrentPositionCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
|
||||||
|
|
||||||
|
private object[] results;
|
||||||
|
|
||||||
|
public GetCurrentPositionCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) :
|
||||||
|
base(exception, cancelled, userState) {
|
||||||
|
this.results = results;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Result {
|
||||||
|
get {
|
||||||
|
base.RaiseExceptionIfNecessary();
|
||||||
|
return ((string)(this.results[0]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[System.Diagnostics.DebuggerStepThroughAttribute()]
|
||||||
|
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
|
||||||
|
public partial class GpsEmulatorServiceClient : System.ServiceModel.ClientBase<GpsEmulatorClient.ServiceReference1.IGpsEmulatorService>, GpsEmulatorClient.ServiceReference1.IGpsEmulatorService {
|
||||||
|
|
||||||
|
private BeginOperationDelegate onBeginGetCurrentPositionDelegate;
|
||||||
|
|
||||||
|
private EndOperationDelegate onEndGetCurrentPositionDelegate;
|
||||||
|
|
||||||
|
private System.Threading.SendOrPostCallback onGetCurrentPositionCompletedDelegate;
|
||||||
|
|
||||||
|
private BeginOperationDelegate onBeginOpenDelegate;
|
||||||
|
|
||||||
|
private EndOperationDelegate onEndOpenDelegate;
|
||||||
|
|
||||||
|
private System.Threading.SendOrPostCallback onOpenCompletedDelegate;
|
||||||
|
|
||||||
|
private BeginOperationDelegate onBeginCloseDelegate;
|
||||||
|
|
||||||
|
private EndOperationDelegate onEndCloseDelegate;
|
||||||
|
|
||||||
|
private System.Threading.SendOrPostCallback onCloseCompletedDelegate;
|
||||||
|
|
||||||
|
public GpsEmulatorServiceClient() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public GpsEmulatorServiceClient(string endpointConfigurationName) :
|
||||||
|
base(endpointConfigurationName) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public GpsEmulatorServiceClient(string endpointConfigurationName, string remoteAddress) :
|
||||||
|
base(endpointConfigurationName, remoteAddress) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public GpsEmulatorServiceClient(string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) :
|
||||||
|
base(endpointConfigurationName, remoteAddress) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public GpsEmulatorServiceClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) :
|
||||||
|
base(binding, remoteAddress) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public System.Net.CookieContainer CookieContainer {
|
||||||
|
get {
|
||||||
|
System.ServiceModel.Channels.IHttpCookieContainerManager httpCookieContainerManager = this.InnerChannel.GetProperty<System.ServiceModel.Channels.IHttpCookieContainerManager>();
|
||||||
|
if ((httpCookieContainerManager != null)) {
|
||||||
|
return httpCookieContainerManager.CookieContainer;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
System.ServiceModel.Channels.IHttpCookieContainerManager httpCookieContainerManager = this.InnerChannel.GetProperty<System.ServiceModel.Channels.IHttpCookieContainerManager>();
|
||||||
|
if ((httpCookieContainerManager != null)) {
|
||||||
|
httpCookieContainerManager.CookieContainer = value;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
throw new System.InvalidOperationException("Unable to set the CookieContainer. Please make sure the binding contains an HttpC" +
|
||||||
|
"ookieContainerBindingElement.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public event System.EventHandler<GetCurrentPositionCompletedEventArgs> GetCurrentPositionCompleted;
|
||||||
|
|
||||||
|
public event System.EventHandler<System.ComponentModel.AsyncCompletedEventArgs> OpenCompleted;
|
||||||
|
|
||||||
|
public event System.EventHandler<System.ComponentModel.AsyncCompletedEventArgs> CloseCompleted;
|
||||||
|
|
||||||
|
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||||
|
System.IAsyncResult GpsEmulatorClient.ServiceReference1.IGpsEmulatorService.BeginGetCurrentPosition(System.AsyncCallback callback, object asyncState) {
|
||||||
|
return base.Channel.BeginGetCurrentPosition(callback, asyncState);
|
||||||
|
}
|
||||||
|
|
||||||
|
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||||
|
string GpsEmulatorClient.ServiceReference1.IGpsEmulatorService.EndGetCurrentPosition(System.IAsyncResult result) {
|
||||||
|
return base.Channel.EndGetCurrentPosition(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
private System.IAsyncResult OnBeginGetCurrentPosition(object[] inValues, System.AsyncCallback callback, object asyncState) {
|
||||||
|
return ((GpsEmulatorClient.ServiceReference1.IGpsEmulatorService)(this)).BeginGetCurrentPosition(callback, asyncState);
|
||||||
|
}
|
||||||
|
|
||||||
|
private object[] OnEndGetCurrentPosition(System.IAsyncResult result) {
|
||||||
|
string retVal = ((GpsEmulatorClient.ServiceReference1.IGpsEmulatorService)(this)).EndGetCurrentPosition(result);
|
||||||
|
return new object[] {
|
||||||
|
retVal};
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnGetCurrentPositionCompleted(object state) {
|
||||||
|
if ((this.GetCurrentPositionCompleted != null)) {
|
||||||
|
InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs)(state));
|
||||||
|
this.GetCurrentPositionCompleted(this, new GetCurrentPositionCompletedEventArgs(e.Results, e.Error, e.Cancelled, e.UserState));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void GetCurrentPositionAsync() {
|
||||||
|
this.GetCurrentPositionAsync(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void GetCurrentPositionAsync(object userState) {
|
||||||
|
if ((this.onBeginGetCurrentPositionDelegate == null)) {
|
||||||
|
this.onBeginGetCurrentPositionDelegate = new BeginOperationDelegate(this.OnBeginGetCurrentPosition);
|
||||||
|
}
|
||||||
|
if ((this.onEndGetCurrentPositionDelegate == null)) {
|
||||||
|
this.onEndGetCurrentPositionDelegate = new EndOperationDelegate(this.OnEndGetCurrentPosition);
|
||||||
|
}
|
||||||
|
if ((this.onGetCurrentPositionCompletedDelegate == null)) {
|
||||||
|
this.onGetCurrentPositionCompletedDelegate = new System.Threading.SendOrPostCallback(this.OnGetCurrentPositionCompleted);
|
||||||
|
}
|
||||||
|
base.InvokeAsync(this.onBeginGetCurrentPositionDelegate, null, this.onEndGetCurrentPositionDelegate, this.onGetCurrentPositionCompletedDelegate, userState);
|
||||||
|
}
|
||||||
|
|
||||||
|
private System.IAsyncResult OnBeginOpen(object[] inValues, System.AsyncCallback callback, object asyncState) {
|
||||||
|
return ((System.ServiceModel.ICommunicationObject)(this)).BeginOpen(callback, asyncState);
|
||||||
|
}
|
||||||
|
|
||||||
|
private object[] OnEndOpen(System.IAsyncResult result) {
|
||||||
|
((System.ServiceModel.ICommunicationObject)(this)).EndOpen(result);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnOpenCompleted(object state) {
|
||||||
|
if ((this.OpenCompleted != null)) {
|
||||||
|
InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs)(state));
|
||||||
|
this.OpenCompleted(this, new System.ComponentModel.AsyncCompletedEventArgs(e.Error, e.Cancelled, e.UserState));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OpenAsync() {
|
||||||
|
this.OpenAsync(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OpenAsync(object userState) {
|
||||||
|
if ((this.onBeginOpenDelegate == null)) {
|
||||||
|
this.onBeginOpenDelegate = new BeginOperationDelegate(this.OnBeginOpen);
|
||||||
|
}
|
||||||
|
if ((this.onEndOpenDelegate == null)) {
|
||||||
|
this.onEndOpenDelegate = new EndOperationDelegate(this.OnEndOpen);
|
||||||
|
}
|
||||||
|
if ((this.onOpenCompletedDelegate == null)) {
|
||||||
|
this.onOpenCompletedDelegate = new System.Threading.SendOrPostCallback(this.OnOpenCompleted);
|
||||||
|
}
|
||||||
|
base.InvokeAsync(this.onBeginOpenDelegate, null, this.onEndOpenDelegate, this.onOpenCompletedDelegate, userState);
|
||||||
|
}
|
||||||
|
|
||||||
|
private System.IAsyncResult OnBeginClose(object[] inValues, System.AsyncCallback callback, object asyncState) {
|
||||||
|
return ((System.ServiceModel.ICommunicationObject)(this)).BeginClose(callback, asyncState);
|
||||||
|
}
|
||||||
|
|
||||||
|
private object[] OnEndClose(System.IAsyncResult result) {
|
||||||
|
((System.ServiceModel.ICommunicationObject)(this)).EndClose(result);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnCloseCompleted(object state) {
|
||||||
|
if ((this.CloseCompleted != null)) {
|
||||||
|
InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs)(state));
|
||||||
|
this.CloseCompleted(this, new System.ComponentModel.AsyncCompletedEventArgs(e.Error, e.Cancelled, e.UserState));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CloseAsync() {
|
||||||
|
this.CloseAsync(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CloseAsync(object userState) {
|
||||||
|
if ((this.onBeginCloseDelegate == null)) {
|
||||||
|
this.onBeginCloseDelegate = new BeginOperationDelegate(this.OnBeginClose);
|
||||||
|
}
|
||||||
|
if ((this.onEndCloseDelegate == null)) {
|
||||||
|
this.onEndCloseDelegate = new EndOperationDelegate(this.OnEndClose);
|
||||||
|
}
|
||||||
|
if ((this.onCloseCompletedDelegate == null)) {
|
||||||
|
this.onCloseCompletedDelegate = new System.Threading.SendOrPostCallback(this.OnCloseCompleted);
|
||||||
|
}
|
||||||
|
base.InvokeAsync(this.onBeginCloseDelegate, null, this.onEndCloseDelegate, this.onCloseCompletedDelegate, userState);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override GpsEmulatorClient.ServiceReference1.IGpsEmulatorService CreateChannel() {
|
||||||
|
return new GpsEmulatorServiceClientChannel(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
private class GpsEmulatorServiceClientChannel : ChannelBase<GpsEmulatorClient.ServiceReference1.IGpsEmulatorService>, GpsEmulatorClient.ServiceReference1.IGpsEmulatorService {
|
||||||
|
|
||||||
|
public GpsEmulatorServiceClientChannel(System.ServiceModel.ClientBase<GpsEmulatorClient.ServiceReference1.IGpsEmulatorService> client) :
|
||||||
|
base(client) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public System.IAsyncResult BeginGetCurrentPosition(System.AsyncCallback callback, object asyncState) {
|
||||||
|
object[] _args = new object[0];
|
||||||
|
System.IAsyncResult _result = base.BeginInvoke("GetCurrentPosition", _args, callback, asyncState);
|
||||||
|
return _result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string EndGetCurrentPosition(System.IAsyncResult result) {
|
||||||
|
object[] _args = new object[0];
|
||||||
|
string _result = ((string)(base.EndInvoke("GetCurrentPosition", _args, result)));
|
||||||
|
return _result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<ReferenceGroup xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" ID="b7dcd30b-0e90-42aa-84b6-7a2973854c58" xmlns="urn:schemas-microsoft-com:xml-wcfservicemap">
|
||||||
|
<ClientOptions>
|
||||||
|
<GenerateAsynchronousMethods>true</GenerateAsynchronousMethods>
|
||||||
|
<EnableDataBinding>true</EnableDataBinding>
|
||||||
|
<ExcludedTypes />
|
||||||
|
<ImportXmlTypes>false</ImportXmlTypes>
|
||||||
|
<GenerateInternalTypes>false</GenerateInternalTypes>
|
||||||
|
<GenerateMessageContracts>false</GenerateMessageContracts>
|
||||||
|
<NamespaceMappings />
|
||||||
|
<CollectionMappings>
|
||||||
|
<CollectionMapping TypeName="System.Collections.ObjectModel.ObservableCollection`1" Category="List" />
|
||||||
|
</CollectionMappings>
|
||||||
|
<GenerateSerializableTypes>false</GenerateSerializableTypes>
|
||||||
|
<Serializer>Auto</Serializer>
|
||||||
|
<UseSerializerForFaults>true</UseSerializerForFaults>
|
||||||
|
<ReferenceAllAssemblies>true</ReferenceAllAssemblies>
|
||||||
|
<ReferencedAssemblies />
|
||||||
|
<ReferencedDataContractTypes />
|
||||||
|
<ServiceContractMappings />
|
||||||
|
</ClientOptions>
|
||||||
|
<MetadataSources>
|
||||||
|
<MetadataSource Address="http://localhost:8192/" Protocol="http" SourceId="1" />
|
||||||
|
</MetadataSources>
|
||||||
|
<Metadata>
|
||||||
|
<MetadataFile FileName="MainWindow.wsdl" MetadataType="Wsdl" ID="d7bdc5eb-4337-4f27-96e1-4177e7543b46" SourceId="1" SourceUrl="http://localhost:8192/?wsdl" />
|
||||||
|
<MetadataFile FileName="item.disco" MetadataType="Disco" ID="21784fa5-1260-40bc-8e5f-2a8396603bfb" SourceId="1" SourceUrl="http://localhost:8192/?disco" />
|
||||||
|
<MetadataFile FileName="item.xsd" MetadataType="Schema" ID="2dfe2d47-9f63-4936-b072-c08f90287d85" SourceId="1" SourceUrl="http://localhost:8192/?xsd=xsd0" />
|
||||||
|
<MetadataFile FileName="item1.xsd" MetadataType="Schema" ID="5fb0232e-5597-4e7b-a01f-40d010171ea0" SourceId="1" SourceUrl="http://localhost:8192/?xsd=xsd1" />
|
||||||
|
</Metadata>
|
||||||
|
<Extensions>
|
||||||
|
<ExtensionFile FileName="configuration91.svcinfo" Name="configuration91.svcinfo" />
|
||||||
|
<ExtensionFile FileName="configuration.svcinfo" Name="configuration.svcinfo" />
|
||||||
|
</Extensions>
|
||||||
|
</ReferenceGroup>
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<configurationSnapshot xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="urn:schemas-microsoft-com:xml-wcfconfigurationsnapshot">
|
||||||
|
<behaviors />
|
||||||
|
<bindings>
|
||||||
|
<binding digest="System.ServiceModel.Configuration.BasicHttpBindingElement, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089:<?xml version="1.0" encoding="utf-16"?><Data maxBufferSize="2147483647" name="BasicHttpBinding_IGpsEmulatorService"><security mode="None" /></Data>" bindingType="basicHttpBinding" name="BasicHttpBinding_IGpsEmulatorService" />
|
||||||
|
</bindings>
|
||||||
|
<endpoints>
|
||||||
|
<endpoint normalizedDigest="<?xml version="1.0" encoding="utf-16"?><Data address="http://localhost:8192/GpsEmulator" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IGpsEmulatorService" contract="ServiceReference1.IGpsEmulatorService" name="BasicHttpBinding_IGpsEmulatorService" />" digest="<?xml version="1.0" encoding="utf-16"?><Data address="http://localhost:8192/GpsEmulator" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IGpsEmulatorService" contract="ServiceReference1.IGpsEmulatorService" name="BasicHttpBinding_IGpsEmulatorService" />" contractName="ServiceReference1.IGpsEmulatorService" name="BasicHttpBinding_IGpsEmulatorService" />
|
||||||
|
</endpoints>
|
||||||
|
</configurationSnapshot>
|
||||||
@@ -0,0 +1,201 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<SavedWcfConfigurationInformation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Version="9.1" CheckSum="cPUHtSo3XQ/cjOCAE2DwkrhkKi4=">
|
||||||
|
<bindingConfigurations>
|
||||||
|
<bindingConfiguration bindingType="basicHttpBinding" name="BasicHttpBinding_IGpsEmulatorService">
|
||||||
|
<properties>
|
||||||
|
<property path="/name" isComplexType="false" isExplicitlyDefined="true" clrType="System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<serializedValue>BasicHttpBinding_IGpsEmulatorService</serializedValue>
|
||||||
|
</property>
|
||||||
|
<property path="/closeTimeout" isComplexType="false" isExplicitlyDefined="true" clrType="System.TimeSpan, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<serializedValue />
|
||||||
|
</property>
|
||||||
|
<property path="/openTimeout" isComplexType="false" isExplicitlyDefined="true" clrType="System.TimeSpan, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<serializedValue />
|
||||||
|
</property>
|
||||||
|
<property path="/receiveTimeout" isComplexType="false" isExplicitlyDefined="true" clrType="System.TimeSpan, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<serializedValue />
|
||||||
|
</property>
|
||||||
|
<property path="/sendTimeout" isComplexType="false" isExplicitlyDefined="true" clrType="System.TimeSpan, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<serializedValue />
|
||||||
|
</property>
|
||||||
|
<property path="/allowCookies" isComplexType="false" isExplicitlyDefined="true" clrType="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<serializedValue />
|
||||||
|
</property>
|
||||||
|
<property path="/bypassProxyOnLocal" isComplexType="false" isExplicitlyDefined="true" clrType="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<serializedValue />
|
||||||
|
</property>
|
||||||
|
<property path="/hostNameComparisonMode" isComplexType="false" isExplicitlyDefined="false" clrType="System.ServiceModel.HostNameComparisonMode, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<serializedValue>StrongWildcard</serializedValue>
|
||||||
|
</property>
|
||||||
|
<property path="/maxBufferSize" isComplexType="false" isExplicitlyDefined="true" clrType="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<serializedValue>2147483647</serializedValue>
|
||||||
|
</property>
|
||||||
|
<property path="/maxBufferPoolSize" isComplexType="false" isExplicitlyDefined="true" clrType="System.Int64, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<serializedValue />
|
||||||
|
</property>
|
||||||
|
<property path="/maxReceivedMessageSize" isComplexType="false" isExplicitlyDefined="true" clrType="System.Int64, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<serializedValue>2147483647</serializedValue>
|
||||||
|
</property>
|
||||||
|
<property path="/messageEncoding" isComplexType="false" isExplicitlyDefined="false" clrType="System.ServiceModel.WSMessageEncoding, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<serializedValue>Text</serializedValue>
|
||||||
|
</property>
|
||||||
|
<property path="/proxyAddress" isComplexType="false" isExplicitlyDefined="false" clrType="System.Uri, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<serializedValue />
|
||||||
|
</property>
|
||||||
|
<property path="/readerQuotas" isComplexType="true" isExplicitlyDefined="false" clrType="System.ServiceModel.Configuration.XmlDictionaryReaderQuotasElement, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<serializedValue>System.ServiceModel.Configuration.XmlDictionaryReaderQuotasElement</serializedValue>
|
||||||
|
</property>
|
||||||
|
<property path="/readerQuotas/maxDepth" isComplexType="false" isExplicitlyDefined="false" clrType="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<serializedValue>0</serializedValue>
|
||||||
|
</property>
|
||||||
|
<property path="/readerQuotas/maxStringContentLength" isComplexType="false" isExplicitlyDefined="false" clrType="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<serializedValue>0</serializedValue>
|
||||||
|
</property>
|
||||||
|
<property path="/readerQuotas/maxArrayLength" isComplexType="false" isExplicitlyDefined="false" clrType="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<serializedValue>0</serializedValue>
|
||||||
|
</property>
|
||||||
|
<property path="/readerQuotas/maxBytesPerRead" isComplexType="false" isExplicitlyDefined="false" clrType="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<serializedValue>0</serializedValue>
|
||||||
|
</property>
|
||||||
|
<property path="/readerQuotas/maxNameTableCharCount" isComplexType="false" isExplicitlyDefined="false" clrType="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<serializedValue>0</serializedValue>
|
||||||
|
</property>
|
||||||
|
<property path="/security" isComplexType="true" isExplicitlyDefined="false" clrType="System.ServiceModel.Configuration.BasicHttpSecurityElement, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<serializedValue>System.ServiceModel.Configuration.BasicHttpSecurityElement</serializedValue>
|
||||||
|
</property>
|
||||||
|
<property path="/security/mode" isComplexType="false" isExplicitlyDefined="true" clrType="System.ServiceModel.BasicHttpSecurityMode, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<serializedValue>None</serializedValue>
|
||||||
|
</property>
|
||||||
|
<property path="/security/transport" isComplexType="true" isExplicitlyDefined="false" clrType="System.ServiceModel.Configuration.HttpTransportSecurityElement, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<serializedValue>System.ServiceModel.Configuration.HttpTransportSecurityElement</serializedValue>
|
||||||
|
</property>
|
||||||
|
<property path="/security/transport/clientCredentialType" isComplexType="false" isExplicitlyDefined="false" clrType="System.ServiceModel.HttpClientCredentialType, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<serializedValue>None</serializedValue>
|
||||||
|
</property>
|
||||||
|
<property path="/security/transport/proxyCredentialType" isComplexType="false" isExplicitlyDefined="false" clrType="System.ServiceModel.HttpProxyCredentialType, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<serializedValue>None</serializedValue>
|
||||||
|
</property>
|
||||||
|
<property path="/security/transport/extendedProtectionPolicy" isComplexType="true" isExplicitlyDefined="false" clrType="System.Security.Authentication.ExtendedProtection.Configuration.ExtendedProtectionPolicyElement, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<serializedValue>System.Security.Authentication.ExtendedProtection.Configuration.ExtendedProtectionPolicyElement</serializedValue>
|
||||||
|
</property>
|
||||||
|
<property path="/security/transport/extendedProtectionPolicy/policyEnforcement" isComplexType="false" isExplicitlyDefined="false" clrType="System.Security.Authentication.ExtendedProtection.PolicyEnforcement, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<serializedValue>Never</serializedValue>
|
||||||
|
</property>
|
||||||
|
<property path="/security/transport/extendedProtectionPolicy/protectionScenario" isComplexType="false" isExplicitlyDefined="false" clrType="System.Security.Authentication.ExtendedProtection.ProtectionScenario, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<serializedValue>TransportSelected</serializedValue>
|
||||||
|
</property>
|
||||||
|
<property path="/security/transport/extendedProtectionPolicy/customServiceNames" isComplexType="true" isExplicitlyDefined="false" clrType="System.Security.Authentication.ExtendedProtection.Configuration.ServiceNameElementCollection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<serializedValue>(Collection)</serializedValue>
|
||||||
|
</property>
|
||||||
|
<property path="/security/transport/realm" isComplexType="false" isExplicitlyDefined="false" clrType="System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<serializedValue />
|
||||||
|
</property>
|
||||||
|
<property path="/security/message" isComplexType="true" isExplicitlyDefined="false" clrType="System.ServiceModel.Configuration.BasicHttpMessageSecurityElement, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<serializedValue>System.ServiceModel.Configuration.BasicHttpMessageSecurityElement</serializedValue>
|
||||||
|
</property>
|
||||||
|
<property path="/security/message/clientCredentialType" isComplexType="false" isExplicitlyDefined="false" clrType="System.ServiceModel.BasicHttpMessageCredentialType, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<serializedValue>UserName</serializedValue>
|
||||||
|
</property>
|
||||||
|
<property path="/security/message/algorithmSuite" isComplexType="false" isExplicitlyDefined="false" clrType="System.ServiceModel.Security.SecurityAlgorithmSuite, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<serializedValue>Default</serializedValue>
|
||||||
|
</property>
|
||||||
|
<property path="/textEncoding" isComplexType="false" isExplicitlyDefined="false" clrType="System.Text.Encoding, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<serializedValue>System.Text.UTF8Encoding</serializedValue>
|
||||||
|
</property>
|
||||||
|
<property path="/transferMode" isComplexType="false" isExplicitlyDefined="false" clrType="System.ServiceModel.TransferMode, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<serializedValue>Buffered</serializedValue>
|
||||||
|
</property>
|
||||||
|
<property path="/useDefaultWebProxy" isComplexType="false" isExplicitlyDefined="true" clrType="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<serializedValue />
|
||||||
|
</property>
|
||||||
|
</properties>
|
||||||
|
</bindingConfiguration>
|
||||||
|
</bindingConfigurations>
|
||||||
|
<endpoints>
|
||||||
|
<endpoint name="BasicHttpBinding_IGpsEmulatorService" contract="ServiceReference1.IGpsEmulatorService" bindingType="basicHttpBinding" address="http://localhost:8192/GpsEmulator" bindingConfiguration="BasicHttpBinding_IGpsEmulatorService">
|
||||||
|
<properties>
|
||||||
|
<property path="/address" isComplexType="false" isExplicitlyDefined="true" clrType="System.Uri, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<serializedValue>http://localhost:8192/GpsEmulator</serializedValue>
|
||||||
|
</property>
|
||||||
|
<property path="/behaviorConfiguration" isComplexType="false" isExplicitlyDefined="false" clrType="System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<serializedValue />
|
||||||
|
</property>
|
||||||
|
<property path="/binding" isComplexType="false" isExplicitlyDefined="true" clrType="System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<serializedValue>basicHttpBinding</serializedValue>
|
||||||
|
</property>
|
||||||
|
<property path="/bindingConfiguration" isComplexType="false" isExplicitlyDefined="true" clrType="System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<serializedValue>BasicHttpBinding_IGpsEmulatorService</serializedValue>
|
||||||
|
</property>
|
||||||
|
<property path="/contract" isComplexType="false" isExplicitlyDefined="true" clrType="System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<serializedValue>ServiceReference1.IGpsEmulatorService</serializedValue>
|
||||||
|
</property>
|
||||||
|
<property path="/headers" isComplexType="true" isExplicitlyDefined="false" clrType="System.ServiceModel.Configuration.AddressHeaderCollectionElement, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<serializedValue>System.ServiceModel.Configuration.AddressHeaderCollectionElement</serializedValue>
|
||||||
|
</property>
|
||||||
|
<property path="/headers/headers" isComplexType="false" isExplicitlyDefined="true" clrType="System.ServiceModel.Channels.AddressHeaderCollection, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<serializedValue><Header /></serializedValue>
|
||||||
|
</property>
|
||||||
|
<property path="/identity" isComplexType="true" isExplicitlyDefined="false" clrType="System.ServiceModel.Configuration.IdentityElement, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<serializedValue>System.ServiceModel.Configuration.IdentityElement</serializedValue>
|
||||||
|
</property>
|
||||||
|
<property path="/identity/userPrincipalName" isComplexType="true" isExplicitlyDefined="false" clrType="System.ServiceModel.Configuration.UserPrincipalNameElement, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<serializedValue>System.ServiceModel.Configuration.UserPrincipalNameElement</serializedValue>
|
||||||
|
</property>
|
||||||
|
<property path="/identity/userPrincipalName/value" isComplexType="false" isExplicitlyDefined="false" clrType="System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<serializedValue />
|
||||||
|
</property>
|
||||||
|
<property path="/identity/servicePrincipalName" isComplexType="true" isExplicitlyDefined="false" clrType="System.ServiceModel.Configuration.ServicePrincipalNameElement, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<serializedValue>System.ServiceModel.Configuration.ServicePrincipalNameElement</serializedValue>
|
||||||
|
</property>
|
||||||
|
<property path="/identity/servicePrincipalName/value" isComplexType="false" isExplicitlyDefined="false" clrType="System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<serializedValue />
|
||||||
|
</property>
|
||||||
|
<property path="/identity/dns" isComplexType="true" isExplicitlyDefined="false" clrType="System.ServiceModel.Configuration.DnsElement, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<serializedValue>System.ServiceModel.Configuration.DnsElement</serializedValue>
|
||||||
|
</property>
|
||||||
|
<property path="/identity/dns/value" isComplexType="false" isExplicitlyDefined="false" clrType="System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<serializedValue />
|
||||||
|
</property>
|
||||||
|
<property path="/identity/rsa" isComplexType="true" isExplicitlyDefined="false" clrType="System.ServiceModel.Configuration.RsaElement, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<serializedValue>System.ServiceModel.Configuration.RsaElement</serializedValue>
|
||||||
|
</property>
|
||||||
|
<property path="/identity/rsa/value" isComplexType="false" isExplicitlyDefined="false" clrType="System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<serializedValue />
|
||||||
|
</property>
|
||||||
|
<property path="/identity/certificate" isComplexType="true" isExplicitlyDefined="false" clrType="System.ServiceModel.Configuration.CertificateElement, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<serializedValue>System.ServiceModel.Configuration.CertificateElement</serializedValue>
|
||||||
|
</property>
|
||||||
|
<property path="/identity/certificate/encodedValue" isComplexType="false" isExplicitlyDefined="false" clrType="System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<serializedValue />
|
||||||
|
</property>
|
||||||
|
<property path="/identity/certificateReference" isComplexType="true" isExplicitlyDefined="false" clrType="System.ServiceModel.Configuration.CertificateReferenceElement, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<serializedValue>System.ServiceModel.Configuration.CertificateReferenceElement</serializedValue>
|
||||||
|
</property>
|
||||||
|
<property path="/identity/certificateReference/storeName" isComplexType="false" isExplicitlyDefined="false" clrType="System.Security.Cryptography.X509Certificates.StoreName, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<serializedValue>My</serializedValue>
|
||||||
|
</property>
|
||||||
|
<property path="/identity/certificateReference/storeLocation" isComplexType="false" isExplicitlyDefined="false" clrType="System.Security.Cryptography.X509Certificates.StoreLocation, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<serializedValue>LocalMachine</serializedValue>
|
||||||
|
</property>
|
||||||
|
<property path="/identity/certificateReference/x509FindType" isComplexType="false" isExplicitlyDefined="false" clrType="System.Security.Cryptography.X509Certificates.X509FindType, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<serializedValue>FindBySubjectDistinguishedName</serializedValue>
|
||||||
|
</property>
|
||||||
|
<property path="/identity/certificateReference/findValue" isComplexType="false" isExplicitlyDefined="false" clrType="System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<serializedValue />
|
||||||
|
</property>
|
||||||
|
<property path="/identity/certificateReference/isChainIncluded" isComplexType="false" isExplicitlyDefined="false" clrType="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<serializedValue>False</serializedValue>
|
||||||
|
</property>
|
||||||
|
<property path="/name" isComplexType="false" isExplicitlyDefined="true" clrType="System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<serializedValue>BasicHttpBinding_IGpsEmulatorService</serializedValue>
|
||||||
|
</property>
|
||||||
|
<property path="/kind" isComplexType="false" isExplicitlyDefined="false" clrType="System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<serializedValue />
|
||||||
|
</property>
|
||||||
|
<property path="/endpointConfiguration" isComplexType="false" isExplicitlyDefined="false" clrType="System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<serializedValue />
|
||||||
|
</property>
|
||||||
|
</properties>
|
||||||
|
</endpoint>
|
||||||
|
</endpoints>
|
||||||
|
</SavedWcfConfigurationInformation>
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<discovery xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/disco/">
|
||||||
|
<contractRef ref="http://localhost:8192/?wsdl" docRef="http://localhost:8192/" xmlns="http://schemas.xmlsoap.org/disco/scl/" />
|
||||||
|
</discovery>
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<xs:schema xmlns:tns="http://tempuri.org/" elementFormDefault="qualified" targetNamespace="http://tempuri.org/" xmlns:xs="http://www.w3.org/2001/XMLSchema">
|
||||||
|
<xs:element name="GetCurrentPosition">
|
||||||
|
<xs:complexType>
|
||||||
|
<xs:sequence />
|
||||||
|
</xs:complexType>
|
||||||
|
</xs:element>
|
||||||
|
<xs:element name="GetCurrentPositionResponse">
|
||||||
|
<xs:complexType>
|
||||||
|
<xs:sequence>
|
||||||
|
<xs:element minOccurs="0" name="GetCurrentPositionResult" nillable="true" type="xs:string" />
|
||||||
|
</xs:sequence>
|
||||||
|
</xs:complexType>
|
||||||
|
</xs:element>
|
||||||
|
</xs:schema>
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<xs:schema xmlns:tns="http://schemas.microsoft.com/2003/10/Serialization/" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://schemas.microsoft.com/2003/10/Serialization/" xmlns:xs="http://www.w3.org/2001/XMLSchema">
|
||||||
|
<xs:element name="anyType" nillable="true" type="xs:anyType" />
|
||||||
|
<xs:element name="anyURI" nillable="true" type="xs:anyURI" />
|
||||||
|
<xs:element name="base64Binary" nillable="true" type="xs:base64Binary" />
|
||||||
|
<xs:element name="boolean" nillable="true" type="xs:boolean" />
|
||||||
|
<xs:element name="byte" nillable="true" type="xs:byte" />
|
||||||
|
<xs:element name="dateTime" nillable="true" type="xs:dateTime" />
|
||||||
|
<xs:element name="decimal" nillable="true" type="xs:decimal" />
|
||||||
|
<xs:element name="double" nillable="true" type="xs:double" />
|
||||||
|
<xs:element name="float" nillable="true" type="xs:float" />
|
||||||
|
<xs:element name="int" nillable="true" type="xs:int" />
|
||||||
|
<xs:element name="long" nillable="true" type="xs:long" />
|
||||||
|
<xs:element name="QName" nillable="true" type="xs:QName" />
|
||||||
|
<xs:element name="short" nillable="true" type="xs:short" />
|
||||||
|
<xs:element name="string" nillable="true" type="xs:string" />
|
||||||
|
<xs:element name="unsignedByte" nillable="true" type="xs:unsignedByte" />
|
||||||
|
<xs:element name="unsignedInt" nillable="true" type="xs:unsignedInt" />
|
||||||
|
<xs:element name="unsignedLong" nillable="true" type="xs:unsignedLong" />
|
||||||
|
<xs:element name="unsignedShort" nillable="true" type="xs:unsignedShort" />
|
||||||
|
<xs:element name="char" nillable="true" type="tns:char" />
|
||||||
|
<xs:simpleType name="char">
|
||||||
|
<xs:restriction base="xs:int" />
|
||||||
|
</xs:simpleType>
|
||||||
|
<xs:element name="duration" nillable="true" type="tns:duration" />
|
||||||
|
<xs:simpleType name="duration">
|
||||||
|
<xs:restriction base="xs:duration">
|
||||||
|
<xs:pattern value="\-?P(\d*D)?(T(\d*H)?(\d*M)?(\d*(\.\d*)?S)?)?" />
|
||||||
|
<xs:minInclusive value="-P10675199DT2H48M5.4775808S" />
|
||||||
|
<xs:maxInclusive value="P10675199DT2H48M5.4775807S" />
|
||||||
|
</xs:restriction>
|
||||||
|
</xs:simpleType>
|
||||||
|
<xs:element name="guid" nillable="true" type="tns:guid" />
|
||||||
|
<xs:simpleType name="guid">
|
||||||
|
<xs:restriction base="xs:string">
|
||||||
|
<xs:pattern value="[\da-fA-F]{8}-[\da-fA-F]{4}-[\da-fA-F]{4}-[\da-fA-F]{4}-[\da-fA-F]{12}" />
|
||||||
|
</xs:restriction>
|
||||||
|
</xs:simpleType>
|
||||||
|
<xs:attribute name="FactoryType" type="xs:QName" />
|
||||||
|
<xs:attribute name="Id" type="xs:ID" />
|
||||||
|
<xs:attribute name="Ref" type="xs:IDREF" />
|
||||||
|
</xs:schema>
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
<configuration>
|
||||||
|
<system.serviceModel>
|
||||||
|
<bindings>
|
||||||
|
<basicHttpBinding>
|
||||||
|
<binding name="BasicHttpBinding_IGpsEmulatorService" maxBufferSize="2147483647"
|
||||||
|
maxReceivedMessageSize="2147483647">
|
||||||
|
<security mode="None" />
|
||||||
|
</binding>
|
||||||
|
</basicHttpBinding>
|
||||||
|
</bindings>
|
||||||
|
<client>
|
||||||
|
<endpoint address="http://localhost:8192/GpsEmulator" binding="basicHttpBinding"
|
||||||
|
bindingConfiguration="BasicHttpBinding_IGpsEmulatorService"
|
||||||
|
contract="ServiceReference1.IGpsEmulatorService" name="BasicHttpBinding_IGpsEmulatorService" />
|
||||||
|
</client>
|
||||||
|
</system.serviceModel>
|
||||||
|
</configuration>
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
<Application
|
||||||
|
x:Class="GpsEmulatorPhoneTestClient.App"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
|
||||||
|
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone">
|
||||||
|
|
||||||
|
<!--Application Resources-->
|
||||||
|
<Application.Resources>
|
||||||
|
</Application.Resources>
|
||||||
|
|
||||||
|
<Application.ApplicationLifetimeObjects>
|
||||||
|
<!--Required object that handles lifetime events for the application-->
|
||||||
|
<shell:PhoneApplicationService
|
||||||
|
Launching="Application_Launching" Closing="Application_Closing"
|
||||||
|
Activated="Application_Activated" Deactivated="Application_Deactivated"/>
|
||||||
|
</Application.ApplicationLifetimeObjects>
|
||||||
|
|
||||||
|
</Application>
|
||||||
@@ -0,0 +1,138 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Net;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
using System.Windows.Documents;
|
||||||
|
using System.Windows.Input;
|
||||||
|
using System.Windows.Media;
|
||||||
|
using System.Windows.Media.Animation;
|
||||||
|
using System.Windows.Navigation;
|
||||||
|
using System.Windows.Shapes;
|
||||||
|
using Microsoft.Phone.Controls;
|
||||||
|
using Microsoft.Phone.Shell;
|
||||||
|
using System.Threading;
|
||||||
|
|
||||||
|
namespace GpsEmulatorPhoneTestClient
|
||||||
|
{
|
||||||
|
public partial class App : Application
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Provides easy access to the root frame of the Phone Application.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The root frame of the Phone Application.</returns>
|
||||||
|
public PhoneApplicationFrame RootFrame { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Constructor for the Application object.
|
||||||
|
/// </summary>
|
||||||
|
public App()
|
||||||
|
{
|
||||||
|
// Global handler for uncaught exceptions.
|
||||||
|
UnhandledException += Application_UnhandledException;
|
||||||
|
|
||||||
|
// Show graphics profiling information while debugging.
|
||||||
|
if (System.Diagnostics.Debugger.IsAttached)
|
||||||
|
{
|
||||||
|
// Display the current frame rate counters.
|
||||||
|
Application.Current.Host.Settings.EnableFrameRateCounter = true;
|
||||||
|
|
||||||
|
// Show the areas of the app that are being redrawn in each frame.
|
||||||
|
//Application.Current.Host.Settings.EnableRedrawRegions = true;
|
||||||
|
|
||||||
|
// Enable non-production analysis visualization mode,
|
||||||
|
// which shows areas of a page that are being GPU accelerated with a colored overlay.
|
||||||
|
//Application.Current.Host.Settings.EnableCacheVisualization = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Standard Silverlight initialization
|
||||||
|
InitializeComponent();
|
||||||
|
|
||||||
|
// Phone-specific initialization
|
||||||
|
InitializePhoneApplication();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Code to execute when the application is launching (eg, from Start)
|
||||||
|
// This code will not execute when the application is reactivated
|
||||||
|
private void Application_Launching(object sender, LaunchingEventArgs e)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
// Code to execute when the application is activated (brought to foreground)
|
||||||
|
// This code will not execute when the application is first launched
|
||||||
|
private void Application_Activated(object sender, ActivatedEventArgs e)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
// Code to execute when the application is deactivated (sent to background)
|
||||||
|
// This code will not execute when the application is closing
|
||||||
|
private void Application_Deactivated(object sender, DeactivatedEventArgs e)
|
||||||
|
{
|
||||||
|
Thread.Sleep(TimeSpan.FromSeconds(20));
|
||||||
|
System.Diagnostics.Debugger.Break();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Code to execute when the application is closing (eg, user hit Back)
|
||||||
|
// This code will not execute when the application is deactivated
|
||||||
|
private void Application_Closing(object sender, ClosingEventArgs e)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
// Code to execute if a navigation fails
|
||||||
|
private void RootFrame_NavigationFailed(object sender, NavigationFailedEventArgs e)
|
||||||
|
{
|
||||||
|
if (System.Diagnostics.Debugger.IsAttached)
|
||||||
|
{
|
||||||
|
// A navigation has failed; break into the debugger
|
||||||
|
System.Diagnostics.Debugger.Break();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Code to execute on Unhandled Exceptions
|
||||||
|
private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e)
|
||||||
|
{
|
||||||
|
if (System.Diagnostics.Debugger.IsAttached)
|
||||||
|
{
|
||||||
|
// An unhandled exception has occurred; break into the debugger
|
||||||
|
System.Diagnostics.Debugger.Break();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Phone application initialization
|
||||||
|
|
||||||
|
// Avoid double-initialization
|
||||||
|
private bool phoneApplicationInitialized = false;
|
||||||
|
|
||||||
|
// Do not add any additional code to this method
|
||||||
|
private void InitializePhoneApplication()
|
||||||
|
{
|
||||||
|
if (phoneApplicationInitialized)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Create the frame but don't set it as RootVisual yet; this allows the splash
|
||||||
|
// screen to remain active until the application is ready to render.
|
||||||
|
RootFrame = new PhoneApplicationFrame();
|
||||||
|
RootFrame.Navigated += CompleteInitializePhoneApplication;
|
||||||
|
|
||||||
|
// Handle navigation failures
|
||||||
|
RootFrame.NavigationFailed += RootFrame_NavigationFailed;
|
||||||
|
|
||||||
|
// Ensure we don't initialize again
|
||||||
|
phoneApplicationInitialized = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Do not add any additional code to this method
|
||||||
|
private void CompleteInitializePhoneApplication(object sender, NavigationEventArgs e)
|
||||||
|
{
|
||||||
|
// Set the root visual to allow the application to render
|
||||||
|
if (RootVisual != RootFrame)
|
||||||
|
RootVisual = RootFrame;
|
||||||
|
|
||||||
|
// Remove this handler since it is no longer needed
|
||||||
|
RootFrame.Navigated -= CompleteInitializePhoneApplication;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
|
After Width: | Height: | Size: 1.8 KiB |
|
After Width: | Height: | Size: 3.4 KiB |
@@ -0,0 +1,6 @@
|
|||||||
|
<Deployment xmlns="http://schemas.microsoft.com/client/2007/deployment" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" EntryPointAssembly="GpsEmulatorPhoneTestClient" EntryPointType="GpsEmulatorPhoneTestClient.App" RuntimeVersion="3.0.40624.0">
|
||||||
|
<Deployment.Parts>
|
||||||
|
<AssemblyPart x:Name="GpsEmulatorPhoneTestClient" Source="GpsEmulatorPhoneTestClient.dll" />
|
||||||
|
<AssemblyPart x:Name="GpsEmulatorClient" Source="GpsEmulatorClient.dll" />
|
||||||
|
</Deployment.Parts>
|
||||||
|
</Deployment>
|
||||||
|
After Width: | Height: | Size: 1.8 KiB |
|
After Width: | Height: | Size: 3.4 KiB |
@@ -0,0 +1,6 @@
|
|||||||
|
<Deployment xmlns="http://schemas.microsoft.com/client/2007/deployment" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" EntryPointAssembly="GpsEmulatorPhoneTestClient" EntryPointType="GpsEmulatorPhoneTestClient.App" RuntimeVersion="3.0.40624.0">
|
||||||
|
<Deployment.Parts>
|
||||||
|
<AssemblyPart x:Name="GpsEmulatorPhoneTestClient" Source="GpsEmulatorPhoneTestClient.dll" />
|
||||||
|
<AssemblyPart x:Name="GpsEmulatorClient" Source="GpsEmulatorClient.dll" />
|
||||||
|
</Deployment.Parts>
|
||||||
|
</Deployment>
|
||||||
|
After Width: | Height: | Size: 1.8 KiB |
|
After Width: | Height: | Size: 3.4 KiB |
@@ -0,0 +1,125 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
|
<ProductVersion>10.0.20506</ProductVersion>
|
||||||
|
<SchemaVersion>2.0</SchemaVersion>
|
||||||
|
<ProjectGuid>{BF7316A8-A2C5-4176-8D7F-672AD12F474D}</ProjectGuid>
|
||||||
|
<ProjectTypeGuids>{C089C8C0-30E0-4E22-80C0-CE093F111A43};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
|
||||||
|
<OutputType>Library</OutputType>
|
||||||
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
|
<RootNamespace>GpsEmulatorPhoneTestClient</RootNamespace>
|
||||||
|
<AssemblyName>GpsEmulatorPhoneTestClient</AssemblyName>
|
||||||
|
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||||
|
<SilverlightVersion>$(TargetFrameworkVersion)</SilverlightVersion>
|
||||||
|
<TargetFrameworkProfile>WindowsPhone</TargetFrameworkProfile>
|
||||||
|
<TargetFrameworkIdentifier>Silverlight</TargetFrameworkIdentifier>
|
||||||
|
<SilverlightApplication>true</SilverlightApplication>
|
||||||
|
<SupportedCultures>
|
||||||
|
</SupportedCultures>
|
||||||
|
<XapOutputs>true</XapOutputs>
|
||||||
|
<GenerateSilverlightManifest>true</GenerateSilverlightManifest>
|
||||||
|
<XapFilename>GpsEmulatorPhoneTestClient.xap</XapFilename>
|
||||||
|
<SilverlightManifestTemplate>Properties\AppManifest.xml</SilverlightManifestTemplate>
|
||||||
|
<SilverlightAppEntry>GpsEmulatorPhoneTestClient.App</SilverlightAppEntry>
|
||||||
|
<ValidateXaml>true</ValidateXaml>
|
||||||
|
<ThrowErrorsInValidation>true</ThrowErrorsInValidation>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
<OutputPath>Bin\Debug</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE;SILVERLIGHT;WINDOWS_PHONE</DefineConstants>
|
||||||
|
<NoStdLib>true</NoStdLib>
|
||||||
|
<NoConfig>true</NoConfig>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>Bin\Release</OutputPath>
|
||||||
|
<DefineConstants>TRACE;SILVERLIGHT;WINDOWS_PHONE</DefineConstants>
|
||||||
|
<NoStdLib>true</NoStdLib>
|
||||||
|
<NoConfig>true</NoConfig>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Tests|AnyCPU'">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<OutputPath>bin\Tests\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE;SILVERLIGHT;WINDOWS_PHONE</DefineConstants>
|
||||||
|
<NoStdLib>true</NoStdLib>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
|
<CodeAnalysisLogFile>Bin\Debug\GpsEmulatorPhoneTestClient.dll.CodeAnalysisLog.xml</CodeAnalysisLogFile>
|
||||||
|
<CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
|
||||||
|
<CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||||
|
<CodeAnalysisRuleSetDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets</CodeAnalysisRuleSetDirectories>
|
||||||
|
<CodeAnalysisRuleDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules</CodeAnalysisRuleDirectories>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="Microsoft.Phone" />
|
||||||
|
<Reference Include="Microsoft.Phone.Interop" />
|
||||||
|
<Reference Include="System.Device" />
|
||||||
|
<Reference Include="System.Windows" />
|
||||||
|
<Reference Include="system" />
|
||||||
|
<Reference Include="System.Core" />
|
||||||
|
<Reference Include="System.Net" />
|
||||||
|
<Reference Include="System.Xml" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="App.xaml.cs">
|
||||||
|
<DependentUpon>App.xaml</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="MainPage.xaml.cs">
|
||||||
|
<DependentUpon>MainPage.xaml</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ApplicationDefinition Include="App.xaml">
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
</ApplicationDefinition>
|
||||||
|
<Page Include="MainPage.xaml">
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
</Page>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="Properties\AppManifest.xml" />
|
||||||
|
<None Include="Properties\WMAppManifest.xml" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Content Include="ApplicationIcon.png">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
|
<Content Include="Background.png">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
|
<Resource Include="Images\GpsOn.png" />
|
||||||
|
<Content Include="SplashScreenImage.jpg" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\GpsEmulatorClient\GpsEmulatorClient.csproj">
|
||||||
|
<Project>{A128812A-1249-4562-BDF4-5E17951B8434}</Project>
|
||||||
|
<Name>GpsEmulatorClient</Name>
|
||||||
|
</ProjectReference>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup />
|
||||||
|
<Import Project="$(MSBuildExtensionsPath)\Microsoft\Silverlight for Phone\$(TargetFrameworkVersion)\Microsoft.Silverlight.$(TargetFrameworkProfile).Overrides.targets" />
|
||||||
|
<Import Project="$(MSBuildExtensionsPath)\Microsoft\Silverlight for Phone\$(TargetFrameworkVersion)\Microsoft.Silverlight.CSharp.targets" />
|
||||||
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
|
<Target Name="BeforeBuild">
|
||||||
|
</Target>
|
||||||
|
<Target Name="AfterBuild">
|
||||||
|
</Target>
|
||||||
|
-->
|
||||||
|
<ProjectExtensions />
|
||||||
|
</Project>
|
||||||
|
After Width: | Height: | Size: 3.1 KiB |
@@ -0,0 +1,61 @@
|
|||||||
|
<phone:PhoneApplicationPage
|
||||||
|
x:Class="GpsEmulatorPhoneTestClient.MainPage"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
|
||||||
|
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="696"
|
||||||
|
FontFamily="{StaticResource PhoneFontFamilyNormal}"
|
||||||
|
FontSize="{StaticResource PhoneFontSizeNormal}"
|
||||||
|
Foreground="{StaticResource PhoneForegroundBrush}"
|
||||||
|
SupportedOrientations="Portrait" Orientation="Portrait"
|
||||||
|
shell:SystemTray.IsVisible="True">
|
||||||
|
|
||||||
|
<!--LayoutRoot is the root grid where all page content is placed-->
|
||||||
|
<Grid x:Name="LayoutRoot" Background="Transparent">
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="Auto"/>
|
||||||
|
<RowDefinition Height="*"/>
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
|
||||||
|
<!--TitlePanel contains the name of the application and page title-->
|
||||||
|
<StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
|
||||||
|
<TextBlock x:Name="ApplicationTitle" Text="GPS Emulator Test Client" Style="{StaticResource PhoneTextNormalStyle}"/>
|
||||||
|
<TextBlock x:Name="PageTitle" Text="My Location" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
|
||||||
|
</StackPanel>
|
||||||
|
|
||||||
|
<!--ContentPanel - place additional content here-->
|
||||||
|
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition/>
|
||||||
|
<ColumnDefinition/>
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition/>
|
||||||
|
<RowDefinition/>
|
||||||
|
<RowDefinition/>
|
||||||
|
<RowDefinition/>
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<TextBlock Grid.Row="0" Grid.Column="0" VerticalAlignment="Center" FontSize="{StaticResource PhoneFontSizeLarge}">Time Acquired</TextBlock>
|
||||||
|
<TextBlock Grid.Row="0" Grid.Column="1" VerticalAlignment="Center" FontSize="{StaticResource PhoneFontSizeMedium}" x:Name="tbTimeAcquired">Undefined</TextBlock>
|
||||||
|
<TextBlock Grid.Row="1" Grid.Column="0" VerticalAlignment="Center" FontSize="{StaticResource PhoneFontSizeLarge}">Latitude</TextBlock>
|
||||||
|
<TextBlock Grid.Row="1" Grid.Column="1" VerticalAlignment="Center" FontSize="{StaticResource PhoneFontSizeMedium}" x:Name="tbLatitude">Undefined</TextBlock>
|
||||||
|
<TextBlock Grid.Row="2" Grid.Column="0" VerticalAlignment="Center" FontSize="{StaticResource PhoneFontSizeLarge}">Longtitude</TextBlock>
|
||||||
|
<TextBlock Grid.Row="2" Grid.Column="1" VerticalAlignment="Center" FontSize="{StaticResource PhoneFontSizeMedium}" x:Name="tbLongtitude">Undefined</TextBlock>
|
||||||
|
<TextBlock Grid.Row="3" Grid.Column="0" VerticalAlignment="Center" FontSize="{StaticResource PhoneFontSizeLarge}">Device Status</TextBlock>
|
||||||
|
<TextBlock Grid.Row="3" Grid.Column="1" VerticalAlignment="Center" FontSize="{StaticResource PhoneFontSizeMedium}" x:Name="tbDeviceStatus">Undefined</TextBlock>
|
||||||
|
</Grid>
|
||||||
|
</Grid>
|
||||||
|
|
||||||
|
<!--Sample code showing usage of ApplicationBar-->
|
||||||
|
<phone:PhoneApplicationPage.ApplicationBar>
|
||||||
|
<shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
|
||||||
|
<shell:ApplicationBarIconButton x:Name="btnStart" IconUri="/Images/GpsOn.png" Text="Start" Click="btnStart_Click"/>
|
||||||
|
<shell:ApplicationBarIconButton x:Name="btnStop" IconUri="/Images/appbar_button2.png" Text="Stop" Click="btnStop_Click"/>
|
||||||
|
<shell:ApplicationBarIconButton x:Name="btnTicks" IconUri="/Images/appbar_button2.png" Text="Ticks" Click="btnTicks_Click"/>
|
||||||
|
</shell:ApplicationBar>
|
||||||
|
</phone:PhoneApplicationPage.ApplicationBar>
|
||||||
|
|
||||||
|
</phone:PhoneApplicationPage>
|
||||||
@@ -0,0 +1,76 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// define GPS EMULATOR when working with Windows Phone GPS Emulator to simulate location
|
||||||
|
#define GPS_EMULATOR
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Net;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
using System.Windows.Documents;
|
||||||
|
using System.Windows.Input;
|
||||||
|
using System.Windows.Media;
|
||||||
|
using System.Windows.Media.Animation;
|
||||||
|
using System.Windows.Shapes;
|
||||||
|
using Microsoft.Phone.Controls;
|
||||||
|
using GpsEmulatorClient;
|
||||||
|
using System.Device.Location;
|
||||||
|
using System.Threading;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
namespace GpsEmulatorPhoneTestClient
|
||||||
|
{
|
||||||
|
public partial class MainPage : PhoneApplicationPage
|
||||||
|
{
|
||||||
|
// the wathcer through which we'll get the device location
|
||||||
|
private IGeoPositionWatcher<GeoCoordinate> _Watcher;
|
||||||
|
private static int counter = 0;
|
||||||
|
|
||||||
|
// Constructor
|
||||||
|
public MainPage()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
|
||||||
|
#if GPS_EMULATOR
|
||||||
|
_Watcher = new GpsEmulatorClient.GeoCoordinateWatcher();
|
||||||
|
#else
|
||||||
|
_Watcher = new System.Device.Location.GeoCoordinateWatcher();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
_Watcher.PositionChanged += new EventHandler<GeoPositionChangedEventArgs<GeoCoordinate>>(watcher_PositionChanged);
|
||||||
|
_Watcher.StatusChanged += new EventHandler<GeoPositionStatusChangedEventArgs>(watcher_StatusChanged);
|
||||||
|
}
|
||||||
|
|
||||||
|
void watcher_StatusChanged(object sender, GeoPositionStatusChangedEventArgs e)
|
||||||
|
{
|
||||||
|
tbDeviceStatus.Text = e.Status.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
void watcher_PositionChanged(object sender, GeoPositionChangedEventArgs<GeoCoordinate> e)
|
||||||
|
{
|
||||||
|
tbTimeAcquired.Text = e.Position.Timestamp.ToString();
|
||||||
|
tbLatitude.Text = e.Position.Location.Latitude.ToString();
|
||||||
|
tbLongtitude.Text = e.Position.Location.Longitude.ToString();
|
||||||
|
|
||||||
|
System.Diagnostics.Debug.WriteLine("watcher_PositionChanged + " + DateTime.Now.Second);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void btnStart_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
_Watcher.Start();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void btnStop_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
_Watcher.Stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void btnTicks_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
PageTitle.Text = counter.ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
<Deployment xmlns="http://schemas.microsoft.com/client/2007/deployment"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
>
|
||||||
|
<Deployment.Parts>
|
||||||
|
</Deployment.Parts>
|
||||||
|
</Deployment>
|
||||||