/// <summary> /// Gets an item from the artwork cache. /// </summary> /// <param name="trackID">The item's ID.</param> /// <returns>A CacheReceipt that indicates the success of the request and the Uri of the image, if possible.</returns> internal static CacheReceipt <Uri> GetArtworkCacheItem(uint trackID) { var x = _local.CreateContainer(ArtContainerGuid.ToString(), Windows.Storage.ApplicationDataCreateDisposition.Always).Values[trackID.ToString()] as string; if (x == null) { return(new CacheReceipt <Uri>(CacheStatus.Uncached, null)); } else if (x.Length == 0) { return(new CacheReceipt <Uri>(CacheStatus.CannotCache, null)); } else { return(new CacheReceipt <Uri>(CacheStatus.Cached, new Uri(x))); } }
//Method to save whatever number is in the textbox to local storage container. public void save(object sender, RoutedEventArgs e) { Button b = (Button)sender; Windows.Storage.ApplicationDataContainer localSettings = Windows.Storage.ApplicationData.Current.LocalSettings; Windows.Storage.ApplicationDataContainer container = localSettings.CreateContainer("savedContent", Windows.Storage.ApplicationDataCreateDisposition.Always); localSettings.Containers["savedContent"].Values["exampleSetting"] = answer.Text; }
/// <summary> /// Creates or opens the specified settings container in the current settings container. /// </summary> /// <param name="name">The name of the container.</param> /// <param name="disposition">One of the enumeration values.</param> /// <remarks>On iOS the name must be a value Shared App Group name and disposition must be Existing.</remarks> /// <returns>The settings container.</returns> public ApplicationDataContainer CreateContainer(string name, ApplicationDataCreateDisposition disposition) { #if __IOS__ || __TVOS__ if (disposition != ApplicationDataCreateDisposition.Existing) { throw new ArgumentException("Only ApplicationDataCreateDisposition.Existing is supported", "disposition"); } return(new Storage.ApplicationDataContainer(ApplicationDataLocality.SharedLocal, name)); #elif WINDOWS_UWP || WINDOWS_APP || WINDOWS_PHONE_APP || WINDOWS_PHONE_81 return(new ApplicationDataContainer(_container.CreateContainer(name, (Windows.Storage.ApplicationDataCreateDisposition)((int)disposition)))); #else throw new PlatformNotSupportedException(); #endif }
//Method that takes whatever number was saved to the local storage container and place it into the textbox. public void load(object sender, RoutedEventArgs e) { Button b = (Button)sender; Windows.Storage.ApplicationDataContainer localSettings = Windows.Storage.ApplicationData.Current.LocalSettings; Windows.Storage.ApplicationDataContainer container = localSettings.CreateContainer("savedContent", Windows.Storage.ApplicationDataCreateDisposition.Always); bool hasContainer = localSettings.Containers.ContainsKey("savedContent"); bool hasSetting = false; if (hasContainer) { hasSetting = localSettings.Containers["savedContent"].Values.ContainsKey("exampleSetting"); answer.Text += localSettings.Containers["savedContent"].Values["exampleSetting"]; } }
public static bool SetConfig(string KeyName, string KeyValue) { try { Windows.Storage.ApplicationDataContainer localSettings = Windows.Storage.ApplicationData.Current.LocalSettings; Windows.Storage.ApplicationDataContainer container = localSettings.CreateContainer("NUTtyUPSClient", Windows.Storage.ApplicationDataCreateDisposition.Always); localSettings.Containers["NUTtyUPSClient"].Values[KeyName] = KeyValue; } catch (Exception e) { NUTInitialization.debugLog.Error("[CONFIG] Could not save setting: " + KeyName + " with value " + KeyValue + "\nException:" + e); return(false); } NUTInitialization.debugLog.Trace("[CONFIG] Set registry key " + KeyName + " with value " + KeyValue); return(true); }
protected override void OnNavigatedTo(NavigationEventArgs e) { Windows.Storage.ApplicationDataContainer localSettings = Windows.Storage.ApplicationData.Current.LocalSettings; Windows.Storage.ApplicationDataContainer container = null; // Create a setting in a container if (localSettings.Containers.ContainsKey("DeutschPractice")) { container = localSettings.Containers["DeutschPractice"]; } else { container = localSettings.CreateContainer("DeutschPractice", Windows.Storage.ApplicationDataCreateDisposition.Always); } nounStats = LoadStats(container, "derdiedas"); }
private void SaveBt_Click(object sender, RoutedEventArgs e) { LocationHelper.Geolocator.MovementThreshold = Convert.ToDouble(MoveThresholdTb.Text); LocationHelper.Geolocator.DesiredAccuracyInMeters = Convert.ToUInt32(AccuracyTb.Text); LocationHelper.Geolocator.ReportInterval = Convert.ToUInt32(IntervalTb.Text); // Create a setting in a container Windows.Storage.ApplicationDataContainer container = localSettings.CreateContainer("GeolocatorSettings", Windows.Storage.ApplicationDataCreateDisposition.Always); if (localSettings.Containers.ContainsKey("GeolocatorSettings")) { localSettings.Containers["GeolocatorSettings"].Values["MovementThreshold"] = LocationHelper.Geolocator.MovementThreshold; localSettings.Containers["GeolocatorSettings"].Values["DesiredAccuracyInMeters"] = LocationHelper.Geolocator.DesiredAccuracyInMeters; localSettings.Containers["GeolocatorSettings"].Values["ReportInterval"] = LocationHelper.Geolocator.ReportInterval; } }
/// <summary> /// Запрос времени у сервера /// </summary> public async void get_time() { var reginfo = new Dictionary <string, string>(); reginfo["type"] = "get_time";; string jsonString = await GET_Query_Data("http://localhost/test/api/index.php", reginfo); JsonObject jsonObject = JsonObject.Parse(jsonString); string time = jsonObject.GetNamedString("time"); textBlock1.Text = "Server answer 1"; textBox1.Text = jsonString; DateTime server_date = DateTime.Parse(time, System.Globalization.CultureInfo.InvariantCulture); string t = server_date.ToString("HH:mm:ss tt"); textBlock2.Text = "Server Time"; textBox2.Text = server_date.ToString(); DateTime localDate = DateTime.Now; textBlock3.Text = "Current Time"; textBox3.Text = localDate.ToString("HH:mm"); Windows.Storage.ApplicationDataContainer localSettings = Windows.Storage.ApplicationData.Current.LocalSettings; // Create a setting in a container Windows.Storage.ApplicationDataContainer container = localSettings.CreateContainer("DataDiffierences", Windows.Storage.ApplicationDataCreateDisposition.Always); if (localSettings.Containers.ContainsKey("DataDiffierences")) { localSettings.Containers["DataDiffierences"].Values["Minute"] = localDate.Minute - server_date.Minute; localSettings.Containers["DataDiffierences"].Values["Second"] = localDate.Second - server_date.Second; localSettings.Containers["DataDiffierences"].Values["Millisecond"] = localDate.Millisecond - server_date.Millisecond; } }
public static string GetConfig(string KeyName) { NUTInitialization.debugLog.Trace("[CONFIG] Checking for existince of setting: " + KeyName); Windows.Storage.ApplicationDataContainer localSettings = Windows.Storage.ApplicationData.Current.LocalSettings; Windows.Storage.ApplicationDataContainer container = localSettings.CreateContainer("NUTtyUPSClient", Windows.Storage.ApplicationDataCreateDisposition.Always); object s; try { s = localSettings.Containers["NUTtyUPSClient"].Values[KeyName].ToString(); } catch (NullReferenceException) { NUTInitialization.debugLog.Error("[CONFIG] Registry key does not exist: " + KeyName); return(null); } catch (Exception e) { NUTInitialization.debugLog.Error("[CONFIG] Failed to read registry key: " + e); return(null); } return(s.ToString()); }
/// <summary> /// 创建设置容器 /// </summary> /// <param name="containerName"></param> /// <returns></returns> private static Windows.Storage.ApplicationDataContainer CreateContainer(string containerName) => localSettings.CreateContainer(containerName, Windows.Storage.ApplicationDataCreateDisposition.Always);
async private void prepareData() { if (!localSettings.Containers.ContainsKey("userInfo")) { MessageDialog msgbox = new MessageDialog("Please log-in first. Go to settings from the main menu."); await msgbox.ShowAsync(); Frame.Navigate(typeof(Settings)); return; } if (!localSettings.Containers.ContainsKey("dailyChallenge")) { Debug.WriteLine("needed to create"); localSettings.CreateContainer("dailyChallenge", Windows.Storage.ApplicationDataCreateDisposition.Always); localSettings.Containers["dailyChallenge"].Values["Date"] = "2004-01-01T01:01:01.000Z"; toRefresh = true; } else { string lastDate = localSettings.Containers["dailyChallenge"].Values["Date"].ToString(); string format = "yyyy-MM-ddTHH:mm:ss.fffZ"; DateTime lastchallengedate = DateTime.ParseExact(lastDate, format, CultureInfo.InvariantCulture); if (lastchallengedate.Date < DateTime.Now.Date) { toRefresh = true; } } Debug.WriteLine("To refresh = " + toRefresh); if (toRefresh) { progressbar.Text = "Fetching new data"; progressbar.ShowAsync(); var client = new HttpClient(); var response = await client.GetAsync(new Uri("http://codeinn-acecoders.rhcloud.com:8000/query/daily")); var result = await response.Content.ReadAsStringAsync(); Debug.WriteLine(result); try { // The server sends a single challenge so the list would be singly-occupied. List <Problems> dailychall = JsonConvert.DeserializeObject <List <Problems> >(result); foreach (Problems prob in dailychall) { localSettings.Containers["dailyChallenge"].Values["Date"] = prob.CreationDate; localSettings.Containers["dailyChallenge"].Values["Content"] = prob.Content; localSettings.Containers["dailyChallenge"].Values["Name"] = prob.Name; localSettings.Containers["dailyChallenge"].Values["Description"] = prob.Description; localSettings.Containers["dailyChallenge"].Values["Id"] = prob.Id; displayedObject = prob; } } catch { Debug.WriteLine("Internal error."); progressbar.Text = "Error"; } progressbar.HideAsync(); } else { string name = localSettings.Containers["dailyChallenge"].Values["Name"].ToString(); string content = localSettings.Containers["dailyChallenge"].Values["Content"].ToString(); string description = localSettings.Containers["dailyChallenge"].Values["Description"].ToString(); displayedObject = new Problems(0, name, description, content, "Admin"); //await Task.Delay(1000); } populateContent(); }