Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / whidbey / NetFxQFE / ndp / fx / src / WinForms / Managed / System / WinForms / VisualStyles / VisualStyleInformation.cs / 1 / VisualStyleInformation.cs
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
/*
*/
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.MSInternal", "CA905:SystemAndMicrosoftNamespacesRequireApproval", Scope="namespace", Target="System.Windows.Forms.VisualStyles")]
namespace System.Windows.Forms.VisualStyles {
using System;
using System.Text;
using System.Drawing;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Diagnostics.CodeAnalysis;
///
///
///
/// Provides information about the current visual style.
/// NOTE:
/// 1) These properties (except SupportByOS, which is always meaningful) are meaningful only
/// if visual styles are supported and have currently been applied by the user.
/// 2) A subset of these use VisualStyleRenderer objects, so they are
/// not meaningful unless VisualStyleRenderer.IsSupported is true.
///
///
public static class VisualStyleInformation {
//Make this per-thread, so that different threads can safely use these methods.
[ThreadStatic]
private static VisualStyleRenderer visualStyleRenderer = null;
///
///
///
/// Used to find whether visual styles are supported by the current OS. Same as
/// using the OSFeature class to see if themes are supported.
///
///
public static bool IsSupportedByOS {
get {
return (OSFeature.Feature.IsPresent(OSFeature.Themes));
}
}
///
///
///
/// Returns true if a visual style has currently been applied by the user, else false.
///
///
public static bool IsEnabledByUser {
get {
if (!IsSupportedByOS) {
return false;
}
return (SafeNativeMethods.IsAppThemed());
}
}
internal static string ThemeFilename {
get {
if (IsEnabledByUser) {
StringBuilder filename = new StringBuilder(512);
SafeNativeMethods.GetCurrentThemeName(filename, filename.Capacity, null, 0, null, 0);
return (filename.ToString());
}
return String.Empty;
}
}
///
///
/// The current visual style's color scheme name.
///
public static string ColorScheme {
get {
if (IsEnabledByUser) {
StringBuilder colorScheme = new StringBuilder(512);
SafeNativeMethods.GetCurrentThemeName(null, 0, colorScheme, colorScheme.Capacity, null, 0);
return (colorScheme.ToString());
}
return String.Empty;
}
}
///
///
/// The current visual style's size name.
///
public static string Size {
get {
if (IsEnabledByUser) {
StringBuilder size = new StringBuilder(512);
SafeNativeMethods.GetCurrentThemeName(null, 0, null, 0, size, size.Capacity);
return (size.ToString());
}
return String.Empty;
}
}
///
///
/// The current visual style's display name.
///
public static string DisplayName {
get {
if (IsEnabledByUser) {
StringBuilder name = new StringBuilder(512);
SafeNativeMethods.GetThemeDocumentationProperty(ThemeFilename, VisualStyleDocProperty.DisplayName, name, name.Capacity);
return name.ToString();
}
return String.Empty;
}
}
///
///
/// The current visual style's company.
///
public static string Company {
get {
if (IsEnabledByUser) {
StringBuilder company = new StringBuilder(512);
SafeNativeMethods.GetThemeDocumentationProperty(ThemeFilename, VisualStyleDocProperty.Company, company, company.Capacity);
return company.ToString();
}
return String.Empty;
}
}
///
///
/// The name of the current visual style's author.
///
public static string Author {
get {
if (IsEnabledByUser) {
StringBuilder author = new StringBuilder(512);
SafeNativeMethods.GetThemeDocumentationProperty(ThemeFilename, VisualStyleDocProperty.Author, author, author.Capacity);
return author.ToString();
}
return String.Empty;
}
}
///
///
/// The current visual style's copyright information.
///
public static string Copyright {
get {
if (IsEnabledByUser) {
StringBuilder copyright = new StringBuilder(512);
SafeNativeMethods.GetThemeDocumentationProperty(ThemeFilename, VisualStyleDocProperty.Copyright, copyright, copyright.Capacity);
return copyright.ToString();
}
return String.Empty;
}
}
///
///
/// The current visual style's url.
///
[SuppressMessage("Microsoft.Design", "CA1056:UriPropertiesShouldNotBeStrings")]
public static string Url {
[SuppressMessage("Microsoft.Design", "CA1054:UriParametersShouldNotBeStrings")]
get {
if (IsEnabledByUser) {
StringBuilder url = new StringBuilder(512);
SafeNativeMethods.GetThemeDocumentationProperty(ThemeFilename, VisualStyleDocProperty.Url, url, url.Capacity);
return url.ToString();
}
return String.Empty;
}
}
///
///
/// The current visual style's version.
///
public static string Version {
get {
if (IsEnabledByUser) {
StringBuilder version = new StringBuilder(512);
SafeNativeMethods.GetThemeDocumentationProperty(ThemeFilename, VisualStyleDocProperty.Version, version, version.Capacity);
return version.ToString();
}
return String.Empty;
}
}
///
///
/// The current visual style's description.
///
public static string Description {
get {
if (IsEnabledByUser) {
StringBuilder description = new StringBuilder(512);
SafeNativeMethods.GetThemeDocumentationProperty(ThemeFilename, VisualStyleDocProperty.Description, description, description.Capacity);
return description.ToString();
}
return String.Empty;
}
}
///
///
/// Returns true if the current theme supports flat menus, else false.
///
public static bool SupportsFlatMenus {
get {
if (Application.RenderWithVisualStyles) {
if (visualStyleRenderer == null) {
visualStyleRenderer = new VisualStyleRenderer(VisualStyleElement.Window.Caption.Active);
}
else {
visualStyleRenderer.SetParameters(VisualStyleElement.Window.Caption.Active);
}
return (SafeNativeMethods.GetThemeSysBool(new HandleRef(null, visualStyleRenderer.Handle), VisualStyleSystemProperty.SupportsFlatMenus));
}
return false;
}
}
///
///
/// The minimum color depth supported by the current visual style.
///
public static int MinimumColorDepth {
get {
if (Application.RenderWithVisualStyles) {
if (visualStyleRenderer == null) {
visualStyleRenderer = new VisualStyleRenderer(VisualStyleElement.Window.Caption.Active);
}
else {
visualStyleRenderer.SetParameters(VisualStyleElement.Window.Caption.Active);
}
int mcDepth = 0;
SafeNativeMethods.GetThemeSysInt(new HandleRef(null, visualStyleRenderer.Handle), VisualStyleSystemProperty.MinimumColorDepth, ref mcDepth);
return mcDepth;
}
return 0;
}
}
///
///
/// Border Color that Windows XP renders for controls like TextBox and ComboBox.
///
public static Color TextControlBorder {
get {
if (Application.RenderWithVisualStyles) {
if (visualStyleRenderer == null) {
visualStyleRenderer = new VisualStyleRenderer(VisualStyleElement.TextBox.TextEdit.Normal);
}
else {
visualStyleRenderer.SetParameters(VisualStyleElement.TextBox.TextEdit.Normal);
}
Color borderColor = visualStyleRenderer.GetColor(ColorProperty.BorderColor);
return borderColor;
}
return SystemColors.WindowFrame;
}
}
///
///
/// This is the color buttons and tab pages are highlighted with when they are moused over on themed OS.
///
public static Color ControlHighlightHot {
get {
if (Application.RenderWithVisualStyles) {
if (visualStyleRenderer == null) {
visualStyleRenderer = new VisualStyleRenderer(VisualStyleElement.Button.PushButton.Normal);
}
else {
visualStyleRenderer.SetParameters(VisualStyleElement.Button.PushButton.Normal);
}
Color accentColor = visualStyleRenderer.GetColor(ColorProperty.AccentColorHint);
return accentColor;
}
return SystemColors.ButtonHighlight;
}
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
/*
*/
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.MSInternal", "CA905:SystemAndMicrosoftNamespacesRequireApproval", Scope="namespace", Target="System.Windows.Forms.VisualStyles")]
namespace System.Windows.Forms.VisualStyles {
using System;
using System.Text;
using System.Drawing;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Diagnostics.CodeAnalysis;
///
///
///
/// Provides information about the current visual style.
/// NOTE:
/// 1) These properties (except SupportByOS, which is always meaningful) are meaningful only
/// if visual styles are supported and have currently been applied by the user.
/// 2) A subset of these use VisualStyleRenderer objects, so they are
/// not meaningful unless VisualStyleRenderer.IsSupported is true.
///
///
public static class VisualStyleInformation {
//Make this per-thread, so that different threads can safely use these methods.
[ThreadStatic]
private static VisualStyleRenderer visualStyleRenderer = null;
///
///
///
/// Used to find whether visual styles are supported by the current OS. Same as
/// using the OSFeature class to see if themes are supported.
///
///
public static bool IsSupportedByOS {
get {
return (OSFeature.Feature.IsPresent(OSFeature.Themes));
}
}
///
///
///
/// Returns true if a visual style has currently been applied by the user, else false.
///
///
public static bool IsEnabledByUser {
get {
if (!IsSupportedByOS) {
return false;
}
return (SafeNativeMethods.IsAppThemed());
}
}
internal static string ThemeFilename {
get {
if (IsEnabledByUser) {
StringBuilder filename = new StringBuilder(512);
SafeNativeMethods.GetCurrentThemeName(filename, filename.Capacity, null, 0, null, 0);
return (filename.ToString());
}
return String.Empty;
}
}
///
///
/// The current visual style's color scheme name.
///
public static string ColorScheme {
get {
if (IsEnabledByUser) {
StringBuilder colorScheme = new StringBuilder(512);
SafeNativeMethods.GetCurrentThemeName(null, 0, colorScheme, colorScheme.Capacity, null, 0);
return (colorScheme.ToString());
}
return String.Empty;
}
}
///
///
/// The current visual style's size name.
///
public static string Size {
get {
if (IsEnabledByUser) {
StringBuilder size = new StringBuilder(512);
SafeNativeMethods.GetCurrentThemeName(null, 0, null, 0, size, size.Capacity);
return (size.ToString());
}
return String.Empty;
}
}
///
///
/// The current visual style's display name.
///
public static string DisplayName {
get {
if (IsEnabledByUser) {
StringBuilder name = new StringBuilder(512);
SafeNativeMethods.GetThemeDocumentationProperty(ThemeFilename, VisualStyleDocProperty.DisplayName, name, name.Capacity);
return name.ToString();
}
return String.Empty;
}
}
///
///
/// The current visual style's company.
///
public static string Company {
get {
if (IsEnabledByUser) {
StringBuilder company = new StringBuilder(512);
SafeNativeMethods.GetThemeDocumentationProperty(ThemeFilename, VisualStyleDocProperty.Company, company, company.Capacity);
return company.ToString();
}
return String.Empty;
}
}
///
///
/// The name of the current visual style's author.
///
public static string Author {
get {
if (IsEnabledByUser) {
StringBuilder author = new StringBuilder(512);
SafeNativeMethods.GetThemeDocumentationProperty(ThemeFilename, VisualStyleDocProperty.Author, author, author.Capacity);
return author.ToString();
}
return String.Empty;
}
}
///
///
/// The current visual style's copyright information.
///
public static string Copyright {
get {
if (IsEnabledByUser) {
StringBuilder copyright = new StringBuilder(512);
SafeNativeMethods.GetThemeDocumentationProperty(ThemeFilename, VisualStyleDocProperty.Copyright, copyright, copyright.Capacity);
return copyright.ToString();
}
return String.Empty;
}
}
///
///
/// The current visual style's url.
///
[SuppressMessage("Microsoft.Design", "CA1056:UriPropertiesShouldNotBeStrings")]
public static string Url {
[SuppressMessage("Microsoft.Design", "CA1054:UriParametersShouldNotBeStrings")]
get {
if (IsEnabledByUser) {
StringBuilder url = new StringBuilder(512);
SafeNativeMethods.GetThemeDocumentationProperty(ThemeFilename, VisualStyleDocProperty.Url, url, url.Capacity);
return url.ToString();
}
return String.Empty;
}
}
///
///
/// The current visual style's version.
///
public static string Version {
get {
if (IsEnabledByUser) {
StringBuilder version = new StringBuilder(512);
SafeNativeMethods.GetThemeDocumentationProperty(ThemeFilename, VisualStyleDocProperty.Version, version, version.Capacity);
return version.ToString();
}
return String.Empty;
}
}
///
///
/// The current visual style's description.
///
public static string Description {
get {
if (IsEnabledByUser) {
StringBuilder description = new StringBuilder(512);
SafeNativeMethods.GetThemeDocumentationProperty(ThemeFilename, VisualStyleDocProperty.Description, description, description.Capacity);
return description.ToString();
}
return String.Empty;
}
}
///
///
/// Returns true if the current theme supports flat menus, else false.
///
public static bool SupportsFlatMenus {
get {
if (Application.RenderWithVisualStyles) {
if (visualStyleRenderer == null) {
visualStyleRenderer = new VisualStyleRenderer(VisualStyleElement.Window.Caption.Active);
}
else {
visualStyleRenderer.SetParameters(VisualStyleElement.Window.Caption.Active);
}
return (SafeNativeMethods.GetThemeSysBool(new HandleRef(null, visualStyleRenderer.Handle), VisualStyleSystemProperty.SupportsFlatMenus));
}
return false;
}
}
///
///
/// The minimum color depth supported by the current visual style.
///
public static int MinimumColorDepth {
get {
if (Application.RenderWithVisualStyles) {
if (visualStyleRenderer == null) {
visualStyleRenderer = new VisualStyleRenderer(VisualStyleElement.Window.Caption.Active);
}
else {
visualStyleRenderer.SetParameters(VisualStyleElement.Window.Caption.Active);
}
int mcDepth = 0;
SafeNativeMethods.GetThemeSysInt(new HandleRef(null, visualStyleRenderer.Handle), VisualStyleSystemProperty.MinimumColorDepth, ref mcDepth);
return mcDepth;
}
return 0;
}
}
///
///
/// Border Color that Windows XP renders for controls like TextBox and ComboBox.
///
public static Color TextControlBorder {
get {
if (Application.RenderWithVisualStyles) {
if (visualStyleRenderer == null) {
visualStyleRenderer = new VisualStyleRenderer(VisualStyleElement.TextBox.TextEdit.Normal);
}
else {
visualStyleRenderer.SetParameters(VisualStyleElement.TextBox.TextEdit.Normal);
}
Color borderColor = visualStyleRenderer.GetColor(ColorProperty.BorderColor);
return borderColor;
}
return SystemColors.WindowFrame;
}
}
///
///
/// This is the color buttons and tab pages are highlighted with when they are moused over on themed OS.
///
public static Color ControlHighlightHot {
get {
if (Application.RenderWithVisualStyles) {
if (visualStyleRenderer == null) {
visualStyleRenderer = new VisualStyleRenderer(VisualStyleElement.Button.PushButton.Normal);
}
else {
visualStyleRenderer.SetParameters(VisualStyleElement.Button.PushButton.Normal);
}
Color accentColor = visualStyleRenderer.GetColor(ColorProperty.AccentColorHint);
return accentColor;
}
return SystemColors.ButtonHighlight;
}
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- XmlDictionaryReaderQuotas.cs
- ZoneLinkButton.cs
- SparseMemoryStream.cs
- ColumnBinding.cs
- XmlCharType.cs
- ReferenceSchema.cs
- DataGridViewCellStateChangedEventArgs.cs
- StrokeCollectionConverter.cs
- StringPropertyBuilder.cs
- WindowsPrincipal.cs
- ResetableIterator.cs
- PersistenceException.cs
- TableItemPattern.cs
- DataServiceClientException.cs
- OperandQuery.cs
- CodeSubDirectory.cs
- FixedSOMTableCell.cs
- WaitHandleCannotBeOpenedException.cs
- XmlSchemaDocumentation.cs
- ItemMap.cs
- EdmEntityTypeAttribute.cs
- BoolExpressionVisitors.cs
- DataSourceControlBuilder.cs
- MouseCaptureWithinProperty.cs
- CallId.cs
- ValidatorCompatibilityHelper.cs
- DbgUtil.cs
- PingReply.cs
- WrappedKeySecurityToken.cs
- GenericFlowSwitchHelper.cs
- OpCopier.cs
- streamingZipPartStream.cs
- DocumentPage.cs
- codemethodreferenceexpression.cs
- TabletDeviceInfo.cs
- DashStyle.cs
- TabControlDesigner.cs
- AttributeTableBuilder.cs
- DbConnectionOptions.cs
- StyleHelper.cs
- SslStreamSecurityUpgradeProvider.cs
- SQLBinaryStorage.cs
- AlphabeticalEnumConverter.cs
- BatchServiceHost.cs
- DisplayMemberTemplateSelector.cs
- HttpUnhandledOperationInvoker.cs
- OutputChannel.cs
- PathGeometry.cs
- TextBoxBaseDesigner.cs
- ChangeProcessor.cs
- TabItemWrapperAutomationPeer.cs
- MatrixCamera.cs
- FixedSOMElement.cs
- TcpProcessProtocolHandler.cs
- CompleteWizardStep.cs
- VisualTreeHelper.cs
- CallbackValidator.cs
- CanonicalFontFamilyReference.cs
- WebColorConverter.cs
- DataGridColumnHeaderAutomationPeer.cs
- SqlProcedureAttribute.cs
- TypeBuilder.cs
- EFDataModelProvider.cs
- ExpandableObjectConverter.cs
- ColumnMapCopier.cs
- ListViewItem.cs
- Keywords.cs
- DataGridViewRowHeaderCell.cs
- StringConcat.cs
- LinqDataSourceDeleteEventArgs.cs
- QuaternionValueSerializer.cs
- ReadContentAsBinaryHelper.cs
- MasterPageBuildProvider.cs
- ArcSegment.cs
- CustomCategoryAttribute.cs
- ClientTargetCollection.cs
- SqlErrorCollection.cs
- SqlComparer.cs
- RequestQueryParser.cs
- BamlTreeUpdater.cs
- Keywords.cs
- ArrayConverter.cs
- BamlResourceContent.cs
- WindowInteropHelper.cs
- SubpageParaClient.cs
- ZipFileInfo.cs
- FlowLayoutPanel.cs
- AuthenticationModuleElementCollection.cs
- RegexTypeEditor.cs
- FlowDocumentPaginator.cs
- LocatorPart.cs
- DataPagerCommandEventArgs.cs
- ExtensionSimplifierMarkupObject.cs
- CodeAttributeArgumentCollection.cs
- WebRequestModulesSection.cs
- SwitchLevelAttribute.cs
- ELinqQueryState.cs
- SuppressMergeCheckAttribute.cs
- ValidatingCollection.cs
- DefaultPerformanceCounters.cs