public override void OnFrameworkInitializationCompleted() { AssetBank.LoadAssets(); _lifetime = (IClassicDesktopStyleApplicationLifetime)ApplicationLifetime; // Initialize suspension hooks. var suspension = new AutoSuspendHelper(ApplicationLifetime); RxApp.SuspensionHost.CreateNewAppState = () => new MainWindowViewModel(); //RxApp.SuspensionHost.SetupDefaultSuspendResume(new NewtonsoftJsonSuspensionDriver("appstate.json")); RxApp.SuspensionHost.SetupDefaultSuspendResume(new NewtonsoftJsonSuspensionDriver(Program.Settings.ConfigDir + "/appstate.json")); suspension.OnFrameworkInitializationCompleted(); // Read main view model state from disk. var state = RxApp.SuspensionHost.GetAppState <MainWindowViewModel>(); Locator.CurrentMutable.RegisterConstant <IScreen>(state); // Register views. Locator.CurrentMutable.Register <IViewFor <ChessboardViewModel> >(() => new Chessboard()); Locator.CurrentMutable.Register <IViewFor <PlayViewModel> >(() => new PlayView()); Locator.CurrentMutable.Register <IViewFor <LoginViewModel> >(() => new LoginView()); Locator.CurrentMutable.Register <IViewFor <StartMenuViewModel> >(() => new StartMenuView()); Locator.CurrentMutable.Register <IViewFor <CreateGameViewModel> >(() => new CreateGameView()); Locator.CurrentMutable.Register <IViewFor <GameBrowserViewModel> >(() => new GameBrowserView()); Locator.CurrentMutable.Register <IViewFor <ChessClockViewModel> >(() => new ChessClock()); Locator.CurrentMutable.Register <IViewFor <CapturedPicesViewModel> >(() => new CapturedPices()); Locator.CurrentMutable.Register <IViewFor <ChatboxViewModel> >(() => new Chatbox()); Locator.CurrentMutable.Register <IViewFor <RegisterUserViewModel> >(() => new RegisterUserView()); // Show the main window. new MainWindow { DataContext = Locator.Current.GetService <IScreen>() }.Show(); base.OnFrameworkInitializationCompleted(); }
public App() { InitializeComponent(); _autoSuspendHelper = new AutoSuspendHelper(this); RxApp.SuspensionHost.CreateNewAppState = () => new MainState(); RxApp.SuspensionHost.SetupDefaultSuspendResume(new NewtonsoftJsonSuspensionDriver("appstate.json")); }
public override void Initialize() { AvaloniaXamlLoader.Load(this); _suspendHelper = new AutoSuspendHelper(ApplicationLifetime); RxApp.SuspensionHost.CreateNewAppState = () => new ConfigViewModel(); RxApp.SuspensionHost.SetupDefaultSuspendResume(new BinaryConfigurationSuspensionDriver(ConfigFileName)); }
protected override async void OnLaunched(LaunchActivatedEventArgs e) { var stateFile = await ApplicationData .Current.LocalFolder .CreateFileAsync("state.json", CreationCollisionOption.OpenIfExists); var autoSuspendHelper = new AutoSuspendHelper(this); RxApp.SuspensionHost.CreateNewAppState = () => new MainState(); RxApp.SuspensionHost.SetupDefaultSuspendResume(new NewtonsoftJsonSuspensionDriver(stateFile.Path)); autoSuspendHelper.OnLaunched(e); if (!(Window.Current.Content is Frame rootFrame)) { rootFrame = new Frame(); rootFrame.NavigationFailed += OnNavigationFailed; Window.Current.Content = rootFrame; } if (e.PrelaunchActivated == false) { if (rootFrame.Content == null) { rootFrame.Navigate(typeof(MainView), e.Arguments); } Window.Current.Activate(); } }
public override void OnFrameworkInitializationCompleted() { // Register services. // TODO: Move to project with models? var sp = BuildDependencies(); // Reregistering things in Splat. Locator.CurrentMutable.RegisterConstant(sp.GetService <IParameterVMsHolder>()); // Registering ViewModels in Splat locator. Locator.CurrentMutable.Register(() => sp.GetService <IDeviceConnectionViewModel>()); Locator.CurrentMutable.Register(() => sp.GetService <IAinsCountSelectionViewModel>()); var suspension = new AutoSuspendHelper(ApplicationLifetime); RxApp.SuspensionHost.CreateNewAppState = () => new MainWindowViewModel(); RxApp.SuspensionHost.SetupDefaultSuspendResume(new NewtonsoftJsonSuspensionDriver("appstate.json")); suspension.OnFrameworkInitializationCompleted(); Locator.CurrentMutable.RegisterConstant <IScreen>(RxApp.SuspensionHost.GetAppState <MainWindowViewModel>()); // Used for Router.Navigate? Locator.CurrentMutable.Register <IViewFor <ITelemetry100ViewModel> >(() => new Telemetry100View()); Locator.CurrentMutable.Register <IViewFor <ISettingsViewModel> >(() => new SettingsView()); //Locator.CurrentMutable.Register<IViewFor<HelpViewModel>>(() => new HelpView()); new MainWindow { DataContext = Locator.Current.GetService <IScreen>() }.Show(); //ViewModels.ParameterPresentation.ParametersPresenterXmlSerializer.Serialize("params.xml", new PsnProtocolConfigurationLoaderFromXml("psn.Буровая.АИН1.xml").LoadConfiguration(), false); base.OnFrameworkInitializationCompleted(); }
protected PhoneBootstrapper(PhoneApplicationFrame frame, AutoSuspendHelper suspendHelper) { Contract.Requires <ArgumentNullException>(frame != null, "frame"); Contract.Requires <ArgumentNullException>(suspendHelper != null, "suspendHelper"); this.frame = frame; this.suspendHelper = suspendHelper; }
public override void OnCreate() { base.OnCreate(); suspendHelper = new AutoSuspendHelper(this); RxApp.SuspensionHost.CreateNewAppState = () => new AppBootstrapper(); RxApp.SuspensionHost.SetupDefaultSuspendResume(); }
public AppDelegate() { // if you want to use a different Application Delegate class from "AppDelegate" // you can specify it here. RxApp.SuspensionHost.CreateNewAppState = () => new AppState(); RxApp.SuspensionHost.SetupDefaultSuspendResume(); autoSuspendHelper = new AutoSuspendHelper(this); }
/// <summary> /// Initializes the singleton application object. This is the first line of authored code /// executed, and as such is the logical equivalent of main() or WinMain(). /// </summary> public App() { this.InitializeComponent(); this.Suspending += this.OnSuspending; autoSuspendHelper = new AutoSuspendHelper(this); RxApp.SuspensionHost.CreateNewAppState = () => new MainPageViewModel(); RxApp.SuspensionHost.SetupDefaultSuspendResume(); }
public ActivationService(App app, Lazy <UIElement> shell = null) { _app = app; _shell = shell; RxApp.SuspensionHost.CreateNewAppState = () => new AppBootstrapper(); RxApp.SuspensionHost.SetupDefaultSuspendResume(); _autoSuspendHelper = new AutoSuspendHelper(app); }
protected iOSBootstrapper(ReactiveApplicationDelegate application, UIWindow window, AutoSuspendHelper suspendHelper) { Contract.Requires <ArgumentNullException>(application != null, "application"); Contract.Requires <ArgumentNullException>(window != null, "window"); Contract.Requires <ArgumentNullException>(suspendHelper != null, "suspendHelper"); this.application = application; this.window = window; this.suspendHelper = suspendHelper; }
public App() { this.mutex = SingleInstanceManager.TryAcquireMutex(); this.namedPipeManager = new NamedPipeManager(Assembly.GetExecutingAssembly().FullName); var autoSuspendHelper = new AutoSuspendHelper(this); GC.KeepAlive(autoSuspendHelper); BlobCache.ApplicationName = Assembly.GetExecutingAssembly().GetName().Name; }
public override void OnCreate() { base.OnCreate(); suspendHelper = new AutoSuspendHelper(this); RxApp.SuspensionHost.CreateNewAppState = () => { Console.WriteLine("Creating app state"); return(new AppBootstrapper()); }; RxApp.SuspensionHost.SetupDefaultSuspendResume(); }
// // This method is invoked when the application has loaded and is ready to run. In this // method you should instantiate the window, load the UI into it and then make the window // visible. // // You have 17 seconds to return from this method, or iOS will terminate your application. // public override bool FinishedLaunching(UIApplication app, NSDictionary options) { global::Xamarin.Forms.Forms.Init(); suspendHelper = ReactiveUI.XamlForms.Sample.App.Initialize(this); suspendHelper.FinishedLaunching(app, options); LoadApplication(new ReactiveUI.XamlForms.Sample.App()); base.FinishedLaunching(app, options); return(true); }
public App() { this.mutex = SingleInstanceManager.TryAcquireMutex(); this.namedPipeManager = new NamedPipeManager(Assembly.GetExecutingAssembly()?.FullName ?? String.Empty); PlatformRegistrationManager.SetRegistrationNamespaces(RegistrationNamespace.Wpf); var autoSuspendHelper = new AutoSuspendHelper(this); GC.KeepAlive(autoSuspendHelper); BlobCache.ApplicationName = Assembly.GetExecutingAssembly().GetName()?.Name ?? String.Empty; }
public AppDelegate() { RxApp.SuspensionHost.CreateNewAppState = () => new AppState(); RxApp.SuspensionHost.SetupDefaultSuspendResume(); MessageBar.MessageBarManager.SharedInstance.StyleSheet = new RenderMessageBarStyleSheet(); #if DEBUG || ADHOC ServicePointManager.ServerCertificateValidationCallback += (sender, certificate, chain, errors) => true; #endif autoSuspendHelper = new AutoSuspendHelper(this); }
public override void OnCreate() { base.OnCreate(); _autoSuspendHelper = new AutoSuspendHelper(this); // CoolStuff: The job of AutoSuspendHelper is, that it will // automatically save and reload exactly *one* object of your // choice when the app is suspended. If the object can't be // reloaded (i.e. if the app is starting for the first time), // we're telling ReactiveUI here how to create a new one from // scratch. RxApp.SuspensionHost.CreateNewAppState = () => new AppBootstrapper(); RxApp.SuspensionHost.SetupDefaultSuspendResume(); }
public override bool FinishedLaunching(UIApplication app, NSDictionary options) { Forms.Init(); RxApp.SuspensionHost.SetupDefaultSuspendResume(); suspendHelper = new AutoSuspendHelper(this); suspendHelper.FinishedLaunching(app, options); window = new UIWindow(UIScreen.MainScreen.Bounds); var bootstrapper = RxApp.SuspensionHost.GetAppState <AppBootstrapper>(); window.RootViewController = bootstrapper.CreateMainPage().CreateViewController(); window.MakeKeyAndVisible(); return(true); }
public override void OnFrameworkInitializationCompleted() { ServicePropvider = ConfigureServices(new ServiceCollection()); var suspension = new AutoSuspendHelper(ApplicationLifetime); RxApp.DefaultExceptionHandler = ServicePropvider.GetService <AppExceptionHandler>(); RxApp.SuspensionHost.SetupDefaultSuspendResume(ServicePropvider.GetService <AppSuspendDriver>()); suspension.OnFrameworkInitializationCompleted(); var mainWindow = ServicePropvider.GetService <MainWindow>(); mainWindow.DataContext = ServicePropvider.GetService <MainWindowViewModel>(); mainWindow.Show(); base.OnFrameworkInitializationCompleted(); }
public void AutoSuspendHelper_Should_Immediately_Fire_IsLaunchingNew() { using (UnitTestApplication.Start(TestServices.MockWindowingPlatform)) using (var lifetime = new ClassicDesktopStyleApplicationLifetime(Application.Current)) { var isLaunchingReceived = false; var application = AvaloniaLocator.Current.GetService <Application>(); application.ApplicationLifetime = lifetime; // Initialize ReactiveUI Suspension as in real-world scenario. var suspension = new AutoSuspendHelper(application.ApplicationLifetime); RxApp.SuspensionHost.IsLaunchingNew.Subscribe(_ => isLaunchingReceived = true); suspension.OnFrameworkInitializationCompleted(); Assert.True(isLaunchingReceived); } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); MobileCenter.Start("34d7d8ca-c1f9-4099-b41c-da723fb37bf6", typeof(Analytics), typeof(Crashes)); RxApp.SuspensionHost.CreateNewAppState = () => new AppBootstrapper(); _suspendHelper = new AutoSuspendHelper(Application); RxApp.SuspensionHost.SetupDefaultSuspendResume(); var bootstrapper = RxApp.SuspensionHost.GetAppState <AppBootstrapper>(); //bootstrapper.CreateFlyoutMenu(); }
public override void OnFrameworkInitializationCompleted() { var suspension = new AutoSuspendHelper(ApplicationLifetime); RxApp.SuspensionHost.CreateNewAppState = () => new MainViewModel(); RxApp.SuspensionHost.SetupDefaultSuspendResume(new NewtonsoftJsonSuspensionDriver("appstate.json")); suspension.OnFrameworkInitializationCompleted(); Locator.CurrentMutable.RegisterConstant <IScreen>(RxApp.SuspensionHost.GetAppState <MainViewModel>()); Locator.CurrentMutable.Register <IViewFor <SearchViewModel> >(() => new SearchView()); Locator.CurrentMutable.Register <IViewFor <LoginViewModel> >(() => new LoginView()); new MainView { DataContext = Locator.Current.GetService <IScreen>() }.Show(); base.OnFrameworkInitializationCompleted(); }
protected override void OnCreate(Bundle savedInstanceState) { var path = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal); var file = System.IO.Path.Combine(path, "state.json"); var autoSuspendHelper = new AutoSuspendHelper(Application); RxApp.SuspensionHost.CreateNewAppState = () => new MainState(); RxApp.SuspensionHost.SetupDefaultSuspendResume(new NewtonsoftJsonSuspensionDriver(file)); TabLayoutResource = Resource.Layout.Tabbar; ToolbarResource = Resource.Layout.Toolbar; base.OnCreate(savedInstanceState); global::Xamarin.Forms.Forms.Init(this, savedInstanceState); Plugin.Iconize.Iconize.Init(Resource.Id.toolbar, Resource.Id.sliding_tabs); LoadApplication(new App(BuildMainViewModel())); }
public override void OnFrameworkInitializationCompleted() { Akavache.BlobCache.ApplicationName = "CamelotiaV2"; var suspension = new AutoSuspendHelper(ApplicationLifetime); RxApp.SuspensionHost.CreateNewAppState = () => new MainState(); RxApp.SuspensionHost.SetupDefaultSuspendResume(new NewtonsoftJsonSuspensionDriver("appstate.json")); suspension.OnFrameworkInitializationCompleted(); if (Debugger.IsAttached || IsRelease()) { var window = new Window { Height = 590, Width = 850, MinHeight = 590, MinWidth = 850, }; AttachDevTools(window); window.Content = CreateView(window); window.Show(); } else { var window = new LiveViewHost(this, Console.WriteLine) { Height = 590, Width = 850, MinHeight = 590, MinWidth = 850, Content = "Please wait for the app to rebuild from sources...", HorizontalContentAlignment = HorizontalAlignment.Center, VerticalContentAlignment = VerticalAlignment.Center, }; AttachDevTools(window); window.StartWatchingSourceFilesForHotReloading(); window.Show(); } RxApp.DefaultExceptionHandler = Observer.Create <Exception>(Console.WriteLine); base.OnFrameworkInitializationCompleted(); }
public override void OnFrameworkInitializationCompleted() { // Configure ReactiveUI suspension management. var suspension = new AutoSuspendHelper(ApplicationLifetime); // RxApp.SuspensionHost.CreateNewAppState = () => new MainState(); // RxApp.SuspensionHost.SetupDefaultSuspendResume(new NewtonsoftJsonSuspensionDriver("appstate.json")); suspension.OnFrameworkInitializationCompleted(); base.OnFrameworkInitializationCompleted(); // Configure app dependencies. var window = new MainView(); // var styles = new AvaloniaStyleManager(window); Akavache.BlobCache.ApplicationName = "SocialQ"; // window.SwitchThemeButton.Click += (sender, args) => styles.UseNextTheme(); window.DataContext = new MainViewModel(); // window.DataContext = new MainViewModel( // RxApp.SuspensionHost.GetAppState<MainState>(), // new ProviderFactory( // new AvaloniaYandexAuthenticator(), // Akavache.BlobCache.UserAccount // ), // (state, provider) => new ProviderViewModel(state, // owner => new CreateFolderViewModel(state.CreateFolderState, owner, provider), // owner => new RenameFileViewModel(state.RenameFileState, owner, provider), // (file, owner) => new FileViewModel(owner, file), // (folder, owner) => new FolderViewModel(owner, folder), // new AuthViewModel( // new DirectAuthViewModel(state.AuthState.DirectAuthState, provider), // new HostAuthViewModel(state.AuthState.HostAuthState, provider), // new OAuthViewModel(provider), // provider // ), // new AvaloniaFileManager(window), // provider // ) // ); window.Show(); }
public override void OnFrameworkInitializationCompleted() { Locator.CurrentMutable.Register(() => new ServiceBusHelper(), typeof(IServiceBusHelper)); Locator.CurrentMutable.RegisterLazySingleton(() => new LoggingService(), typeof(ILoggingService)); var suspension = new AutoSuspendHelper(ApplicationLifetime); RxApp.SuspensionHost.CreateNewAppState = () => new AppState(); RxApp.SuspensionHost.SetupDefaultSuspendResume(new NewtonsoftJsonSuspensionDriver("appstate.json")); suspension.OnFrameworkInitializationCompleted(); var state = RxApp.SuspensionHost.GetAppState <AppState>(); Locator.CurrentMutable.RegisterLazySingleton(() => state, typeof(IAppState)); new MainWindow { DataContext = new MainWindowViewModel() }.Show(); base.OnFrameworkInitializationCompleted(); }
/// <summary> /// Constructor for the Application object. /// </summary> public App() { // Global handler for uncaught exceptions. UnhandledException += Application_UnhandledException; // Standard XAML initialization InitializeComponent(); // Phone-specific initialization InitializePhoneApplication(); // Language display initialization InitializeLanguage(); // Show graphics profiling information while debugging. if (Debugger.IsAttached) { // Display the current frame rate counters. Application.Current.Host.Settings.EnableFrameRateCounter = true; // Show the areas of the app that are being redrawn in each frame. //Application.Current.Host.Settings.EnableRedrawRegions = true; // Enable non-production analysis visualization mode, // which shows areas of a page that are handed off to GPU with a colored overlay. //Application.Current.Host.Settings.EnableCacheVisualization = true; // Prevent the screen from turning off while under the debugger by disabling the // application's idle detection. // Caution: - Use this under debug mode only. Application that disables user idle // detection will continue to run and consume battery power when the user // is not using the phone. PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled; } this.autoSuspendHelper = new AutoSuspendHelper(this); RxApp.SuspensionHost.CreateNewAppState = () => new AppBootstrapper(); RxApp.SuspensionHost.SetupDefaultSuspendResume(); }
public void ShouldPersistState_Should_Fire_On_App_Exit_When_SuspensionDriver_Is_Initialized() { using (UnitTestApplication.Start(TestServices.MockWindowingPlatform)) using (var lifetime = new ClassicDesktopStyleApplicationLifetime(Application.Current)) { var shouldPersistReceived = false; var application = AvaloniaLocator.Current.GetService <Application>(); application.ApplicationLifetime = lifetime; // Initialize ReactiveUI Suspension as in real-world scenario. var suspension = new AutoSuspendHelper(application.ApplicationLifetime); RxApp.SuspensionHost.CreateNewAppState = () => new AppState { Example = "Foo" }; RxApp.SuspensionHost.ShouldPersistState.Subscribe(_ => shouldPersistReceived = true); RxApp.SuspensionHost.SetupDefaultSuspendResume(new DummySuspensionDriver()); suspension.OnFrameworkInitializationCompleted(); lifetime.Shutdown(); Assert.True(shouldPersistReceived); Assert.Equal("Foo", RxApp.SuspensionHost.GetAppState <AppState>().Example); } }
public override void OnFrameworkInitializationCompleted() { // Create the AutoSuspendHelper. var suspension = new AutoSuspendHelper(ApplicationLifetime); RxApp.SuspensionHost.CreateNewAppState = () => new MainWindowViewModel(); RxApp.SuspensionHost.SetupDefaultSuspendResume(new JsonSuspensionDriver(new JsonSuspensionSettings { Filename = "appstate.json", JsonSerializerSettings = new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.All, Formatting = Formatting.Indented } }, Locator.Current.GetService <IList <JsonConverter> >())); suspension.OnFrameworkInitializationCompleted(); // Load the saved view model state. var state = RxApp.SuspensionHost.GetAppState <MainWindowViewModel>(); new MainWindow { DataContext = state }.Show(); base.OnFrameworkInitializationCompleted(); }
public AutoSuspendHelper Initialize() { var scheduler = RxApp.MainThreadScheduler; //Make sure this is called after something accesses RxApp so that RxApp can register its defaults //And then this can override those Registrations.Register(Locator.CurrentMutable); autoSuspendHelper = new AutoSuspendHelper(this); RxApp.SuspensionHost.SetupDefaultSuspendResume(); RxApp.SuspensionHost.CreateNewAppState = () => { //Ensure App has initialize //Xam Forms gets annoyed if you don't have a page on the //Navigation stack so this just ensures that it is there var bootStrapper = new AppBootstrapper(); bootStrapper.Init(); return(bootStrapper); }; return(autoSuspendHelper); }