public override void AddSettings(string key, UserSettings obj)
 {
     _settings[key] = obj;
 }
 public abstract void AddSettings(string key, UserSettings obj);
 public abstract void AddSettings(string key, UserSettings settings);
 public override void AddSettings(string key, UserSettings obj)
 {
     _package.AddWindowSettings(key, obj);
 }
 public void AddSettings(string key, UserSettings obj)
 {
     _settings.WindowSettings[key] = obj;
 }
        private void InitSourceRepoList(UserSettings settings)
        {
            // init source repo list
            _sourceRepoList.Items.Clear();
            var enabledSources = GetEnabledSources();
            foreach (var source in enabledSources)
            {
                _sourceRepoList.Items.Add(source);
            }

            // get active source name.
            string activeSourceName = null;

            // try saved user settings first.
            if (settings != null && !String.IsNullOrEmpty(settings.SourceRepository))
            {
                activeSourceName = settings.SourceRepository;
            }
            else
            {
                // no user settings found. Then use the active source from PackageSourceProvider.
                activeSourceName = Model.Context.SourceProvider.PackageSourceProvider.ActivePackageSourceName;
            }

            if (activeSourceName != null)
            {
                _activeSource = enabledSources
                    .FirstOrDefault(s => activeSourceName.Equals(s.PackageSource.Name, StringComparison.CurrentCultureIgnoreCase));
            }

            if (_activeSource == null)
            {
                _activeSource = enabledSources.FirstOrDefault();
            }

            if (_activeSource != null)
            {
                _sourceRepoList.SelectedItem = _activeSource;
            }
        }
        // Save the settings of this doc window in the UIContext. Note that the settings
        // are not guaranteed to be persisted. We need to call Model.Context.SaveSettings()
        // to persist the settings.
        public void SaveSettings()
        {
            UserSettings settings = new UserSettings();
            if (_activeSource != null)
            {
                settings.SourceRepository = _activeSource.PackageSource.Name;
            }

            settings.ShowPreviewWindow = _detailModel.Options.ShowPreviewWindow;
            settings.RemoveDependencies = _detailModel.Options.RemoveDependencies;
            settings.ForceRemove = _detailModel.Options.ForceRemove;
            settings.DependencyBehavior = _detailModel.Options.SelectedDependencyBehavior.Behavior;
            settings.FileConflictAction = _detailModel.Options.SelectedFileConflictAction.Action;
            settings.IncludePrerelease = _checkboxPrerelease.IsChecked == true;

            var filterItem = _filter.SelectedItem as FilterItem;
            if (filterItem != null)
            {
                settings.SelectedFilter = filterItem.Filter;
            }

            string key = GetSettingsKey();
            Model.Context.AddSettings(key, settings);
        }
        private void ApplySettings(
            UserSettings settings, 
            NuGet.Configuration.ISettings nugetSettings)
        {
            if (settings == null)
            {
                if (nugetSettings == null)
                {
                    return;
                }

                // set depency behavior to the value from nugetSettings
                SetSelectedDepencyBehavior(GetDependencyBehaviorFromConfig(nugetSettings));
                return;
            }

            _detailModel.Options.ShowPreviewWindow = settings.ShowPreviewWindow;
            _detailModel.Options.RemoveDependencies = settings.RemoveDependencies;
            _detailModel.Options.ForceRemove = settings.ForceRemove;
            _checkboxPrerelease.IsChecked = settings.IncludePrerelease;

            SetSelectedDepencyBehavior(settings.DependencyBehavior);

            var selectedFileConflictAction = _detailModel.Options.FileConflictActions.
                FirstOrDefault(a => a.Action == settings.FileConflictAction);
            if (selectedFileConflictAction != null)
            {
                _detailModel.Options.SelectedFileConflictAction = selectedFileConflictAction;
            }
        }
        private void InitializeFilterList(UserSettings settings)
        {
            _filter.DisplayMemberPath = "Text";
            var items = new[] {
                new FilterItem(Filter.All, Resx.Resources.Filter_All),
                new FilterItem(Filter.Installed, Resx.Resources.Filter_Installed),
                new FilterItem(Filter.UpdatesAvailable, Resx.Resources.Filter_UpgradeAvailable)
            };
            
            foreach (var item in items)
            {
                _filter.Items.Add(item);               
            }

            if (settings != null)
            {
                _filter.SelectedItem = items.First(item => item.Filter == settings.SelectedFilter);
            }
            else
            {
                _filter.SelectedItem = items[0];
            }
        }