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
- MutexSecurity.cs
- ActiveXHelper.cs
- CacheSection.cs
- TrustLevelCollection.cs
- PasswordBox.cs
- FrameworkElementFactoryMarkupObject.cs
- XmlSubtreeReader.cs
- ElementFactory.cs
- RectAnimation.cs
- Debugger.cs
- FormClosedEvent.cs
- TraceHandler.cs
- PublisherMembershipCondition.cs
- TransactionCache.cs
- ActivityDesignerResources.cs
- ManagementInstaller.cs
- DateTimeFormat.cs
- DelayedRegex.cs
- PublisherIdentityPermission.cs
- DecoderFallback.cs
- SymbolMethod.cs
- XamlParser.cs
- CapabilitiesAssignment.cs
- ButtonChrome.cs
- mactripleDES.cs
- CalendarDesigner.cs
- DesignerOptions.cs
- RegexTypeEditor.cs
- PerformanceCountersElement.cs
- SettingsPropertyWrongTypeException.cs
- KeyFrames.cs
- InvalidProgramException.cs
- XmlSchemaAttribute.cs
- StackSpiller.cs
- TextRange.cs
- XpsFixedPageReaderWriter.cs
- SizeLimitedCache.cs
- itemelement.cs
- MDIControlStrip.cs
- CustomAttributeFormatException.cs
- DataGridItemEventArgs.cs
- ObjectFactoryCodeDomTreeGenerator.cs
- PagerSettings.cs
- UIElementParaClient.cs
- EntityChangedParams.cs
- ArgumentNullException.cs
- XmlSchemaSimpleContentExtension.cs
- ScrollChrome.cs
- LifetimeManager.cs
- PostBackOptions.cs
- InvalidPropValue.cs
- ReaderWriterLockWrapper.cs
- GeneralTransformGroup.cs
- ReplacementText.cs
- TouchPoint.cs
- cookiecollection.cs
- XmlWellformedWriter.cs
- ColorDialog.cs
- _emptywebproxy.cs
- RegexStringValidator.cs
- MimeMultiPart.cs
- GenericTextProperties.cs
- shaperfactory.cs
- DoubleCollection.cs
- wmiprovider.cs
- ScrollEventArgs.cs
- TimeSpanValidatorAttribute.cs
- CacheMemory.cs
- NavigationPropertySingletonExpression.cs
- FixedTextView.cs
- WindowsAuthenticationModule.cs
- safesecurityhelperavalon.cs
- AspNetSynchronizationContext.cs
- ImageAutomationPeer.cs
- ByteConverter.cs
- DesignerVerb.cs
- XmlSerializationReader.cs
- DbConnectionFactory.cs
- FunctionImportMapping.ReturnTypeRenameMapping.cs
- SignHashRequest.cs
- SafeCoTaskMem.cs
- DataException.cs
- MultilineStringConverter.cs
- PriorityChain.cs
- ColumnReorderedEventArgs.cs
- ObjectDataSourceMethodEventArgs.cs
- SuppressIldasmAttribute.cs
- XPathDocumentIterator.cs
- GroupPartitionExpr.cs
- BindingEditor.xaml.cs
- PaperSize.cs
- CodeTypeReference.cs
- LogicalChannelCollection.cs
- FigureParaClient.cs
- DataObjectCopyingEventArgs.cs
- WebSysDisplayNameAttribute.cs
- TextViewSelectionProcessor.cs
- Bezier.cs
- MultiSelectRootGridEntry.cs
- Property.cs