static ViewModelLocator() { ServiceLocator.SetLocatorProvider(() => SimpleIoc.Default); // Register Services if (!SimpleIoc.Default.IsRegistered <INavigationService>()) { var navigationService = CreateNavigationService(); SimpleIoc.Default.Register(() => navigationService); } if (!SimpleIoc.Default.IsRegistered <IReactiveTVShowTimeApiService>()) { var tvshowtimeApiService = new ReactiveTVShowTimeApiService(); SimpleIoc.Default.Register <IReactiveTVShowTimeApiService>(() => tvshowtimeApiService); } if (!SimpleIoc.Default.IsRegistered <IHamburgerMenuService>()) { var hamburgerMenuService = new HamburgerMenuService(); SimpleIoc.Default.Register <IHamburgerMenuService>(() => hamburgerMenuService); } if (!SimpleIoc.Default.IsRegistered <IObjectStorageHelper>()) { var localObjectStorageHelper = new LocalObjectStorageHelper(); SimpleIoc.Default.Register <IObjectStorageHelper>(() => localObjectStorageHelper, ServiceLocatorConstants.LocalObjectStorageHelper); var roamingObjectStorageHelper = new RoamingObjectStorageHelper(); SimpleIoc.Default.Register <IObjectStorageHelper>(() => roamingObjectStorageHelper, ServiceLocatorConstants.RoamingObjectStorageHelper); } if (!SimpleIoc.Default.IsRegistered <IEventService>()) { var eventService = new EventService(); SimpleIoc.Default.Register <IEventService>(() => eventService); } if (!SimpleIoc.Default.IsRegistered <IToastNotificationService>()) { var toastNotificationService = new ToastNotificationService(); SimpleIoc.Default.Register <IToastNotificationService>(() => toastNotificationService); } // Register ViewModels SimpleIoc.Default.Register <AgendaViewModel>(); SimpleIoc.Default.Register <CollectionViewModel>(); SimpleIoc.Default.Register <EpisodeViewModel>(); SimpleIoc.Default.Register <ExploreViewModel>(); SimpleIoc.Default.Register <FeedbackViewModel>(); SimpleIoc.Default.Register <LoginViewModel>(); SimpleIoc.Default.Register <MainViewModel>(); SimpleIoc.Default.Register <SettingsViewModel>(); SimpleIoc.Default.Register <ShowViewModel>(); SimpleIoc.Default.Register <ToWatchViewModel>(); SimpleIoc.Default.Register <UpcomingViewModel>(); }
private async void UploadConfigButton_Click(object sender, RoutedEventArgs e) { try { var helper = new RoamingObjectStorageHelper(); var portfolio = Portfolio.PurchaseList; if (portfolio == null || portfolio.Count == 0) { await new ContentDialog() { Title = "Empty portfolio", Content = "Your current portfolio is empty.", DefaultButton = ContentDialogButton.Primary, PrimaryButtonText = "Export", IsPrimaryButtonEnabled = false, CloseButtonText = "Cancel", RequestedTheme = ((Frame)Window.Current.Content).RequestedTheme }.ShowAsync(); } else { ContentDialog exportDialog = new ContentDialog() { Title = $"Export {portfolio.Count} purchases?", Content = "This will create a backup of your current portfolio in the cloud.", DefaultButton = ContentDialogButton.Primary, PrimaryButtonText = "Export", CloseButtonText = "Cancel", RequestedTheme = ((Frame)Window.Current.Content).RequestedTheme }; var response = await exportDialog.ShowAsync(); if (response == ContentDialogResult.Primary) { await helper.SaveFileAsync(portfolioKey, portfolio); } } } catch (Exception ex) { await new MessageDialog("Error uploading your portfolio. Try again later.").ShowAsync(); } }
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(); } }
/// <summary> /// Invoked when the application is launched normally by the end user. Other entry points /// will be used such as when the application is launched to open a specific file. /// </summary> /// <param name="e">Details about the launch request and process.</param> protected async override void OnLaunched(LaunchActivatedEventArgs e) { //IPropertySet roamingProperties = Application.Current.RoamingSettings.Values(); RoamingObjectStorageHelper roamingProperties = new RoamingObjectStorageHelper(); //IPropertySet roamingProperties = Windows.Storage.ApplicationData.Current.RoamingSettings.Values; Frame rootFrame = Window.Current.Content as Frame; Windows.UI.Core.SystemNavigationManager.GetForCurrentView().BackRequested += App_BackRequested; // Do not repeat app initialization when the Window already has content, // just ensure that the window is active if (rootFrame == null) { // Create a Frame to act as the navigation context and navigate to the first page rootFrame = new Frame(); rootFrame.NavigationFailed += OnNavigationFailed; if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) { //TODO: Load state from previously suspended application } // Place the frame in the current Window Window.Current.Content = rootFrame; } var k = roamingProperties.KeyExists("HasBeenHereBefore"); if (roamingProperties.KeyExists("HasBeenHereBefore")) { try { var localSettings = Windows.Storage.ApplicationData.Current.LocalSettings; authToken = localSettings.Values["authToken"].ToString(); } catch { if (e.PrelaunchActivated == false) { if (rootFrame.Content == null) { // When the navigation stack isn't restored navigate to the first page, // configuring the new page by passing required information as a navigation // parameter rootFrame.Navigate(typeof(MainPage), e.Arguments); } // Ensure the current window is active Window.Current.Activate(); } } if (e.PrelaunchActivated == false) { if (rootFrame.Content == null) { // When the navigation stack isn't restored navigate to the first page, // configuring the new page by passing required information as a navigation // parameter DataManager.StatusCode res = await DataManager.LoginAsync(authToken); if (res == DataManager.StatusCode.NoInternet) { } if (res == DataManager.StatusCode.Success) { rootFrame.Navigate(typeof(Home), e.Arguments); } else { rootFrame.Navigate(typeof(MainPage), e.Arguments); MessageDialog dialog = new MessageDialog("No Pre-stored data found, please connect to the internet"); await dialog.ShowAsync(); } } // Ensure the current window is active Window.Current.Activate(); } } else { // The First Time App Starts Case //roamingProperties["HasBeenHereBefore"] = bool.TrueString; roamingProperties.Save("HasBeenHereBefore", true); rootFrame.Navigate(typeof(Welcome), e.Arguments); Window.Current.Activate(); } }
public static async Task LoadAsync() { RoamingObjectStorageHelper helper = new RoamingObjectStorageHelper(); _websites = await helper.ReadFileAsync("keyWebsites", _websites); }
//Saves the Website List in Roaming Storage to allow cross device sync. //TODO: At a prompt when file gets over 100kb. public static async Task SaveAsync(List <Website> keyLargeObject) { RoamingObjectStorageHelper helper = new RoamingObjectStorageHelper(); await helper.SaveFileAsync("keyWebsites", _websites); }