예제 #1
0
 public InstallViewModel(
     BootstrapperApplicationModel model)
 {
     this.model = model;
     this.State = InstallState.Initializing;
     this.WireUpEventHandlers();
     this.InstallCommand = new DelegateCommand(() =>
                                               this.model.PlanAction(LaunchAction.Install),
                                               () => this.State == InstallState.NotPresent);
     this.UninstallCommand = new DelegateCommand(() =>
                                                 this.model.PlanAction(LaunchAction.Uninstall),
                                                 () => this.State == InstallState.Present);
     this.CancelCommand = new DelegateCommand(() =>
     {
         this.model.LogMessage("Cancelling...");
         if (this.State == InstallState.Applying)
         {
             this.State = InstallState.Cancelled;
         }
         else
         {
             CustomBootstrapperApplication.Dispatcher
             .InvokeShutdown();
         }
     }, () => this.State != InstallState.Cancelled);
 }
    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);
    }
예제 #3
0
        public void Initialize(BootstrapperApplicationModel bootstrapperApplicationModel)
        {
            this.Model                 = bootstrapperApplicationModel;
            this.Model.DetectBegin    += Model_DetectBegin;
            this.Model.DetectComplete += Model_DetectComplete;

            this.Model.PlanBegin          += Model_PlanBegin;
            this.Model.PlanComplete       += Model_PlanComplete;
            this.Model.CommandLineParsing += Model_CommandLineParsing;
            this.Model.ApplyComplete      += Model_ApplyComplete;
        }
        protected override void Run()
        {
            Dispatcher = Dispatcher.CurrentDispatcher;
            var model     = new BootstrapperApplicationModel(this);
            var viewModel = new InstallViewModel(model);

            view    = new InstallView(viewModel);
            restreq = new restart();
            model.SetWindowHandle(view);
            this.Engine.Detect();
            view.Show();
            Dispatcher.Run();
            this.Engine.Quit(model.FinalResult);
        }
예제 #5
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);
        }
예제 #6
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);
        }
예제 #7
0
        private void WireUpEventHandlers(BootstrapperApplicationModel model)
        {
            model.Application.CacheComplete        += CacheComplete;
            model.Application.CacheAcquireProgress += CacheAcquireProgress;

            model.Application.ExecuteProgress   += ExecuteProgress;
            model.Application.ExecuteMsiMessage += ExecuteMsiMessage;

            model.Application.PlanBegin           += PlanBegin;
            model.Application.PlanComplete        += PlanComplete;
            model.Application.PlanPackageComplete += PlanPackageComplete;

            model.Application.ApplyBegin    += ApplyBegin;
            model.Application.Progress      += ApplyProgress;
            model.Application.ApplyComplete += ApplyComplete;

            model.Application.ExecutePackageBegin    += ExecutePackageBegin;
            model.Application.ExecutePackageComplete += ExecutePackageComplete;

            model.Application.DetectPackageComplete += DetectPackageComplete;
        }
 public SilentUninstallViewModel(BootstrapperApplicationModel model, Engine engine)
 {
     this.model  = model;
     this.engine = engine;
     WireUpEventHandlers();
 }
예제 #9
0
 public WPFBootstrapper()
 {
     this.model = new BootstrapperApplicationModel(this);
 }