/// <summary> /// The main page loaded. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> private async void MainPageLoaded(object sender, RoutedEventArgs e) { var settings = ApplicationData.Current.RoamingSettings.Values; PolicyDown.LowThresholdMb = (int)settings["LowThreshold"]; PolicyDown.MidThresholdMb = (int)settings["MidThreshold"]; PolicyUp.LowThresholdMb = (int)settings["LowThreshold"]; PolicyUp.MidThresholdMb = (int)settings["MidThreshold"]; var lowThresholdMultipliedByDiscount = (int)settings["LowThreshold"] * Math.Pow(1 - (((int)settings["PctDiscount"]) / 100.0), -1); var midThresholdMultipliedByDiscount = (int)settings["MidThreshold"] * Math.Pow(1 - (((int)settings["PctDiscount"]) / 100.0), -1); ActualDown.LowThresholdMb = (int)lowThresholdMultipliedByDiscount; ActualDown.MidThresholdMb = (int)midThresholdMultipliedByDiscount; ActualUp.LowThresholdMb = (int)lowThresholdMultipliedByDiscount; ActualUp.MidThresholdMb = (int)midThresholdMultipliedByDiscount; if (settings.ContainsKey("BandwidthClass")) { UpdateUi(BandwidthResults.RetrieveFromIsolatedStorage(), false); } if (!settings.ContainsKey("user")) { OnSettingsCommand(null); } else { await Scrape(); } }
/// <summary> /// Updates each <see cref="BandwidthMeter" /> with the appropriate result text. /// </summary> /// <param name="bandwidthResults"> /// The bandwidth results. /// </param> /// <param name="fromNetwork"> /// Whether the update is from storage or the network scraper. /// </param> public void UpdateUi(BandwidthResults bandwidthResults, bool fromNetwork) { foreach (var control in new Dictionary <BandwidthMeter, string> { { PolicyDown, bandwidthResults.PolicyReceived }, { PolicyUp, bandwidthResults.PolicySent }, { ActualDown, bandwidthResults.ActualReceived }, { ActualUp, bandwidthResults.ActualSent } }) { control.Key.UpdateBorder(GetBandwidthNumberFromString(control.Value), PolicyDown.ActualHeight); control.Key.UpdateText(control.Value); } }