public async Task CreateAppLocalData() { var ObjectStorageHelper = new StorageHelper<LocalAppData>(StorageType.Local); LocalAppData LoadedData = await ObjectStorageHelper.LoadASync("AllAppData"); //If file hasn't been created. Create it if (LoadedData == null) { //Never created this file, create it now LocalAppData NewAppDataStruct = new LocalAppData(); await Task.Run(() => ObjectStorageHelper.SaveASync(NewAppDataStruct, "AllAppData")); } }
private async void MainPage_Loaded(object sender, RoutedEventArgs e) { if (FocusCount == 0) { SaveAndLoad DataSaverLoader = new SaveAndLoad(); await DataSaverLoader.CreateAppLocalData(); AllData = await DataSaverLoader.LoadData(); foreach (CardObj Card in AllData.AllCardData) { MyUserControl1 control = new MyUserControl1(500, 300, Card); control.Width = 600; control.Height = 400; control.HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Left; control.VerticalAlignment = Windows.UI.Xaml.VerticalAlignment.Top; control.disableEditing(); MainPage.AllCards.Add(control); } this.cardCarousel.setup(); } FocusCount++; }
public async Task SaveData(LocalAppData Data) { var ObjectStorageHelper = new StorageHelper<LocalAppData>(StorageType.Local); await Task.Run(() => ObjectStorageHelper.SaveASync(Data, "AllAppData")); }