private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e) { // Cookie container = store["HFRcookies"] as CookieContainer; if (container.Count < 3) { List <Cookie> listCookies = store["listHFRcookies"] as List <Cookie>; foreach (Cookie c in listCookies) { container.Add(new Uri("https://forum.hardware.fr", UriKind.Absolute), c); } store.Remove("HFRcookies"); store.Add("HFRcookies", container); } // Hash check hash = store["hash"] as String; // GET NavigationContext.QueryString.TryGetValue("pseudodesti", out pseudoDestiDirect); NavigationContext.QueryString.TryGetValue("url", out urlPost); if (pseudoDestiDirect != null) { pseudoTextBox.Text = pseudoDestiDirect; pseudoTextBox.Hint = ""; } }
private static void AddDefaultSettings(IsolatedStorageSettings settings) { settings.Add("MidThreshold", 8000); settings.Add("LowThreshold", 9000); settings.Add("MidRate", 1024); settings.Add("LowRate", 256); settings.Add("PctDiscount", 75); }
public Password() { InitializeComponent(); appSettings = IsolatedStorageSettings.ApplicationSettings; if (!appSettings.Contains("pass")) { appSettings.Add("pass", "blue"); } if (!appSettings.Contains("fake")) { appSettings.Add("fake", "red"); } pass = (string)appSettings["pass"]; fakePass = (string)appSettings["fake"]; }
public StorageHandler() { settings = IsolatedStorageSettings.ApplicationSettings; if (!settings.Contains(levelsKey)) { settings.Add(levelsKey, new LevelsInfo()); } if (!settings.Contains(challengesKey)) { settings.Add(challengesKey, new ChallengesInfo()); } }
// Constructor public MainPage() { InitializeComponent(); settings = IsolatedStorageSettings.ApplicationSettings; if (! settings.Contains("data")) { settings.Add("data", ""); } }
// Constructor public MainPage() { settings = IsolatedStorageSettings.ApplicationSettings; if (!settings.Contains("index")) { settings.Add("index", 0); settings.Add("primero", 0); } else { valorInicial = Convert.ToInt32(settings["index"]); } InitializeComponent(); this.Loaded += MainPage_Loaded; }
//constructor gets settings public StorageSetting() { settings = IsolatedStorageSettings.ApplicationSettings; if (!settings.Contains(RouteMode)) { settings.Add(RouteMode, RouteModeDefault); settings.Save(); } }
void FotoTomada_Loaded(object sender, RoutedEventArgs e) { ReadFromIsolatedStorage("FotoSacada"); settings = IsolatedStorageSettings.ApplicationSettings; if (!settings.Contains("mostrarPopUp")) { settings.Add("mostrarPopUp","True"); } }
// Constructor public MainPage() { InitializeComponent(); settings = IsolatedStorageSettings.ApplicationSettings; if (! settings.Contains("memory")) { settings.Add("memory", ""); } if (!settings.Contains("haptic")) { settings.Add("haptic", is_haptic); } is_haptic = settings["haptic"].ToString(); b_haptic = (ApplicationBarIconButton)ApplicationBar.Buttons[0]; b_nohaptic = (ApplicationBarIconButton)ApplicationBar.Buttons[1]; b_point = (ApplicationBarIconButton)ApplicationBar.Buttons[2]; b_comma = (ApplicationBarIconButton)ApplicationBar.Buttons[3]; b_haptic.IsEnabled = is_haptic == "0"; b_nohaptic.IsEnabled = is_haptic != "0"; // decimal point or comma is hidden during a callback in do_load() }
private void LoadSettings() { _isolatedStorageSettings = IsolatedStorageSettings.ApplicationSettings; if (_isolatedStorageSettings.Contains(_merchantServerUrlKey)) { MerchantServerUrl.Text = (string)_isolatedStorageSettings[_merchantServerUrlKey]; } else _isolatedStorageSettings.Add(_merchantServerUrlKey, ""); }
// Constructor public MainPage() { InitializeComponent(); //Thread.Sleep(2000); settings = IsolatedStorageSettings.ApplicationSettings; colocarAudiosSiNoExisten(); if (!settings.Contains("mostrarMensajeMusica")) { //MessageBox.Show("hola"); settings.Add("mostrarMensajeMusica", "false"); } }
public bool Write(string key, string val) { try { settings = IsolatedStorageSettings.ApplicationSettings; settings.Add(key, val); return true; } catch(ArgumentException ex) { return false; } }
private void SaveCity(string city) { m_appSettings = IsolatedStorageSettings.ApplicationSettings; if (m_appSettings.Contains("city")) { m_appSettings["city"] = city; } else { m_appSettings.Add("city", city); } m_appSettings.Save(); WebService.City = city; }
// Constructor public MainPage() { InitializeComponent(); settings = IsolatedStorageSettings.ApplicationSettings; ready = false; DateTime now = DateTime.Now; Debugger.Log(0, "Debug", "NextCirc Version " + NextCirc.Images.About.appVersion.ToString("N1") + "\nCurrent Time: " + now.ToShortDateString() + " " + now.ToShortTimeString() + "\n\n"); // Load saved stop if (settings.Contains(curStopKey)) { currentStop = Convert.ToInt32(settings[curStopKey]); Debugger.Log(0, "Debug", "found setting = " + currentStop + "\n"); } else { settings.Add(curStopKey, currentStop); Debugger.Log(0, "Debug", "no setting\n"); } // Build list of stops stopList = new List<CircStop>(); // TODO: stopList.Add(new CircStop("NextCirc", new GeoCoordinate(0, 0), 0)); stopList.Add(new CircStop("south forty", new GeoCoordinate(38.645327, -90.312952), 0)); stopList.Add(new CircStop("mallinckrodt (to skinker)", new GeoCoordinate(38.647021, -90.309522), 3)); stopList.Add(new CircStop("skinker", new GeoCoordinate(38.647654, -90.30133), 6)); stopList.Add(new CircStop("millbrook", new GeoCoordinate(38.650172, -90.311331), 10)); stopList.Add(new CircStop("brookings", new GeoCoordinate(38.647923, -90.304025), 14)); stopList.Add(new CircStop("mallinckrodt (to south forty)", new GeoCoordinate(38.647021, -90.309522), 17)); this.stopPicker.ItemsSource = stopList; this.stopPicker.SelectedIndex = currentStop; ready = true; Debugger.Log(0, "Debug", "initialized.\n"); chooseStop(currentStop); // Register timer to keep View up to date DispatcherTimer timer = new DispatcherTimer(); timer.Tick += timer_Tick; timer.Interval = new TimeSpan(0, 0, 1); timer.Start(); // Sample code to localize the ApplicationBar //BuildLocalizedApplicationBar(); }
public static void Write <TT>(string name, TT value) { System.IO.IsolatedStorage.IsolatedStorageSettings settings = System.IO.IsolatedStorage.IsolatedStorageSettings.ApplicationSettings; if (settings == null) { return; } if (settings.Contains(name)) { settings[name] = value; } else { settings.Add(name, value); } settings.Save(); }
private void favorisListPicker_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (pageLoaded) { try { if (favorisListPicker.SelectedIndex == 0) { store.Remove("favorisType"); store.Add("favorisType", "1"); } if (favorisListPicker.SelectedIndex == 1) { store.Remove("favorisType"); store.Add("favorisType", "2"); } if (favorisListPicker.SelectedIndex == 2) { store.Remove("favorisType"); store.Add("favorisType", "3"); } } catch { } } }
/// <summary> /// Private helper method for performing saves on settings /// </summary> /// <param name="store">The IsolatedStorageSettings store to use (either "site" or "application")</param> /// <param name="key">The key of the object to save</param> /// <param name="value">The value to be saved in storage</param> private static void SaveOrUpdateSetting(IsolatedStorageSettings store, string key, object value) { if (store.Contains(key)) { store[key] = value; } //Otheriwse, add this new key and its value to the store else { store.Add(key, value); } store.Save(); }
protected override void OnBackKeyPress(System.ComponentModel.CancelEventArgs e) { store.Add("navigatedBack", "true"); }
void InitializeSettings() { appSettings = IsolatedStorageSettings.ApplicationSettings; if (appSettings.Contains(playerWins) == false) { appSettings.Add(playerWins, 0); } if (appSettings.Contains(phoneWins) == false) { appSettings.Add(phoneWins, 0); } if (appSettings.Contains(draws) == false) { appSettings.Add(draws, 0); } }
// Constructor public MainPage() { ready = false; settings = IsolatedStorageSettings.ApplicationSettings; InitializeComponent(); // Set maps API key map.CredentialsProvider = new ApplicationIdCredentialsProvider("BING_MAPS_API_KEY_HERE"); // Populate location list source = new List<Stops>(); source.Add(new Stops() { Name = "south forty", ShortName="south 40", Location = new GeoCoordinate(38.645327, -90.312952) }); source.Add(new Stops() { Name = "mallinckrodt (to skinker)", ShortName = "mallinckrodt", Location = new GeoCoordinate(38.647021, -90.309522) }); source.Add(new Stops() { Name = "skinker", ShortName = "skinker", Location = new GeoCoordinate(38.647654, -90.30133) }); source.Add(new Stops() { Name = "millbrook", ShortName = "millbrook", Location = new GeoCoordinate(38.650172, -90.311331) }); source.Add(new Stops() { Name = "brookings", ShortName = "brookings", Location = new GeoCoordinate(38.647923, -90.304025) }); source.Add(new Stops() { Name = "mallinckrodt (to south forty)", ShortName = "mallinckrodt", Location = new GeoCoordinate(38.647021, -90.309522) }); this.stopPicker.ItemsSource = source; // Add all text blocks to a List for animating textBlocks = new List<FrameworkElement>(); textBlocks.Add(nextStopTime); textBlocks.Add(nextStopTime2); textBlocks.Add(nextStopTime3); // Create pins for each location pins = new List<Pushpin>(); for (int i = 0; i < source.Count; i++) { Pushpin p = new Pushpin(); p.Location = new GeoCoordinate(0, 0); pins.Add(p); map.Children.Add(p); } // Set up location services if (!settings.Contains("UseLocation")) { MessageBoxResult m = MessageBox.Show("Automatically select a circulator stop based on your physical location? You can change this later in Settings.", "Location Service Request", MessageBoxButton.OKCancel); if (m == MessageBoxResult.OK) { useLoc = true; settings["UseLocation"] = "true"; } else { useLoc = false; settings["UseLocation"] = "false"; } } else if (settings["UseLocation"].ToString() == "true") { useLoc = true; } // Initialize current location pin and location watcher if (useLoc) { curpin = new Pushpin(); curpin.Content = "current location"; curpin.Background = new SolidColorBrush(Colors.Blue); curpin.Location = new GeoCoordinate(0, 0); map.Children.Add(curpin); loc = new GeoCoordinateWatcher(GeoPositionAccuracy.Default); updateLocation(); } DateTime now = DateTime.Now; DateTime firstStop; int numOfStops; if (!settings.Contains("chosenStop")) { settings.Add("chosenStop", 0); currentStop = 0; } else { currentStop = Convert.ToInt32(settings["chosenStop"]); } // Determine whether it's a weekend or weekday and generate schedule accordingly if (now.DayOfWeek == DayOfWeek.Sunday || now.DayOfWeek == DayOfWeek.Saturday) { firstStop = new DateTime(now.Year, now.Month, now.Day, 12, 0, 0); numOfStops = 41; } else { firstStop = new DateTime(now.Year, now.Month, now.Day, 7, 40, 0); numOfStops = 54; } // South 40 s40 = new List<DateTime>(); s40.Add(firstStop); for (int i = 0; i < numOfStops; i++) { s40.Add(s40.Last().AddMinutes(20)); } // AR Mallinckrodt ARmal = new List<DateTime>(); foreach(DateTime d in s40) { ARmal.Add(d.AddMinutes(3)); } // Skinker skinker = new List<DateTime>(); foreach (DateTime d in ARmal) { skinker.Add(d.AddMinutes(3)); } // Millbrook millbrook = new List<DateTime>(); foreach (DateTime d in skinker) { millbrook.Add(d.AddMinutes(4)); } // Brookings brookings = new List<DateTime>(); foreach (DateTime d in millbrook) { brookings.Add(d.AddMinutes(4)); } // Mallinckrodt mallinckrodt = new List<DateTime>(); foreach (DateTime d in brookings) { mallinckrodt.Add(d.AddMinutes(3)); } // Change colors if light theme Visibility isLight = (Visibility)Resources["PhoneLightThemeVisibility"]; // for light theme if (isLight == System.Windows.Visibility.Visible) { nextStopTime2.Foreground = new SolidColorBrush(Colors.Gray); nextStopTime3.Foreground = new SolidColorBrush(Colors.LightGray); } stopPicker.SelectedIndex = currentStop; ready = true; buildMap(); updateTime(); }
private void loadSettings() { settings = IsolatedStorageSettings.ApplicationSettings; if (!settings.Contains("cm")) { cm = true; settings.Add("cm", "1"); settings.Save(); } else { string cmSetting = IsolatedStorageSettings.ApplicationSettings["cm"] as string; if (cmSetting.Contains("1")) { cm = true; } else { cm = false; } } if (settings.Contains("login")) { btnLogout.IsEnabled = true; } }
public void CheckSettings (IsolatedStorageSettings settings) { Assert.AreEqual (0, settings.Count, "Empty-Count"); Assert.AreEqual (0, settings.Keys.Count, "Empty-Keys.Count"); Assert.AreEqual (0, settings.Values.Count, "Empty-Values.Count"); settings.Add ("key", "value"); Assert.Throws (delegate { settings.Add (null, "x"); }, typeof (ArgumentNullException), "Add(null,x)"); Assert.Throws (delegate { settings.Add ("key", "another string"); }, typeof (ArgumentException), "Add(twice)"); Assert.AreEqual (1, settings.Count, "Count"); Assert.AreEqual (1, settings.Keys.Count, "Keys.Count"); Assert.AreEqual (1, settings.Values.Count, "Values.Count"); Assert.AreEqual (1, (settings as ICollection).Count, "ICollection.Count"); Assert.IsTrue (settings.Contains ("key"), "Contains-key"); Assert.IsFalse (settings.Contains ("value"), "Contains-value"); Assert.Throws (delegate { settings.Contains (null); }, typeof (ArgumentNullException), "Contains(null)"); Assert.AreEqual ("value", settings ["key"], "this[key]"); settings ["key"] = null; Assert.IsNull (settings ["key"], "this[key]-null"); Assert.Throws (delegate { Console.WriteLine (settings ["unexisting"]); }, typeof (KeyNotFoundException), "this[unexisting]"); Assert.Throws (delegate { settings [null] = null; }, typeof (ArgumentNullException), "this[null] set"); settings.Remove ("key"); Assert.AreEqual (0, settings.Count, "Remove/Count"); Assert.IsFalse (settings.Remove ("unexisting"), "Remove(unexisting)"); Assert.Throws (delegate { settings.Remove (null); }, typeof (ArgumentNullException), "Remove(null)"); settings.Add ("key", "value"); Assert.AreEqual (1, settings.Count, "Add2/Count"); string s; Assert.IsTrue (settings.TryGetValue<string> ("key", out s), "TryGetValue(key)"); Assert.AreEqual ("value", s, "out value"); object o; Assert.IsTrue (settings.TryGetValue<object> ("key", out o), "TryGetValue(object)"); Assert.AreEqual ("value", s, "out value/object"); Assert.IsFalse (settings.TryGetValue<string> ("value", out s), "TryGetValue(value)"); Assert.Throws (delegate { settings.TryGetValue<string> (null, out s); }, typeof (ArgumentNullException), "TryGetValue(null)"); settings.Clear (); Assert.AreEqual (0, settings.Count, "Clear/Count"); }
public void Format (IsolatedStorageSettings settings, IsolatedStorageFile isf) { settings.Clear (); settings.Add ("a", 1); settings.Save (); Dictionary<string, object> dict = null; using (IsolatedStorageFileStream fs = new IsolatedStorageFileStream ("__LocalSettings", FileMode.Open, isf)) { using (StreamReader sr = new StreamReader (fs)) { DataContractSerializer reader = new DataContractSerializer (typeof (Dictionary<string, object>)); dict = (Dictionary<string, object>) reader.ReadObject (fs); } } Assert.AreEqual (1, dict.Count, "settings.Count"); Assert.AreEqual (1, dict ["a"], "settings.a"); dict ["b"] = 2; using (IsolatedStorageFileStream fs = new IsolatedStorageFileStream ("__LocalSettings", FileMode.Create, isf)) { using (StreamReader sr = new StreamReader (fs)) { DataContractSerializer writer = new DataContractSerializer (dict.GetType ()); writer.WriteObject (fs, dict); } } // saved but not re-loaded Assert.AreEqual (1, settings.Count, "Count"); settings.Clear (); }
private void TrySetIndividualSetting(IsolatedStorageSettings settings, Setting settingNameEnum, string settingValue) { var settingName = settingNameEnum.ToString(); if (settings.Contains(settingName)) { settings[settingName] = settingValue; } else { settings.Add(settingName, settingValue); } }
private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e) { SystemTray.ProgressIndicator = new ProgressIndicator(); SystemTray.ProgressIndicator.IsIndeterminate = true; if ((string)store["disableLandscape"] == "true") { ListTopicPage.SupportedOrientations = SupportedPageOrientation.Portrait; } if (store.Contains("navigatedback")) { store.Remove("navigatedback"); if (isoStore.DirectoryExists("topics")) { foreach (string fileName in isoStore.GetFileNames("topics/*")) { isoStore.DeleteFile("topics/" + fileName); } } } else { // Récupération de l'URI de la sous-catégorie NavigationContext.QueryString.TryGetValue("souscaturi", out souscatUri); souscatUri = HttpUtility.UrlDecode(souscatUri); // Récupération de l'ID de la catégorie NavigationContext.QueryString.TryGetValue("idcat", out idCat); // Récupération du nom du forum NavigationContext.QueryString.TryGetValue("souscatname", out souscatName); if (souscatName == null) { souscatName = GetCatName.PlainNameFromId(idCat); } topicsPivot.Title = souscatName.ToUpper(); // Récupération de la provenance NavigationContext.QueryString.TryGetValue("from", out from); if (from == "changepage") { NavigationService.RemoveBackEntry(); } // Pivot NavigationContext.QueryString.TryGetValue("pivot", out pivot); // listPageNumber NavigationContext.QueryString.TryGetValue("listpagenumber", out listPageNumber); if (Convert.ToInt32(listPageNumber) > 1) { ((ApplicationBarIconButton)ApplicationBar.Buttons[1]).IsEnabled = true; } else { ((ApplicationBarIconButton)ApplicationBar.Buttons[1]).IsEnabled = false; } if (!souscatUri.Contains("cat=0")) { souscatUri = souscatUri.Substring(0, souscatUri.Length - 5) + listPageNumber + ".htm"; } if (pivot == "drap") { topicsPivot.SelectedIndex = 1; } else if (pivot == "topics") { topicsPivot.SelectedIndex = 0; } // Récupération du cookie if (store.Contains("HFRcookies")) { container = store["HFRcookies"] as CookieContainer; } else { // Création du cookie de l'user List <Cookie> listCookies = store["listHFRcookies"] as List <Cookie>; foreach (Cookie c in listCookies) { container.Add(new Uri("https://forum.hardware.fr", UriKind.Absolute), c); } store.Remove("HFRcookies"); store.Add("HFRcookies", container); } // ItemsSources drapList.ItemsSource = null; topicsList.ItemsSource = null; // Téléchargement de la liste DownloadTopicsDrapals(Convert.ToInt32(listPageNumber)); } }