protected override void Run()
    {
        Dispatcher = Dispatcher.CurrentDispatcher;
        var model   = new BootstrapperApplicationModel(this);
        var command = model.BootstrapperApplication.Command;

        if (command.Action == LaunchAction.Uninstall && (command.Display == Display.None || command.Display == Display.Embedded))
        {
            model.LogMessage("Starting silent uninstaller.");
            var viewModel = new SilentUninstallViewModel(model, Engine);
            Engine.Detect();
        }
        else
        {
            model.LogMessage("Starting installer.");
            var viewModel = new InstallViewModel(model);
            var view      = new InstallView(viewModel);
            view.Closed += (sender, e) => Dispatcher.InvokeShutdown();
            model.SetWindowHandle(view);
            Engine.Detect();
            view.Show();
        }
        Dispatcher.Run();
        Engine.Quit(model.FinalResult);
    }
Exemple #2
0
        //This is our UI's primary entry point. This method will be called by the Burn engine.
        protected override void Run()
        {
            //Dispatcher object provides a means for sending messages between the UI thread and any backend threads.
            Dispatcher = Dispatcher.CurrentDispatcher;

            //MVVM pattern
            var model     = new BootstrapperApplicationModel(this);
            var viewModel = new InstallViewModel(model);
            var view      = new InstallView(viewModel);

            // Sets the handle for a Windows Presentation Foundation (WPF) window.
            // This handle is used by the Burn engine when performing the install or uninstall.
            model.SetWindowHandle(view);

            //This will start the Burn engine. engine will go-ahead to check if our bundle is already installed.
            this.Engine.Detect();

            //This code is to wait for a second before closing our flash screen. Otherwise the WPF window will load very fast.
            var timer = new DispatcherTimer {
                Interval = TimeSpan.FromSeconds(1)
            };

            timer.Start();
            timer.Tick += (sender, args) =>
            {
                model.LogMessage("Time elapsed.Loading the window");
                timer.Stop();
                view.Show();
            };

            //This event is fired when the window is loaded. Here we are closing the flash screen.
            view.Loaded += (sender, e) =>
            {
                model.LogMessage("FrameworkElement loaded event fired.");
                model.CustomBootstrapperApplication.Engine.CloseSplashScreen();
            };

            //halts execution of this method at that line until the Dispatcher is shut down.
            Dispatcher.Run();

            //shut down the Burn engine
            this.Engine.Quit(model.FinalResult);
        }
Exemple #3
0
        public InstallViewModel(BootstrapperApplicationModel model)
        {
            Model = model;
            State = InstallState.Initializing;
            executingPackageOrderIndex = new Dictionary <string, int>();

            InstallCommand = new RelayCommand
                             (
                param => Model.PlanAction(LaunchAction.Install),
                param => State == InstallState.NotPresent
                             );

            UninstallCommand = new RelayCommand
                               (
                param =>
            {
                Model.PlanAction(LaunchAction.Uninstall);
                isUnstalling = true;
            },
                param => State == InstallState.Present
                               );

            CancelCommand = new RelayCommand
                            (
                param =>
            {
                Model.LogMessage("Cancelling...");
                if (State == InstallState.Applying)
                {
                    State = InstallState.Cancelled;
                }
                else
                {
                    BootstrapperProgram.Dispatcher.InvokeShutdown();
                }
            },
                param => State != InstallState.Cancelled
                            );

            WireUpEventHandlers(Model);
        }
Exemple #4
0
 protected void PlanBegin(object sender, PlanBeginEventArgs e)
 {
     _model.LogMessage("PlanBegin event fired.");
     this._model.LogMessage("Display:" + this.DisplayLevel.ToString());
     this._model.LogMessage("Action:" + this.Action.ToString());
 }