protected override void OnRegisterKnownTypesForSerialization() { // Set up the list of known types for the SuspensionManager SessionStateService.RegisterKnownType(typeof(Meeting)); SessionStateService.RegisterKnownType(typeof(Message)); SessionStateService.RegisterKnownType(typeof(EventMessage)); }
protected override void OnRegisterKnownTypesForSerialization() { base.OnRegisterKnownTypesForSerialization(); SessionStateService.RegisterKnownType(typeof(ReadOnlyDictionary <string, ReadOnlyCollection <string> >)); SessionStateService.RegisterKnownType(typeof(Person)); SessionStateService.RegisterKnownType(typeof(State)); }
/// <summary> /// Initializes the Frame and its content. /// </summary> /// <param name="args">The <see cref="IActivatedEventArgs"/> instance containing the event data.</param> /// <returns>A task of a Frame that holds the app content.</returns> protected async Task <Frame> InitializeFrameAsync(IActivatedEventArgs args) { // Create a Frame to act as the navigation context and navigate to the first page var rootFrame = new Frame(); if (ExtendedSplashScreenFactory != null) { Page extendedSplashScreen = this.ExtendedSplashScreenFactory.Invoke(args.SplashScreen); rootFrame.Content = extendedSplashScreen; } rootFrame.Navigated += OnNavigated; var frameFacade = new FrameFacadeAdapter(rootFrame); //Initialize PrismApplication common services SessionStateService = new SessionStateService(); //Configure VisualStateAwarePage with the ability to get the session state for its frame VisualStateAwarePage.GetSessionStateForFrame = frame => SessionStateService.GetSessionStateForFrame(frameFacade); //Associate the frame with a key SessionStateService.RegisterFrame(frameFacade, "AppFrame"); NavigationService = CreateNavigationService(frameFacade, SessionStateService); DeviceGestureService = CreateDeviceGestureService(); DeviceGestureService.GoBackRequested += OnGoBackRequested; DeviceGestureService.GoForwardRequested += OnGoForwardRequested; // Set a factory for the ViewModelLocator to use the default resolution mechanism to construct view models ViewModelLocationProvider.SetDefaultViewModelFactory(Resolve); OnRegisterKnownTypesForSerialization(); if (args.PreviousExecutionState == ApplicationExecutionState.Terminated) { await SessionStateService.RestoreSessionStateAsync(); } await OnInitializeAsync(args); if (args.PreviousExecutionState == ApplicationExecutionState.Terminated) { // Restore the saved session state and navigate to the last page visited try { SessionStateService.RestoreFrameState(); NavigationService.RestoreSavedNavigation(); _isRestoringFromTermination = true; } catch (SessionStateServiceException) { // Something went wrong restoring state. // Assume there is no state and continue } } return(rootFrame); }
protected override void OnRegisterKnownTypesForSerialization() { base.OnRegisterKnownTypesForSerialization(); SessionStateService.RegisterKnownType(typeof(Models.IPhoto)); SessionStateService.RegisterKnownType(typeof(Models.FlickrPhoto)); SessionStateService.RegisterKnownType(typeof(Models.PhotoSize)); }
protected override void OnRegisterKnownTypesForSerialization() { SessionStateService.RegisterKnownType(typeof(Country)); SessionStateService.RegisterKnownType(typeof(List <Country>)); SessionStateService.RegisterKnownType(typeof(Publication)); SessionStateService.RegisterKnownType(typeof(List <Publication>)); SessionStateService.RegisterKnownType(typeof(PublicationViewModel)); SessionStateService.RegisterKnownType(typeof(List <PublicationViewModel>)); SessionStateService.RegisterKnownType(typeof(TocCurrentNode)); SessionStateService.RegisterKnownType(typeof(IndexMenuItem)); SessionStateService.RegisterKnownType(typeof(ObservableCollection <IndexMenuItem>)); SessionStateService.RegisterKnownType(typeof(BreadcrumbNav)); SessionStateService.RegisterKnownType(typeof(ObservableCollection <BreadcrumbNav>)); SessionStateService.RegisterKnownType(typeof(NodeExpandStatue)); SessionStateService.RegisterKnownType(typeof(NavMenuItem)); SessionStateService.RegisterKnownType(typeof(NavigationManager)); SessionStateService.RegisterKnownType(typeof(AnnotationTag)); SessionStateService.RegisterKnownType(typeof(TagItem)); SessionStateService.RegisterKnownType(typeof(ObservableCollection <TagItem>)); SessionStateService.RegisterKnownType(typeof(SearchResultModel)); SessionStateService.RegisterKnownType(typeof(List <SearchResultModel>)); SessionStateService.RegisterKnownType(typeof(List <string>)); SessionStateService.RegisterKnownType(typeof(NavigationRecordManager)); SessionStateService.RegisterKnownType(typeof(List <NavigationRecord>)); SessionStateService.RegisterKnownType(typeof(NavigationRecord)); SessionStateService.RegisterKnownType(typeof(NavigationType)); SessionStateService.RegisterKnownType(typeof(RecentHistoryItem)); SessionStateService.RegisterKnownType(typeof(ObservableCollection <RecentHistoryItem>)); }
protected override void OnApplyTemplate() { Frame = GetTemplateChild("PlayerFrame") as Frame; { var frameFacade = new FrameFacadeAdapter(Frame); var sessionStateService = new SessionStateService(); var ns = new FrameNavigationService(frameFacade , (pageToken) => { if (pageToken == nameof(Views.VideoPlayerPage)) { return(typeof(Views.VideoPlayerPage)); } else if (pageToken == nameof(Views.LivePlayerPage)) { return(typeof(Views.LivePlayerPage)); } else { return(typeof(Views.BlankPage)); } }, sessionStateService); (DataContext as ViewModels.MenuNavigatePageBaseViewModel).SetNavigationService(ns); } base.OnApplyTemplate(); }
public static async Task <PlayerWindowManager> CreatePlayerWindowManager(CoreApplicationView playerView) { INavigationService ns = null; int id = 0; await playerView.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { var frame = new Frame(); var frameFacade = new FrameFacadeAdapter(frame); Window.Current.Content = frame; var sessionStateService = new SessionStateService(); ns = new FrameNavigationService(frameFacade , (pageToken) => { if (pageToken == nameof(Views.VideoPlayerControl)) { return(typeof(Views.VideoPlayerControl)); } else { return(typeof(Page)); } }, sessionStateService); id = ApplicationView.GetApplicationViewIdForWindow(playerView.CoreWindow); }); return(new PlayerWindowManager(playerView, id, ns)); }
protected override void OnRegisterKnownTypesForSerialization() { SessionStateService.RegisterKnownType(typeof(UserEntity)); SessionStateService.RegisterKnownType(typeof(TaskEntity)); SessionStateService.RegisterKnownType(typeof(TimeoutException)); SessionStateService.RegisterKnownType(typeof(TechnicalCardEntity)); }
protected override void OnRegisterKnownTypesForSerialization() { base.OnRegisterKnownTypesForSerialization(); SessionStateService.RegisterKnownType(typeof(Eqstra.BusinessLogic.UserInfo)); SessionStateService.RegisterKnownType(typeof(Eqstra.BusinessLogic.LoggedInUser)); SessionStateService.RegisterKnownType(typeof(Eqstra.BusinessLogic.ImageCapture)); SessionStateService.RegisterKnownType(typeof(ObservableCollection <ImageCapture>)); SessionStateService.RegisterKnownType(typeof(Eqstra.BusinessLogic.Enums.CaseTypeEnum)); SessionStateService.RegisterKnownType(typeof(Eqstra.BusinessLogic.Helpers.TaskStatus)); SessionStateService.RegisterKnownType(typeof(Syncfusion.UI.Xaml.Schedule.ScheduleAppointmentCollection)); SessionStateService.RegisterKnownType(typeof(Eqstra.BusinessLogic.CustomerDetails)); SessionStateService.RegisterKnownType(typeof(ObservableCollection <Eqstra.BusinessLogic.ServiceSchedule.DriverTask>)); SessionStateService.RegisterKnownType(typeof(City)); SessionStateService.RegisterKnownType(typeof(Country)); SessionStateService.RegisterKnownType(typeof(Region)); SessionStateService.RegisterKnownType(typeof(Suburb)); SessionStateService.RegisterKnownType(typeof(Province)); SessionStateService.RegisterKnownType(typeof(Supplier)); SessionStateService.RegisterKnownType(typeof(List <City>)); SessionStateService.RegisterKnownType(typeof(List <Country>)); SessionStateService.RegisterKnownType(typeof(List <Region>)); SessionStateService.RegisterKnownType(typeof(List <Suburb>)); SessionStateService.RegisterKnownType(typeof(List <Province>)); SessionStateService.RegisterKnownType(typeof(List <Supplier>)); SessionStateService.RegisterKnownType(typeof(LogonResult)); SessionStateService.RegisterKnownType(typeof(List <string>)); }
protected override System.Threading.Tasks.Task OnInitializeAsync(IActivatedEventArgs args) { SessionStateService.RegisterKnownType(typeof(Task)); SessionStateService.RegisterKnownType(typeof(TITask)); SessionStateService.RegisterKnownType(typeof(UserInfo)); SessionStateService.RegisterKnownType(typeof(TIData)); SessionStateService.RegisterKnownType(typeof(MaintenanceRepair)); SessionStateService.RegisterKnownType(typeof(Pithline.FMS.BusinessLogic.Portable.TIModels.ImageCapture)); EventAggregator = new EventAggregator(); _container.RegisterInstance(NavigationService); _container.RegisterInstance(EventAggregator); _container.RegisterInstance(SessionStateService); //Register Services _container.RegisterType <ITaskService, TaskService>(new ContainerControlledLifetimeManager()); _container.RegisterType <IUserService, UserService>(new ContainerControlledLifetimeManager()); _container.RegisterType <IHttpFactory, HttpFactory>(new ContainerControlledLifetimeManager()); ViewModelLocationProvider.SetDefaultViewTypeToViewModelTypeResolver((viewType) => { var viewModelTypeName = string.Format(CultureInfo.InvariantCulture, "Pithline.FMS.TechnicalInspection.UILogic.WindowsPhone.ViewModels.{0}ViewModel,Pithline.FMS.TechnicalInspection.UILogic.WindowsPhone, Version=1.0.0.0, Culture=neutral", viewType.Name); return(Type.GetType(viewModelTypeName)); }); return(base.OnInitializeAsync(args)); }
protected override void OnRegisterKnownTypesForSerialization() { SessionStateService.RegisterKnownType(typeof(VKGroup)); SessionStateService.RegisterKnownType(typeof(VKGroupExtended)); SessionStateService.RegisterKnownType(typeof(VKGroupSettings)); SessionStateService.RegisterKnownType(typeof(VKUser)); SessionStateService.RegisterKnownType(typeof(PaginatedCollection <VKNewsfeedItem>)); base.OnRegisterKnownTypesForSerialization(); }
protected override void OnRegisterKnownTypesForSerialization() { base.OnRegisterKnownTypesForSerialization(); SessionStateService.RegisterKnownType(typeof(Eqstra.BusinessLogic.UserInfo)); SessionStateService.RegisterKnownType(typeof(Eqstra.BusinessLogic.Customer)); SessionStateService.RegisterKnownType(typeof(Eqstra.BusinessLogic.LoggedInUser)); SessionStateService.RegisterKnownType(typeof(Eqstra.BusinessLogic.Helpers.TaskStatus)); SessionStateService.RegisterKnownType(typeof(Syncfusion.UI.Xaml.Schedule.ScheduleAppointmentCollection)); SessionStateService.RegisterKnownType(typeof(Eqstra.BusinessLogic.DocumentDelivery.CDCustomerDetails)); SessionStateService.RegisterKnownType(typeof(ObservableCollection <CollectDeliveryTask>)); SessionStateService.RegisterKnownType(typeof(List <string>)); }
protected override void OnRegisterKnownTypesForSerialization() { // Set up the list of known types for the SuspensionManager SessionStateService.RegisterKnownType(typeof(Address)); SessionStateService.RegisterKnownType(typeof(PaymentMethod)); SessionStateService.RegisterKnownType(typeof(UserInfo)); SessionStateService.RegisterKnownType(typeof(CheckoutDataViewModel)); SessionStateService.RegisterKnownType(typeof(ObservableCollection <CheckoutDataViewModel>)); SessionStateService.RegisterKnownType(typeof(ShippingMethod)); SessionStateService.RegisterKnownType(typeof(ReadOnlyDictionary <string, ReadOnlyCollection <string> >)); SessionStateService.RegisterKnownType(typeof(Order)); SessionStateService.RegisterKnownType(typeof(Product)); SessionStateService.RegisterKnownType(typeof(ReadOnlyCollection <Product>)); }
protected override void OnRegisterKnownTypesForSerialization() { base.OnRegisterKnownTypesForSerialization(); // Subscriptions page state SessionStateService.RegisterKnownType(typeof(TreeItemBase)); SessionStateService.RegisterKnownType(typeof(SubscriptionItem)); SessionStateService.RegisterKnownType(typeof(CategoryItem)); SessionStateService.RegisterKnownType(typeof(List <TreeItemBase>)); // Stream page state SessionStateService.RegisterKnownType(typeof(StreamItem)); SessionStateService.RegisterKnownType(typeof(EmptySpaceStreamItem)); SessionStateService.RegisterKnownType(typeof(StreamItemCollectionState)); }
public void SessionStateServiceDeleteReturnsSuccess() { // arrange const bool expectedResult = true; var documentService = A.Fake <IDocumentService <SessionStateModel <TestSessionStateModel> > >(); A.CallTo(() => documentService.DeleteAsync(A <Guid> .Ignored)).Returns(expectedResult); var sessionStateService = new SessionStateService <TestSessionStateModel>(documentService); // act var result = sessionStateService.DeleteAsync(Guid.NewGuid()).Result; // assert A.CallTo(() => documentService.DeleteAsync(A <Guid> .Ignored)).MustHaveHappenedOnceExactly(); A.Equals(result, expectedResult); }
public void SessionStateServiceGetByIdReturnsnullWhenNotFound() { // arrange SessionStateModel <TestSessionStateModel>?expectedResult = default; var documentService = A.Fake <IDocumentService <SessionStateModel <TestSessionStateModel> > >(); A.CallTo(() => documentService.GetByIdAsync(A <Guid> .Ignored, A <string> .Ignored)).Returns(expectedResult); var sessionStateService = new SessionStateService <TestSessionStateModel>(documentService); // act var result = sessionStateService.GetAsync(Guid.NewGuid()).Result; // assert A.CallTo(() => documentService.GetByIdAsync(A <Guid> .Ignored, A <string> .Ignored)).MustHaveHappenedOnceExactly(); A.Equals(result, expectedResult); }
public void SessionStateServiceSaveReturnsSuccess() { // arrange const HttpStatusCode expectedResult = HttpStatusCode.Created; var documentService = A.Fake <IDocumentService <SessionStateModel <TestSessionStateModel> > >(); A.CallTo(() => documentService.UpsertAsync(A <SessionStateModel <TestSessionStateModel> > .Ignored)).Returns(expectedResult); var sessionStateService = new SessionStateService <TestSessionStateModel>(documentService); // act var result = sessionStateService.SaveAsync(A.Fake <SessionStateModel <TestSessionStateModel> >()).Result; // assert A.CallTo(() => documentService.UpsertAsync(A <SessionStateModel <TestSessionStateModel> > .Ignored)).MustHaveHappenedOnceExactly(); A.Equals(result, expectedResult); }
protected override void OnRegisterKnownTypesForSerialization() { base.OnRegisterKnownTypesForSerialization(); // These types are used in the game state. SessionStateService.RegisterKnownType(typeof(GoGameState)); SessionStateService.RegisterKnownType(typeof(GoPlayer)); SessionStateService.RegisterKnownType(typeof(PlayerType)); SessionStateService.RegisterKnownType(typeof(GoGameStatus)); SessionStateService.RegisterKnownType(typeof(GoColor)); SessionStateService.RegisterKnownType(typeof(MoveType)); SessionStateService.RegisterKnownType(typeof(GoOperation)); SessionStateService.RegisterKnownType(typeof(MoveType)); SessionStateService.RegisterKnownType(typeof(GoResultCode)); SessionStateService.RegisterKnownType(typeof(GoMoveHistoryItem)); SessionStateService.RegisterKnownType(typeof(GoMove)); SessionStateService.RegisterKnownType(typeof(GoMoveResult)); }
protected override System.Threading.Tasks.Task OnInitializeAsync(IActivatedEventArgs args) { SessionStateService.RegisterKnownType(typeof(Country)); SessionStateService.RegisterKnownType(typeof(Province)); SessionStateService.RegisterKnownType(typeof(City)); SessionStateService.RegisterKnownType(typeof(Suburb)); SessionStateService.RegisterKnownType(typeof(Region)); SessionStateService.RegisterKnownType(typeof(Task)); SessionStateService.RegisterKnownType(typeof(ServiceSchedulingDetail)); SessionStateService.RegisterKnownType(typeof(Supplier)); SessionStateService.RegisterKnownType(typeof(DestinationType)); SessionStateService.RegisterKnownType(typeof(LocationType)); SessionStateService.RegisterKnownType(typeof(Address)); SessionStateService.RegisterKnownType(typeof(UserInfo)); SessionStateService.RegisterKnownType(typeof(ImageCapture)); EventAggregator = new EventAggregator(); _container.RegisterInstance(NavigationService); _container.RegisterInstance(EventAggregator); _container.RegisterInstance(SessionStateService); //Register Services _container.RegisterType <ITaskService, TaskService>(new ContainerControlledLifetimeManager()); _container.RegisterType <ISupplierService, SupplierService>(new ContainerControlledLifetimeManager()); _container.RegisterType <IServiceDetailService, ServiceDetailService>(new ContainerControlledLifetimeManager()); _container.RegisterType <ILocationService, LocationService>(new ContainerControlledLifetimeManager()); _container.RegisterType <IUserService, UserService>(new ContainerControlledLifetimeManager()); _container.RegisterType <IHttpFactory, HttpFactory>(new ContainerControlledLifetimeManager()); ViewModelLocationProvider.SetDefaultViewTypeToViewModelTypeResolver((viewType) => { var viewModelTypeName = string.Format(CultureInfo.InvariantCulture, "Pithline.FMS.ServiceScheduling.UILogic.Portable.{0}ViewModel,Pithline.FMS.ServiceScheduling.UILogic.Portable, Version=1.0.0.0, Culture=neutral", viewType.Name); return(Type.GetType(viewModelTypeName)); }); return(base.OnInitializeAsync(args)); }
protected override void OnRegisterKnownTypesForSerialization() { base.OnRegisterKnownTypesForSerialization(); SessionStateService.RegisterKnownType(typeof(Eqstra.BusinessLogic.UserInfo)); SessionStateService.RegisterKnownType(typeof(Eqstra.BusinessLogic.TITask)); SessionStateService.RegisterKnownType(typeof(Eqstra.BusinessLogic.Customer)); SessionStateService.RegisterKnownType(typeof(Eqstra.BusinessLogic.LoggedInUser)); SessionStateService.RegisterKnownType(typeof(Eqstra.BusinessLogic.ImageCapture)); SessionStateService.RegisterKnownType(typeof(ObservableCollection <ImageCapture>)); SessionStateService.RegisterKnownType(typeof(Eqstra.BusinessLogic.Enums.CaseTypeEnum)); SessionStateService.RegisterKnownType(typeof(Eqstra.BusinessLogic.Helpers.TaskStatus)); SessionStateService.RegisterKnownType(typeof(Syncfusion.UI.Xaml.Schedule.ScheduleAppointmentCollection)); SessionStateService.RegisterKnownType(typeof(Eqstra.BusinessLogic.Enums.VehicleTypeEnum)); SessionStateService.RegisterKnownType(typeof(Eqstra.BusinessLogic.CustomerDetails)); SessionStateService.RegisterKnownType(typeof(ObservableCollection <Eqstra.BusinessLogic.TITask>)); SessionStateService.RegisterKnownType(typeof(LogonResult)); SessionStateService.RegisterKnownType(typeof(TIData)); SessionStateService.RegisterKnownType(typeof(MaintenanceRepair)); SessionStateService.RegisterKnownType(typeof(List <string>)); }
/// <summary> /// Invoked when application execution is being suspended. Application state is saved /// without knowing whether the application will be terminated or resumed with the contents /// of memory still intact. /// </summary> /// <param name="sender">The source of the suspend request.</param> /// <param name="e">Details about the suspend request.</param> private async void OnSuspending(object sender, SuspendingEventArgs e) { IsSuspending = true; try { var deferral = e.SuspendingOperation.GetDeferral(); //Bootstrap inform navigation service that app is suspending. NavigationService.Suspending(); // Save application state await SessionStateService.SaveAsync(); deferral.Complete(); } finally { IsSuspending = false; } }
protected override void OnRegisterKnownTypesForSerialization() { base.OnRegisterKnownTypesForSerialization(); SessionStateService.RegisterKnownType(typeof(Eqstra.BusinessLogic.UserInfo)); SessionStateService.RegisterKnownType(typeof(Eqstra.BusinessLogic.Task)); SessionStateService.RegisterKnownType(typeof(Eqstra.BusinessLogic.Customer)); SessionStateService.RegisterKnownType(typeof(Eqstra.BusinessLogic.LoggedInUser)); SessionStateService.RegisterKnownType(typeof(Eqstra.BusinessLogic.Passenger.PAccessories)); SessionStateService.RegisterKnownType(typeof(Eqstra.BusinessLogic.Passenger.PBodywork)); SessionStateService.RegisterKnownType(typeof(Eqstra.BusinessLogic.ImageCapture)); SessionStateService.RegisterKnownType(typeof(ObservableCollection <ImageCapture>)); SessionStateService.RegisterKnownType(typeof(Eqstra.BusinessLogic.Passenger.PGlass)); SessionStateService.RegisterKnownType(typeof(Eqstra.BusinessLogic.Passenger.PInspectionProof)); SessionStateService.RegisterKnownType(typeof(Eqstra.BusinessLogic.Enums.CaseTypeEnum)); SessionStateService.RegisterKnownType(typeof(Eqstra.BusinessLogic.Helpers.TaskStatus)); SessionStateService.RegisterKnownType(typeof(Syncfusion.UI.Xaml.Schedule.ScheduleAppointmentCollection)); SessionStateService.RegisterKnownType(typeof(Eqstra.BusinessLogic.Enums.VehicleTypeEnum)); SessionStateService.RegisterKnownType(typeof(Eqstra.BusinessLogic.CustomerDetails)); SessionStateService.RegisterKnownType(typeof(ObservableCollection <Eqstra.BusinessLogic.Task>)); SessionStateService.RegisterKnownType(typeof(LogonResult)); SessionStateService.RegisterKnownType(typeof(List <string>)); }
/// <summary> /// Initializes the Frame and its content. /// </summary> /// <param name="args">The <see cref="IActivatedEventArgs"/> instance containing the event data.</param> /// <returns>A task of a Frame that holds the app content.</returns> protected async Task<Frame> InitializeFrameAsync(IActivatedEventArgs args) { // Create a Frame to act as the navigation context and navigate to the first page var rootFrame = new Frame(); if (ExtendedSplashScreenFactory != null) { Page extendedSplashScreen = this.ExtendedSplashScreenFactory.Invoke(args.SplashScreen); rootFrame.Content = extendedSplashScreen; } rootFrame.Navigated += OnNavigated; var frameFacade = new FrameFacadeAdapter(rootFrame); //Initialize PrismApplication common services SessionStateService = new SessionStateService(); //Configure VisualStateAwarePage with the ability to get the session state for its frame VisualStateAwarePage.GetSessionStateForFrame = frame => SessionStateService.GetSessionStateForFrame(frameFacade); //Associate the frame with a key SessionStateService.RegisterFrame(frameFacade, "AppFrame"); NavigationService = CreateNavigationService(frameFacade, SessionStateService); DeviceGestureService = CreateDeviceGestureService(); DeviceGestureService.InitializeEventHandlers(); DeviceGestureService.GoBackRequested += OnGoBackRequested; DeviceGestureService.GoForwardRequested += OnGoForwardRequested; // Set a factory for the ViewModelLocator to use the default resolution mechanism to construct view models ViewModelLocationProvider.SetDefaultViewModelFactory(Resolve); OnRegisterKnownTypesForSerialization(); if (args.PreviousExecutionState == ApplicationExecutionState.Terminated) { await SessionStateService.RestoreSessionStateAsync(); } await OnInitializeAsync(args); if (args.PreviousExecutionState == ApplicationExecutionState.Terminated) { // Restore the saved session state and navigate to the last page visited try { SessionStateService.RestoreFrameState(); NavigationService.RestoreSavedNavigation(); _isRestoringFromTermination = true; } catch (SessionStateServiceException) { // Something went wrong restoring state. // Assume there is no state and continue } } return rootFrame; }
/// <summary> /// Initializes the Frame and its content. /// </summary> /// <param name="args">The <see cref="IActivatedEventArgs"/> instance containing the event data.</param> /// <returns>A task of a Frame that holds the app content.</returns> protected virtual async Task <Frame> InitializeFrameAsync(IActivatedEventArgs args) { CreateAndConfigureContainer(); EventAggregator = CreateEventAggregator(); // Create a Frame to act as the navigation context and navigate to the first page var rootFrame = CreateRootFrame(); if (ExtendedSplashScreenFactory != null) { Page extendedSplashScreen = ExtendedSplashScreenFactory.Invoke(args.SplashScreen); rootFrame.Content = extendedSplashScreen; } var frameFacade = new FrameFacadeAdapter(rootFrame, EventAggregator); //Initialize PrismApplication common services SessionStateService = CreateSessionStateService(); //Configure VisualStateAwarePage with the ability to get the session state for its frame SessionStateAwarePage.GetSessionStateForFrame = frame => SessionStateService.GetSessionStateForFrame(frameFacade); //Associate the frame with a key SessionStateService.RegisterFrame(frameFacade, "AppFrame"); NavigationService = CreateNavigationService(frameFacade, SessionStateService); DeviceGestureService = CreateDeviceGestureService(); DeviceGestureService.GoBackRequested += OnGoBackRequested; DeviceGestureService.GoForwardRequested += OnGoForwardRequested; // Set a factory for the ViewModelLocator to use the default resolution mechanism to construct view models Logger.Log("Configuring ViewModelLocator", Category.Debug, Priority.Low); ConfigureViewModelLocator(); OnRegisterKnownTypesForSerialization(); bool canRestore = await SessionStateService.CanRestoreSessionStateAsync(); bool shouldRestore = canRestore && ShouldRestoreState(args); if (shouldRestore) { await SessionStateService.RestoreSessionStateAsync(); } await OnInitializeAsync(args); if (shouldRestore) { // Restore the saved session state and navigate to the last page visited try { SessionStateService.RestoreFrameState(); NavigationService.RestoreSavedNavigation(); _isRestoringFromTermination = true; } catch (SessionStateServiceException) { // Something went wrong restoring state. // Assume there is no state and continue } } return(rootFrame); }
/// <summary> /// Initializes the Frame and its content. /// </summary> /// <param name="args">The <see cref="IActivatedEventArgs"/> instance containing the event data.</param> /// <returns>A task of a Frame that holds the app content.</returns> protected async Task<Frame> InitializeFrameAsync(IActivatedEventArgs args) { var rootFrame = Window.Current.Content as Frame; // 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(); if (ExtendedSplashScreenFactory != null) { Page extendedSplashScreen = this.ExtendedSplashScreenFactory.Invoke(args.SplashScreen); rootFrame.Content = extendedSplashScreen; } var frameFacade = new FrameFacadeAdapter(rootFrame); //Initialize PrismApplication common services SessionStateService = new SessionStateService(); //Configure VisualStateAwarePage with the ability to get the session state for its frame VisualStateAwarePage.GetSessionStateForFrame = frame => SessionStateService.GetSessionStateForFrame(frameFacade); //Associate the frame with a key SessionStateService.RegisterFrame(frameFacade, "AppFrame"); NavigationService = CreateNavigationService(frameFacade, SessionStateService); if (ApiInformation.IsTypePresent("Windows.UI.ApplicationSettings.SettingsPane")) { // TODO BL : keep an eye on MSDN for future SDK release updates on SettingsPane #pragma warning disable CS0618 // Type or member is obsolete // Still marked on MSDN as a valid type for the Windows family SettingsPane.GetForCurrentView().CommandsRequested += OnCommandsRequested; #pragma warning restore CS0618 } // Register hardware back button event if present if (ApiInformation.IsEventPresent("Windows.Phone.UI.Input.HardwareButtons", "BackPressed")) { HardwareButtons.BackPressed += HardwareButtonsOnBackPressed; } // Set a factory for the ViewModelLocator to use the default resolution mechanism to construct view models ViewModelLocationProvider.SetDefaultViewModelFactory(Resolve); OnRegisterKnownTypesForSerialization(); if (args.PreviousExecutionState == ApplicationExecutionState.Terminated) { await SessionStateService.RestoreSessionStateAsync(); } await OnInitializeAsync(args); if (args.PreviousExecutionState == ApplicationExecutionState.Terminated) { // Restore the saved session state and navigate to the last page visited try { SessionStateService.RestoreFrameState(); NavigationService.RestoreSavedNavigation(); _isRestoringFromTermination = true; } catch (SessionStateServiceException) { // Something went wrong restoring state. // Assume there is no state and continue } } // Place the frame in the current Window Window.Current.Content = rootFrame; } return rootFrame; }
private async Task <HohoemaViewManager> GetEnsureSecondaryView() { if (CoreAppView == null) { var playerView = CoreApplication.CreateNewView(); HohoemaSecondaryViewFrameViewModel vm = null; int id = 0; ApplicationView view = null; INavigationService ns = null; await playerView.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() => { playerView.TitleBar.ExtendViewIntoTitleBar = true; var content = new Views.HohoemaSecondaryViewFrame(); var frameFacade = new FrameFacadeAdapter(content.Frame); var sessionStateService = new SessionStateService(); ns = new FrameNavigationService(frameFacade , (pageToken) => { if (pageToken == nameof(Views.VideoPlayerPage)) { return(typeof(Views.VideoPlayerPage)); } else if (pageToken == nameof(Views.LivePlayerPage)) { return(typeof(Views.LivePlayerPage)); } else { return(typeof(Views.BlankPage)); } }, sessionStateService); vm = content.DataContext as HohoemaSecondaryViewFrameViewModel; Window.Current.Content = content; id = ApplicationView.GetApplicationViewIdForWindow(playerView.CoreWindow); view = ApplicationView.GetForCurrentView(); view.TitleBar.ButtonBackgroundColor = Windows.UI.Colors.Transparent; view.TitleBar.ButtonInactiveBackgroundColor = Windows.UI.Colors.Transparent; Window.Current.Activate(); await ApplicationViewSwitcher.TryShowAsStandaloneAsync(id, ViewSizePreference.Default, MainView.Id, ViewSizePreference.Default); // ウィンドウサイズの保存と復元 if (Helpers.DeviceTypeHelper.IsDesktop) { var localObjectStorageHelper = App.Current.Container.Resolve <Microsoft.Toolkit.Uwp.Helpers.LocalObjectStorageHelper>(); if (localObjectStorageHelper.KeyExists(secondary_view_size)) { view.TryResizeView(localObjectStorageHelper.Read <Size>(secondary_view_size)); } view.VisibleBoundsChanged += View_VisibleBoundsChanged; } view.Consolidated += SecondaryAppView_Consolidated; }); ViewId = id; AppView = view; _SecondaryViewVM = vm; CoreAppView = playerView; NavigationService = ns; } NowShowingSecondaryView = true; return(this); }
protected override void OnRegisterKnownTypesForSerialization() { base.OnRegisterKnownTypesForSerialization(); SessionStateService.RegisterKnownType(typeof(Collection <ShareData>)); }
/// <summary> /// Initializes the Frame and its content. /// </summary> /// <param name="args">The <see cref="IActivatedEventArgs"/> instance containing the event data.</param> /// <returns>A task of a Frame that holds the app content.</returns> protected async Task <Frame> InitializeFrameAsync(IActivatedEventArgs args) { var rootFrame = Window.Current.Content as Frame; // 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(); if (ExtendedSplashScreenFactory != null) { Page extendedSplashScreen = this.ExtendedSplashScreenFactory.Invoke(args.SplashScreen); rootFrame.Content = extendedSplashScreen; } var frameFacade = new FrameFacadeAdapter(rootFrame); //Initialize PrismApplication common services SessionStateService = new SessionStateService(); //Configure VisualStateAwarePage with the ability to get the session state for its frame VisualStateAwarePage.GetSessionStateForFrame = frame => SessionStateService.GetSessionStateForFrame(frameFacade); //Associate the frame with a key SessionStateService.RegisterFrame(frameFacade, "AppFrame"); NavigationService = CreateNavigationService(frameFacade, SessionStateService); //TODO: BDN Figure out what to do about settings pane stuff //SettingsPane.GetForCurrentView().CommandsRequested += OnCommandsRequested; // Set a factory for the ViewModelLocator to use the default resolution mechanism to construct view models ViewModelLocationProvider.SetDefaultViewModelFactory(Resolve); OnRegisterKnownTypesForSerialization(); if (args.PreviousExecutionState == ApplicationExecutionState.Terminated) { await SessionStateService.RestoreSessionStateAsync(); } OnInitialize(args); if (args.PreviousExecutionState == ApplicationExecutionState.Terminated) { // Restore the saved session state and navigate to the last page visited try { SessionStateService.RestoreFrameState(); NavigationService.RestoreSavedNavigation(); _isRestoringFromTermination = true; } catch (SessionStateServiceException) { // Something went wrong restoring state. // Assume there is no state and continue } } // Place the frame in the current Window Window.Current.Content = rootFrame; } return(rootFrame); }
/// <summary> /// Initializes the Frame and its content. /// </summary> /// <param name="args">The <see cref="IActivatedEventArgs"/> instance containing the event data.</param> /// <returns>A task of a Frame that holds the app content.</returns> protected async Task <Frame> InitializeFrameAsync(IActivatedEventArgs args) { var rootFrame = Window.Current.Content as Frame; // 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(); if (ExtendedSplashScreenFactory != null) { Page extendedSplashScreen = this.ExtendedSplashScreenFactory.Invoke(args.SplashScreen); rootFrame.Content = extendedSplashScreen; } var frameFacade = new FrameFacadeAdapter(rootFrame); //Initialize PrismApplication common services SessionStateService = new SessionStateService(); //Configure VisualStateAwarePage with the ability to get the session state for its frame VisualStateAwarePage.GetSessionStateForFrame = frame => SessionStateService.GetSessionStateForFrame(frameFacade); //Associate the frame with a key SessionStateService.RegisterFrame(frameFacade, "AppFrame"); NavigationService = CreateNavigationService(frameFacade, SessionStateService); if (ApiInformation.IsTypePresent("Windows.UI.ApplicationSettings.SettingsPane")) { // TODO BL : keep an eye on MSDN for future SDK release updates on SettingsPane #pragma warning disable CS0618 // Type or member is obsolete // Still marked on MSDN as a valid type for the Windows family SettingsPane.GetForCurrentView().CommandsRequested += OnCommandsRequested; #pragma warning restore CS0618 } // Register hardware back button event if present if (ApiInformation.IsEventPresent("Windows.Phone.UI.Input.HardwareButtons", "BackPressed")) { HardwareButtons.BackPressed += HardwareButtonsOnBackPressed; } // Set a factory for the ViewModelLocator to use the default resolution mechanism to construct view models ViewModelLocationProvider.SetDefaultViewModelFactory(Resolve); OnRegisterKnownTypesForSerialization(); if (args.PreviousExecutionState == ApplicationExecutionState.Terminated) { await SessionStateService.RestoreSessionStateAsync(); } await OnInitializeAsync(args); if (args.PreviousExecutionState == ApplicationExecutionState.Terminated) { // Restore the saved session state and navigate to the last page visited try { SessionStateService.RestoreFrameState(); NavigationService.RestoreSavedNavigation(); _isRestoringFromTermination = true; } catch (SessionStateServiceException) { // Something went wrong restoring state. // Assume there is no state and continue } } // Place the frame in the current Window Window.Current.Content = rootFrame; } return(rootFrame); }
private async Task <PlayerViewManager> GetEnsureSecondaryView() { if (IsMainView && SecondaryCoreAppView == null) { var playerView = CoreApplication.CreateNewView(); HohoemaSecondaryViewFrameViewModel vm = null; int id = 0; ApplicationView view = null; INavigationService ns = null; await playerView.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() => { // SecondaryViewのスケジューラをセットアップ SecondaryViewScheduler = new CoreDispatcherScheduler(playerView.Dispatcher); playerView.TitleBar.ExtendViewIntoTitleBar = true; var content = new Views.HohoemaSecondaryViewFrame(); var frameFacade = new FrameFacadeAdapter(content.Frame, EventAggregator); var sessionStateService = new SessionStateService(); //sessionStateService.RegisterFrame(frameFacade, "secondary_view_player"); ns = new FrameNavigationService(frameFacade , (pageToken) => { if (pageToken == nameof(Views.VideoPlayerPage)) { return(typeof(Views.VideoPlayerPage)); } else if (pageToken == nameof(Views.LivePlayerPage)) { return(typeof(Views.LivePlayerPage)); } else { return(typeof(Views.BlankPage)); } }, sessionStateService); vm = content.DataContext as HohoemaSecondaryViewFrameViewModel; Window.Current.Content = content; id = ApplicationView.GetApplicationViewIdForWindow(playerView.CoreWindow); view = ApplicationView.GetForCurrentView(); view.TitleBar.ButtonBackgroundColor = Windows.UI.Colors.Transparent; view.TitleBar.ButtonInactiveBackgroundColor = Windows.UI.Colors.Transparent; Window.Current.Activate(); await ApplicationViewSwitcher.TryShowAsStandaloneAsync(id, ViewSizePreference.UseHalf, MainViewId, ViewSizePreference.UseHalf); // ウィンドウサイズの保存と復元 if (Services.Helpers.DeviceTypeHelper.IsDesktop) { var localObjectStorageHelper = App.Current.Container.Resolve <Microsoft.Toolkit.Uwp.Helpers.LocalObjectStorageHelper>(); if (localObjectStorageHelper.KeyExists(secondary_view_size)) { view.TryResizeView(localObjectStorageHelper.Read <Size>(secondary_view_size)); } view.VisibleBoundsChanged += View_VisibleBoundsChanged; } view.Consolidated += SecondaryAppView_Consolidated; }); SecondaryAppView = view; _SecondaryViewVM = vm; SecondaryCoreAppView = playerView; SecondaryViewPlayerNavigationService = ns; App.Current.Container.RegisterInstance(SECONDARY_VIEW_PLAYER_NAVIGATION_SERVICE, SecondaryViewPlayerNavigationService); } return(this); }
/// <summary> /// Initializes the Frame and its content. /// </summary> /// <param name="args">The <see cref="IActivatedEventArgs"/> instance containing the event data.</param> /// <returns>A task of a Frame that holds the app content.</returns> protected async Task<Frame> InitializeFrameAsync(IActivatedEventArgs args) { var rootFrame = Window.Current.Content as Frame; // 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(); if (ExtendedSplashScreenFactory != null) { Page extendedSplashScreen = this.ExtendedSplashScreenFactory.Invoke(args.SplashScreen); rootFrame.Content = extendedSplashScreen; } var frameFacade = new FrameFacadeAdapter(rootFrame); //Initialize PrismApplication common services SessionStateService = new SessionStateService(); //Configure VisualStateAwarePage with the ability to get the session state for its frame VisualStateAwarePage.GetSessionStateForFrame = frame => SessionStateService.GetSessionStateForFrame(frameFacade); //Associate the frame with a key SessionStateService.RegisterFrame(frameFacade, "AppFrame"); NavigationService = CreateNavigationService(frameFacade, SessionStateService); //TODO: BDN Figure out what to do about settings pane stuff //SettingsPane.GetForCurrentView().CommandsRequested += OnCommandsRequested; // Set a factory for the ViewModelLocator to use the default resolution mechanism to construct view models ViewModelLocationProvider.SetDefaultViewModelFactory(Resolve); OnRegisterKnownTypesForSerialization(); if (args.PreviousExecutionState == ApplicationExecutionState.Terminated) { await SessionStateService.RestoreSessionStateAsync(); } OnInitialize(args); if (args.PreviousExecutionState == ApplicationExecutionState.Terminated) { // Restore the saved session state and navigate to the last page visited try { SessionStateService.RestoreFrameState(); NavigationService.RestoreSavedNavigation(); _isRestoringFromTermination = true; } catch (SessionStateServiceException) { // Something went wrong restoring state. // Assume there is no state and continue } } // Place the frame in the current Window Window.Current.Content = rootFrame; } return rootFrame; }
protected override void OnRegisterKnownTypesForSerialization() { base.OnRegisterKnownTypesForSerialization(); SessionStateService.RegisterKnownType(typeof(Person)); }
protected override void OnRegisterKnownTypesForSerialization() { SessionStateService.RegisterKnownType(typeof(UserInfo)); SessionStateService.RegisterKnownType(typeof(User)); SessionStateService.RegisterKnownType(typeof(Dictionary <string, Collection <string> >)); }