コード例 #1
0
ファイル: Settings.cs プロジェクト: tekkies/OpenCover.UI
        /// <summary>
        /// Initializes the settings
        /// </summary>
        /// <param name="configurationSettingsStore">The settings store</param>
        public Settings(WritableSettingsStore configurationSettingsStore)
        {
            _store = configurationSettingsStore;

            _showLinesColored   = _store.GetBoolean(SETTINGS_PATH, "ShowLinesColored", false);
            _showCoverageGlyphs = _store.GetBoolean(SETTINGS_PATH, "ShowCoverageGlyphs", true);
        }
コード例 #2
0
 public static void Load()
 {
     ResourcesFolderName   = settings.GetString(collectionName, nameof(ResourcesFolderName));
     ResourcesManagerName  = settings.GetString(collectionName, nameof(ResourcesManagerName));
     UseStaticResourceXAML = settings.GetBoolean(collectionName, nameof(UseStaticResourceXAML));
     SetLocaleOnStartup    = settings.GetBoolean(collectionName, nameof(SetLocaleOnStartup));
 }
コード例 #3
0
ファイル: Settings.cs プロジェクト: bigmat/OpenCover.UI
        /// <summary>
        /// Initializes the settings
        /// </summary>
        /// <param name="configurationSettingsStore">The settings store</param>
        public Settings(WritableSettingsStore configurationSettingsStore)
        {
            _store = configurationSettingsStore;

            _showLinesColored = _store.GetBoolean(SETTINGS_PATH, SettingNames.ShowLinesColored, false);
            _showCoverageGlyphs = _store.GetBoolean(SETTINGS_PATH, SettingNames.ShowCoverageGlyphs, true);
        }
コード例 #4
0
ファイル: Settings.cs プロジェクト: xsysfan/OpenCover.UI
        /// <summary>
        /// Initializes the settings
        /// </summary>
        /// <param name="configurationSettingsStore">The settings store</param>
        public Settings(WritableSettingsStore configurationSettingsStore)
        {
            _store = configurationSettingsStore;

            _showLinesColored     = _store.GetBoolean(SETTINGS_PATH, SettingNames.ShowLinesColored, false);
            _showCoverageGlyphs   = _store.GetBoolean(SETTINGS_PATH, SettingNames.ShowCoverageGlyphs, true);
            _showUncoveredClasses = _store.GetBoolean(SETTINGS_PATH, SettingNames.ShowUncoveredClasses, true);
        }
コード例 #5
0
ファイル: Settings.cs プロジェクト: gasyleiss/CrmUpdater
        /// <summary>
        /// Reads and parses Crm Connections from settings store
        /// </summary>
        /// <returns>Returns Crm Connetions</returns>
        private CrmConnections GetCrmConnections()
        {
            if (_settingsStore.PropertyExists(CollectionPath, ConnectionsPropertyName) == false)
            {
                return(null);
            }

            var connectionsXml = _settingsStore.GetString(CollectionPath, ConnectionsPropertyName);

            try
            {
                var connections    = XmlSerializerHelper.Deserialize <List <ConnectionDetail> >(connectionsXml);
                var crmConnections = new CrmConnections {
                    Connections = connections
                };
                var publisAfterUpload = true;
                if (_settingsStore.PropertyExists(CollectionPath, AutoPublishPropertyName))
                {
                    publisAfterUpload = _settingsStore.GetBoolean(CollectionPath, AutoPublishPropertyName);
                }
                crmConnections.PublishAfterUpload = publisAfterUpload;

                var ignoreExtensions = false;
                if (_settingsStore.PropertyExists(CollectionPath, IgnoreExtensionsProprtyName))
                {
                    ignoreExtensions = _settingsStore.GetBoolean(CollectionPath, IgnoreExtensionsProprtyName);
                }
                crmConnections.IgnoreExtensions = ignoreExtensions;


                var extendedLog = false;
                if (_settingsStore.PropertyExists(CollectionPath, ExtendedLogProprtyName))
                {
                    extendedLog = _settingsStore.GetBoolean(CollectionPath, ExtendedLogProprtyName);
                }
                crmConnections.ExtendedLog = extendedLog;

                foreach (var connection in crmConnections.Connections)
                {
                    if (!string.IsNullOrEmpty(connection.UserPassword))
                    {
                        connection.UserPassword = DecryptString(connection.UserPassword);
                    }
                }

                return(crmConnections);
            }
            catch (Exception)
            {
                Logger.WriteLine("Failed to parse connection settings");
                return(null);
            }
        }
コード例 #6
0
        public static void LoadCurrent()
        {
            try
            {
                if (!settingsStore.CollectionExists(COLLECTION_PATH))
                {
                    return;
                }

                if (settingsStore.PropertyExists(COLLECTION_PATH, nameof(FontSettings.Font)))
                {
                    CurrentSettings.Font = settingsStore.GetString(COLLECTION_PATH, nameof(FontSettings.Font));
                }

                if (settingsStore.PropertyExists(COLLECTION_PATH, nameof(FontSettings.Size)))
                {
                    var    str = settingsStore.GetString(COLLECTION_PATH, nameof(FontSettings.Size));
                    double size;
                    double.TryParse(str, out size);
                    CurrentSettings.Size = size;
                }

                if (settingsStore.PropertyExists(COLLECTION_PATH, nameof(FontSettings.Italic)))
                {
                    CurrentSettings.Italic = settingsStore.GetBoolean(COLLECTION_PATH, nameof(FontSettings.Italic));
                }

                if (settingsStore.PropertyExists(COLLECTION_PATH, nameof(FontSettings.Opacity)))
                {
                    var    str = settingsStore.GetString(COLLECTION_PATH, nameof(FontSettings.Opacity));
                    double opacity;
                    double.TryParse(str, out opacity);
                    CurrentSettings.Opacity = opacity;
                }

                if (settingsStore.PropertyExists(COLLECTION_PATH, nameof(FontSettings.HighlightKeywordsOnly)))
                {
                    CurrentSettings.HighlightKeywordsOnly = settingsStore.GetBoolean(COLLECTION_PATH,
                                                                                     nameof(FontSettings.HighlightKeywordsOnly));
                }

                if (settingsStore.PropertyExists(COLLECTION_PATH, nameof(FontSettings.UnderlineImportantComments)))
                {
                    CurrentSettings.UnderlineImportantComments = settingsStore.GetBoolean(COLLECTION_PATH,
                                                                                          nameof(FontSettings.UnderlineImportantComments));
                }
            }
            catch (Exception ex)
            {
                Debug.Fail(ex.Message);
            }
        }
コード例 #7
0
        public Settings(IServiceProvider provider)
        {
            SettingsManager settingsManager = new ShellSettingsManager(provider);

            _settingsStore = settingsManager.GetWritableSettingsStore(SettingsScope.UserSettings);
            if (!_settingsStore.CollectionExists("DebugAttachManagerProcesses"))
            {
                return;
            }
            IEnumerable <string> services = _settingsStore.GetSubCollectionNames("DebugAttachManagerProcesses");

            foreach (var s in services)
            {
                var p = new StoredProcessInfo
                {
                    ProcessName = _settingsStore.GetString("DebugAttachManagerProcesses\\" + s, "ProcessName"),
                    Title       = _settingsStore.PropertyExists("DebugAttachManagerProcesses\\" + s, "Title") ?
                                  _settingsStore.GetString("DebugAttachManagerProcesses\\" + s, "Title") : null,
                    RemoteServerName = _settingsStore.PropertyExists("DebugAttachManagerProcesses\\" + s, "RemoteServerName") ?
                                       _settingsStore.GetString("DebugAttachManagerProcesses\\" + s, "RemoteServerName") : null,
                    RemotePortNumber = _settingsStore.PropertyExists("DebugAttachManagerProcesses\\" + s, "RemotePortNumber") ?
                                       _settingsStore.GetInt64("DebugAttachManagerProcesses\\" + s, "RemotePortNumber") : (long?)null,
                    Selected  = _settingsStore.GetBoolean("DebugAttachManagerProcesses\\" + s, "Selected"),
                    DebugMode = _settingsStore.PropertyExists("DebugAttachManagerProcesses\\" + s, "DebugMode") ?
                                _settingsStore.GetString("DebugAttachManagerProcesses\\" + s, "DebugMode") : null
                };
                Processes.Add(p.Hash, p);
            }

            if (_settingsStore.PropertyExists("DebugAttachManagerProcesses", "RemoteServer"))
            {
                RemoteServer = _settingsStore.GetString("DebugAttachManagerProcesses", "RemoteServer");
            }

            for (int i = 0; i < Constants.NUMBER_OF_OPTIONAL_COLUMNS; i++)
            {
                string columnName = $"Column{i}";
                if (_settingsStore.PropertyExists("DebugAttachManagerProcesses", columnName))
                {
                    ProcessesColumns[i] = _settingsStore.GetBoolean("DebugAttachManagerProcesses", columnName);
                }
                else
                {
                    if (i == 0)
                    {
                        // This is a hack, so we display PID by default
                        ProcessesColumns[i] = true;
                    }
                }
            }
        }
コード例 #8
0
ファイル: SettingsStore.cs プロジェクト: ehmz11/aaa
        /// <summary>
        /// Read from a settings store
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="subpath">The subcollection path (appended to the path passed to the constructor)</param>
        /// <param name="property">The property name to read</param>
        /// <param name="defaultValue">The default value to use in case the property doesn't exist.
        /// The type of the default value will be used to figure out the proper way to read the property, so if pass null,
        /// the property will be read as a string (which may or may not be what you want)</param>
        /// <returns></returns>
        public object Read(string subpath, string property, object defaultValue)
        {
            Guard.ArgumentNotNull(property, nameof(property));
            Guard.ArgumentNotEmptyString(property, nameof(property));

            var collection = subpath != null?Path.Combine(root, subpath) : root;

            store.CreateCollection(collection);

            if (defaultValue is bool)
            {
                return(store.GetBoolean(collection, property, (bool)defaultValue));
            }
            else if (defaultValue is int)
            {
                return(store.GetInt32(collection, property, (int)defaultValue));
            }
            else if (defaultValue is uint)
            {
                return(store.GetUInt32(collection, property, (uint)defaultValue));
            }
            else if (defaultValue is long)
            {
                return(store.GetInt64(collection, property, (long)defaultValue));
            }
            else if (defaultValue is ulong)
            {
                return(store.GetUInt64(collection, property, (ulong)defaultValue));
            }
            return(store.GetString(collection, property, defaultValue?.ToString() ?? ""));
        }
        void LoadSettings()
        {
            SettingsManager       settingsManager            = new ShellSettingsManager(LogcatOutputToolWindowCommand.Instance.ServiceProvider);
            WritableSettingsStore configurationSettingsStore = settingsManager.GetWritableSettingsStore(SettingsScope.UserSettings);
            string adb_path  = configurationSettingsStore.GetString(StoreCategoryName, StorePropertyAdbPathName, "");
            uint   log_limit = configurationSettingsStore.GetUInt32(StoreCategoryName, StorePropertyLogsLimitName, 20000);
            bool   is_auto   = configurationSettingsStore.GetBoolean(StoreCategoryName, StorePropertyAutoScrollName, false);

            LogLimitCount  = log_limit;
            adb.AdbExePath = adb_path;
            IsAutoScroll   = is_auto;
            ColumnWidth[0] = configurationSettingsStore.GetUInt32(StoreCategoryName, StorePropertyLevelWidthName, 60);
            ColumnWidth[1] = configurationSettingsStore.GetUInt32(StoreCategoryName, StorePropertyTimeWidthName, 120);
            ColumnWidth[2] = configurationSettingsStore.GetUInt32(StoreCategoryName, StorePropertyPidWidthName, 60);
            ColumnWidth[3] = configurationSettingsStore.GetUInt32(StoreCategoryName, StorePropertyTagWidthName, 120);
            ColumnWidth[4] = configurationSettingsStore.GetUInt32(StoreCategoryName, StorePropertyTextWidthName, 600);

            if (IsAutoScroll)
            {
                Dispatcher.InvokeAsync(() => { AutoScrollLabel.Content = "Auto Scroll On"; });
            }
            else
            {
                Dispatcher.InvokeAsync(() => { AutoScrollLabel.Content = "Auto Scroll Off"; });
            }
        }
コード例 #10
0
        public Settings(IServiceProvider provider)
        {
            SettingsManager settingsManager = new ShellSettingsManager(provider);

            _settingsStore = settingsManager.GetWritableSettingsStore(SettingsScope.UserSettings);
            if (!_settingsStore.CollectionExists("DebugAttachManagerProcesses"))
            {
                return;
            }
            IEnumerable <string> services = _settingsStore.GetSubCollectionNames("DebugAttachManagerProcesses");

            foreach (var s in services)
            {
                var p = new StoredProcessInfo
                {
                    ProcessName = _settingsStore.GetString("DebugAttachManagerProcesses\\" + s, "ProcessName"),
                    Title       = _settingsStore.PropertyExists("DebugAttachManagerProcesses\\" + s, "Title") ?
                                  _settingsStore.GetString("DebugAttachManagerProcesses\\" + s, "Title") : null,
                    RemoteServerName = _settingsStore.PropertyExists("DebugAttachManagerProcesses\\" + s, "RemoteServerName") ?
                                       _settingsStore.GetString("DebugAttachManagerProcesses\\" + s, "RemoteServerName") : null,
                    RemotePortNumber = _settingsStore.PropertyExists("DebugAttachManagerProcesses\\" + s, "RemotePortNumber") ?
                                       _settingsStore.GetInt64("DebugAttachManagerProcesses\\" + s, "RemotePortNumber") : (long?)null,
                    Selected  = _settingsStore.GetBoolean("DebugAttachManagerProcesses\\" + s, "Selected"),
                    DebugMode = _settingsStore.PropertyExists("DebugAttachManagerProcesses\\" + s, "DebugMode") ?
                                _settingsStore.GetString("DebugAttachManagerProcesses\\" + s, "DebugMode") : null
                };
                Processes.Add(p.Hash, p);
            }

            if (_settingsStore.PropertyExists("DebugAttachManagerProcesses", "RemoteServer"))
            {
                RemoteServer = _settingsStore.GetString("DebugAttachManagerProcesses", "RemoteServer");
            }
        }
コード例 #11
0
        private static void LoadSettingsFromStore(ISettings settings)
        {
            var properties = GetProperties(settings);

            foreach (var prop in properties)
            {
                if (store.PropertyExists(settings.Key, prop.Name))
                {
                    switch (prop.GetValue(settings))
                    {
                    case bool b:
                        prop.SetValue(settings, store.GetBoolean(settings.Key, prop.Name));
                        break;

                    case int i:
                        prop.SetValue(settings, store.GetInt32(settings.Key, prop.Name));
                        break;

                    case double d when double.TryParse(store.GetString(settings.Key, prop.Name), out double value):
                        prop.SetValue(settings, value);

                        break;

                    case string s:
                        prop.SetValue(settings, store.GetString(settings.Key, prop.Name));
                        break;
                    }
                }
            }
        }
コード例 #12
0
        public object Read(string subPath, string property, object defaultValue)
        {
            Validate.IsNotNull(property, nameof(property));
            Validate.IsNotEmpty(property, nameof(property));

            var collection = subPath != null?Path.Combine(_root, subPath) : _root;

            _store.CreateCollection(collection);

            if (defaultValue is bool b)
            {
                return(_store.GetBoolean(collection, property, b));
            }
            if (defaultValue is int i)
            {
                return(_store.GetInt32(collection, property, i));
            }
            if (defaultValue is uint u)
            {
                return(_store.GetUInt32(collection, property, u));
            }
            if (defaultValue is long l)
            {
                return(_store.GetInt64(collection, property, l));
            }
            if (defaultValue is ulong ul)
            {
                return(_store.GetUInt64(collection, property, ul));
            }
            return(_store.GetString(collection, property, defaultValue?.ToString() ?? ""));
        }
        public static void LoadCurrent()
        {
            if (!settingsStore.CollectionExists(CollectionPath))
            {
                return;
            }

            Current.IsEnabled = settingsStore.GetBoolean(CollectionPath, "IsEnabled", true);
        }
コード例 #14
0
        private object Get(string key, Type targetType = null, object defaultValue = null, SerializationMode serializationMode = SerializationMode.Xml)
        {
            try
            {
                if (targetType == null)
                {
                    targetType = ConvertSettingsType(Check.TryCatch <SettingsType, Exception>(() => settingsStore.GetPropertyType(collectionPath, key)));
                }

                object result = null;

                if (targetType.IsEnum)
                {
                    targetType = typeof(int);
                }
                if (targetType == typeof(bool))
                {
                    result = settingsStore.GetBoolean(collectionPath, key, Convert.ToBoolean(defaultValue));
                }
                else if (targetType == typeof(string))
                {
                    result = settingsStore.GetString(collectionPath, key, defaultValue as string);
                }
                else if (targetType == typeof(int))
                {
                    result = settingsStore.GetInt32(collectionPath, key, Convert.ToInt32(defaultValue));
                }
                else
                {
                    if (settingsStore.PropertyExists(collectionPath, key))
                    {
                        if (serializationMode == SerializationMode.Xml)
                        {
                            string       xmlContent = settingsStore.GetString(collectionPath, key);
                            var          serializer = new XmlSerializer(targetType);
                            MemoryStream ms         = new MemoryStream(Encoding.UTF8.GetBytes(xmlContent));
                            var          res        = serializer.Deserialize(ms);
                            return(res);
                        }
                        else
                        {
                            var ms = settingsStore.GetMemoryStream(collectionPath, key);
                            if (ms != null)
                            {
                                var serializer = new BinaryFormatter();
                                result = serializer.Deserialize(ms);
                            }
                        }
                    }
                }
                return(result ?? defaultValue);
            }
            catch (Exception)
            {
                return(defaultValue);
            }
        }
コード例 #15
0
 /// <summary>
 /// Loads DexterInfo from Settings Store
 /// </summary>
 /// <returns>loaded DexterInfo</returns>
 public DexterInfo Load()
 {
     if (!settingsStore.CollectionExists(DexterStoreName))
     {
         return(new DexterInfo());
     }
     else
     {
         return(new DexterInfo()
         {
             dexterHome = settingsStore.GetString(DexterStoreName, "dexterHome"),
             dexterServerIp = settingsStore.GetString(DexterStoreName, "dexterServerIp"),
             dexterServerPort = settingsStore.GetInt32(DexterStoreName, "dexterServerPort"),
             userName = settingsStore.GetString(DexterStoreName, "userName"),
             userPassword = settingsStore.GetString(DexterStoreName, "userPassword"),
             standalone = settingsStore.GetBoolean(DexterStoreName, "standalone"),
             IsDexterHomeEnabled = settingsStore.GetBoolean(DexterStoreName, "isDexterHomeEnabled"),
         });
     }
 }
コード例 #16
0
ファイル: UserSettingsHelper.cs プロジェクト: msawczyn/JiraEX
        public static bool ReadBoolFromUserSettings(string propertyName)
        {
            try
            {
                bool ret = _userSettingsStore.GetBoolean(REGISTRY_FOLDER_NAME, propertyName);

                return(ret);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
コード例 #17
0
ファイル: Program.cs プロジェクト: radical/roslyn-tools
        private static void EnableLoadingAllExtensions(WritableSettingsStore settingsStore)
        {
            const string EnableAdminExtensionsProperty = "EnableAdminExtensions";

            if (!settingsStore.CollectionExists(ExtensionManagerCollectionPath))
            {
                settingsStore.CreateCollection(ExtensionManagerCollectionPath);
            }

            if (!settingsStore.GetBoolean(ExtensionManagerCollectionPath, EnableAdminExtensionsProperty, defaultValue: false))
            {
                settingsStore.SetBoolean(ExtensionManagerCollectionPath, EnableAdminExtensionsProperty, value: true);
            }
        }
コード例 #18
0
        private static bool GetBooleanProperty(WritableSettingsStore store, string propertyName, bool defaultValue)
        {
            try {
                if (!store.PropertyExists(CollectionName, propertyName))
                {
                    store.SetBoolean(CollectionName, propertyName, defaultValue);
                }

                return(store.GetBoolean(CollectionName, propertyName));
            } catch {
                store.SetBoolean(CollectionName, propertyName, defaultValue);
                return(defaultValue);
            }
        }
コード例 #19
0
        public static void LoadSettings(ISettings settings)
        {
            try
            {
                if (store.CollectionExists(settings.Key) != true)
                {
                    return;
                }

                var type = settings.GetType();

                foreach (var prop in type.GetProperties().Where(p => Attribute.IsDefined(p, typeof(SettingAttribute))))
                {
                    if (prop.PropertyType == typeof(bool))
                    {
                        if (store.PropertyExists(settings.Key, prop.Name))
                        {
                            prop.SetValue(settings, store.GetBoolean(settings.Key, prop.Name));
                        }
                    }
                    else if (prop.PropertyType == typeof(int))
                    {
                        if (store.PropertyExists(settings.Key, prop.Name))
                        {
                            prop.SetValue(settings, store.GetInt32(settings.Key, prop.Name));
                        }
                    }
                    else if (prop.PropertyType == typeof(double))
                    {
                        if (store.PropertyExists(settings.Key, prop.Name))
                        {
                            double.TryParse(store.GetString(settings.Key, prop.Name), out double value);
                            prop.SetValue(settings, value);
                        }
                    }
                    else if (prop.PropertyType == typeof(string))
                    {
                        if (store.PropertyExists(settings.Key, prop.Name))
                        {
                            prop.SetValue(settings, store.GetString(settings.Key, prop.Name));
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.Fail(ex.Message);
            }
        }
コード例 #20
0
ファイル: OptionsPage.cs プロジェクト: denisabt/ClippyVS
        private IClippyVSSettings GetClippySettings()
        {
            ThreadHelper.ThrowIfNotOnUIThread();
            bool res = false;

            if (_store.PropertyExists(Constants.SettingsCollectionPath, "ShowAtStartup"))
            {
                res = _store.GetBoolean(Constants.SettingsCollectionPath, "ShowAtStartup");
            }

            return(new ClippyVSSettings(_store)
            {
                ShowAtStartup = res
            });
        }
コード例 #21
0
ファイル: ClippyVSSettings.cs プロジェクト: denisabt/ClippyVS
 /// <summary>
 /// Read the stored settings
 /// </summary>
 private void LoadSettings()
 {
     try
     {
         // Tries to retrieve the configurations if previously saved
         if (writableSettingsStore.PropertyExists(Constants.SettingsCollectionPath, ShowAtStartupStoreName))
         {
             ShowAtStartup = writableSettingsStore.GetBoolean(Constants.SettingsCollectionPath, ShowAtStartupStoreName);
             Debug.WriteLine("Setting loaded which is {0}", ShowAtStartup);
         }
     }
     catch (ArgumentException ex)
     {
         Debug.Fail(ex.Message);
     }
 }
コード例 #22
0
        public bool GetBoolean(string propertyName)
        {
            try
            {
                if (_settingsStore.PropertyExists(CollectionPath, propertyName))
                {
                    return(_settingsStore.GetBoolean(CollectionPath, propertyName));
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }

            return(false);
        }
コード例 #23
0
        public static object GetValue(this WritableSettingsStore store, string collectionPath, PropertyDescriptor property)
        {
            if (store.PropertyExists(collectionPath, property.Name))
            {
                switch (property.PropertyType)
                {
                case Type t when t == typeof(string): return(store.GetString(collectionPath, property.Name));

                case Type t when t == typeof(int): return(store.GetInt32(collectionPath, property.Name));

                case Type t when t == typeof(long): return(store.GetInt64(collectionPath, property.Name));

                case Type t when t == typeof(bool): return(store.GetBoolean(collectionPath, property.Name));
                }
            }
            return(null);
        }
コード例 #24
0
        /// <summary>
        /// Loads the detect errors flag
        /// </summary>
        /// <param name="store">The writable settings store</param>
        /// <returns>The detect error flag or if not found, the default detect error flag</returns>
        public static bool LoadDetectErrorsFlag(this WritableSettingsStore store)
        {
            bool detectErrorFlag = DefaultRainbowIndentOptions.defaultDetectErrorsFlag;

            if (store == null)
            {
                return(detectErrorFlag);
            }
            if (!store.PropertyExists(CollectionName, DetectErrorsPropertyName))
            {
                store.SaveDetectErrorsFlag(detectErrorFlag);
            }
            else
            {
                detectErrorFlag = store.GetBoolean(CollectionName, DetectErrorsPropertyName);
            }
            return(detectErrorFlag);
        }
コード例 #25
0
        internal bool GetBoolean(string propertyName, bool defaultValue)
        {
            EnsureCollectionExists();
            try
            {
                if (!_settingsStore.PropertyExists(CollectionPath, propertyName))
                {
                    return(defaultValue);
                }

                return(_settingsStore.GetBoolean(CollectionPath, propertyName));
            }
            catch (Exception e)
            {
                Report(String.Format(ErrorGetFormat, propertyName), e);
                return(defaultValue);
            }
        }
コード例 #26
0
        public static async System.Threading.Tasks.Task InitializeAsync(AsyncPackage package)
        {
            { // Adding callback method to "Parallel Builds Monitor" menu item into "VS -> Menu -> View -> Other Windows" menu
                IMenuCommandService commandService = (IMenuCommandService)await package.GetServiceAsync(typeof(IMenuCommandService));

                Microsoft.Assumes.Present(commandService);
                CommandID   menuCommandID = new CommandID(typeof(MainMenuCommandSet).GUID, (int)MainMenuCommandSet.ShowToolWindow);
                MenuCommand menuItem      = new MenuCommand((s, e) => Execute(package), menuCommandID);
                commandService.AddCommand(menuItem);
            }

            { // Start listening VS Events...
                // Should we always collect data even when "Parallel Builds Monitor" pane is closed?
                // What if user open PBM pane in the the middle of build? Should we show Gantt chart or draw notice like "Restart build to see results"?
                // If we decide not to collect data when PBM pane is closed, then user must manually activate PBM before build in order to have Gantt.
                // This is because "Output" pane is left as active after each build, so "Output" pane will be active pane after VS restart.
                PBMCommand.Initialize(package);
            }

            { // Show and Activate "Parallel Builds Monitor" pane
              // Do we really want to activate "Parallel Builds Monitor" pane after each solution load?
              // Or maybe we want to do that only once after installation?
              // Will it work when PBM plugin is installed whn solution is already opened?

                const string          collectionName            = "PBMSettings";
                const string          propertyName              = "FirstRun";
                SettingsManager       settingsManager           = new ShellSettingsManager(PBMCommand.ServiceProvider);
                WritableSettingsStore writableUserSettingsStore = settingsManager.GetWritableSettingsStore(SettingsScope.UserSettings);
                if (!writableUserSettingsStore.CollectionExists(collectionName))
                {
                    writableUserSettingsStore.CreateCollection(collectionName);
                }

                bool firstRun = writableUserSettingsStore.GetBoolean(collectionName, propertyName, true);
                if (firstRun)
                {
                    writableUserSettingsStore.SetBoolean(collectionName, propertyName, false);
                    Execute(package);
                }
            }
        }
コード例 #27
0
ファイル: POptions.cs プロジェクト: wilsonk/AntlrVSIX
        public static bool GetBoolean(string option)
        {
            Initialize();
            bool default_value = false;

            defaults.TryGetValue(option, out object value);
            if (value == null)
            {
                default_value = false;
            }
            else if (value is bool)
            {
                default_value = (bool)value;
            }
            if (persistent_settings != null)
            {
                return(persistent_settings.GetBoolean("AntlrVSIX", option, default_value));
            }
            else
            {
                return(default_value);
            }
        }
コード例 #28
0
        public static T ReadSetting <T>(string propertyName)
        {
            CreatePropertyIfDoesNotExist <T>(propertyName);

            object value;

            switch (Type.GetTypeCode(typeof(T)))
            {
            case TypeCode.String:
                value = _userSettingsStore.GetString(CollectionName, propertyName);
                return((T)Convert.ChangeType(value, typeof(T)));

            case TypeCode.Boolean:
                value = _userSettingsStore.GetBoolean(CollectionName, propertyName);
                return((T)Convert.ChangeType(value, typeof(T)));

            case TypeCode.Int32:
                value = _userSettingsStore.GetInt32(CollectionName, propertyName);
                return((T)Convert.ChangeType(value, typeof(T)));

            case TypeCode.Int64:
                value = _userSettingsStore.GetInt64(CollectionName, propertyName);
                return((T)Convert.ChangeType(value, typeof(T)));

            case TypeCode.UInt32:
                value = _userSettingsStore.GetUInt32(CollectionName, propertyName);
                return((T)Convert.ChangeType(value, typeof(T)));

            case TypeCode.UInt64:
                value = _userSettingsStore.GetUInt64(CollectionName, propertyName);
                return((T)Convert.ChangeType(value, typeof(T)));

            default:
                value = _userSettingsStore.GetString(CollectionName, propertyName);
                return((T)Convert.ChangeType(value, typeof(T)));
            }
        }
コード例 #29
0
        /// <summary>
        /// Called when the window has loaded
        /// </summary>
        private void OnLoad(object sender, RoutedEventArgs e)
        {
            // Window icon
            var icon = WindowExtensions.ImageSourceFromIcon(Properties.Resources.oof);

            if (icon != null)
            {
                Icon = icon;
            }

            // Hide/disable minimize button
            WindowExtensions.HideMinimizeAndMaximizeButtons(this, hideMaximize: false);

            // Restore window size and position, if any
            try
            {
                var settingsManager = new ShellSettingsManager(Package);

                WritableSettingsStore = settingsManager.GetWritableSettingsStore(SettingsScope.UserSettings);

                if (WritableSettingsStore.CollectionExists(SS_Collection) == true)
                {
                    // These two are required from now on
                    WindowStartupLocation = WindowStartupLocation.Manual;
                    SizeToContent         = SizeToContent.Manual;

                    // Window size and position
                    Top         = WritableSettingsStore.GetInt32(SS_Collection, SS_WindowTop);
                    Left        = WritableSettingsStore.GetInt32(SS_Collection, SS_WindowLeft);
                    Height      = WritableSettingsStore.GetInt32(SS_Collection, SS_WindowHeight);
                    Width       = WritableSettingsStore.GetInt32(SS_Collection, SS_WindowWidth);
                    WindowState = (WindowState)WritableSettingsStore.GetInt32(SS_Collection, SS_WindowState);

                    // Other settings
                    chActiveItem.IsChecked = WritableSettingsStore.GetBoolean(SS_Collection, SS_ActiveItem);

                    rbLeftPanelTC.IsChecked  = WritableSettingsStore.GetBoolean(SS_Collection, SS_LeftPanelTC);
                    rbRightPanelTC.IsChecked = WritableSettingsStore.GetBoolean(SS_Collection, SS_RightPanelTC);

                    if (rbLeftPanelTC.IsChecked == rbRightPanelTC.IsChecked)
                    {
                        // Impossible case that should not be possible but has somehow happened, so here is the fix
                        rbLeftPanelTC.IsChecked  = true;
                        rbRightPanelTC.IsChecked = false;
                    }
                }
                else
                {
                    // Create collection now to be able to check for other settings the 1st time around
                    WritableSettingsStore.CreateCollection(SS_Collection);

                    // Must have a default
                    rbLeftPanelTC.IsChecked = true;
                }
            }
            catch (Exception)
            {
                // Ignore quietly
            }

            // Load configurations and active path
#pragma warning disable VSTHRD010

            if (Paths.ListSolutionConfigurations(Dte, lbConfigurations, ref _activePath) == false)
            {
                // Something went wrong so abort
                // Error reporting, if any, is to be done in the calling method above
                Close();
            }

#pragma warning restore VSTHRD010

            // Double-click on an item brings up TotalCommander without further ado
            lbConfigurations.MouseDoubleClick += LbConfigurations_MouseDoubleClick;
        }
コード例 #30
0
        /// <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>
        /// <param name="cancellationToken">A cancellation token to monitor for initialization cancellation, which can occur when VS is shutting down.</param>
        /// <param name="progress">A provider for progress updates.</param>
        /// <returns>A task representing the async work of package initialization, or an already completed task if there is none. Do not return null from this method.</returns>
        protected override async Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress)
        {
            // When initialized asynchronously, the current thread may be a background thread at this point.
            // Do any initialization that requires the UI thread after switching to the UI thread.
            await this.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);

            try
            {
                SettingsManager settingsManager = new ShellSettingsManager(ServiceProvider);

                configurationSettingsStore = settingsManager.GetWritableSettingsStore(SettingsScope.UserSettings);

                configurationSettingsStore.CreateCollection("LuaDkmDebugger");

                attachOnLaunch   = configurationSettingsStore.GetBoolean("LuaDkmDebugger", "AttachOnLaunch", true);
                breakOnError     = configurationSettingsStore.GetBoolean("LuaDkmDebugger", "BreakOnError", true);
                releaseDebugLogs = configurationSettingsStore.GetBoolean("LuaDkmDebugger", "ReleaseDebugLogs", false);
                showHiddenFrames = configurationSettingsStore.GetBoolean("LuaDkmDebugger", "ShowHiddenFrames", false);
                useSchema        = configurationSettingsStore.GetBoolean("LuaDkmDebugger", "UseSchema", false);

                LuaDkmDebuggerComponent.LocalComponent.attachOnLaunch   = attachOnLaunch;
                LuaDkmDebuggerComponent.LocalComponent.breakOnError     = breakOnError;
                LuaDkmDebuggerComponent.LocalComponent.releaseDebugLogs = releaseDebugLogs;
                LuaDkmDebuggerComponent.LocalComponent.showHiddenFrames = showHiddenFrames;
                LuaDkmDebuggerComponent.LocalComponent.useSchema        = useSchema;
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine("Failed to setup setting with " + e.Message);
            }

            OleMenuCommandService commandService = ServiceProvider.GetService(typeof(IMenuCommandService)) as OleMenuCommandService;

            if (commandService != null)
            {
                {
                    CommandID menuCommandID = new CommandID(CommandSet, LuaInitializeCommandId);

                    OleMenuCommand menuItem = new OleMenuCommand((object sender, EventArgs args) =>
                    {
                        if (sender is OleMenuCommand command)
                        {
                            command.Visible = false;
                        }
                    }, menuCommandID);

                    menuItem.BeforeQueryStatus += (object sender, EventArgs args) =>
                    {
                        if (sender is OleMenuCommand command)
                        {
                            command.Visible = false;
                        }
                    };

                    menuItem.Visible = false;

                    commandService.AddCommand(menuItem);
                }

                {
                    CommandID menuCommandID = new CommandID(CommandSet, LuaAttachOnLaunchCommandId);

                    OleMenuCommand menuItem = new OleMenuCommand((object sender, EventArgs args) =>
                    {
                        HandleToggleMenuItem(sender, args, "AttachOnLaunch", ref LuaDkmDebuggerComponent.LocalComponent.attachOnLaunch, ref attachOnLaunch);
                    }, menuCommandID);

                    menuItem.BeforeQueryStatus += (object sender, EventArgs args) =>
                    {
                        if (sender is OleMenuCommand command)
                        {
                            command.Checked = attachOnLaunch;
                        }
                    };

                    menuItem.Enabled = true;
                    menuItem.Checked = attachOnLaunch;

                    commandService.AddCommand(menuItem);
                }

                {
                    CommandID menuCommandID = new CommandID(CommandSet, LuaBreakOnErrorCommandId);

                    OleMenuCommand menuItem = new OleMenuCommand((object sender, EventArgs args) =>
                    {
                        HandleToggleMenuItem(sender, args, "BreakOnError", ref LuaDkmDebuggerComponent.LocalComponent.breakOnError, ref breakOnError);
                    }, menuCommandID);

                    menuItem.BeforeQueryStatus += (object sender, EventArgs args) =>
                    {
                        if (sender is OleMenuCommand command)
                        {
                            command.Checked = breakOnError;
                        }
                    };

                    menuItem.Enabled = true;
                    menuItem.Checked = breakOnError;

                    commandService.AddCommand(menuItem);
                }

                {
                    CommandID menuCommandID = new CommandID(CommandSet, LoggingCommandId);

                    OleMenuCommand menuItem = new OleMenuCommand((object sender, EventArgs args) =>
                    {
                        HandleToggleMenuItem(sender, args, "ReleaseDebugLogs", ref LuaDkmDebuggerComponent.LocalComponent.releaseDebugLogs, ref releaseDebugLogs);
                    }, menuCommandID);

                    menuItem.BeforeQueryStatus += (object sender, EventArgs args) =>
                    {
                        if (sender is OleMenuCommand command)
                        {
                            command.Checked = releaseDebugLogs;
                        }
                    };

                    menuItem.Enabled = true;
                    menuItem.Checked = releaseDebugLogs;

                    commandService.AddCommand(menuItem);
                }

                {
                    CommandID menuCommandID = new CommandID(CommandSet, LuaShowHiddenFramesCommandId);

                    OleMenuCommand menuItem = new OleMenuCommand((object sender, EventArgs args) =>
                    {
                        HandleToggleMenuItem(sender, args, "ShowHiddenFrames", ref LuaDkmDebuggerComponent.LocalComponent.showHiddenFrames, ref showHiddenFrames);
                    }, menuCommandID);

                    menuItem.BeforeQueryStatus += (object sender, EventArgs args) =>
                    {
                        if (sender is OleMenuCommand command)
                        {
                            command.Checked = showHiddenFrames;
                        }
                    };

                    menuItem.Enabled = true;
                    menuItem.Checked = showHiddenFrames;

                    commandService.AddCommand(menuItem);
                }

                {
                    CommandID menuCommandID = new CommandID(CommandSet, LuaUseSchemaCommandId);

                    OleMenuCommand menuItem = new OleMenuCommand((object sender, EventArgs args) =>
                    {
                        HandleToggleMenuItem(sender, args, "UseSchema", ref LuaDkmDebuggerComponent.LocalComponent.useSchema, ref useSchema);
                    }, menuCommandID);

                    menuItem.BeforeQueryStatus += (object sender, EventArgs args) =>
                    {
                        if (sender is OleMenuCommand command)
                        {
                            command.Checked = useSchema;
                        }
                    };

                    menuItem.Enabled = true;
                    menuItem.Checked = useSchema;

                    commandService.AddCommand(menuItem);
                }

                {
                    CommandID menuCommandID = new CommandID(CommandSet, LuaShowScriptListCommandId);

                    MenuCommand menuItem = new MenuCommand((object sender, EventArgs args) =>
                    {
                        JoinableTaskFactory.RunAsync(async() =>
                        {
                            ToolWindowPane window = await ShowToolWindowAsync(
                                typeof(ScriptListWindow),
                                0,
                                create: true,
                                cancellationToken: DisposalToken);
                        });
                    }, menuCommandID);

                    commandService.AddCommand(menuItem);
                }
            }

            try
            {
                DTE2 dte = (DTE2)ServiceProvider.GetService(typeof(SDTE));

                scriptListWindowState.dte = dte;

                Debugger5 debugger = dte?.Debugger as Debugger5;

                var debuggerEventHandler = new LuaDebuggerEventHandler(this, debugger);

                ServiceContainer.AddService(debuggerEventHandler.GetType(), debuggerEventHandler, promote: true);
            }
            catch (Exception e)
            {
                Debug.WriteLine("Failed to setup debuggerEventHandler with " + e.Message);
            }
        }
コード例 #31
0
        public bool GetBooleanByProject(Project project, string key, bool defaultValue = false)
        {
            var collectionPath = GetOrCreateCollectionByProject(project);

            return(store.GetBoolean(collectionPath, key, defaultValue));
        }