public PackageInfo?SelectPackage(string?searchTerm)
        {
            if (_viewModel == null)
            {
                _viewModel = ViewModelFactory.CreatePackageChooserViewModel(null);
                _viewModel.PackageDownloadRequested += OnPackageDownloadRequested;
            }

            var dialog = new PackageChooserDialog(SettingsManager, _viewModel)
            {
                Owner = Window.Value
            };

            ReCenterPackageChooserDialog(dialog);

            try
            {
                dialog.ShowDialog(searchTerm);
            }
            catch (ArgumentException e)
            {
                UIServices.Show(e.Message, MessageLevel.Error);
            }

            return(_viewModel.SelectedPackage);
        }
Exemple #2
0
        private void SelectDependencyButtonClicked(object sender, System.Windows.RoutedEventArgs e)
        {
            if (!NetworkInterface.GetIsNetworkAvailable())
            {
                UIServices.Show(
                    PackageExplorer.Resources.Resources.NoNetworkConnection,
                    MessageLevel.Warning);
                return;
            }

            var dialog = new PackageChooserDialog()
            {
                Owner       = Window.GetWindow(this),
                DataContext = PackageViewModelFactory.CreatePackageChooserViewModel()
            };
            var result = dialog.ShowDialog();

            if (result ?? false)
            {
                var selectedPackage = dialog.SelectedPackage;
                if (selectedPackage != null)
                {
                    _newPackageDependency.Id          = selectedPackage.Id;
                    _newPackageDependency.VersionSpec = VersionUtility.ParseVersionSpec(selectedPackage.Version.ToString());
                }
            }
        }
Exemple #3
0
        private void OpenPackageFromNuGetFeed()
        {
            if (!NetworkInterface.GetIsNetworkAvailable())
            {
                UIServices.Show(
                    PackageExplorer.Resources.Resources.NoNetworkConnection,
                    MessageLevel.Warning);
                return;
            }

            bool canceled = AskToSaveCurrentFile();

            if (canceled)
            {
                return;
            }

            var dialog = new PackageChooserDialog()
            {
                Owner       = this,
                DataContext = _packageViewModelFactory.CreatePackageChooserViewModel()
            };

            bool?result = dialog.ShowDialog();

            if (result ?? false)
            {
                PackageInfo selectedPackage = dialog.SelectedPackage;
                if (selectedPackage != null)
                {
                    Version  packageVersion = new Version(selectedPackage.Version);
                    IPackage cachePackage   = MachineCache.Default.FindPackage(selectedPackage.Id, packageVersion);;
                    if (cachePackage == null || cachePackage.GetHash() != selectedPackage.PackageHash)
                    {
                        // if not in the cache, or if the cache package's hash is different from the feed hash, (re)download it
                        var progressWindow = new DownloadProgressWindow(
                            selectedPackage.DownloadUrl,
                            selectedPackage.Id,
                            packageVersion)
                        {
                            Owner = this
                        };

                        result = progressWindow.ShowDialog();
                        if (result ?? false)
                        {
                            cachePackage = progressWindow.DownloadedPackage;
                        }
                    }

                    if (cachePackage != null)
                    {
                        DataServicePackage servicePackage = selectedPackage.AsDataServicePackage();
                        servicePackage.CorePackage = cachePackage;
                        LoadPackage(servicePackage, selectedPackage.DownloadUrl.ToString(), PackageType.DataServicePackage);
                    }
                }
            }
        }
        public PackageInfo SelectPluginPackage()
        {
            if (_pluginDialog == null)
            {
                _pluginViewModel = ViewModelFactory.CreatePackageChooserViewModel(NuGetConstants.PluginFeedUrl);
                _pluginDialog    = new PackageChooserDialog(SettingsManager, _pluginViewModel);
            }

            _pluginDialog.Owner = Window.Value;
            ReCenterPackageChooserDialog(_pluginDialog);
            _pluginDialog.ShowDialog();
            return(_pluginViewModel.SelectedPackage);
        }
Exemple #5
0
        public PackageInfo SelectPackage(string searchTerm)
        {
            if (_dialog == null)
            {
                _viewModel = ViewModelFactory.CreatePackageChooserViewModel(null);
                _viewModel.PackageDownloadRequested += OnPackageDownloadRequested;
                _dialog = new PackageChooserDialog(_viewModel);
            }

            _dialog.Owner = Window.Value;
            ReCenterPackageChooserDialog(_dialog);
            _dialog.ShowDialog(searchTerm);
            return(_viewModel.SelectedPackage);
        }
        public PackageInfo?SelectPackage(string?searchTerm)
        {
            if (_viewModel == null)
            {
                _viewModel = ViewModelFactory.CreatePackageChooserViewModel(null);
                _viewModel.PackageDownloadRequested += OnPackageDownloadRequested;
            }

            var dialog = new PackageChooserDialog(SettingsManager, _viewModel)
            {
                Owner = Window.Value
            };

            ReCenterPackageChooserDialog(dialog);
            dialog.ShowDialog(searchTerm);

            return(_viewModel.SelectedPackage);
        }
Exemple #7
0
        private void OpenPackageFromNuGetFeed()
        {
            if (!NetworkInterface.GetIsNetworkAvailable()) {
                UIServices.Show(
                    PackageExplorer.Resources.Resources.NoNetworkConnection,
                    MessageLevel.Warning);
                return;
            }

            bool canceled = AskToSaveCurrentFile();
            if (canceled) {
                return;
            }

            var dialog = new PackageChooserDialog() {
                Owner = this,
                DataContext = _packageViewModelFactory.CreatePackageChooserViewModel()
            };

            bool? result = dialog.ShowDialog();
            if (result ?? false) {
                PackageInfo selectedPackage = dialog.SelectedPackage;
                if (selectedPackage != null) {
                    Version packageVersion = new Version(selectedPackage.Version);
                    IPackage cachePackage = MachineCache.Default.FindPackage(selectedPackage.Id, packageVersion); ;
                    if (cachePackage == null || cachePackage.GetHash() != selectedPackage.PackageHash) {
                        // if not in the cache, or if the cache package's hash is different from the feed hash, (re)download it
                        var progressWindow = new DownloadProgressWindow(
                            selectedPackage.DownloadUrl,
                            selectedPackage.Id,
                            packageVersion) {
                                Owner = this
                            };

                        result = progressWindow.ShowDialog();
                        if (result ?? false) {
                            cachePackage = progressWindow.DownloadedPackage;
                        }
                    }

                    if (cachePackage != null) {
                        DataServicePackage servicePackage = selectedPackage.AsDataServicePackage();
                        servicePackage.CorePackage = cachePackage;
                        LoadPackage(servicePackage, selectedPackage.DownloadUrl.ToString(), PackageType.DataServicePackage);
                    }
                }
            }
        }