Esempio n. 1
0
        private async void DownloadConfigButton_Click(object sender, RoutedEventArgs e)
        {
            var helper = new RoamingObjectStorageHelper();

            // Read complex/large objects
            if (await helper.FileExistsAsync(portfolioKey))
            {
                var obj = await helper.ReadFileAsync <ObservableCollection <PurchaseClass> >(portfolioKey);

                ContentDialog importDialog = new ContentDialog()
                {
                    Title             = $"Import {obj.Count} purchases?",
                    Content           = "This will clear your current portfolio and download your backup.",
                    DefaultButton     = ContentDialogButton.Primary,
                    PrimaryButtonText = "Import",
                    CloseButtonText   = "Cancel",
                    RequestedTheme    = ((Frame)Window.Current.Content).RequestedTheme
                };

                var response = await importDialog.ShowAsync();

                if (response == ContentDialogResult.Primary)
                {
                    Portfolio.importPortfolio(obj);
                }
            }
            else
            {
                ContentDialog importDialog = new ContentDialog()
                {
                    Title                  = "No backup found.",
                    Content                = "You don't seem to have uploaded any portfolio before.",
                    DefaultButton          = ContentDialogButton.Primary,
                    IsPrimaryButtonEnabled = false,
                    PrimaryButtonText      = "Import",
                    CloseButtonText        = "Cancel",
                    RequestedTheme         = ((Frame)Window.Current.Content).RequestedTheme
                };
                await importDialog.ShowAsync();
            }
        }
Esempio n. 2
0
        public static async Task LoadAsync()
        {
            RoamingObjectStorageHelper helper = new RoamingObjectStorageHelper();

            _websites = await helper.ReadFileAsync("keyWebsites", _websites);
        }