コード例 #1
0
        public InstallListViewModel(IChocolateyInstaller installer, ConsoleViewModel console, InstalledPackagesViewModel installedPackages, ISetupScriptCreator scriptCreator)
        {
            this._installer = installer;
            this._console = console;
            this._installedPackages = installedPackages;
            this._scriptCreator = scriptCreator;

            this.Packages = new ObservableCollection<ChocolateyPackageVersion>();
            this.IsWorking = false;
            this.StatusMessage = "Ready";

            this.AddPackageToInstallListCommand = new RelayCommand<ChocolateyPackageVersion>(this.AddPackageToInstallList);
            this.RemovePackageFromInstallListCommand =
                new RelayCommand<ChocolateyPackageVersion>(this.RemovePackageToInstallList, package => package != null);
            this.ClearInstallListCommand = new RelayCommand(() => this.Packages.Clear(), () => this.Packages.Any() && !this.IsWorking);
            this.InstallPackagesCommand = new RelayCommand(async () => await this.InstallPackages(), () => this.Packages.Any() && !this.IsWorking);
            this.CancelInstallCommand = new RelayCommand(async () => await this.CancelInstall());
            this.SaveSetupScriptCommand = new RelayCommand(this.SaveSetupScript, () => this.Packages.Any() && !this.IsWorking);
        }
コード例 #2
0
        public InstalledPackagesViewModel(
            IInstalledPackagesManager packagesManager, 
            IChocolateyInstaller installer, 
            ConsoleViewModel console)
        {
            this._packagesManager = packagesManager;
            this._installer = installer;
            this._console = console;

            this.UninstallPackageCommand = new RelayCommand<ChocolateyPackageVersion>(async p => await this.UninstallPackage(p), p => p != null && !this.IsWorking);
            this.UpdatePackageCommand = new RelayCommand<ChocolateyPackageVersion>(async p => await this.UpdatePackage(p), p => p != null && !this.IsWorking);
            this.RefreshInstalledPackagesCommand = new RelayCommand(async () => await this.RefreshPackages(), () => !this.IsWorking);
            this.UpdateAllCommand = new RelayCommand(async () => await this.UpdateAllPackages(), () => !this.IsWorking);

            this.IsWorking = false;
            this.StatusMessage = "Ready";
            this.SelectedPackage = null;

            this.InstalledPackages = new ObservableCollection<ChocolateyPackageVersion>();
        }
コード例 #3
0
        public ChocolateyPackagesViewModel(
            IChocolateyFeedFactory feedFactory,
            ChocolateySourcesViewModel sourcesViewModel,
            ConsoleViewModel consoleViewModel,
            IChocolateyInstaller installer,
            InstalledPackagesViewModel installedPackagesViewModel,
            InstallListViewModel installListView)
        {
            this._sourcesViewModel = sourcesViewModel;
            this._feedFactory = feedFactory;
            this._consoleViewModel = consoleViewModel;
            this._installer = installer;
            this._installedPackagesViewModel = installedPackagesViewModel;
            this._installListViewModel = installListView;

            this._sourcesViewModel.SelectedSourceChanged += async newSource => await this.HandleSelectedSourceChanged(newSource);

            this.RegisterCommands();

            this.IsWorking = false;
            this.CanSelectPackage = false;
            this.StatusMessage = "Ready";
        }