Click here to Skip to main content
15,897,371 members
Articles / Mobile Apps

Using the Skyhook Wireless XPS Positioning Service in Managed Code

Rate me:
Please Sign up or sign in to vote.
4.95/5 (15 votes)
20 Jan 2009CPOL28 min read 89.2K   1.4K   57  
Wrapper and sample programs demonstrating the use of the Skyhook Wireless XPS SDK (hybrid position system using GPS, WiFi Positioning, and Celltower positioning)
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;

namespace J2i.Net.FindMe.Common
{
    static class ApplicationEnvironment
    {
        static  readonly string ApprovedContactListFileName = "approvedContacts";
        static readonly string SettingsFileName = "user.settings";
        static readonly string TileFolderName = "Tile";

        static string _applicationFolder=null;
        static string _approvedContactListFilePath = null;
        static string _settingsFilePath = null;
        static string _tileFolderPath = null;
        static string _databasePath = null;
        static string _connectionString = null;
        static string _alertSoundPath = null;

        

        public static string ApplicationFolder
        {
            get
            {
                if (_applicationFolder == null)
                {
                    _applicationFolder =  Path.GetDirectoryName(typeof(ApplicationEnvironment).Assembly.GetModules()[0].FullyQualifiedName);
                }
                return _applicationFolder;
            }
        }

        public static string ApprovedContactListFilePath
        {
            get
            {
                if (_approvedContactListFilePath == null)
                {
                    _approvedContactListFilePath = String.Format("{0}{2}{1}", ApplicationFolder, ApprovedContactListFileName, Path.DirectorySeparatorChar);
                }
                return _approvedContactListFilePath;
            }
        }

        public static string SettingsFilePath
        {
            get
            {
                if (_settingsFilePath == null)
                {
                    _settingsFilePath = String.Format("{0}{2}{1}", ApplicationFolder, SettingsFileName, Path.DirectorySeparatorChar);
                }
                return _settingsFilePath;
            }
        }

        public static  string TileFolderPath
        {
            get
            {
                if (_tileFolderPath == null)
                {
                    _tileFolderPath = String.Format("{0}{2}{1}", ApplicationFolder, TileFolderName, Path.DirectorySeparatorChar);
                    if(!Directory.Exists(_tileFolderPath))
                        Directory.CreateDirectory(_tileFolderPath);
                }
                return _tileFolderPath;
            }
        }

        public static string DatabasePath
        {
            get
            {
                if (_databasePath == null)
                {
                    _databasePath = Path.Combine(ApplicationFolder, "Assets\\Data\\LocationLog.sdf");
                }
                return _databasePath;
            }
        }

        public static string ConnectionString
        {
            get
            {
                if (_connectionString == null)
                {
                    _connectionString = String.Format("Data Source={0}",DatabasePath);
                }
                return _connectionString;
            }
        }

        public static string AlertSoundPath
        {
            get
            {
                if (_alertSoundPath == null)
                {
                    _alertSoundPath = Path.Combine(ApplicationFolder, "Assets\\Sound\\Alert.wav");
                }
                return _alertSoundPath;
            }
        }




    }
}

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.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer
United States United States
I attended Southern Polytechnic State University and earned a Bachelors of Science in Computer Science and later returned to earn a Masters of Science in Software Engineering. I've largely developed solutions that are based on a mix of Microsoft technologies with open source technologies mixed in. I've got an interest in astronomy and you'll see that interest overflow into some of my code project articles from time to time.



Twitter:@j2inet

Instagram: j2inet


Comments and Discussions