Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Framework / MS / Win32 / UxThemeWrapper.cs / 1305600 / UxThemeWrapper.cs
using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Runtime.InteropServices; using System.Security; using System.Windows; using System.Windows.Media; using System.Text; using MS.Win32; using MS.Internal; namespace MS.Win32 { ////// Wrapper class for loading UxTheme system theme data /// internal static class UxThemeWrapper { static UxThemeWrapper() { _isActive = SafeNativeMethods.IsUxThemeActive(); } internal static bool IsActive { get { return _isActive; } } internal static string ThemeName { get { if (IsActive) { if (_themeName == null) { EnsureThemeName(); } return _themeName; } else { return "classic"; } } } internal static string ThemeColor { get { Debug.Assert(IsActive, "Queried ThemeColor while UxTheme is not active."); if (_themeColor == null) { EnsureThemeName(); } return _themeColor; } } ////// Critical - as this code performs an elevation to get current theme name /// TreatAsSafe - the "critical data" is transformed into "safe data" /// all the info stored is the currrent theme name and current color - e.g. "Luna", "NormalColor" /// Does not contain a path - considered safe. /// [SecurityCritical, SecurityTreatAsSafe] private static void EnsureThemeName() { StringBuilder themeName = new StringBuilder(Win32.NativeMethods.MAX_PATH); StringBuilder themeColor = new StringBuilder(Win32.NativeMethods.MAX_PATH); if (UnsafeNativeMethods.GetCurrentThemeName(themeName, themeName.Capacity, themeColor, themeColor.Capacity, null, 0) == 0) { // Success _themeName = themeName.ToString(); _themeName = Path.GetFileNameWithoutExtension(_themeName); _themeColor = themeColor.ToString(); } else { // Failed to retrieve the name _themeName = _themeColor = String.Empty; } } internal static void OnThemeChanged() { _isActive = SafeNativeMethods.IsUxThemeActive(); _themeName = null; _themeColor = null; } private static bool _isActive; private static string _themeName; private static string _themeColor; } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu
![Network programming in C#, Network Programming in VB.NET, Network Programming in .NET](/images/book.jpg)
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- WebBrowserUriTypeConverter.cs
- ResourceManager.cs
- CopyEncoder.cs
- OutputCacheProfileCollection.cs
- ToolStripDropDownClosedEventArgs.cs
- AppLevelCompilationSectionCache.cs
- GZipUtils.cs
- LinqDataView.cs
- PopupRootAutomationPeer.cs
- ExpressionHelper.cs
- SiteOfOriginContainer.cs
- TextModifier.cs
- followingsibling.cs
- ThreadExceptionEvent.cs
- SelectionEditor.cs
- StreamWriter.cs
- LabelAutomationPeer.cs
- KeyEventArgs.cs
- LineInfo.cs
- DbConnectionStringBuilder.cs
- EncoderReplacementFallback.cs
- NativeMethods.cs
- SapiGrammar.cs
- ClientOptions.cs
- DecimalAnimation.cs
- CommandDevice.cs
- FamilyTypefaceCollection.cs
- LocatorBase.cs
- TextCompositionEventArgs.cs
- VariantWrapper.cs
- ProtocolsConfigurationHandler.cs
- QilGenerator.cs
- InstancePersistenceContext.cs
- SuppressIldasmAttribute.cs
- sitestring.cs
- MessageContractImporter.cs
- XmlTypeMapping.cs
- XPathBinder.cs
- PasswordBox.cs
- CallTemplateAction.cs
- AspNetHostingPermission.cs
- SimpleType.cs
- WindowsSpinner.cs
- MatrixTransform.cs
- ModelVisual3D.cs
- ComponentChangingEvent.cs
- ActivationServices.cs
- UnsafeNativeMethods.cs
- OletxResourceManager.cs
- Ref.cs
- ObfuscateAssemblyAttribute.cs
- VariableExpressionConverter.cs
- DBSqlParserTableCollection.cs
- OpCodes.cs
- CodeParameterDeclarationExpressionCollection.cs
- ListControl.cs
- WindowsEditBoxRange.cs
- XmlAnyAttributeAttribute.cs
- AsyncPostBackTrigger.cs
- StopRoutingHandler.cs
- AffineTransform3D.cs
- HtmlInputImage.cs
- FactoryGenerator.cs
- RegexRunner.cs
- DrawingContextWalker.cs
- HandlerFactoryCache.cs
- QilLoop.cs
- Panel.cs
- HybridObjectCache.cs
- PackageRelationshipCollection.cs
- CheckableControlBaseAdapter.cs
- MarkupCompilePass2.cs
- ToolStripDropDown.cs
- DesignerLoader.cs
- FieldAccessException.cs
- DataGridTextBox.cs
- Content.cs
- WebServiceMethodData.cs
- WebServiceEnumData.cs
- PropertyChange.cs
- XmlDocumentType.cs
- SwitchElementsCollection.cs
- ScrollBarAutomationPeer.cs
- DispatcherExceptionFilterEventArgs.cs
- ConnectionsZone.cs
- ControlUtil.cs
- XmlSerializationWriter.cs
- NumberFunctions.cs
- RenderOptions.cs
- DriveNotFoundException.cs
- FileFormatException.cs
- VirtualDirectoryMapping.cs
- SessionSwitchEventArgs.cs
- CompressedStack.cs
- ArglessEventHandlerProxy.cs
- Dynamic.cs
- StagingAreaInputItem.cs
- cookieexception.cs
- SamlAdvice.cs
- TransactionContext.cs