/// <summary> /// Gets the System defined settings for the ExplorerBar according /// to the current System theme /// </summary> /// <param name="useClassicTheme">Specifies whether the current system theme /// should be ignored and return unthemed settings</param> /// <returns>An ExplorerBarInfo object that contains the System defined /// settings for the ExplorerBar according to the current System theme</returns> public static ExplorerBarInfo GetSystemExplorerBarSettings(bool useClassicTheme) { // check if we can return the cached theme // note: caching a classic theme seems to cause a few // problems i haven't been able to resolve, so // for the moment always return a new // ExplorerBarInfo if useClassicTheme is true if (currentShellStyle != null && !useClassicTheme) { if (currentShellStyle.ShellStylePath != null && currentShellStyle.ShellStylePath.Equals(GetShellStylePath())) { return currentShellStyle; } } ExplorerBarInfo systemTheme; // check if we are using themes. if so, load up the // appropriate shellstyle.dll if (!useClassicTheme && UxTheme.AppThemed && LoadShellStyleDll()) { try { // get the uifile contained in the shellstyle.dll // and get ready to parse it Parser parser = new Parser(GetResourceUIFile()); // let the parser do its stuff systemTheme = parser.Parse(); systemTheme.SetOfficialTheme(true); systemTheme.ShellStylePath = GetShellStylePath(); } catch { // something went wrong, so use default settings systemTheme = new ExplorerBarInfo(); systemTheme.UseClassicTheme(); systemTheme.SetOfficialTheme(true); // add non-themed arrows as the ExplorerBar will // look funny without them. systemTheme.SetUnthemedArrowImages(); } finally { // unload the shellstyle.dll FreeShellStyleDll(); } } else { // no themes available, so use default settings systemTheme = new ExplorerBarInfo(); systemTheme.UseClassicTheme(); systemTheme.SetOfficialTheme(true); // add non-themed arrows as the ExplorerBar will // look funny without them. systemTheme.SetUnthemedArrowImages(); } // cache the theme currentShellStyle = systemTheme; return systemTheme; }
/// <summary> /// Gets the System defined settings for the ExplorerBar specified /// by the shellstyle.dll at the specified path /// </summary> /// <param name="stylePath">The path to the shellstyle.dll</param> /// <returns>An ExplorerBarInfo object that contains the settings for /// the ExplorerBar specified by the shellstyle.dll at the specified path</returns> public static ExplorerBarInfo GetSystemExplorerBarSettings(string stylePath) { // check if we can return the cached theme if (currentShellStyle != null) { if (!currentShellStyle.ClassicTheme && currentShellStyle.ShellStylePath != null && currentShellStyle.ShellStylePath.Equals(stylePath)) { return currentShellStyle; } } ExplorerBarInfo systemTheme; // attampt to load the specified shellstyle.dll if (LoadShellStyleDll(stylePath)) { try { // get the uifile contained in the shellstyle.dll // and get ready to parse it Parser parser = new Parser(GetResourceUIFile()); // let the parser do its stuff systemTheme = parser.Parse(); systemTheme.SetOfficialTheme(false); systemTheme.ShellStylePath = stylePath; } catch { // something went wrong, so try to use current system theme systemTheme = GetSystemExplorerBarSettings(); } finally { // unload the shellstyle.dll FreeShellStyleDll(); } } else { // no themes available, so use default settings systemTheme = new ExplorerBarInfo(); systemTheme.UseClassicTheme(); systemTheme.SetOfficialTheme(true); // add non-themed arrows as the ExplorerBar will // look funny without them. systemTheme.SetUnthemedArrowImages(); } // cache the theme currentShellStyle = systemTheme; return systemTheme; }