private async void Page_Loaded(object sender, RoutedEventArgs e) { ClearErrorMessage(); saveButton.Focus(FocusState.Keyboard); _savedAppSettings = await ApplicationUtilities.GetAppSettings(); if (_savedAppSettings != null && _savedAppSettings.CompanyImage.Length > 0) { Uri uri = new Uri(@"ms-appdata:///local/" + _savedAppSettings.CompanyImage, UriKind.Absolute); try { var file = await StorageFile.GetFileFromApplicationUriAsync(uri); using (var fileStream = await file.OpenAsync(FileAccessMode.Read)) { BitmapImage bitmapImage = new BitmapImage { DecodePixelHeight = 300, DecodePixelWidth = 300 }; await bitmapImage.SetSourceAsync(fileStream); CompanyImage.Source = bitmapImage; } } catch (Exception) { } } }
public static async Task<AppModel> GetAppSettings() { // ReSharper disable once RedundantAssignment var appModel = new AppModel(); var storage = new StorageHelper<AppModel>(StorageType.Local); try { appModel = await storage.LoadASync(@"AppSetting.xml"); } catch (Exception) { appModel = null; } return appModel; }
private void saveManageSettings(string file) { var appSettings = new AppModel("12345", file); var storageHelper = new StorageHelper<AppModel>(StorageType.Local); storageHelper.SaveASync(appSettings, "AppSetting"); }
private void SaveManageSettings_Click(object sender, RoutedEventArgs e) { var appSettings = new AppModel("12345",FilePath.Text); var storageHelper = new StorageHelper<AppModel>(StorageType.Local); storageHelper.SaveASync(appSettings, "AppSetting"); }