示例#1
0
        public void Store()
        {
            try
            {
                if (!writableSettingsStore.CollectionExists(Constants.SettingsCollectionPath))
                {
                    writableSettingsStore.CreateCollection(Constants.SettingsCollectionPath);
                }

                writableSettingsStore.SetInt32(Constants.SettingsCollectionPath, "FilenameColor", this.FilenameColor.ToArgb());
                writableSettingsStore.SetInt32(Constants.SettingsCollectionPath, "FoldersColor", this.FoldersColor.ToArgb());
                writableSettingsStore.SetInt32(Constants.SettingsCollectionPath, "ProjectColor", this.ProjectColor.ToArgb());

                writableSettingsStore.SetString(Constants.SettingsCollectionPath, "ViewFilename", this.ViewFilename.ToString());
                writableSettingsStore.SetString(Constants.SettingsCollectionPath, "ViewFolders", this.ViewFolders.ToString());
                writableSettingsStore.SetString(Constants.SettingsCollectionPath, "ViewProject", this.ViewProject.ToString());

                writableSettingsStore.SetString(Constants.SettingsCollectionPath, "FilenameSize", this.FilenameSize.ToString());
                writableSettingsStore.SetString(Constants.SettingsCollectionPath, "FoldersSize", this.FoldersSize.ToString());
                writableSettingsStore.SetString(Constants.SettingsCollectionPath, "ProjectSize", this.ProjectSize.ToString());

                writableSettingsStore.SetString(Constants.SettingsCollectionPath, "Position", this.Position.ToString());
                writableSettingsStore.SetString(Constants.SettingsCollectionPath, "Opacity", this.Opacity.ToString());
                writableSettingsStore.SetString(Constants.SettingsCollectionPath, "Theme", this.Theme.ToString());

                SettingsChanged?.Invoke(this, EventArgs.Empty);
            }
            catch (Exception ex)
            {
                Debug.Fail(ex.Message);
            }
        }
示例#2
0
        public void Save()
        {
            if (!_store.CollectionExists(COLLECTION_PATH))
            {
                _store.CreateCollection(COLLECTION_PATH);
            }

            _store.SetBoolean(COLLECTION_PATH, IS_DESIGNER_ENABLED_PROPERTY, IsDesignerEnabled);
            _store.SetBoolean(COLLECTION_PATH, IS_REVERSED_PROPERTY, IsReversed);
            _store.SetInt32(COLLECTION_PATH, SPLIT_ORIENTATION_PROPERTY, (int)SplitOrientation);
            _store.SetInt32(COLLECTION_PATH, DOCUMENT_VIEW_PROPERTY, (int)DocumentView);
        }
        public void Write(string subPath, string property, object value)
        {
            Validate.IsNotNull(property, nameof(property));
            Validate.IsNotEmpty(property, nameof(property));

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

            _store.CreateCollection(collection);

            if (value is bool b)
            {
                _store.SetBoolean(collection, property, b);
            }
            else if (value is int i)
            {
                _store.SetInt32(collection, property, i);
            }
            else if (value is uint u)
            {
                _store.SetUInt32(collection, property, u);
            }
            else if (value is long l)
            {
                _store.SetInt64(collection, property, l);
            }
            else if (value is ulong ul)
            {
                _store.SetUInt64(collection, property, ul);
            }
            else
            {
                _store.SetString(collection, property, value?.ToString() ?? "");
            }
        }
示例#4
0
        private void RaiseParametersChanged(Parameter param)
        {
            if (ParametersChanged != null)
            {
                ParametersChanged(this, new ParametersEnventArgs(param));
            }

            if (param == Parameter.Port || param == Parameter.DisableESMTP)
            {
                SettingsManager       settingsManager            = new ShellSettingsManager(VMSTPSettingsStore.ServiceProvider);
                WritableSettingsStore configurationSettingsStore = settingsManager.GetWritableSettingsStore(SettingsScope.UserSettings);

                bool collectionExists = configurationSettingsStore.CollectionExists(VMSTPSettingsStore.Collection);
                if (!collectionExists)
                {
                    configurationSettingsStore.CreateCollection(VMSTPSettingsStore.Collection);
                }

                if (collectionExists || configurationSettingsStore.CollectionExists(VMSTPSettingsStore.Collection))
                {
                    configurationSettingsStore.SetBoolean(VMSTPSettingsStore.Collection, "DisableESMTP", DisableESMTP);
                    configurationSettingsStore.SetInt32(VMSTPSettingsStore.Collection, "Port", Port);
                }
            }
        }
示例#5
0
        private static bool SaveSettingsIntoStore(ISettings settings)
        {
            var saved = false;

            var properties = GetProperties(settings);

            foreach (var prop in properties)
            {
                switch (prop.GetValue(settings))
                {
                case bool b:
                    store.SetBoolean(settings.Key, prop.Name, b);
                    saved = true;
                    break;

                case int i:
                    store.SetInt32(settings.Key, prop.Name, i);
                    saved = true;
                    break;

                case double d:
                    store.SetString(settings.Key, prop.Name, d.ToString());
                    saved = true;
                    break;

                case string s:
                    store.SetString(settings.Key, prop.Name, s);
                    saved = true;
                    break;
                }
            }

            return(saved);
        }
示例#6
0
        public static void IgnoreSolution(bool ignore)
        {
            WritableSettingsStore wstore = _settings.GetWritableSettingsStore(SettingsScope.UserSettings);

            if (!wstore.CollectionExists(Constants.VSIX_NAME))
            {
                wstore.CreateCollection(Constants.VSIX_NAME);
            }

            string solution = VSPackage.GetSolution();

            if (string.IsNullOrEmpty(solution))
            {
                return;
            }

            string property = GetPropertyName(solution);

            if (ignore)
            {
                wstore.SetInt32(Constants.VSIX_NAME, property, 1);
            }
            else
            {
                wstore.DeleteProperty(Constants.VSIX_NAME, property);
            }
        }
示例#7
0
        public void Write(string subpath, string property, object value)
        {
            Guard.ArgumentNotNull(property, nameof(property));
            Guard.ArgumentNotEmptyString(property, nameof(property));

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

            store.CreateCollection(collection);

            if (value is bool)
            {
                store.SetBoolean(collection, property, (bool)value);
            }
            else if (value is int)
            {
                store.SetInt32(collection, property, (int)value);
            }
            else if (value is uint)
            {
                store.SetUInt32(collection, property, (uint)value);
            }
            else if (value is long)
            {
                store.SetInt64(collection, property, (long)value);
            }
            else if (value is ulong)
            {
                store.SetUInt64(collection, property, (ulong)value);
            }
            else
            {
                store.SetString(collection, property, value?.ToString() ?? "");
            }
        }
示例#8
0
        public static void WriteSetting <T>(string propertyName, T propertyValue)
        {
            switch (Type.GetTypeCode(typeof(T)))
            {
            case TypeCode.String:
                _userSettingsStore.SetString(CollectionName, propertyName, Convert.ToString(propertyValue));
                break;

            case TypeCode.Boolean:
                _userSettingsStore.SetBoolean(CollectionName, propertyName, Convert.ToBoolean(propertyValue));
                break;

            case TypeCode.Int32:
                _userSettingsStore.SetInt32(CollectionName, propertyName, Convert.ToInt32(propertyValue));
                break;

            case TypeCode.Int64:
                _userSettingsStore.SetInt64(CollectionName, propertyName, Convert.ToInt64(propertyValue));
                break;

            case TypeCode.UInt32:
                _userSettingsStore.SetUInt32(CollectionName, propertyName, Convert.ToUInt32(propertyValue));
                break;

            case TypeCode.UInt64:
                _userSettingsStore.SetUInt64(CollectionName, propertyName, Convert.ToUInt64(propertyValue));
                break;

            default:
                _userSettingsStore.SetString(CollectionName, propertyName, Convert.ToString(propertyValue));
                break;
            }
        }
        private void Set(string key, object value, Type targetType = null, SerializationMode serializationMode = SerializationMode.Xml)
        {
            if (targetType == null)
            {
                if (value is int && (int)value == 0)
                {
                    value      = false;
                    targetType = typeof(bool);
                }
                else if (value is int && (int)value == 1)
                {
                    value      = true;
                    targetType = typeof(bool);
                }
                else
                {
                    targetType = ConvertSettingsType(Check.TryCatch <SettingsType, Exception>(() => settingsStore.GetPropertyType(collectionPath, key)), value?.GetType());
                }
            }

            if (targetType.IsEnum)
            {
                targetType = typeof(int);
            }

            if (targetType == typeof(bool))
            {
                settingsStore.SetBoolean(collectionPath, key, Convert.ToBoolean(value));
            }
            else if (targetType == typeof(string))
            {
                var s = value?.ToString() ?? string.Empty;
                settingsStore.SetString(collectionPath, key, s);
            }
            else if (targetType == typeof(int))
            {
                settingsStore.SetInt32(collectionPath, key, Convert.ToInt32(value));
            }
            else
            {
                using (var ms = new MemoryStream())
                {
                    if (serializationMode == SerializationMode.Binary)
                    {
                        var serializer = new BinaryFormatter();
                        serializer.Serialize(ms, value);
                        ms.Position = 0;
                        settingsStore.SetMemoryStream(collectionPath, key, ms);
                    }
                    else if (serializationMode == SerializationMode.Xml)
                    {
                        var serializer = new XmlSerializer(targetType);
                        serializer.Serialize(ms, value);
                        string xmlContent = Encoding.UTF8.GetString(ms.ToArray());
                        settingsStore.SetString(collectionPath, key, xmlContent);
                    }
                }
            }
        }
示例#10
0
 private static void SetOption(WritableSettingsStore store, string catelogName, string optionName, int value)
 {
     if (!store.CollectionExists(COLLECTION_PATH))
     {
         store.CreateCollection(COLLECTION_PATH);
     }
     store?.SetInt32(COLLECTION_PATH, CombineCatelogAndOptionName(catelogName, optionName), value);
 }
示例#11
0
 public void SetInt32(string propertyName, int val)
 {
     try
     {
         _settingsStore.SetInt32(CollectionPath, propertyName, val);
     }
     catch (Exception ex)
     {
         Debug.WriteLine(ex.Message);
     }
 }
示例#12
0
        public static void SetInt32(string option, int value)
        {
            Initialize();
            defaults[option] = value;
            if (persistent_settings == null)
            {
                return;
            }
            IEnumerable <string> collection = persistent_settings.GetSubCollectionNames("AntlrVSIX");

            persistent_settings.SetInt32("AntlrVSIX", option, value);
        }
示例#13
0
        private void SaveShortcutFileInfoToSettingsStore(string collectionPrefix, ShortcutFileInfo shortcutFileInfo)
        {
            // Store values in UserSettingsStore. Use the "Name" property as the Collection key
            string collectionPath = $"{collectionPrefix}\\{shortcutFileInfo.DisplayName}";

            UserSettingsStore.CreateCollection(collectionPath);
            UserSettingsStore.SetString(collectionPath, NAME, shortcutFileInfo.DisplayName);
            UserSettingsStore.SetString(collectionPath, FILEPATH, shortcutFileInfo.Filepath);
            UserSettingsStore.SetString(collectionPath, EXTENSION_NAME, shortcutFileInfo.ExtensionName);
            UserSettingsStore.SetString(collectionPath, LAST_WRITE_TIME, shortcutFileInfo.LastWriteTime.ToString(ShortcutFileInfo.DATETIME_FORMAT));
            UserSettingsStore.SetInt32(collectionPath, FLAGS, shortcutFileInfo.NotifyFlag);
        }
        public void CreateFilterStoreData(string name, string tag, int pid, string text, string package,
                                          LogcatItem.Level level)
        {
            SettingsManager       settingsManager            = new ShellSettingsManager(LogcatOutputToolWindowCommand.Instance.ServiceProvider);
            WritableSettingsStore configurationSettingsStore = settingsManager.GetWritableSettingsStore(SettingsScope.UserSettings);

            configurationSettingsStore.CreateCollection(LogcatOutputToolWindowControl.StoreFilterCollectionName);
            string filter_sub_collection = LogcatOutputToolWindowControl.StoreFilterCollectionName
                                           + "\\" + name;

            configurationSettingsStore.CreateCollection(filter_sub_collection);
            configurationSettingsStore.SetString(filter_sub_collection,
                                                 LogcatOutputToolWindowControl.StorePropertyFilterTagName, tag);
            configurationSettingsStore.SetInt32(filter_sub_collection,
                                                LogcatOutputToolWindowControl.StorePropertyFilterPidName, pid);
            configurationSettingsStore.SetString(filter_sub_collection,
                                                 LogcatOutputToolWindowControl.StorePropertyFilterMsgName, text);
            configurationSettingsStore.SetString(filter_sub_collection,
                                                 LogcatOutputToolWindowControl.StorePropertyFilterPackageName, package);
            configurationSettingsStore.SetInt32(filter_sub_collection,
                                                LogcatOutputToolWindowControl.StorePropertyFilterLevelName, (int)level);
        }
示例#15
0
        /// <summary>
        /// Saves DexterInfo to Settings Store
        /// </summary>
        /// <param name="dexterInfo">DexterInfo to save</param>
        public void Save(DexterInfo dexterInfo)
        {
            if (!settingsStore.CollectionExists(DexterStoreName))
            {
                settingsStore.CreateCollection(DexterStoreName);
            }

            settingsStore.SetString(DexterStoreName, "dexterHome", dexterInfo.dexterHome);
            settingsStore.SetString(DexterStoreName, "dexterServerIp", dexterInfo.dexterServerIp);
            settingsStore.SetInt32(DexterStoreName, "dexterServerPort", dexterInfo.dexterServerPort);
            settingsStore.SetString(DexterStoreName, "userName", dexterInfo.userName);
            settingsStore.SetString(DexterStoreName, "userPassword", dexterInfo.userPassword);
            settingsStore.SetBoolean(DexterStoreName, "standalone", dexterInfo.standalone);
        }
示例#16
0
 private void SaveSettings()
 {
     try
     {
         _writableSettingsStore.CreateCollection(CollectionPath);
         _writableSettingsStore.SetInt32(CollectionPath, IndentSizeName, _indentSize);
         _writableSettingsStore.SetString(CollectionPath, CompilerPathName, _compilerPath);
         _writableSettingsStore.SetString(CollectionPath, SrcPathName, _srcPath);
     }
     catch (Exception ex)
     {
         Debug.Fail(ex.Message);
     }
 }
示例#17
0
        public static void SaveSettings(ISettings settings)
        {
            try
            {
                if (store.CollectionExists(settings.Key) != true)
                {
                    store.CreateCollection(settings.Key);
                }

                var anySaved = false;

                var type = settings.GetType();

                foreach (var prop in type.GetProperties().Where(p => Attribute.IsDefined(p, typeof(SettingAttribute))))
                {
                    if (prop.PropertyType == typeof(bool))
                    {
                        store.SetBoolean(settings.Key, prop.Name, ((bool)(prop.GetValue(settings))));
                        anySaved = true;
                    }
                    else if (prop.PropertyType == typeof(int))
                    {
                        store.SetInt32(settings.Key, prop.Name, ((int)(prop.GetValue(settings))));
                        anySaved = true;
                    }
                    else if (prop.PropertyType == typeof(double))
                    {
                        store.SetString(settings.Key, prop.Name, prop.GetValue(settings).ToString());
                        anySaved = true;
                    }
                    else if (prop.PropertyType == typeof(string))
                    {
                        store.SetString(settings.Key, prop.Name, ((string)(prop.GetValue(settings))));
                        anySaved = true;
                    }
                }

                if (anySaved)
                {
                    SettingsChanged?.Invoke();
                }
            }
            catch (Exception ex)
            {
                Debug.Fail(ex.Message);
            }
        }
        private void SaveSelection()
        {
            try
            {
                WritableSettingsStore wstore = _settings.GetWritableSettingsStore(SettingsScope.UserSettings);

                if (!wstore.CollectionExists(Vsix.Name))
                {
                    wstore.CreateCollection(Vsix.Name);
                }

                wstore.SetInt32(Vsix.Name, "type", cbType.SelectedIndex);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.Write(ex);
            }
        }
示例#19
0
        public void SaveUserSettings(ExtensionSettings settings)
        {
            try
            {
                SettingsManager       settingsManager   = new ShellSettingsManager(ServiceProvider);
                WritableSettingsStore userSettingsStore = settingsManager.GetWritableSettingsStore(SettingsScope.UserSettings);

                if (!userSettingsStore.CollectionExists("Team Room Extension"))
                {
                    userSettingsStore.CreateCollection("Team Room Extension");
                }

                userSettingsStore.SetInt32("Team Room Extension", "RoomId", settings.TeamRoomId);
                userSettingsStore.SetString("Team Room Extension", "TeamProjectUri", settings.ProjectCollectionUri != null ? settings.ProjectCollectionUri.ToString() : "");
            }
            catch (Exception ex)
            {
            }
        }
        public static void SetValue(this WritableSettingsStore store, string collectionPath, string propertyName, object value)
        {
            switch (value)
            {
            case null: store.DeleteProperty(collectionPath, propertyName);
                break;

            case string s: store.SetString(collectionPath, propertyName, s);
                break;

            case long l: store.SetInt64(collectionPath, propertyName, l);
                break;

            case int i: store.SetInt32(collectionPath, propertyName, i);
                break;

            case bool b: store.SetBoolean(collectionPath, propertyName, b);
                break;
            }
        }
示例#21
0
        /// <summary>
        /// Saves window size and position
        /// </summary>
        private void OnClosing(object sender, CancelEventArgs e)
        {
            try
            {
                // This check should be unnecessary unless there was an Exception in OnLoad
                if (WritableSettingsStore.CollectionExists(SS_Collection) == false)
                {
                    WritableSettingsStore.CreateCollection(SS_Collection);
                }

                // Window size and position
                WritableSettingsStore.SetInt32(SS_Collection, SS_WindowTop, (int)Top);
                WritableSettingsStore.SetInt32(SS_Collection, SS_WindowLeft, (int)Left);
                WritableSettingsStore.SetInt32(SS_Collection, SS_WindowWidth, (int)Width);
                WritableSettingsStore.SetInt32(SS_Collection, SS_WindowHeight, (int)Height);
                WritableSettingsStore.SetInt32(SS_Collection, SS_WindowState, (int)WindowState);
            }
            catch (Exception)
            {
                // Ignore quietly
            }
        }
示例#22
0
        public static void IgnoreFileType(IEnumerable <string> fileTypes, bool ignore)
        {
            WritableSettingsStore wstore = _settings.GetWritableSettingsStore(SettingsScope.UserSettings);

            if (!wstore.CollectionExists(Constants.VSIX_NAME))
            {
                wstore.CreateCollection(Constants.VSIX_NAME);
            }

            foreach (string fileType in fileTypes)
            {
                string property = fileType.ToLowerInvariant();

                if (ignore)
                {
                    wstore.SetInt32(Constants.VSIX_NAME, property, 1);
                }
                else
                {
                    wstore.DeleteProperty(Constants.VSIX_NAME, property);
                }
            }
        }
示例#23
0
 private static void SetVersionToLatest()
 {
     Store.SetInt32(CollectionPath, VersionKey, LatestVersion);
 }
示例#24
0
 internal void ResetSettings()
 {
     userSettingsStore.SetInt32(SettingsCollectionName, MinimumToShowName, DefaultToShow);
     userSettingsStore.SetString(SettingsCollectionName, GoodColorName, DefaultGoodColor);
     userSettingsStore.SetString(SettingsCollectionName, BadColorName, DefaultBadColor);
 }
示例#25
0
        protected void WriteInt32(string settingsRoot, string property, int value)
        {
            WritableSettingsStore userSettingsStore = GetWritableSettingsStore(settingsRoot);

            userSettingsStore.SetInt32(settingsRoot, property, value);
        }
示例#26
0
 /// <summary>
 /// Saves the given indentsize to the settings store using a specific collection and property name
 /// </summary>
 /// <param name="store">The writable settings store</param>
 /// <param name="indentSize">The indent size to save</param>
 public static void SaveIndentSize(this WritableSettingsStore store, int indentSize)
 {
     store.SetInt32(collectionName, indentSizePropertyName, indentSize);
 }
 public void SetInt32(string collectionPath, string propertyName, int value)
 {
     settingsStore.SetInt32(collectionPath, propertyName, value);
 }