using System; using System.IO.IsolatedStorage; using MahTweets.Mobile.Core.Interfaces; using Microsoft.Phone.Controls; namespace MahTweets.Mobile.Core { public class ApplicationSettings : IApplicationSettings { public bool RunBehindLockScreen { get { if (!IsolatedStorageSettings.ApplicationSettings.Contains("RunBehindLockScreen")) IsolatedStorageSettings.ApplicationSettings.Add("RunBehindLockScreen", false); return (bool)IsolatedStorageSettings.ApplicationSettings["RunBehindLockScreen"]; } set { if (!IsolatedStorageSettings.ApplicationSettings.Contains("RunBehindLockScreen")) IsolatedStorageSettings.ApplicationSettings.Add("RunBehindLockScreen", value); IsolatedStorageSettings.ApplicationSettings["RunBehindLockScreen"] = value; } } public bool AllowGPS { get { if (!IsolatedStorageSettings.ApplicationSettings.Contains("AllowGPS")) IsolatedStorageSettings.ApplicationSettings.Add("AllowGPS", false); return (bool)IsolatedStorageSettings.ApplicationSettings["AllowGPS"]; } set { if (!IsolatedStorageSettings.ApplicationSettings.Contains("AllowGPS")) IsolatedStorageSettings.ApplicationSettings.Add("AllowGPS", value); IsolatedStorageSettings.ApplicationSettings["AllowGPS"] = value; } } public string UploaderName { get { if (IsolatedStorageSettings.ApplicationSettings.Contains("UploaderName")) return (string)IsolatedStorageSettings.ApplicationSettings["UploaderName"]; return null; } set { if (!IsolatedStorageSettings.ApplicationSettings.Contains("UploaderName")) IsolatedStorageSettings.ApplicationSettings.Add("UploaderName", value); else IsolatedStorageSettings.ApplicationSettings["UploaderName"] = value; } } public string UrlShortener { get { if (!IsolatedStorageSettings.ApplicationSettings.Contains("UrlShortener")) IsolatedStorageSettings.ApplicationSettings.Add("UrlShortener", "is.gd"); return (string)IsolatedStorageSettings.ApplicationSettings["UrlShortener"]; } set { if (!IsolatedStorageSettings.ApplicationSettings.Contains("UrlShortener")) IsolatedStorageSettings.ApplicationSettings.Add("UrlShortener", value); IsolatedStorageSettings.ApplicationSettings["UrlShortener"] = value; } } public string PushAccount { get { if (!IsolatedStorageSettings.ApplicationSettings.Contains("PushAccount")) return null; return (string)IsolatedStorageSettings.ApplicationSettings["PushAccount"]; } set { if (!IsolatedStorageSettings.ApplicationSettings.Contains("PushAccount")) IsolatedStorageSettings.ApplicationSettings.Add("PushAccount", value); IsolatedStorageSettings.ApplicationSettings["PushAccount"] = value; } } public PushNotificationOptions Push { get { if (!IsolatedStorageSettings.ApplicationSettings.Contains("Push")) IsolatedStorageSettings.ApplicationSettings.Add("Push", PushNotificationOptions.None); return (PushNotificationOptions)IsolatedStorageSettings.ApplicationSettings["Push"]; } set { if (!IsolatedStorageSettings.ApplicationSettings.Contains("Push")) IsolatedStorageSettings.ApplicationSettings.Add("Push", value); IsolatedStorageSettings.ApplicationSettings["Push"] = value; } } public DateTime LastRefreshTime { get { if (!IsolatedStorageSettings.ApplicationSettings.Contains("LastRefreshTime")) IsolatedStorageSettings.ApplicationSettings.Add("LastRefreshTime", DateTime.Now.Subtract(new TimeSpan(1))); return (DateTime)IsolatedStorageSettings.ApplicationSettings["LastRefreshTime"]; } set { if (!IsolatedStorageSettings.ApplicationSettings.Contains("LastRefreshTime")) IsolatedStorageSettings.ApplicationSettings.Add("LastRefreshTime", value); IsolatedStorageSettings.ApplicationSettings["LastRefreshTime"] = value; } } public bool PullToRefresh { get { if (!IsolatedStorageSettings.ApplicationSettings.Contains("PullToRefresh")) IsolatedStorageSettings.ApplicationSettings.Add("PullToRefresh", false); return (bool)IsolatedStorageSettings.ApplicationSettings["PullToRefresh"]; } set { if (!IsolatedStorageSettings.ApplicationSettings.Contains("PullToRefresh")) IsolatedStorageSettings.ApplicationSettings.Add("PullToRefresh", value); IsolatedStorageSettings.ApplicationSettings["PullToRefresh"] = value; } } public string InstaPaperUsername { get { if (IsolatedStorageSettings.ApplicationSettings.Contains("InstaPaperUsername")) return (string)IsolatedStorageSettings.ApplicationSettings["InstaPaperUsername"]; return null; } set { if (!IsolatedStorageSettings.ApplicationSettings.Contains("InstaPaperUsername")) IsolatedStorageSettings.ApplicationSettings.Add("InstaPaperUsername", value); else IsolatedStorageSettings.ApplicationSettings["InstaPaperUsername"] = value; } } public string InstaPaperPassword { get { if (IsolatedStorageSettings.ApplicationSettings.Contains("InstaPaperPassword")) return (string)IsolatedStorageSettings.ApplicationSettings["InstaPaperPassword"]; return null; } set { if (!IsolatedStorageSettings.ApplicationSettings.Contains("InstaPaperPassword")) IsolatedStorageSettings.ApplicationSettings.Add("InstaPaperPassword", value); else IsolatedStorageSettings.ApplicationSettings["InstaPaperPassword"] = value; ; } } public bool UseInternalBrowser { get { if (IsolatedStorageSettings.ApplicationSettings.Contains("UseInternalBrowser")) return (bool)IsolatedStorageSettings.ApplicationSettings["UseInternalBrowser"]; IsolatedStorageSettings.ApplicationSettings.Add("UseInternalBrowser", true); return true; } set { if (!IsolatedStorageSettings.ApplicationSettings.Contains("UseInternalBrowser")) IsolatedStorageSettings.ApplicationSettings.Add("UseInternalBrowser", value); else IsolatedStorageSettings.ApplicationSettings["UseInternalBrowser"] = value; } } public DistanceUnit DistanceUnit { get { if (IsolatedStorageSettings.ApplicationSettings.Contains("DistanceUnit")) return (DistanceUnit)IsolatedStorageSettings.ApplicationSettings["DistanceUnit"]; return Core.DistanceUnit.Kilometres; } set { if (IsolatedStorageSettings.ApplicationSettings.Contains("DistanceUnit")) IsolatedStorageSettings.ApplicationSettings["DistanceUnit"] = value; else IsolatedStorageSettings.ApplicationSettings.Add("DistanceUnit", value); } } public SupportedPageOrientation OrientationLock { get { throw new NotImplementedException(); } set { throw new NotImplementedException(); } } } }