- wimowifipositioningservice_code.zip
- WiMoWiFiPositioningService
- J2i.Net.FindMe
- Assets
- Data
- LocationLog.sdf
- Images
- Allowed.bmp
- Disallowed.bmp
- Sound
- Alert.wav
- bin
- Debug
- Common
- Controls
- Interface
- J2i.Net.FindMe.csproj
- J2i.Net.FindMe.csproj.user
- J2i.Net.FindMe.idc
- Program.cs
- Properties
- Utility
- Web References
- VE.Common
- common.disco
- common.wsdl
- CountryRegionInfo.datasource
- DataSource.datasource
- EntityType.datasource
- Reference.cs
- Reference.map
- VersionInfo.datasource
- VE.Geocode
- VE.Imagery
- wpsapi.dll
- WpsProxy.dll
- J2i.Net.LocationSettings
- J2i.Net.MapPoint.RenderMap
- bin
- Debug
- J2i.Net.LocationSettings.dll
- J2i.Net.MapPoint.RenderMap.exe
- J2i.Net.WiFiPositioning.dll
- WpsProxy.cs
- WpsProxy.dll
- Form1.cs
- Form1.Designer.cs
- Form1.resx
- J2i.Net.MapPoint.RenderMap.csproj
- J2i.Net.MapPoint.RenderMap.csproj.user
- Program.cs
- Properties
- Web References
- VirtualEarthCommon
- Address1.datasource
- CountryRegionInfo1.datasource
- DataSource1.datasource
- EntityType1.datasource
- FindResults1.datasource
- LatLong1.datasource
- LineDriveMapImage1.datasource
- Location1.datasource
- MapImage1.datasource
- mappoint.wsdl
- MapViewRepresentations1.datasource
- PixelCoord1.datasource
- Reference.cs
- Reference.map
- Route1.datasource
- VersionInfo1.datasource
- VirtualEarthImaging
- wpsapi.dll
- WpsProxy.dll
- J2i.Net.OpenCellID.Client
- J2i.Net.OpenCellID
- J2i.Net.WiFiPositioning
- MapPoint.SimpleClient
- SetMyKeys
- SimpleClient
- WiMoWiFiPositioning.html
- WiMoWiFiPositioningService.sln
- WpsProxy
|
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Net;
using System.Text;
using System.Windows.Forms;
using MapPoint.SimpleClient.MapPoint.Service;
using J2i.Net.WiFiPositioning;
using J2i.Net.LocationSettings;
namespace MapPoint.SimpleClient
{
public partial class Form1 : Form
{
Wps _wps = null;
delegate void DisplayResultsDelegate(FindResult[] resultList);
RegistrySettings _registrySettings = new RegistrySettings();
DisplayResultsDelegate _displayResults;
StringDictionary _entityDictionary = new StringDictionary();
string[,] _entityData = new string[,] {
{ "Manufacturing", "SICDivD" },
{"Wholesale Trade", "SICDivF"},
{"Retail Trade", "SICDivG"} ,
{"Services","SICDivI"},
{"Fast Food","FoodType27"},
{"Indian Food","FoodType8"},
{"Sea Food","FoodType13"}
};
public Form1()
{
InitializeComponent();
_displayResults = new DisplayResultsDelegate(this.DisplayResults);
for (int i = 0; i < _entityData.GetUpperBound(0); ++i)
{
_entityDictionary.Add(_entityData[i, 0], _entityData[i,1]);
dupQuery.Items.Add(_entityData[i, 0]);
}
dupQuery.Text = _entityData[0, 0];
ApplySettings();
}
void ApplySettings()
{
if (_wps != null)
_wps.Dispose();
_wps = new Wps(_registrySettings.SkyhookUser, _registrySettings.SkyhookRealm);
}
void RequestSettingsFromUser()
{
J2i.Net.LocationSettings.AccountForm af = new AccountForm();
if (DialogResult.OK == af.ShowDialog())
{
_registrySettings.LoadApplicationKeyValues();
ApplySettings();
}
}
void LoadSettings()
{
_registrySettings.LoadApplicationKeyValues();
if((_registrySettings.MapPointAppID.Length==0)||(_registrySettings.MapPointPassword.Length==0))
ApplySettings();
}
private void miSearch_Click(object sender, EventArgs e)
{
MapPoint.Service.FindServiceSoap findService = new global::MapPoint.SimpleClient.MapPoint.Service.FindServiceSoap();
//To prevent to annoying URI Exception in the debug output. Optional.
findService.Proxy = System.Net.GlobalProxySelection.GetEmptyWebProxy();
//Specify our credentials for authorization
findService.Credentials = new NetworkCredential(_registrySettings.MapPointAppID, _registrySettings.MapPointPassword);
findService.PreAuthenticate = true;
FindFilter findFilter = new FindFilter();
//http://msdn.microsoft.com/en-us/library/cc534903.aspx
findFilter.EntityTypeName = _entityDictionary[dupQuery.Text];
//only display the display name for each search result
findFilter.PropertyNames = new string[]{"DisplayName"};
MapPoint.Service.LatLong latLong = new MapPoint.Service.LatLong();
latLong.Latitude = Double.Parse(txtLatitude.Text);
latLong.Longitude = Double.Parse(txtLongitude.Text);
MapPoint.Service.FindNearbySpecification findSpecification = new MapPoint.Service.FindNearbySpecification();
findSpecification.DataSourceName = _registrySettings.MapPointDataSource;
//If the user has not selected a datasource then we will
//use the NavTech North American datasource
if (findSpecification.DataSourceName.Length == 0)
findSpecification.DataSourceName = "NavTech.NA";
findSpecification.LatLong = latLong;
findSpecification.Distance = 100;
findSpecification.Filter = findFilter;
FindResults resultList = null;
try
{
resultList = findService.FindNearby(findSpecification);
if (resultList.Results != null)
{
DisplayResults(resultList.Results);
}
}
catch(Exception exc)
{
System.Diagnostics.Debug.WriteLine(exc.ToString());
}
}
void DisplayResults(FindResult[] resultList)
{
if (this.InvokeRequired)
{
this.Invoke(_displayResults, new object[] { resultList });
}
else
{
lstResults.Items.Clear();
if ((resultList == null) || (resultList.Length == 0))
{
lstResults.Items.Add("No Results");
}
else
{
for (int i = 0; i < resultList.Length; ++i)
{
lstResults.Items.Add(resultList[i].FoundLocation.Entity.DisplayName);
}
}
}
}
private void Form1_Load(object sender, EventArgs e)
{
LoadSettings();
UpdatePosition();
}
void UpdatePosition()
{
WiFiLocation location = null;
if (ResultCode.OK == _wps.GetWiFiLocation(StreetAddressLookupType.NoStreet, out location))
{
this.txtLatitude.Text = location.Latitude.ToString();
this.txtLongitude.Text = location.Longitude.ToString();
}
else
{
MessageBox.Show("Could not acquire location");
}
}
private void miUpdatePosition_Click(object sender, EventArgs e)
{
UpdatePosition();
}
private void miSettings_Click(object sender, EventArgs e)
{
RequestSettingsFromUser();
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.