StringDictionary GetFileExtensionMappings() { IAnkhConfigurationService configService = site.GetService(typeof(IAnkhConfigurationService)) as IAnkhConfigurationService; StringDictionary map = new StringDictionary(); if (configService == null) { return(map); } using (RegistryKey key = configService.OpenVSInstanceKey("Default Editors")) { if (key != null) { foreach (string name in key.GetSubKeyNames()) { using (RegistryKey extkey = key.OpenSubKey(name, false)) { if (extkey != null) { object obj = extkey.GetValue("Custom"); if (obj is string) { string ext = "." + name; map[ext] = obj.ToString(); // extension -> editor. } } } } } } return(map); }
void LoadThemeData() { if (!VSVersion.VS2012OrLater) { _themed = false; return; } _themeLight = _themeDark = false; IAnkhConfigurationService config = GetService <IAnkhConfigurationService>(); IWinFormsThemingService wts = GetService <IWinFormsThemingService>(); Guid themeGuid; if (config == null || wts == null || !wts.GetCurrentTheme(out themeGuid)) { _themed = false; return; } if (themeGuid == Guid.Empty) { // Before the first theme switch no theme is set, but the light theme // is used anyway _themed = true; _themeLight = true; _themeDark = true; return; } using (RegistryKey rk = config.OpenVSInstanceKey("Extensions\\AnkhSVN\\Themes")) { object v; if (rk != null) { v = rk.GetValue(themeGuid.ToString("B")); } else { v = null; } if (v is int) { _themed = true; int vv = (int)v; _themeLight = (vv & 0x01) != 0; _themeDark = (vv & 0x02) != 0; } else { _themed = true; } } }
static Hashtable GetEditors(IServiceProvider site) { if (AnkhEditorFactory.editors != null) { return(AnkhEditorFactory.editors); } Hashtable editors = new Hashtable(); IAnkhConfigurationService configService = site.GetService(typeof(IAnkhConfigurationService)) as IAnkhConfigurationService; if (configService == null) { return(editors); } using (RegistryKey editorsKey = configService.OpenVSInstanceKey("Editors")) { if (editorsKey != null) { foreach (string editorGuid in editorsKey.GetSubKeyNames()) { Guid guid = GetGuid(editorGuid); using (RegistryKey editorKey = editorsKey.OpenSubKey(editorGuid, false)) { object value = editorKey.GetValue(null); string name = (value != null) ? value.ToString() : editorGuid.ToString(); RegistryKey extensions = editorKey.OpenSubKey("Extensions", false); if (extensions != null) { foreach (string s in extensions.GetValueNames()) { if (!string.IsNullOrEmpty(s)) { EditorInfo ei = new EditorInfo(); ei.Name = name; ei.Guid = guid; object obj = extensions.GetValue(s); if (obj is int) { ei.Priority = (int)obj; } string ext = (s == "*") ? s : "." + s; AddEditorInfo(editors, ext, ei); } } } } } } } return(AnkhEditorFactory.editors = editors); }
void LoadProjectFlagMap() { _projectFlagMapLoaded = true; IAnkhConfigurationService configService = GetService <IAnkhConfigurationService>(); if (configService == null) { return; } using (RegistryKey projectHandlingKey = configService.OpenVSInstanceKey("Extensions\\AnkhSVN\\ProjectHandling")) { if (projectHandlingKey == null) { return; } foreach (string typeValue in projectHandlingKey.GetSubKeyNames()) { if (typeValue.Length != 38) // No proper guid { continue; } try { using (RegistryKey projectTypeKey = projectHandlingKey.OpenSubKey(typeValue)) { object v = projectTypeKey.GetValue("flags"); if (!(v is int)) { continue; } Guid projectType = new Guid(typeValue); SccProjectFlags flags = (SccProjectFlags)(int)v; _projectFlagMap.Add(projectType, flags); } } catch { /* Parse Error */ } } } }
/// <summary> /// Gets the UI version (as might be remapped by the MSI) /// </summary> /// <returns></returns> private Version GetUIVersion() { // We can't use our services here to help us :( // This code might be used from devenv.exe /setup IAnkhConfigurationService configService = GetService <IAnkhConfigurationService>(); if (configService == null) { return(null); } using (RegistryKey rk = configService.OpenVSInstanceKey("Packages\\" + typeof(AnkhSvnPackage).GUID.ToString("b"))) { if (rk == null) { return(null); } string v = rk.GetValue(Ankh.VSPackage.Attributes.ProvideUIVersionAttribute.RemapName) as string; if (string.IsNullOrEmpty(v)) { return(null); } if (v.IndexOf('[') >= 0) { return(null); // When not using remapping we can expect "[ProductVersion]" as value } try { return(new Version(v)); } catch { return(null); } } }
/// <include file='doc\PropertySheet.uex' path='docs/doc[@for="LanguagePreferences.Init"]/*' /> public virtual void Init() { IAnkhConfigurationService configService = GetService <IAnkhConfigurationService>(); if (configService != null) { using (RegistryKey key = configService.OpenVSInstanceKey(null)) { if (key != null) { InitMachinePreferences(key, name); } } using (RegistryKey key = configService.OpenVSUserKey(null)) { if (key != null) { InitUserPreferences(key, name); } } } Connect(); }
static StringDictionary GetLanguageExtensions(IServiceProvider site) { if (AnkhEditorFactory.languageExtensions != null) { return(AnkhEditorFactory.languageExtensions); } IAnkhConfigurationService configService = site.GetService(typeof(IAnkhConfigurationService)) as IAnkhConfigurationService; StringDictionary extensions = new StringDictionary(); if (configService != null) { using (RegistryKey key = configService.OpenVSInstanceKey("Languages\\File Extensions")) { if (key != null) { foreach (string ext in key.GetSubKeyNames()) { using (RegistryKey extkey = key.OpenSubKey(ext, false)) { if (extkey != null) { string fe = ext; string guid = extkey.GetValue(null) as string; // get default value if (!extensions.ContainsKey(fe)) { extensions.Add(fe, guid); } } } } } } } return(AnkhEditorFactory.languageExtensions = extensions); }