Code:
/ DotNET / DotNET / 8.0 / untmp / WIN_WINDOWS / lh_tools_devdiv_wpf / Windows / wcp / Framework / MS / Win32 / UxThemeWrapper.cs / 1 / 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

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- File.cs
- ImageField.cs
- SqlTopReducer.cs
- EndpointPerformanceCounters.cs
- JoinGraph.cs
- SimpleFieldTemplateUserControl.cs
- BinaryParser.cs
- XamlStackWriter.cs
- DecimalKeyFrameCollection.cs
- XmlSchemaComplexContent.cs
- WebPartTransformerCollection.cs
- InputLangChangeEvent.cs
- DoubleAnimation.cs
- ComponentCache.cs
- StringValueSerializer.cs
- DataList.cs
- PropagatorResult.cs
- SqlUDTStorage.cs
- SctClaimSerializer.cs
- SecurityKeyIdentifier.cs
- Transform3D.cs
- HttpCookiesSection.cs
- XmlNamespaceMappingCollection.cs
- BackgroundFormatInfo.cs
- FixedPage.cs
- CommandConverter.cs
- KeyInterop.cs
- ImportCatalogPart.cs
- Property.cs
- HostProtectionPermission.cs
- SqlDataSourceFilteringEventArgs.cs
- _SslState.cs
- UserNameSecurityTokenAuthenticator.cs
- PrintPreviewDialog.cs
- CachedPathData.cs
- RuntimeArgumentHandle.cs
- WebConfigurationHostFileChange.cs
- DataServiceHostWrapper.cs
- Token.cs
- ErrorCodes.cs
- DynamicPropertyHolder.cs
- Renderer.cs
- AppDomainAttributes.cs
- dbenumerator.cs
- SqlUnionizer.cs
- CustomBindingElementCollection.cs
- EventLogLink.cs
- SimpleRecyclingCache.cs
- SelectionItemPattern.cs
- NavigationCommands.cs
- ScriptHandlerFactory.cs
- SpecialFolderEnumConverter.cs
- StatusBarAutomationPeer.cs
- HttpBindingExtension.cs
- DataObject.cs
- DoubleConverter.cs
- CssClassPropertyAttribute.cs
- ControlBuilderAttribute.cs
- DateTimeConverter2.cs
- ComMethodElement.cs
- XmlException.cs
- TypeValidationEventArgs.cs
- ErrorCodes.cs
- FontEditor.cs
- DataRelationPropertyDescriptor.cs
- CodeNamespaceCollection.cs
- COM2PictureConverter.cs
- WindowsListViewGroup.cs
- StreamInfo.cs
- SaveFileDialog.cs
- ToolStrip.cs
- AppSettingsReader.cs
- MetadataSection.cs
- ObjectTag.cs
- Animatable.cs
- DataBoundControl.cs
- LinearKeyFrames.cs
- StyleConverter.cs
- DynamicRenderer.cs
- embossbitmapeffect.cs
- TypedTableGenerator.cs
- InfocardClientCredentials.cs
- BypassElement.cs
- TransformCryptoHandle.cs
- InstanceData.cs
- MatrixAnimationUsingKeyFrames.cs
- Validator.cs
- AssemblyResourceLoader.cs
- EllipseGeometry.cs
- BooleanFacetDescriptionElement.cs
- GPRECTF.cs
- xml.cs
- GridViewSelectEventArgs.cs
- PtsCache.cs
- COM2DataTypeToManagedDataTypeConverter.cs
- SafeNativeMethodsCLR.cs
- PersonalizationProviderCollection.cs
- TableHeaderCell.cs
- WebPartUtil.cs
- XmlSchemaChoice.cs