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
- JsonClassDataContract.cs
- InvalidEnumArgumentException.cs
- ApplicationActivator.cs
- printdlgexmarshaler.cs
- ClassDataContract.cs
- AnnotationStore.cs
- NotificationContext.cs
- SelectQueryOperator.cs
- PropertyCondition.cs
- SettingsAttributes.cs
- HttpHandler.cs
- WebSysDefaultValueAttribute.cs
- DebugView.cs
- OpenTypeLayoutCache.cs
- ScriptReference.cs
- StringArrayConverter.cs
- COMException.cs
- util.cs
- ResourceDescriptionAttribute.cs
- MILUtilities.cs
- ToolBarPanel.cs
- QilGenerator.cs
- SQLDouble.cs
- EdmItemCollection.cs
- MemberPathMap.cs
- MenuItemCollectionEditorDialog.cs
- XPathDocument.cs
- LicenseProviderAttribute.cs
- ReferenceConverter.cs
- DataException.cs
- DrawingGroup.cs
- ReferenceSchema.cs
- Configuration.cs
- HttpRequestBase.cs
- UnsafeNativeMethods.cs
- UnsafeNativeMethodsCLR.cs
- basenumberconverter.cs
- BitmapSource.cs
- OleDbCommand.cs
- DbProviderFactory.cs
- MostlySingletonList.cs
- HtmlFormWrapper.cs
- ProtocolViolationException.cs
- SharedDp.cs
- RenderDataDrawingContext.cs
- AffineTransform3D.cs
- ResourceDescriptionAttribute.cs
- SmtpMail.cs
- RSAProtectedConfigurationProvider.cs
- WebDescriptionAttribute.cs
- AndMessageFilterTable.cs
- MetadataArtifactLoaderFile.cs
- EditorBrowsableAttribute.cs
- CodeDomConfigurationHandler.cs
- XamlPoint3DCollectionSerializer.cs
- GridToolTip.cs
- DataBinding.cs
- JpegBitmapEncoder.cs
- FrameworkReadOnlyPropertyMetadata.cs
- DataContractSerializer.cs
- TextBoxRenderer.cs
- ContainerUIElement3D.cs
- SafeFileHandle.cs
- XPathSingletonIterator.cs
- UserControlAutomationPeer.cs
- SoapIgnoreAttribute.cs
- ToolStripKeyboardHandlingService.cs
- ProxyGenerator.cs
- InternalConfigSettingsFactory.cs
- SqlReferenceCollection.cs
- HostProtectionException.cs
- BinHexDecoder.cs
- KnownTypeAttribute.cs
- MdImport.cs
- Drawing.cs
- ToolStripPanel.cs
- NetMsmqBindingElement.cs
- StreamingContext.cs
- DocComment.cs
- CompareValidator.cs
- ZipIOCentralDirectoryDigitalSignature.cs
- DispatchWrapper.cs
- CaretElement.cs
- FileNotFoundException.cs
- GrammarBuilderWildcard.cs
- WriteStateInfoBase.cs
- BevelBitmapEffect.cs
- EntityViewContainer.cs
- HttpInputStream.cs
- TemplateControlParser.cs
- ChannelServices.cs
- ClientSettingsStore.cs
- DocumentScope.cs
- JsonXmlDataContract.cs
- EraserBehavior.cs
- XNodeValidator.cs
- SqlEnums.cs
- Scripts.cs
- DefaultShape.cs
- OdbcConnectionFactory.cs