コード例 #1
0
        /// <summary>
        /// Shows a custom NuGet-style gallery.
        /// </summary>
        /// <param name="galleryId">A gallery descriptor for the gallery</param>
        /// <param name="installRoot">Root path for installing packages.</param>
        /// <returns>Task that shows the gallery.</returns>
        public Task <bool?> ShowGallery(
            INuGetGalleryDescriptor descriptor,
            string installRoot)
        {
            var feedSource = new FeedSource(descriptor.FeedUri, descriptor.FeedName)
            {
                IsBuiltIn = true,
                FilterTag = descriptor.FilterTag,
            };

            var preferences = this.Host.GetExtensionSpecificPreferences(descriptor.PreferencesStore);
            IFeedSourceStore feedSourceStore;

            // we special case the NuGet gallery to use the system-wide NuGet store
            feedSourceStore = new NuGetFeedSourceStore(preferences);

            // Customize the custom gallery
            var packageSourcesViewModel = new PackageSourcesViewModel(new PackageSourcesModel(feedSource, feedSourceStore));

            var viewModel = new NuGetViewModel(
                descriptor,
                this.Host,
                packageSourcesViewModel,
                (sourceUrl, siteRoot) => new NuGetPackageManager(
                    sourceUrl,
                    siteRoot,
                    this.Host),
                installRoot,
                GetCurrentTaskScheduler());

            viewModel.ShouldShowPrereleaseFilter = true;

            return(Task.Factory.StartNew <bool?>(() =>
            {
                var view = new NuGetView(descriptor.DialogTitle);

                // show the gallery view
                view.DataContext = viewModel;

                return this.Host.ShowDialog(null, view);
            },
                                                 CancellationToken.None,
                                                 TaskCreationOptions.None,
                                                 GetCurrentTaskScheduler()));
        }
コード例 #2
0
ファイル: ButtonBarViewModel.cs プロジェクト: Newtopian/nuget
        public ButtonBarViewModel(NuGetViewModel nuGetViewModel, ICommand closeCommand)
        {
            this.PropertyNames = new List<string>()
            {
                "Loading",
                "SelectedPackage",
                "IsLicensePageVisible",
                "IsDetailsPaneVisible",
                "IsUninstallPageVisible",
            };

            this.ActionButtons = new ObservableCollection<ButtonViewModel>();

            this.NuGetViewModel = nuGetViewModel;
            
            this.CloseCommand = closeCommand;

            this.AcceptButton = new ButtonViewModel()
            {
                // the command assignment here is dynamic (might be update or install)
                Text = Resources.String_I__Accept,
                InvariantName = "acceptButton",
            };

            this.DeclineButton = new ButtonViewModel()
            {
                Command = this.NuGetViewModel.ShowListCommand,
                Text = Resources.String_I__Decline,
                InvariantName = "declineButton",
                IsCancel = true,
            };

            this.InstallButton = new ButtonViewModel()
            {
                Command = this.NuGetViewModel.ShowDetailsPageCommand,
                CommandParameter = PackageViewModelAction.InstallOrUninstall,
                Text = Resources.String__Install,
                InvariantName = "installButton",
            };

            this.UninstallButton = new ButtonViewModel()
            {
                Command = this.NuGetViewModel.ShowUninstallPageCommand,
                Text = Resources.String__Uninstall,
                InvariantName = "uninstallButton",
            };

            this.UpdateButton = new ButtonViewModel()
            {
                Command = this.NuGetViewModel.ShowDetailsPageCommand,
                CommandParameter = PackageViewModelAction.Update,
                Text = Resources.String__Update,
                InvariantName = "updateButton",
            };

            this.UpdateAllButton = new ButtonViewModel()
            {
                Command = this.NuGetViewModel.ShowLicensePageForAllCommand,
                CommandParameter = PackageViewModelAction.UpdateAll,
                Text = Resources.String__Update_All,
                InvariantName = "updateAllButton",
            };

            this.YesButton = new ButtonViewModel()
            {
                // this is dynamic:
                // - from the details page, we want to go to the license page
                // - from the uninstall page, we just want to uninstall
                Text = Resources.String__Yes,
                InvariantName = "yesButton",
            };

            this.NoButton = new ButtonViewModel()
            {
                Command = this.NuGetViewModel.ShowListCommand,
                Text = Resources.String__No,
                InvariantName = "noButton",
                IsCancel = true,
            };

            this.CloseButton = new ButtonViewModel()
            {
                Command = this.CloseCommand,
                Text = Resources.String__Close,
                InvariantName = "closeButton",
                IsCancel = true,
            };

            this.EnableButton = new ButtonViewModel()
            {
                Command = this.NuGetViewModel.EnableCommand,
                Text = Resources.String__Enable,
                InvariantName = "enableButton",
            };

            this.DisableButton = new ButtonViewModel()
            {
                Command = this.NuGetViewModel.DisableCommand,
                Text = Resources.String__Disable,
                InvariantName = "disableButton",
            };

            this.NuGetViewModel.PropertyChanged += Gallery_PropertyChanged;

            this.PrereleaseFilter = new List<string>()
            {
                Resources.Prerelease_Filter_StableOnly,
                Resources.Prerelease_Filter_IncludePrerelease,                
            };

            this.Refresh();
        }
コード例 #3
0
ファイル: NuGetGallery.cs プロジェクト: Newtopian/nuget
        /// <summary>
        /// Shows a custom NuGet-style gallery.
        /// </summary>
        /// <param name="galleryId">A gallery descriptor for the gallery</param>
        /// <param name="installRoot">Root path for installing packages.</param>
        /// <returns>Task that shows the gallery.</returns>
        public Task<bool?> ShowGallery(
            INuGetGalleryDescriptor descriptor,
            string installRoot)
        {
            var feedSource = new FeedSource(descriptor.FeedUri, descriptor.FeedName)
            {
                IsBuiltIn = true,
                FilterTag = descriptor.FilterTag,
            };

            var preferences = this.Host.GetExtensionSpecificPreferences(descriptor.PreferencesStore);
            IFeedSourceStore feedSourceStore;

            // we special case the NuGet gallery to use the system-wide NuGet store
            feedSourceStore = new NuGetFeedSourceStore(preferences);

            // Customize the custom gallery
            var packageSourcesViewModel = new PackageSourcesViewModel(new PackageSourcesModel(feedSource, feedSourceStore));

            var viewModel = new NuGetViewModel(
                descriptor,
                this.Host,
                packageSourcesViewModel,
                (sourceUrl, siteRoot) => new NuGetPackageManager(
                        sourceUrl,
                        siteRoot,
                        this.Host),
                installRoot,
                GetCurrentTaskScheduler());

            viewModel.ShouldShowPrereleaseFilter = true;

            return Task.Factory.StartNew<bool?>(() =>
            {
                var view = new NuGetView(descriptor.DialogTitle);

                // show the gallery view
                view.DataContext = viewModel;

                return this.Host.ShowDialog(null, view);
            },
            CancellationToken.None,
            TaskCreationOptions.None,
            GetCurrentTaskScheduler());
        }
コード例 #4
0
        public ButtonBarViewModel(NuGetViewModel nuGetViewModel, ICommand closeCommand)
        {
            this.PropertyNames = new List <string>()
            {
                "Loading",
                "SelectedPackage",
                "IsLicensePageVisible",
                "IsDetailsPaneVisible",
                "IsUninstallPageVisible",
            };

            this.ActionButtons = new ObservableCollection <ButtonViewModel>();

            this.NuGetViewModel = nuGetViewModel;

            this.CloseCommand = closeCommand;

            this.AcceptButton = new ButtonViewModel()
            {
                // the command assignment here is dynamic (might be update or install)
                Text          = Resources.String_I__Accept,
                InvariantName = "acceptButton",
            };

            this.DeclineButton = new ButtonViewModel()
            {
                Command       = this.NuGetViewModel.ShowListCommand,
                Text          = Resources.String_I__Decline,
                InvariantName = "declineButton",
                IsCancel      = true,
            };

            this.InstallButton = new ButtonViewModel()
            {
                Command          = this.NuGetViewModel.ShowDetailsPageCommand,
                CommandParameter = PackageViewModelAction.InstallOrUninstall,
                Text             = Resources.String__Install,
                InvariantName    = "installButton",
            };

            this.UninstallButton = new ButtonViewModel()
            {
                Command       = this.NuGetViewModel.ShowUninstallPageCommand,
                Text          = Resources.String__Uninstall,
                InvariantName = "uninstallButton",
            };

            this.UpdateButton = new ButtonViewModel()
            {
                Command          = this.NuGetViewModel.ShowDetailsPageCommand,
                CommandParameter = PackageViewModelAction.Update,
                Text             = Resources.String__Update,
                InvariantName    = "updateButton",
            };

            this.UpdateAllButton = new ButtonViewModel()
            {
                Command          = this.NuGetViewModel.ShowLicensePageForAllCommand,
                CommandParameter = PackageViewModelAction.UpdateAll,
                Text             = Resources.String__Update_All,
                InvariantName    = "updateAllButton",
            };

            this.YesButton = new ButtonViewModel()
            {
                // this is dynamic:
                // - from the details page, we want to go to the license page
                // - from the uninstall page, we just want to uninstall
                Text          = Resources.String__Yes,
                InvariantName = "yesButton",
            };

            this.NoButton = new ButtonViewModel()
            {
                Command       = this.NuGetViewModel.ShowListCommand,
                Text          = Resources.String__No,
                InvariantName = "noButton",
                IsCancel      = true,
            };

            this.CloseButton = new ButtonViewModel()
            {
                Command       = this.CloseCommand,
                Text          = Resources.String__Close,
                InvariantName = "closeButton",
                IsCancel      = true,
            };

            this.EnableButton = new ButtonViewModel()
            {
                Command       = this.NuGetViewModel.EnableCommand,
                Text          = Resources.String__Enable,
                InvariantName = "enableButton",
            };

            this.DisableButton = new ButtonViewModel()
            {
                Command       = this.NuGetViewModel.DisableCommand,
                Text          = Resources.String__Disable,
                InvariantName = "disableButton",
            };

            this.NuGetViewModel.PropertyChanged += Gallery_PropertyChanged;

            this.PrereleaseFilter = new List <string>()
            {
                Resources.Prerelease_Filter_StableOnly,
                Resources.Prerelease_Filter_IncludePrerelease,
            };

            this.Refresh();
        }