public void LoadFilterStoreData() { SettingsManager settingsManager = new ShellSettingsManager(LogcatOutputToolWindowCommand.Instance.ServiceProvider); WritableSettingsStore settingsStore = settingsManager.GetWritableSettingsStore(SettingsScope.UserSettings); if (settingsStore.CollectionExists(StoreFilterCollectionName)) { int count = settingsStore.GetSubCollectionCount(StoreFilterCollectionName); IEnumerable <string> filter_name_list = settingsStore.GetSubCollectionNames(LogcatOutputToolWindowControl.StoreFilterCollectionName); if (filter_name_list == null) { return; } foreach (string name in filter_name_list) { string filter_sub_collection = StoreFilterCollectionName + "\\" + name; string tag = settingsStore.GetString(filter_sub_collection, LogcatOutputToolWindowControl.StorePropertyFilterTagName, ""); int pid = settingsStore.GetInt32(filter_sub_collection, LogcatOutputToolWindowControl.StorePropertyFilterPidName, 0); string msg = settingsStore.GetString(filter_sub_collection, LogcatOutputToolWindowControl.StorePropertyFilterMsgName, ""); string pkg = settingsStore.GetString(filter_sub_collection, LogcatOutputToolWindowControl.StorePropertyFilterPackageName, ""); int level = settingsStore.GetInt32(filter_sub_collection, LogcatOutputToolWindowControl.StorePropertyFilterLevelName, 0); AddFilterItem(name, tag, pid, msg, pkg, (LogcatOutputToolWindowControl.LogcatItem.Level)level, false); } } }
private void LoadSettings() { // IsDesignerEnabled, either read from the store or initialize to true. IsDesignerEnabled = !_store.PropertyExists(COLLECTION_PATH, IS_DESIGNER_ENABLED_PROPERTY) || _store.GetBoolean(COLLECTION_PATH, IS_DESIGNER_ENABLED_PROPERTY); SplitOrientation = _store.PropertyExists(COLLECTION_PATH, SPLIT_ORIENTATION_PROPERTY) ? (SplitOrientation)_store.GetInt32(COLLECTION_PATH, SPLIT_ORIENTATION_PROPERTY) : SplitOrientation.Default; DocumentView = _store.PropertyExists(COLLECTION_PATH, DOCUMENT_VIEW_PROPERTY) ? (DocumentView)_store.GetInt32(COLLECTION_PATH, DOCUMENT_VIEW_PROPERTY) : DocumentView.SplitView; IsReversed = _store.PropertyExists(COLLECTION_PATH, IS_REVERSED_PROPERTY) && _store.GetBoolean(COLLECTION_PATH, IS_REVERSED_PROPERTY); }
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() ?? "")); }
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; } } } }
/// <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() ?? "")); }
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); } }
/// <summary> /// Loads the indent size from the settings store. /// </summary> /// <param name="store">The writable settings store</param> /// <returns>The indent size saved or if not found, the default indent size</returns> public static int LoadIndentSize(this WritableSettingsStore store) { if (!store.PropertyExists(collectionName, indentSizePropertyName)) { store.SaveIndentSize(DefaultRainbowIndentOptions.defaultIndentSize); return(DefaultRainbowIndentOptions.defaultIndentSize); } else { return(store.GetInt32(collectionName, indentSizePropertyName)); } }
private void LoadSettings() { try { _indentSize = _writableSettingsStore.GetInt32(CollectionPath, IndentSizeName, _indentSize); _compilerPath = _writableSettingsStore.GetString(CollectionPath, CompilerPathName, _compilerPath); _srcPath = _writableSettingsStore.GetString(CollectionPath, SrcPathName, _srcPath); } catch (Exception ex) { Debug.Fail(ex.Message); } }
internal void LoadSettingsFromStorage() { var installed = userSettingsStore.CollectionExists(SettingsCollectionName); if (!installed) { userSettingsStore.CreateCollection(SettingsCollectionName); ResetSettings(); } this.MinimumToShow = userSettingsStore.GetInt32(SettingsCollectionName, MinimumToShowName, DefaultToShow); this.GoodColor = this.ResolveSettingsColor(GoodColorName, DefaultGoodColor); this.BadColor = this.ResolveSettingsColor(BadColorName, DefaultBadColor); }
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); } }
public int GetInt32(string propertyName) { try { if (_settingsStore.PropertyExists(CollectionPath, propertyName)) { return(_settingsStore.GetInt32(CollectionPath, propertyName)); } } catch (Exception ex) { Debug.WriteLine(ex.Message); } return(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); }
/// <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") }); } }
private ShortcutFileInfo ExtractShortcutsInfoFromSettingsStore(string collectionName, string shortcutDef) { string collectionPath = $"{collectionName}\\{shortcutDef}"; // Extract values from UserSettingsStore string filepath = UserSettingsStore.GetString(collectionPath, FILEPATH); string name = UserSettingsStore.GetString(collectionPath, NAME); string extensionName = UserSettingsStore.GetString(collectionPath, EXTENSION_NAME); DateTime lastWriteTime = DateTime.Parse(UserSettingsStore.GetString(collectionPath, LAST_WRITE_TIME)); int flags = UserSettingsStore.GetInt32(collectionPath, FLAGS, 0); return(new ShortcutFileInfo() { Filepath = filepath, DisplayName = name, ExtensionName = extensionName, LastWriteTime = lastWriteTime, NotifyFlag = flags }); }
// https://msdn.microsoft.com/en-us/library/dn949254.aspx public ExtensionSettings LoadUserSettings() { try { SettingsManager settingsManager = new ShellSettingsManager(ServiceProvider); WritableSettingsStore userSettingsStore = settingsManager.GetWritableSettingsStore(SettingsScope.UserSettings); Uri selectedTeamProjectUri; int selectedRoomId = userSettingsStore.GetInt32("Team Room Extension", "RoomId", 0); Uri.TryCreate(userSettingsStore.GetString("Team Room Extension", "TeamProjectUri", ""), UriKind.Absolute, out selectedTeamProjectUri); return(new ExtensionSettings { ProjectCollectionUri = selectedTeamProjectUri, TeamRoomId = selectedRoomId }); } catch (Exception ex) { return(new ExtensionSettings()); } }
public static int GetInt32(string option) { Initialize(); int default_value = 0; defaults.TryGetValue(option, out object value); if (value == null) { default_value = 0; } else if (value is Int32) { default_value = (int)value; } if (persistent_settings != null) { return(persistent_settings.GetInt32("AntlrVSIX", option, default_value)); } else { return(default_value); } }
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))); } }
private void LoadSettings() { // Default values var lightTheme = WhereAmISettings.LightThemeDefaults(); FilenameSize = lightTheme.FilenameSize; FoldersSize = ProjectSize = lightTheme.FoldersSize; FilenameColor = lightTheme.FilenameColor; FoldersColor = ProjectColor = lightTheme.FoldersColor; Position = lightTheme.Position; Opacity = lightTheme.Opacity; ViewFilename = ViewFolders = ViewProject = lightTheme.ViewFilename; Theme = lightTheme.Theme; try { // Retrieve the Id of the current theme used in VS from user's settings, this is changed a lot in VS2015 string visualStudioThemeId = VSRegistry.RegistryRoot(Microsoft.VisualStudio.Shell.Interop.__VsLocalRegistryType.RegType_UserSettings).OpenSubKey("ApplicationPrivateSettings").OpenSubKey("Microsoft").OpenSubKey("VisualStudio").GetValue("ColorTheme", "de3dbbcd-f642-433c-8353-8f1df4370aba", Microsoft.Win32.RegistryValueOptions.DoNotExpandEnvironmentNames).ToString(); string parsedThemeId = ""; if (visualStudioThemeId.Contains("*")) { parsedThemeId = Guid.Parse(visualStudioThemeId.Split('*')[2]).ToString(); } else { parsedThemeId = Guid.Parse(visualStudioThemeId).ToString(); } switch (parsedThemeId) { case Constants.VisualStudioLightThemeId: // Light case Constants.VisualStudioBlueThemeId: // Blue default: // Just use the defaults break; case Constants.VisualStudioDarkThemeId: // Dark var darkTheme = WhereAmISettings.DarkThemeDefaults(); FilenameSize = darkTheme.FilenameSize; FoldersSize = ProjectSize = darkTheme.FoldersSize; FilenameColor = darkTheme.FilenameColor; FoldersColor = ProjectColor = darkTheme.FoldersColor; Position = darkTheme.Position; Opacity = darkTheme.Opacity; ViewFilename = ViewFolders = ViewProject = darkTheme.ViewFilename; Theme = darkTheme.Theme; break; } // Tries to retrieve the configurations if previously saved if (writableSettingsStore.PropertyExists(Constants.SettingsCollectionPath, "FilenameColor")) { this.FilenameColor = Color.FromArgb(writableSettingsStore.GetInt32(Constants.SettingsCollectionPath, "FilenameColor", this.FilenameColor.ToArgb())); } if (writableSettingsStore.PropertyExists(Constants.SettingsCollectionPath, "FoldersColor")) { this.FoldersColor = Color.FromArgb(writableSettingsStore.GetInt32(Constants.SettingsCollectionPath, "FoldersColor", this.FoldersColor.ToArgb())); } if (writableSettingsStore.PropertyExists(Constants.SettingsCollectionPath, "ProjectColor")) { this.ProjectColor = Color.FromArgb(writableSettingsStore.GetInt32(Constants.SettingsCollectionPath, "ProjectColor", this.ProjectColor.ToArgb())); } if (writableSettingsStore.PropertyExists(Constants.SettingsCollectionPath, "ViewFilename")) { bool b = this.ViewFilename; if (Boolean.TryParse(writableSettingsStore.GetString(Constants.SettingsCollectionPath, "ViewFilename"), out b)) { this.ViewFilename = b; } } if (writableSettingsStore.PropertyExists(Constants.SettingsCollectionPath, "ViewFolders")) { bool b = this.ViewFolders; if (Boolean.TryParse(writableSettingsStore.GetString(Constants.SettingsCollectionPath, "ViewFolders"), out b)) { this.ViewFolders = b; } } if (writableSettingsStore.PropertyExists(Constants.SettingsCollectionPath, "ViewProject")) { bool b = this.ViewProject; if (Boolean.TryParse(writableSettingsStore.GetString(Constants.SettingsCollectionPath, "ViewProject"), out b)) { this.ViewProject = b; } } if (writableSettingsStore.PropertyExists(Constants.SettingsCollectionPath, "FilenameSize")) { double d = this.FilenameSize; if (Double.TryParse(writableSettingsStore.GetString(Constants.SettingsCollectionPath, "FilenameSize"), out d)) { this.FilenameSize = d; } } if (writableSettingsStore.PropertyExists(Constants.SettingsCollectionPath, "FoldersSize")) { double d = this.FoldersSize; if (Double.TryParse(writableSettingsStore.GetString(Constants.SettingsCollectionPath, "FoldersSize"), out d)) { this.FoldersSize = d; } } if (writableSettingsStore.PropertyExists(Constants.SettingsCollectionPath, "ProjectSize")) { double d = this.ProjectSize; if (Double.TryParse(writableSettingsStore.GetString(Constants.SettingsCollectionPath, "ProjectSize"), out d)) { this.ProjectSize = d; } } if (writableSettingsStore.PropertyExists(Constants.SettingsCollectionPath, "Position")) { AdornmentPositions p = this.Position; if (Enum.TryParse <AdornmentPositions>(writableSettingsStore.GetString(Constants.SettingsCollectionPath, "Position"), out p)) { this.Position = p; } } if (writableSettingsStore.PropertyExists(Constants.SettingsCollectionPath, "Opacity")) { double d = this.Opacity; if (Double.TryParse(writableSettingsStore.GetString(Constants.SettingsCollectionPath, "Opacity"), out d)) { this.Opacity = d; } } } catch (Exception ex) { Debug.Fail(ex.Message); } }
/// <summary> /// Called when Snippeter's window has loaded /// </summary> private void OnLoad(object sender, RoutedEventArgs e) { // Window icon var icon = WindowExtensions.ImageSourceFromIcon(Properties.Resources.snippeter); 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); } else { // Create collection now to be able to check for other settings the 1st time around WritableSettingsStore.CreateCollection(SS_Collection); } } catch (Exception) { // Ignore quietly } if (lvSnippets.Visibility == Visibility.Visible) { // Manager mode, thus load available snippets try { var paths = UserSnippetPath.GetFilesInFolder("*.snippet"); LoadSnippets(paths); } catch (Exception ex) { Box.Error("Unable to obtain snippets from the user's snippet directory and, thus, will not run Snippeter.", "Exception: ", ex.Message); Close(); } lvSnippets.ItemsSource = _snippets.Values; } }
static StaticBoilerplateSettings() { SettingsManager settingsManager = new ShellSettingsManager(ServiceProvider.GlobalProvider); Store = settingsManager.GetWritableSettingsStore(SettingsScope.UserSettings); Store.CreateCollection(CollectionPath); // Setting upgrade if needed if (Store.PropertyExists(CollectionPath, VersionKey)) { int storedVersion = Store.GetInt32(CollectionPath, VersionKey); if (storedVersion < LatestVersion) { SetVersionToLatest(); } } else { if (Store.PropertyExists(CollectionPath, TestProjectsKey)) { // We are upgrading from an old version (v0), as we didn't have version tracked, but had a test projects dictionary var mockFrameworks = new List <string> { "Moq", "AutoMoq", "SimpleStubs", "NSubstitute" }; var templateTypes = new List <TemplateType> { TemplateType.File, TemplateType.MockFieldDeclaration, TemplateType.MockFieldInitialization, TemplateType.MockObjectReference }; foreach (string mockFrameworkName in mockFrameworks) { MockFramework mockFramework = MockFrameworks.Get(mockFrameworkName); foreach (TemplateType templateType in templateTypes) { string templateKey = $"Template_{mockFrameworkName}_{templateType}"; if (Store.PropertyExists(CollectionPath, templateKey)) { string oldTemplate = Store.GetString(CollectionPath, templateKey); CreateEntryForTestFramework(oldTemplate, templateType, TestFrameworks.Get("VisualStudio"), mockFramework); CreateEntryForTestFramework(oldTemplate, templateType, TestFrameworks.Get("NUnit"), mockFramework); Store.DeleteProperty(CollectionPath, templateKey); } } } } SetVersionToLatest(); } if (Store.PropertyExists(CollectionPath, TestProjectsKey)) { string dictionaryString = Store.GetString(CollectionPath, TestProjectsKey); if (string.IsNullOrEmpty(dictionaryString)) { TestProjectsDictionary = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase); } else { TestProjectsDictionary = new Dictionary <string, string>(JsonConvert.DeserializeObject <Dictionary <string, string> >(dictionaryString), StringComparer.OrdinalIgnoreCase); } } else { TestProjectsDictionary = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase); } }
/// <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; }
private void LoadSettings() { // Default values _FilenameSize = 60; _FoldersSize = _ProjectSize = 52; _FilenameColor = Color.FromArgb(234, 234, 234); _FoldersColor = _ProjectColor = Color.FromArgb(243, 243, 243); _Position = AdornmentPositions.TopRight; _Opacity = 1; try { // Retrieve the Id of the current theme used in VS from user's settings, this is changed a lot in VS2015 string visualStudioThemeId = VSRegistry.RegistryRoot(Microsoft.VisualStudio.Shell.Interop.__VsLocalRegistryType.RegType_UserSettings).OpenSubKey("ApplicationPrivateSettings").OpenSubKey("Microsoft").OpenSubKey("VisualStudio").GetValue("ColorTheme", "de3dbbcd-f642-433c-8353-8f1df4370aba", Microsoft.Win32.RegistryValueOptions.DoNotExpandEnvironmentNames).ToString(); string parsedThemeId = Guid.Parse(visualStudioThemeId.Split('*')[2]).ToString(); switch (parsedThemeId) { case "de3dbbcd-f642-433c-8353-8f1df4370aba": // Light case "a4d6a176-b948-4b29-8c66-53c97a1ed7d0": // Blue default: // Just use the defaults break; case "1ded0138-47ce-435e-84ef-9ec1f439b749": // Dark _FilenameColor = Color.FromArgb(48, 48, 48); _FoldersColor = _ProjectColor = Color.FromArgb(40, 40, 40); break; } // Tries to retrieve the configurations if previously saved if (writableSettingsStore.PropertyExists(CollectionPath, "FilenameColor")) { this.FilenameColor = Color.FromArgb(writableSettingsStore.GetInt32(CollectionPath, "FilenameColor", this.FilenameColor.ToArgb())); } if (writableSettingsStore.PropertyExists(CollectionPath, "FoldersColor")) { this.FoldersColor = Color.FromArgb(writableSettingsStore.GetInt32(CollectionPath, "FoldersColor", this.FoldersColor.ToArgb())); } if (writableSettingsStore.PropertyExists(CollectionPath, "ProjectColor")) { this.ProjectColor = Color.FromArgb(writableSettingsStore.GetInt32(CollectionPath, "ProjectColor", this.ProjectColor.ToArgb())); } if (writableSettingsStore.PropertyExists(CollectionPath, "ViewFilename")) { bool b = this.ViewFilename; if (Boolean.TryParse(writableSettingsStore.GetString(CollectionPath, "ViewFilename"), out b)) { this.ViewFilename = b; } } if (writableSettingsStore.PropertyExists(CollectionPath, "ViewFolders")) { bool b = this.ViewFolders; if (Boolean.TryParse(writableSettingsStore.GetString(CollectionPath, "ViewFolders"), out b)) { this.ViewFolders = b; } } if (writableSettingsStore.PropertyExists(CollectionPath, "ViewProject")) { bool b = this.ViewProject; if (Boolean.TryParse(writableSettingsStore.GetString(CollectionPath, "ViewProject"), out b)) { this.ViewProject = b; } } if (writableSettingsStore.PropertyExists(CollectionPath, "FilenameSize")) { double d = this.FilenameSize; if (Double.TryParse(writableSettingsStore.GetString(CollectionPath, "FilenameSize"), out d)) { this.FilenameSize = d; } } if (writableSettingsStore.PropertyExists(CollectionPath, "FoldersSize")) { double d = this.FoldersSize; if (Double.TryParse(writableSettingsStore.GetString(CollectionPath, "FoldersSize"), out d)) { this.FoldersSize = d; } } if (writableSettingsStore.PropertyExists(CollectionPath, "ProjectSize")) { double d = this.ProjectSize; if (Double.TryParse(writableSettingsStore.GetString(CollectionPath, "ProjectSize"), out d)) { this.ProjectSize = d; } } if (writableSettingsStore.PropertyExists(CollectionPath, "Position")) { AdornmentPositions p = this.Position; if (Enum.TryParse <AdornmentPositions>(writableSettingsStore.GetString(CollectionPath, "Position"), out p)) { this.Position = p; } } if (writableSettingsStore.PropertyExists(CollectionPath, "Opacity")) { double d = this.Opacity; if (Double.TryParse(writableSettingsStore.GetString(CollectionPath, "Opacity"), out d)) { this.Opacity = d; } } } catch (Exception ex) { Debug.Fail(ex.Message); } }
/// <summary> /// Called when the window has loaded /// </summary> private void OnLoad(object sender, RoutedEventArgs e) { // Window icon var icon = WindowExtensions.ImageSourceFromIcon(Properties.Resources.hug); if (icon != null) { Icon = icon; } // Hide/disable minimize button WindowExtensions.HideMinimizeAndMaximizeButtons(this, hideMaximize: false); // Load available tags HugTags.I.Load(); // Restore window size and position, if any try { var settingsManager = new ShellSettingsManager(Package); WritableSettingsStore = settingsManager.GetWritableSettingsStore(SettingsScope.UserSettings); if (WritableSettingsStore.CollectionExists(SS_Collection) == true && WritableSettingsStore.PropertyExists(SS_Collection, SS_WindowTop) == 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 chAutoSort.IsChecked = WritableSettingsStore.GetBoolean(SS_Collection, SS_AutoSort); } else { // Create collection now to be able to check for other settings the 1st time around WritableSettingsStore.CreateCollection(SS_Collection); // Default to sorted by count chAutoSort.IsChecked = true; } // Disable when automatic sorting by count is enabled btUp.IsEnabled = btDown.IsEnabled = (chAutoSort.IsChecked == false); } catch (Exception ex) { // Report and move on Box.Error("Unable to load settings.", "Exception:", ex.Message); } // Display tags HugTags.I.SortByCount(chAutoSort.IsChecked ?? false); lvTags.ItemsSource = HugTags.I.Items; }
public int GetInt32(string collectionPath, string propertyName, int defaultValue) { return(settingsStore.GetInt32(collectionPath, propertyName, defaultValue)); }