示例#1
0
 /// <summary>
 /// code here is the same as in the settings serializer, but unfortunately
 /// we have to duplicate it, otherwise the options dialog did not load (why?)
 /// </summary>
 /// <param name="optionName"></param>
 /// <param name="serviceProvider"></param>
 /// <returns></returns>
 private bool GetOption(string optionName, IServiceProvider serviceProvider)
 {
     var shellSettingsManager = new ShellSettingsManager(serviceProvider);
     var store = shellSettingsManager.GetWritableSettingsStore(SettingsScope.UserSettings);
     var option = store?.GetBoolean(CollectionPath, optionName, false);
     return option ?? false;
 }
        /// <summary>
        /// Displays the tool window the first time the environment is used after installation.
        /// </summary>
        internal static void InitializeWindowVisibility(IServiceProvider serviceProvider)
        {
            Guard.NotNull(() => serviceProvider, serviceProvider);

            var settingsManager = new ShellSettingsManager(serviceProvider);
            var store = settingsManager.GetWritableSettingsStore(SettingsScope.UserSettings);
            var packageToolWindow = serviceProvider.GetService<IPackageToolWindow>();

            if (!(store.CollectionExists(Constants.SettingsName) &&
                  store.PropertyExists(Constants.SettingsName, VisibilitySetting)))
            {
                //First time after installation
                packageToolWindow.ShowWindow<GuidanceExplorerToolWindow>(true);

                store.CreateCollection(Constants.SettingsName);
                store.SetString(Constants.SettingsName, VisibilitySetting, bool.FalseString);
            }
            else
            {
                // Afterwards, we load the toolwindow so that the drag&drop events can get access to the 
                // toolwindow usercontrol that handles the operations.
                // Querying visibility will automatically create the control.
                packageToolWindow.IsWindowVisible<GuidanceExplorerToolWindow>();
            }
        }
示例#3
0
        public Encouragements(SVsServiceProvider vsServiceProvider)
        {
            var shellSettingsManager = new ShellSettingsManager(vsServiceProvider);
            writableSettingsStore = shellSettingsManager.GetWritableSettingsStore(SettingsScope.UserSettings);

            LoadSettings();
        }
示例#4
0
        private SavedOptions()
        {
            var shellSettingsManager = new ShellSettingsManager(ServiceProvider.GlobalProvider);
            _store = shellSettingsManager.GetWritableSettingsStore(SettingsScope.UserSettings);

            LoadOptions();
        }
示例#5
0
        public WhereAmISettings(SVsServiceProvider vsServiceProvider)
            : this()
        {
            var shellSettingsManager = new ShellSettingsManager(vsServiceProvider);
            writableSettingsStore = shellSettingsManager.GetWritableSettingsStore(SettingsScope.UserSettings);

            LoadSettings();
        }
示例#6
0
        public static SettingsManager GetSettingsManager(IServiceProvider provider) {
            SettingsManager settings = null;
            string devenvPath = null;
            if (provider == null) {
                provider = ServiceProvider.GlobalProvider;
            }

            if (provider != null) {
                try {
                    settings = new ShellSettingsManager(provider);
                } catch (NotSupportedException) {
                    var dte = (DTE)provider.GetService(typeof(DTE));
                    if (dte != null) {
                        devenvPath = dte.FullName;
                    }
                }
            }

            if (settings == null) {
                if (!File.Exists(devenvPath)) {
                    // Running outside VS, so we need to guess which SKU of VS
                    // is being used. This will work correctly if any one SKU is
                    // installed, but may select the wrong SKU if multiple are
                    // installed. As a result, custom environments may not be
                    // available when building or testing Python projects.
                    string devenvRoot = null;
                    using (var root = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32))
                    using (var key = root.OpenSubKey(string.Format(@"Software\Microsoft\VisualStudio\{0}\Setup\VS", AssemblyVersionInfo.VSVersion))) {
                        if (key != null) {
                            devenvRoot = key.GetValue("ProductDir") as string;
                        }
                    }
                    if (Directory.Exists(devenvRoot)) {
                        foreach(var subPath in new[] {
                            "Common7\\IDE\\devenv.exe",
                            "Common7\\IDE\\vwdexpress.exe",
                            "Common7\\IDE\\wdexpress.exe"
                        }) {
                            devenvPath = Path.Combine(devenvRoot, subPath);
                            if (File.Exists(devenvPath)) {
                                break;
                            }
                            devenvPath = null;
                        }
                    }
                }
                if (!File.Exists(devenvPath)) {
                    throw new InvalidOperationException("Cannot find settings store for Visual Studio " + AssemblyVersionInfo.VSVersion);
                }
#if DEBUG
                settings = ExternalSettingsManager.CreateForApplication(devenvPath, "Exp");
#else
                settings = ExternalSettingsManager.CreateForApplication(devenvPath);
#endif
            }

            return settings;
        }
			public void Initialize()
			{
				var shellManager = new ShellSettingsManager(Microsoft.VisualStudio.Shell.ServiceProvider.GlobalProvider);
				this.settingsStore = shellManager.GetWritableSettingsStore(SettingsScope.UserSettings);

				var collection = SettingsManager.GetSettingsCollectionName(typeof(Foo));
				if (this.settingsStore.CollectionExists(collection))
					this.settingsStore.DeleteCollection(collection);
			}
 protected SettingStore()
 {
     SettingsManager settingsManager = new ShellSettingsManager(ServiceProvider.GlobalProvider);
      userSettingsStore = settingsManager.GetWritableSettingsStore(SettingsScope.UserSettings);
     if (!userSettingsStore.CollectionExists(CollectionPath))
     {
         userSettingsStore.CreateCollection(CollectionPath);
     }
 }
示例#9
0
 /// <summary>
 /// code here is the same as in the settings serializer, but unfortunately
 /// we have to duplicate it, otherwise the options dialog did not load (why?)
 /// </summary>
 /// <param name="optionName"></param>
 /// <param name="serviceProvider"></param>
 /// <returns></returns>
 private void SetOption(string optionName, bool value, IServiceProvider serviceProvider)
 {
     var shellSettingsManager = new ShellSettingsManager(serviceProvider);
     var store = shellSettingsManager.GetWritableSettingsStore(SettingsScope.UserSettings);
     if (!store.CollectionExists(CollectionPath))
         store.CreateCollection(CollectionPath);
     store?.SetBoolean(CollectionPath, optionName, value);
     
 }
        internal VersionProvider(IServiceProvider serviceProvider)
        {
            var settingsManager = new ShellSettingsManager(serviceProvider);
            _settingsStore = settingsManager.GetWritableSettingsStore(SettingsScope.UserSettings);

            if (!_settingsStore.CollectionExists(CollectionName))
                _settingsStore.CreateCollection(CollectionName);

            if (_settingsStore.PropertyExists(CollectionName, OldVersionPropertyName))
                _settingsStore.DeleteProperty(CollectionName, OldVersionPropertyName);
        }
        public VisualStudioSymbolSearchService(
            VisualStudioWorkspaceImpl workspace,
            VSShell.SVsServiceProvider serviceProvider)
            : base(workspace, SymbolSearchOptions.Enabled,
                              SymbolSearchOptions.SuggestForTypesInReferenceAssemblies,
                              SymbolSearchOptions.SuggestForTypesInNuGetPackages)
        {
            _workspace = workspace;
            _installerService = workspace.Services.GetService<IPackageInstallerService>();
            _localSettingsDirectory = new ShellSettingsManager(serviceProvider).GetApplicationDataFolder(ApplicationDataFolder.LocalSettings);

            _logService = new LogService((IVsActivityLog)serviceProvider.GetService(typeof(SVsActivityLog)));
        }
        /// <summary>
        /// Initializes properties in the package
        /// </summary>
        /// <param name="package">The package</param>
        private void Initialize(ShelvesetComparerPackage package)
        {
            SettingsManager settingsManager = new ShellSettingsManager(package);
            this.writableSettingsStore = settingsManager.GetWritableSettingsStore(SettingsScope.UserSettings);
            if (!this.writableSettingsStore.CollectionExists("ShelveSetComparer"))
            {
                this.writableSettingsStore.CreateCollection("ShelveSetComparer");
                this.ShowAsButton = true;
                this.TwoUsersView = true;
            }

            this.readableSettingStore = settingsManager.GetReadOnlySettingsStore(SettingsScope.UserSettings);
        }
            public void Initialize()
            {
                var components = VsIdeTestHostContext.ServiceProvider.GetService<SComponentModel, IComponentModel>();

                var manager = new ShellSettingsManager(VsIdeTestHostContext.ServiceProvider);
                var store = manager.GetWritableSettingsStore(SettingsScope.UserSettings);

                if (store.CollectionExists(NuPattern.Runtime.StoreConstants.RegistrySettingsKeyName))
                {
                    store.DeleteCollection(NuPattern.Runtime.StoreConstants.RegistrySettingsKeyName);
                }

                this.manager = components.GetService<ISettingsManager>();
            }
        public static VSDropSettings LoadSettingsFromStorage()
        {
            var settingsManager = new ShellSettingsManager(ServiceProvider.GlobalProvider);
            var userSettingsStore = settingsManager.GetWritableSettingsStore(SettingsScope.UserSettings);

            if (!userSettingsStore.PropertyExists(collectionName, nameof(VSDropSettings)))
                return null;

            var xmlData = userSettingsStore.GetString(collectionName, nameof(VSDropSettings));

            if (!string.IsNullOrEmpty(xmlData)) return VSDropSettings.FromXml(xmlData);

            return null;
        }
 /// <summary>
 /// Initializes a new instance of the ExtensionSettings class
 /// </summary>
 /// <param name="extensionPackage">The extension package</param>
 public ExtensionSettings(Package extensionPackage)
 {
     this.extensionPackage = extensionPackage;
     var settingsManager = new ShellSettingsManager(this.extensionPackage);
     var configurationSettingsStore = settingsManager.GetWritableSettingsStore(SettingsScope.UserSettings);
     if (configurationSettingsStore.CollectionExists(COLLECTION_NAME))
     {
         this.displayTeamViewerButton = configurationSettingsStore.GetBoolean(COLLECTION_NAME, "ShowAsButton");
         this.twoUsersView = configurationSettingsStore.GetBoolean(COLLECTION_NAME, "TwoUsersView");
     }
     else
     {
         this.displayTeamViewerButton = false;
         this.twoUsersView = false;
     }
 }
        public static void SaveToStorage(VSDropSettings settings)
        {
            var settingsManager = new ShellSettingsManager(ServiceProvider.GlobalProvider);
            var userSettingsStore = settingsManager.GetWritableSettingsStore(SettingsScope.UserSettings);

            if (!userSettingsStore.CollectionExists(collectionName))
                userSettingsStore.CreateCollection(collectionName);

            if (settings == null) settings = new VSDropSettings();

            var s = settings;
            userSettingsStore.SetString(
                collectionName,
                nameof(VSDropSettings), s.ToXml()
                );
        }
        /// <summary>
        /// Initialization of the package; this method is called right after the package is sited, so this is the place
        /// where you can put all the initialization code that rely on services provided by VisualStudio.
        /// </summary>
        protected override void Initialize()
        {
            var settingsManager = new ShellSettingsManager(this);
            var configurationSettingsStore = settingsManager.GetWritableSettingsStore(SettingsScope.UserSettings);
            UserSettingsManager.Initialize(configurationSettingsStore);
            
            TryRegisterAssembly();


            //Application.Current.Resources.MergedDictionaries.Add(new ResourceDictionary
            //{
            //    Source = new Uri("/aspnet_debug.VSExtension;component/Resources/Resources.xaml", UriKind.Relative)
            //});

            var dte = (DTE) GetService(typeof (DTE));
            AttachDebugger.Initialize(this, dte);
            base.Initialize();
        }
示例#18
0
        private void LoadSettings()
        {
            _hasLoaded = true;

            SettingsManager settingsManager = new ShellSettingsManager(serviceProvider);
            SettingsStore store = settingsManager.GetReadOnlySettingsStore(SettingsScope.UserSettings);

            LogoAdornment.VisibilityChanged += (sender, isVisible) =>
            {
                WritableSettingsStore wstore = settingsManager.GetWritableSettingsStore(SettingsScope.UserSettings);
                _isVisible = isVisible;

                if (!wstore.CollectionExists(Globals.VsixName))
                    wstore.CreateCollection(Globals.VsixName);

                wstore.SetBoolean(Globals.VsixName, _propertyName, isVisible);
            };

            _isVisible = store.GetBoolean(Globals.VsixName, _propertyName, true);
        }
示例#19
0
        protected override void Initialize()
        {
            var settingsManager = new ShellSettingsManager(this);
            var configurationSettingsStore = settingsManager.GetWritableSettingsStore(SettingsScope.UserSettings);
            UserSettingsManager.Initialize(configurationSettingsStore);
            MonoLogger.Setup();
            base.Initialize();
            var dte = (DTE)GetService(typeof(DTE));
            monoExtension = new MonoVisualStudioExtension(dte);
            TryRegisterAssembly();


            Application.Current.Resources.MergedDictionaries.Add(new ResourceDictionary
            {
                Source = new Uri("/MonoRemoteDebugger.VSExtension;component/Resources/Resources.xaml", UriKind.Relative)
            });

            var mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService;
            InstallMenu(mcs);
        }
示例#20
0
        private static int? GetValueFromPrivateSettingsTextEditor(IServiceProvider serviceProvider, string languageName, string propertyName)
        {
            if (serviceProvider == null) return null;
            if (string.IsNullOrWhiteSpace(languageName)) return null;

            SettingsManager settingsManager = new ShellSettingsManager(serviceProvider);
            var userSettingsStore = settingsManager.GetReadOnlySettingsStore(SettingsScope.UserSettings);

            var privateSettingsTextEditorLanguage = $@"ApplicationPrivateSettings\TextEditor\{languageName}";

            if (userSettingsStore.CollectionExists(privateSettingsTextEditorLanguage) &&
                userSettingsStore.PropertyExists(privateSettingsTextEditorLanguage, propertyName))
            {
                var value = userSettingsStore.GetString(privateSettingsTextEditorLanguage, propertyName);

                int buff;
                if (int.TryParse(value?.Split('*').Last(), out buff))
                    return buff;
            }
            return null;
        }
        public static SettingsManager GetSettingsManager(IServiceProvider provider) {
            SettingsManager settings = null;
            string devenvPath = null;
            if (provider == null) {
                provider = ServiceProvider.GlobalProvider;
            }

            if (provider != null) {
                try {
                    settings = new ShellSettingsManager(provider);
                } catch (NotSupportedException) {
                    var dte = (DTE)provider.GetService(typeof(DTE));
                    if (dte != null) {
                        devenvPath = dte.FullName;
                    }
                }
            }

            if (settings == null) {
                if (!File.Exists(devenvPath)) {
                    using (var root = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32))
                    using (var key = root.OpenSubKey(string.Format(@"Software\Microsoft\VisualStudio\{0}\Setup\VS", VSVersion))) {
                        if (key == null) {
                            throw new InvalidOperationException("Cannot find settings store for Visual Studio " + VSVersion);
                        }
                        devenvPath = key.GetValue("EnvironmentPath") as string;
                    }
                }
                if (!File.Exists(devenvPath)) {
                    throw new InvalidOperationException("Cannot find settings store for Visual Studio " + VSVersion);
                }
#if DEBUG
                settings = ExternalSettingsManager.CreateForApplication(devenvPath, "Exp");
#else
                settings = ExternalSettingsManager.CreateForApplication(devenvPath);
#endif
            }

            return settings;
        }
        protected override void Initialize()
        {
            base.Initialize();

            OleMenuCommandService menuCommandService = GetService(typeof(IMenuCommandService)) as OleMenuCommandService;
            if (menuCommandService != null)
            {
                // This is the drop down combo box itself
                CommandID comboBoxCommandID = new DebugCommandLineCommandID(DebugCommandLineCommand.DebugCommandLineCombo);
                OleMenuCommand comboBoxCommand = new OleMenuCommand(HandleInvokeCombo, HandleChangeCombo, HandleBeforeQueryStatusCombo, comboBoxCommandID);
                menuCommandService.AddCommand(comboBoxCommand);

                // This is the special command to get the list of drop down items
                CommandID comboBoxGetListCommandID = new DebugCommandLineCommandID(DebugCommandLineCommand.DebugCommandLineComboGetList);
                OleMenuCommand comboBoxGetListCommand = new OleMenuCommand(HandleInvokeComboGetList, comboBoxGetListCommandID);
                menuCommandService.AddCommand(comboBoxGetListCommand);
            }

            var shellSettingsManager = new ShellSettingsManager(this);
            SettingsStore = shellSettingsManager.GetWritableSettingsStore(SettingsScope.UserSettings);
            LoadSettings();
        }
示例#23
0
 private static string GetUserFilePath()
 {
     var ssm = new ShellSettingsManager(WebEssentialsPackage.Instance);
     return Path.Combine(ssm.GetApplicationDataFolder(ApplicationDataFolder.RoamingSettings), FileName);
 }
        /// <summary>
        /// This function is the callback used to execute a command when the a menu item is clicked.
        /// See the Initialize method to see how the menu item is associated to this function using
        /// the OleMenuCommandService service and the MenuCommand class.
        /// </summary>
        private void MenuItemCallback(object sender, EventArgs e)
        {
            // Show a Message Box to prove we were here
            IVsUIShell uiShell = (IVsUIShell)GetService(typeof(SVsUIShell));
            Guid clsid = Guid.Empty;
            DeployConfiguration config = new DeployConfiguration();
            SettingsManager settingsManager = new ShellSettingsManager(ServiceProvider.GlobalProvider);
            WritableSettingsStore userSettingsStore = settingsManager.GetWritableSettingsStore(SettingsScope.UserSettings);

            if (!userSettingsStore.CollectionExists("SyncIIS"))
            {
                userSettingsStore.CreateCollection("SyncIIS");
            }

            config.Domain = userSettingsStore.GetString("SyncIIS", "Domain", "");
            config.SetSecurePassword(userSettingsStore.GetString("SyncIIS", "Password", ""));
            config.Site = userSettingsStore.GetString("SyncIIS", "Site", "");
            config.Source = userSettingsStore.GetString("SyncIIS", "Source", "");
            config.Target = userSettingsStore.GetString("SyncIIS", "Target", "").Split(new string[] { "," },
                StringSplitOptions.RemoveEmptyEntries).Select(p => p.Trim()).ToList<string>();
            config.Username = userSettingsStore.GetString("SyncIIS", "Username", "");

            SyncWindow window = new SyncWindow(config);
            window.ShowDialog();

            var settings = window.Configuration;

            userSettingsStore.SetString("SyncIIS", "Domain", settings.Domain);
            userSettingsStore.SetString("SyncIIS", "Password", settings.GetUnsecurePassword());
            userSettingsStore.SetString("SyncIIS", "Site", settings.Site);
            userSettingsStore.SetString("SyncIIS", "Source", settings.Source);
            userSettingsStore.SetString("SyncIIS", "Target", string.Join(",", settings.Target.ToArray()));
            userSettingsStore.SetString("SyncIIS", "Username", settings.Username);
        }
示例#25
0
        private static int? GetValueFromTextEditor(IServiceProvider serviceProvider, string languageName, string propertyName)
        {
            if (serviceProvider == null) return null;
            if (string.IsNullOrWhiteSpace(languageName)) return null;

            SettingsManager settingsManager = new ShellSettingsManager(serviceProvider);
            var userSettingsStore = settingsManager.GetReadOnlySettingsStore(SettingsScope.UserSettings);

            var textEditorLanguage = $@"Text Editor\{languageName}";

            if (userSettingsStore.CollectionExists(textEditorLanguage) &&
                userSettingsStore.PropertyExists(textEditorLanguage, propertyName))
            {
                return userSettingsStore.GetInt32(textEditorLanguage, propertyName);
            }
            return null;
        }
        /// <summary>
        /// Automatically hides the window, if it was automatically opened.
        /// </summary>
        internal static void AutoHideWindow(IServiceProvider serviceProvider)
        {
            Guard.NotNull(() => serviceProvider, serviceProvider);

            var settingsManager = new ShellSettingsManager(serviceProvider);
            var store = settingsManager.GetWritableSettingsStore(SettingsScope.UserSettings);

            if (store.CollectionExists(Constants.SettingsName) &&
                store.PropertyExists(Constants.SettingsName, SolutionBuilderAutoOpenedSetting))
            {
                var packageToolWindow = serviceProvider.GetService<IPackageToolWindow>();

                packageToolWindow.HideWindow<SolutionBuilderToolWindow>();

                store.DeleteProperty(Constants.SettingsName, SolutionBuilderAutoOpenedSetting);
            }
        }
示例#27
0
 internal static WritableSettingsStore GetWritableSettingsStore(this SVsServiceProvider vsServiceProvider, SettingsScope scope)
 {
     var shellSettingsManager = new ShellSettingsManager(vsServiceProvider);
     return shellSettingsManager.GetWritableSettingsStore(scope);
 }
示例#28
0
 internal VimApplicationSettings(SVsServiceProvider vsServiceProvider, [EditorUtilsImport] IProtectedOperations protectedOperations)
 {
     var shellSettingsManager = new ShellSettingsManager(vsServiceProvider);
     _settingsStore = shellSettingsManager.GetWritableSettingsStore(SettingsScope.UserSettings);
     _protectedOperations = protectedOperations;
 }
示例#29
0
 public PaketSettings(ShellSettingsManager settingsManager)
 {
     settingsStore = settingsManager.GetWritableSettingsStore(SettingsScope.UserSettings);
     if (!settingsStore.CollectionExists(StoreCollection))
         settingsStore.CreateCollection(StoreCollection);
 }
示例#30
0
        /// <summary>
        /// Sets the verbosity level.
        /// </summary>
        private void SetVerbosity()
        {
            if (!this.haveCachedVerbosity) {
                this.Verbosity = LoggerVerbosity.Normal;

                try {
                    var settings = new ShellSettingsManager(serviceProvider);
                    var store = settings.GetReadOnlySettingsStore(SettingsScope.UserSettings);
                    if (store.CollectionExists(GeneralCollection) && store.PropertyExists(GeneralCollection, BuildVerbosityProperty)) {
                        this.Verbosity = (LoggerVerbosity)store.GetInt32(GeneralCollection, BuildVerbosityProperty, (int)LoggerVerbosity.Normal);
                    }
                } catch (Exception ex) {
                    var message = string.Format(
                        "Unable to read verbosity option from the registry.{0}{1}",
                        Environment.NewLine,
                        ex.ToString()
                    );
                    this.QueueOutputText(MessageImportance.High, message);
                }

                this.haveCachedVerbosity = true;
            }
        }