Exemplo n.º 1
0
        public override void OnFrameworkInitializationCompleted()
        {
            if (Debugger.IsAttached)
            {
                // Debugging requires pdb loading etc, so we disable live reloading
                // during a test run with an attached debugger.
                var window = new Window();
                window.Content = CreateView(window);
                window.Show();
            }
            else
            {
                // Here, we create a new LiveViewHost, located in the 'Live.Avalonia'
                // namespace, and pass an ILiveView implementation to it. The ILiveView
                // implementation should have a parameterless constructor! Next, we
                // start listening for any changes in the source files. And then, we
                // show the LiveViewHost window. Simple enough, huh?
                var window = new LiveViewHost(this, Console.WriteLine);
                window.StartWatchingSourceFilesForHotReloading();
                window.Show();
            }

            // Here we subscribe to ReactiveUI default exception handler to avoid app
            // termination in case if we do something wrong in our view models. See:
            // https://www.reactiveui.net/docs/handbook/default-exception-handler/
            //
            // In case if you are using another MV* framework, please refer to its
            // documentation explaining global exception handling.
            RxApp.DefaultExceptionHandler = Observer.Create <Exception>(Console.WriteLine);
            base.OnFrameworkInitializationCompleted();
        }
Exemplo n.º 2
0
        public override void OnFrameworkInitializationCompleted()
        {
            var window = new LiveViewHost(this, Console.WriteLine);

            window.StartWatchingSourceFilesForHotReloading();
            window.Show();

            base.OnFrameworkInitializationCompleted();
        }
Exemplo n.º 3
0
        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();
        }