Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / NetFx40 / Tools / System.Activities.Presentation / System / Activities / Presentation / WorkflowDesignerColors.cs / 1305376 / WorkflowDesignerColors.cs
//------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- namespace System.Activities.Presentation { using System; using System.Collections.Generic; using System.Text; using System.Windows.Media; using System.Windows; using System.Runtime; using System.Activities.Presentation.Internal.PropertyEditing; public static class WorkflowDesignerColors { static ResourceDictionary defaultColors; static ResourceDictionary highContrastColors; static ResourceDictionary colorServiceColors; static ResourceDictionary fontResources; public const string WorkflowViewElementBorderColorKey = "WorkflowViewElementBorderColorKey"; public const string WorkflowViewElementBackgroundColorKey = "WorkflowViewElementBackgroundColorKey"; public const string WorkflowViewElementSelectedBackgroundColorKey = "WorkflowViewElementSelectedBackgroundColorKey"; public const string WorkflowViewElementSelectedBorderColorKey = "WorkflowViewElementSelectedBorderColorKey"; public const string DesignerViewStatusBarBackgroundColorKey = "DesignerViewStatusBarBackgroundColorKey"; public const string WorkflowViewElementCaptionColorKey = "WorkflowViewElementCaptionBrushColorKey"; public const string DesignerViewBackgroundColorKey = "DesignerViewBackgroundColorKey"; public const string DesignerViewShellBarColorGradientBeginKey = "DesignerViewShellBarColorGradientBeginKey"; public const string DesignerViewShellBarColorGradientEndKey = "DesignerViewShellBarColorGradientEndKey"; public const string DesignerViewShellBarSelectedColorGradientBeginKey = "DesignerViewShellBarSelectedColorGradientBeginKey"; public const string DesignerViewShellBarSelectedColorGradientEndKey = "DesignerViewShellBarSelectedColorGradientEndKey"; public const string DesignerViewShellBarHoverColorGradientBeginKey = "DesignerViewShellBarSelectedHoverGradientBeginKey"; public const string DesignerViewShellBarHoverColorGradientEndKey = "DesignerViewShellBarSelectedHoverGradientEndKey"; public const string DesignerViewShellBarControlBackgroundColorKey = "DesignerViewShellBarControlBackgroundColorKey"; public const string DesignerViewShellBarCaptionActiveColorKey = "DesignerViewShellBarCaptionActiveColorKey"; public const string DesignerViewShellBarCaptionColorKey = "DesignerViewShellBarCaptionColorKey"; public const string DesignerViewExpandAllCollapseAllButtonColorKey = "DesignerViewExpandAllCollapseAllButtonColorKey"; public const string DesignerViewExpandAllCollapseAllButtonMouseOverColorKey = "DesignerViewExpandAllCollapseAllButtonMouseOverColorKey"; public const string DesignerViewExpandAllCollapseAllPressedColorKey = "DesignerViewExpandAllCollapseAllPressedColorKey"; public const string ContextMenuBackgroundGradientBeginColorKey = "ContextMenuColorGradientBeginColorKey"; public const string ContextMenuBackgroundGradientEndColorKey = "ContextMenuColorGradientEndColorKey"; public const string ContextMenuBorderColorKey = "ContextMenuBorderColorKey"; public const string ContextMenuIconAreaColorKey = "ContextMenuIconAreaColorKey"; public const string ContextMenuMouseOverBeginColorKey = "ContextMenuMouseOverBeginColorKey"; public const string ContextMenuMouseOverMiddle1ColorKey = "ContextMenuMouseOverMiddle1ColorKey"; public const string ContextMenuMouseOverMiddle2ColorKey = "ContextMenuMouseOverMiddle2ColorKey"; public const string ContextMenuMouseOverEndColorKey = "ContextMenuMouseOverEndColorKey"; public const string ContextMenuMouseOverBorderColorKey = "ContextMenuMouseOverBorderColorKey"; public const string ContextMenuItemTextColorKey = "ContextMenuItemTextColorKey"; public const string ContextMenuItemTextHoverColorKey = "ContextMenuItemTextHoverColorKey"; public const string ContextMenuItemTextSelectedColorKey = "ContextMenuItemTextSelectedColorKey"; public const string ContextMenuItemTextDisabledColorKey = "ContextMenuItemTextDisabledColorKey"; public const string ContextMenuSeparatorColorKey = "ContextMenuSeparatorColorKey"; public static string PropertyInspectorTextBrushKey { get { return PropertyInspectorMergedResources.TextBrushKey; } } public static string PropertyInspectorSelectedForegroundBrushKey { get { return PropertyInspectorMergedResources.SelectedForegroundBrushKey; } } public static string PropertyInspectorSelectedBackgroundBrushKey { get { return PropertyInspectorMergedResources.SelectedBackgroundBrushKey; } } public static string PropertyInspectorBackgroundBrushKey { get { return PropertyInspectorMergedResources.BackgroundBrushKey; } } public static string PropertyInspectorBorderBrushKey { get { return PropertyInspectorMergedResources.BorderBrushKey; } } public static string PropertyInspectorCategoryCaptionTextBrushKey { get { return PropertyInspectorMergedResources.CategoryCaptionTextBrushKey; } } public static string PropertyInspectorPaneBrushKey { get { return PropertyInspectorMergedResources.PaneBrushKey; } } public static string PropertyInspectorPopupBrushKey { get { return PropertyInspectorMergedResources.PopupBrushKey; } } public static string PropertyInspectorToolBarItemHoverBackgroundBrushKey { get { return PropertyInspectorMergedResources.ToolBarItemHoverBackgroundBrushKey; } } public static string PropertyInspectorToolBarItemHoverBorderBrushKey { get { return PropertyInspectorMergedResources.ToolBarItemHoverBorderBrushKey; } } public static string PropertyInspectorToolBarItemSelectedBackgroundBrushKey { get { return PropertyInspectorMergedResources.ToolBarItemSelectedBackgroundBrushKey; } } public static string PropertyInspectorToolBarItemSelectedBorderBrushKey { get { return PropertyInspectorMergedResources.ToolBarItemSelectedBorderBrushKey; } } public static string PropertyInspectorToolBarBackgroundBrushKey { get { return PropertyInspectorMergedResources.ToolBarBackgroundBrushKey; } } public static string PropertyInspectorToolBarSeparatorBrushKey { get { return PropertyInspectorMergedResources.ToolBarSeparatorBrushKey; } } public static string PropertyInspectorToolBarTextBoxBorderBrushKey { get { return PropertyInspectorMergedResources.ToolBarTextBoxBorderBrushKey; } } public const string FlowchartExpressionButtonColorKey = "FlowchartExpressionButtonColorKey"; public const string FlowchartExpressionButtonMouseOverColorKey = "FlowchartExpressionButtonMouseOverColorKey"; public const string FlowchartExpressionButtonPressedColorKey = "FlowchartExpressionButtonPressedColorKey"; public static readonly string FontSizeKey = CreateKey("FontSizeKey"); public static readonly string FontFamilyKey = CreateKey("FontFamilyKey"); public static readonly string FontWeightKey = CreateKey("FontWeightKey"); static ResourceDictionary DefaultColors { get { if (defaultColors == null) { Uri resourceLocator = new Uri( string.Concat( typeof(WorkflowDesignerColors).Assembly.GetName().Name, @";component/System/Activities/Presentation/DefaultColorResources.xaml"), UriKind.RelativeOrAbsolute); defaultColors = (ResourceDictionary)Application.LoadComponent(resourceLocator); } Fx.Assert(defaultColors != null, "Could not load default color resources."); return defaultColors; } } static ResourceDictionary HighContrastColors { get { if (highContrastColors == null) { Uri resourceLocator = new Uri( string.Concat( typeof(WorkflowDesignerColors).Assembly.GetName().Name, @";component/System/Activities/Presentation/HighContrastColorResources.xaml"), UriKind.RelativeOrAbsolute); highContrastColors = (ResourceDictionary)Application.LoadComponent(resourceLocator); } Fx.Assert(highContrastColors != null, "Could not load high contrast color resources."); return highContrastColors; } } internal static ResourceDictionary ColorServiceColors { get { if (colorServiceColors == null) { colorServiceColors = new ResourceDictionary(); } return colorServiceColors; } } internal static ResourceDictionary FontResources { get { return WorkflowDesignerColors.fontResources; } set { WorkflowDesignerColors.fontResources = value; } } // Trying to figure out whether or not we are in highcontrast mode is a little tricky. // There are two things highcontrast mode and highcontrast color scheme. unfortunately in some platforms ( w2k3) these are not both updated from OS UX // here is a good article on this http://blogs.msdn.com/oldnewthing/archive/2008/12/03/9167477.aspx // highcontrast mode can be detected easily by using // applications in generatel ( e.g. VS) unfortunately handle high contrast color scheme as well, so we are forced to do it // This is code is dervied from the way VS does this. static bool IsHighContrastEnabled { get { if (SystemParameters.HighContrast) { return true; } if (SystemColors.ControlColor == Colors.Black && SystemColors.ControlTextColor == Colors.White) { return true; } if (SystemColors.ControlColor == Colors.White && SystemColors.ControlTextColor == Colors.Black) { return true; } if (SystemColors.ControlColor == Colors.Black && SystemColors.ControlTextColor == Color.FromArgb(0xff, 0x00, 0xff, 0x00)) { return true; } return false; } } public static Color WorkflowViewElementBorderColor { get { return GetColor(WorkflowDesignerColors.WorkflowViewElementBorderColorKey); } } public static Color WorkflowViewElementBackgroundColor { get { return GetColor(WorkflowDesignerColors.WorkflowViewElementBackgroundColorKey); } } public static Color WorkflowViewElementSelectedBackgroundColor { get { return GetColor(WorkflowDesignerColors.WorkflowViewElementSelectedBackgroundColorKey); } } public static Color GridViewRowHoverColor { get { return GetColor(WorkflowDesignerColors.WorkflowViewElementSelectedBackgroundColorKey, 0xA0); } } public static Color WorkflowViewElementSelectedBorderColor { get { return GetColor(WorkflowDesignerColors.WorkflowViewElementSelectedBorderColorKey); } } public static Color DesignerViewStatusBarBackgroundColor { get { return GetColor(WorkflowDesignerColors.DesignerViewStatusBarBackgroundColorKey); } } public static Color WorkflowViewElementCaptionColor { get { return GetColor(WorkflowDesignerColors.WorkflowViewElementCaptionColorKey); } } public static Color DesignerViewBackgroundColor { get { return GetColor(WorkflowDesignerColors.DesignerViewBackgroundColorKey); } } public static Color DesignerViewShellBarColorGradientBeginColor { get { return GetColor(WorkflowDesignerColors.DesignerViewShellBarColorGradientBeginKey); } } public static Color DesignerViewShellBarColorGradientEndColor { get { return GetColor(WorkflowDesignerColors.DesignerViewShellBarColorGradientEndKey); } } public static Color DesignerViewShellBarSelectedColorGradientBeginColor { get { return GetColor(WorkflowDesignerColors.DesignerViewShellBarSelectedColorGradientBeginKey); } } public static Color DesignerViewShellBarSelectedColorGradientEndColor { get { return GetColor(WorkflowDesignerColors.DesignerViewShellBarSelectedColorGradientEndKey); } } public static Color DesignerViewShellBarHoverColorGradientBeginColor { get { return GetColor(WorkflowDesignerColors.DesignerViewShellBarHoverColorGradientBeginKey); } } public static Color DesignerViewShellBarHoverColorGradientEndColor { get { return GetColor(WorkflowDesignerColors.DesignerViewShellBarHoverColorGradientEndKey); } } public static Color DesignerViewShellBarControlBackgroundColor { get { return GetColor(WorkflowDesignerColors.DesignerViewShellBarControlBackgroundColorKey); } } public static Color DesignerViewShellBarCaptionActiveColor { get { return GetColor(WorkflowDesignerColors.DesignerViewShellBarCaptionActiveColorKey); } } public static Color DesignerViewShellBarCaptionColor { get { return GetColor(WorkflowDesignerColors.DesignerViewShellBarCaptionColorKey); } } public static Brush DesignerViewExpandAllCollapseAllButtonBrush { get { return GetBrush(WorkflowDesignerColors.DesignerViewExpandAllCollapseAllButtonColorKey); } } public static Brush DesignerViewExpandAllCollapseAllButtonMouseOverBrush { get { return GetBrush(WorkflowDesignerColors.DesignerViewExpandAllCollapseAllButtonMouseOverColorKey); } } public static Brush DesignerViewExpandAllCollapseAllPressedBrush { get { return GetBrush(WorkflowDesignerColors.DesignerViewExpandAllCollapseAllPressedColorKey); } } public static Color ContextMenuBackgroundGradientBeginColor { get { return GetColor(WorkflowDesignerColors.ContextMenuBackgroundGradientBeginColorKey); } } public static Color ContextMenuBackgroundGradientEndColor { get { return GetColor(WorkflowDesignerColors.ContextMenuBackgroundGradientEndColorKey); } } public static Color ContextMenuBorderColor { get { return GetColor(WorkflowDesignerColors.ContextMenuBorderColorKey); } } public static Color ContextMenuIconAreaColor { get { return GetColor(WorkflowDesignerColors.ContextMenuIconAreaColorKey); } } public static Color ContextMenuMouseOverBeginColor { get { return GetColor(WorkflowDesignerColors.ContextMenuMouseOverBeginColorKey); } } public static Color ContextMenuMouseOverMiddle1Color { get { return GetColor(WorkflowDesignerColors.ContextMenuMouseOverMiddle1ColorKey); } } public static Color ContextMenuMouseOverMiddle2Color { get { return GetColor(WorkflowDesignerColors.ContextMenuMouseOverMiddle2ColorKey); } } public static Color ContextMenuMouseOverEndColor { get { return GetColor(WorkflowDesignerColors.ContextMenuMouseOverEndColorKey); } } public static Color ContextMenuMouseOverBorderColor { get { return GetColor(WorkflowDesignerColors.ContextMenuMouseOverBorderColorKey); } } public static Color ContextMenuItemTextColor { get { return GetColor(WorkflowDesignerColors.ContextMenuItemTextColorKey); } } public static Color ContextMenuItemTextHoverColor { get { return GetColor(WorkflowDesignerColors.ContextMenuItemTextHoverColorKey); } } public static Color ContextMenuItemTextSelectedColor { get { return GetColor(WorkflowDesignerColors.ContextMenuItemTextSelectedColorKey); } } public static Color ContextMenuItemTextDisabledColor { get { return GetColor(WorkflowDesignerColors.ContextMenuItemTextDisabledColorKey); } } public static Color ContextMenuSeparatorColor { get { return GetColor(WorkflowDesignerColors.ContextMenuSeparatorColorKey); } } public static Brush FlowchartExpressionButtonBrush { get { return GetBrush(WorkflowDesignerColors.FlowchartExpressionButtonColorKey); } } public static Brush FlowchartExpressionButtonMouseOverBrush { get { return GetBrush(WorkflowDesignerColors.FlowchartExpressionButtonMouseOverColorKey); } } public static Brush FlowchartExpressionButtonPressedBrush { get { return GetBrush(WorkflowDesignerColors.FlowchartExpressionButtonPressedColorKey); } } public static FontFamily FontFamily { get { return GetFontFamily(FontFamilyKey); } } public static double FontSize { get { return GetFontSize(FontSizeKey); } } public static FontWeight FontWeight { get { return GetFontWeight(FontWeightKey); } } static Brush GetBrush(string colorKey) { SolidColorBrush brush = null; if (IsHighContrastEnabled) { brush = (SolidColorBrush)WorkflowDesignerColors.HighContrastColors[colorKey]; } else if (WorkflowDesignerColors.ColorServiceColors.Contains(colorKey)) { brush = (SolidColorBrush)WorkflowDesignerColors.ColorServiceColors[colorKey]; } else { brush = (SolidColorBrush)WorkflowDesignerColors.DefaultColors[colorKey]; } if (brush.CanFreeze) { brush.Freeze(); } return brush; } static Color GetColor(string colorKey) { SolidColorBrush brush = (SolidColorBrush)GetBrush(colorKey); return brush.Color; } static Color GetColor(string colorKey, byte alpha) { Color color = GetColor(colorKey); color.A = alpha; return color; } static FontFamily GetFontFamily(string key) { if (IsHighContrastEnabled) { return SystemFonts.MessageFontFamily; } return WorkflowDesignerColors.FontResources.Contains(key) ? (FontFamily)WorkflowDesignerColors.FontResources[key] : SystemFonts.MessageFontFamily; } static double GetFontSize(string key) { if (IsHighContrastEnabled) { return SystemFonts.MessageFontSize; } return WorkflowDesignerColors.FontResources.Contains(key) ? (double)WorkflowDesignerColors.FontResources[key] : SystemFonts.MessageFontSize; } static FontWeight GetFontWeight(string key) { if (IsHighContrastEnabled) { return SystemFonts.MessageFontWeight; } return WorkflowDesignerColors.FontResources.Contains(key) ? (FontWeight)WorkflowDesignerColors.FontResources[key] : SystemFonts.MessageFontWeight; } static string CreateKey(string name) { //return AdornerResources.CreateResourceKey(typeof(PropertyInspectorMergedResources), name); return name; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- namespace System.Activities.Presentation { using System; using System.Collections.Generic; using System.Text; using System.Windows.Media; using System.Windows; using System.Runtime; using System.Activities.Presentation.Internal.PropertyEditing; public static class WorkflowDesignerColors { static ResourceDictionary defaultColors; static ResourceDictionary highContrastColors; static ResourceDictionary colorServiceColors; static ResourceDictionary fontResources; public const string WorkflowViewElementBorderColorKey = "WorkflowViewElementBorderColorKey"; public const string WorkflowViewElementBackgroundColorKey = "WorkflowViewElementBackgroundColorKey"; public const string WorkflowViewElementSelectedBackgroundColorKey = "WorkflowViewElementSelectedBackgroundColorKey"; public const string WorkflowViewElementSelectedBorderColorKey = "WorkflowViewElementSelectedBorderColorKey"; public const string DesignerViewStatusBarBackgroundColorKey = "DesignerViewStatusBarBackgroundColorKey"; public const string WorkflowViewElementCaptionColorKey = "WorkflowViewElementCaptionBrushColorKey"; public const string DesignerViewBackgroundColorKey = "DesignerViewBackgroundColorKey"; public const string DesignerViewShellBarColorGradientBeginKey = "DesignerViewShellBarColorGradientBeginKey"; public const string DesignerViewShellBarColorGradientEndKey = "DesignerViewShellBarColorGradientEndKey"; public const string DesignerViewShellBarSelectedColorGradientBeginKey = "DesignerViewShellBarSelectedColorGradientBeginKey"; public const string DesignerViewShellBarSelectedColorGradientEndKey = "DesignerViewShellBarSelectedColorGradientEndKey"; public const string DesignerViewShellBarHoverColorGradientBeginKey = "DesignerViewShellBarSelectedHoverGradientBeginKey"; public const string DesignerViewShellBarHoverColorGradientEndKey = "DesignerViewShellBarSelectedHoverGradientEndKey"; public const string DesignerViewShellBarControlBackgroundColorKey = "DesignerViewShellBarControlBackgroundColorKey"; public const string DesignerViewShellBarCaptionActiveColorKey = "DesignerViewShellBarCaptionActiveColorKey"; public const string DesignerViewShellBarCaptionColorKey = "DesignerViewShellBarCaptionColorKey"; public const string DesignerViewExpandAllCollapseAllButtonColorKey = "DesignerViewExpandAllCollapseAllButtonColorKey"; public const string DesignerViewExpandAllCollapseAllButtonMouseOverColorKey = "DesignerViewExpandAllCollapseAllButtonMouseOverColorKey"; public const string DesignerViewExpandAllCollapseAllPressedColorKey = "DesignerViewExpandAllCollapseAllPressedColorKey"; public const string ContextMenuBackgroundGradientBeginColorKey = "ContextMenuColorGradientBeginColorKey"; public const string ContextMenuBackgroundGradientEndColorKey = "ContextMenuColorGradientEndColorKey"; public const string ContextMenuBorderColorKey = "ContextMenuBorderColorKey"; public const string ContextMenuIconAreaColorKey = "ContextMenuIconAreaColorKey"; public const string ContextMenuMouseOverBeginColorKey = "ContextMenuMouseOverBeginColorKey"; public const string ContextMenuMouseOverMiddle1ColorKey = "ContextMenuMouseOverMiddle1ColorKey"; public const string ContextMenuMouseOverMiddle2ColorKey = "ContextMenuMouseOverMiddle2ColorKey"; public const string ContextMenuMouseOverEndColorKey = "ContextMenuMouseOverEndColorKey"; public const string ContextMenuMouseOverBorderColorKey = "ContextMenuMouseOverBorderColorKey"; public const string ContextMenuItemTextColorKey = "ContextMenuItemTextColorKey"; public const string ContextMenuItemTextHoverColorKey = "ContextMenuItemTextHoverColorKey"; public const string ContextMenuItemTextSelectedColorKey = "ContextMenuItemTextSelectedColorKey"; public const string ContextMenuItemTextDisabledColorKey = "ContextMenuItemTextDisabledColorKey"; public const string ContextMenuSeparatorColorKey = "ContextMenuSeparatorColorKey"; public static string PropertyInspectorTextBrushKey { get { return PropertyInspectorMergedResources.TextBrushKey; } } public static string PropertyInspectorSelectedForegroundBrushKey { get { return PropertyInspectorMergedResources.SelectedForegroundBrushKey; } } public static string PropertyInspectorSelectedBackgroundBrushKey { get { return PropertyInspectorMergedResources.SelectedBackgroundBrushKey; } } public static string PropertyInspectorBackgroundBrushKey { get { return PropertyInspectorMergedResources.BackgroundBrushKey; } } public static string PropertyInspectorBorderBrushKey { get { return PropertyInspectorMergedResources.BorderBrushKey; } } public static string PropertyInspectorCategoryCaptionTextBrushKey { get { return PropertyInspectorMergedResources.CategoryCaptionTextBrushKey; } } public static string PropertyInspectorPaneBrushKey { get { return PropertyInspectorMergedResources.PaneBrushKey; } } public static string PropertyInspectorPopupBrushKey { get { return PropertyInspectorMergedResources.PopupBrushKey; } } public static string PropertyInspectorToolBarItemHoverBackgroundBrushKey { get { return PropertyInspectorMergedResources.ToolBarItemHoverBackgroundBrushKey; } } public static string PropertyInspectorToolBarItemHoverBorderBrushKey { get { return PropertyInspectorMergedResources.ToolBarItemHoverBorderBrushKey; } } public static string PropertyInspectorToolBarItemSelectedBackgroundBrushKey { get { return PropertyInspectorMergedResources.ToolBarItemSelectedBackgroundBrushKey; } } public static string PropertyInspectorToolBarItemSelectedBorderBrushKey { get { return PropertyInspectorMergedResources.ToolBarItemSelectedBorderBrushKey; } } public static string PropertyInspectorToolBarBackgroundBrushKey { get { return PropertyInspectorMergedResources.ToolBarBackgroundBrushKey; } } public static string PropertyInspectorToolBarSeparatorBrushKey { get { return PropertyInspectorMergedResources.ToolBarSeparatorBrushKey; } } public static string PropertyInspectorToolBarTextBoxBorderBrushKey { get { return PropertyInspectorMergedResources.ToolBarTextBoxBorderBrushKey; } } public const string FlowchartExpressionButtonColorKey = "FlowchartExpressionButtonColorKey"; public const string FlowchartExpressionButtonMouseOverColorKey = "FlowchartExpressionButtonMouseOverColorKey"; public const string FlowchartExpressionButtonPressedColorKey = "FlowchartExpressionButtonPressedColorKey"; public static readonly string FontSizeKey = CreateKey("FontSizeKey"); public static readonly string FontFamilyKey = CreateKey("FontFamilyKey"); public static readonly string FontWeightKey = CreateKey("FontWeightKey"); static ResourceDictionary DefaultColors { get { if (defaultColors == null) { Uri resourceLocator = new Uri( string.Concat( typeof(WorkflowDesignerColors).Assembly.GetName().Name, @";component/System/Activities/Presentation/DefaultColorResources.xaml"), UriKind.RelativeOrAbsolute); defaultColors = (ResourceDictionary)Application.LoadComponent(resourceLocator); } Fx.Assert(defaultColors != null, "Could not load default color resources."); return defaultColors; } } static ResourceDictionary HighContrastColors { get { if (highContrastColors == null) { Uri resourceLocator = new Uri( string.Concat( typeof(WorkflowDesignerColors).Assembly.GetName().Name, @";component/System/Activities/Presentation/HighContrastColorResources.xaml"), UriKind.RelativeOrAbsolute); highContrastColors = (ResourceDictionary)Application.LoadComponent(resourceLocator); } Fx.Assert(highContrastColors != null, "Could not load high contrast color resources."); return highContrastColors; } } internal static ResourceDictionary ColorServiceColors { get { if (colorServiceColors == null) { colorServiceColors = new ResourceDictionary(); } return colorServiceColors; } } internal static ResourceDictionary FontResources { get { return WorkflowDesignerColors.fontResources; } set { WorkflowDesignerColors.fontResources = value; } } // Trying to figure out whether or not we are in highcontrast mode is a little tricky. // There are two things highcontrast mode and highcontrast color scheme. unfortunately in some platforms ( w2k3) these are not both updated from OS UX // here is a good article on this http://blogs.msdn.com/oldnewthing/archive/2008/12/03/9167477.aspx // highcontrast mode can be detected easily by using // applications in generatel ( e.g. VS) unfortunately handle high contrast color scheme as well, so we are forced to do it // This is code is dervied from the way VS does this. static bool IsHighContrastEnabled { get { if (SystemParameters.HighContrast) { return true; } if (SystemColors.ControlColor == Colors.Black && SystemColors.ControlTextColor == Colors.White) { return true; } if (SystemColors.ControlColor == Colors.White && SystemColors.ControlTextColor == Colors.Black) { return true; } if (SystemColors.ControlColor == Colors.Black && SystemColors.ControlTextColor == Color.FromArgb(0xff, 0x00, 0xff, 0x00)) { return true; } return false; } } public static Color WorkflowViewElementBorderColor { get { return GetColor(WorkflowDesignerColors.WorkflowViewElementBorderColorKey); } } public static Color WorkflowViewElementBackgroundColor { get { return GetColor(WorkflowDesignerColors.WorkflowViewElementBackgroundColorKey); } } public static Color WorkflowViewElementSelectedBackgroundColor { get { return GetColor(WorkflowDesignerColors.WorkflowViewElementSelectedBackgroundColorKey); } } public static Color GridViewRowHoverColor { get { return GetColor(WorkflowDesignerColors.WorkflowViewElementSelectedBackgroundColorKey, 0xA0); } } public static Color WorkflowViewElementSelectedBorderColor { get { return GetColor(WorkflowDesignerColors.WorkflowViewElementSelectedBorderColorKey); } } public static Color DesignerViewStatusBarBackgroundColor { get { return GetColor(WorkflowDesignerColors.DesignerViewStatusBarBackgroundColorKey); } } public static Color WorkflowViewElementCaptionColor { get { return GetColor(WorkflowDesignerColors.WorkflowViewElementCaptionColorKey); } } public static Color DesignerViewBackgroundColor { get { return GetColor(WorkflowDesignerColors.DesignerViewBackgroundColorKey); } } public static Color DesignerViewShellBarColorGradientBeginColor { get { return GetColor(WorkflowDesignerColors.DesignerViewShellBarColorGradientBeginKey); } } public static Color DesignerViewShellBarColorGradientEndColor { get { return GetColor(WorkflowDesignerColors.DesignerViewShellBarColorGradientEndKey); } } public static Color DesignerViewShellBarSelectedColorGradientBeginColor { get { return GetColor(WorkflowDesignerColors.DesignerViewShellBarSelectedColorGradientBeginKey); } } public static Color DesignerViewShellBarSelectedColorGradientEndColor { get { return GetColor(WorkflowDesignerColors.DesignerViewShellBarSelectedColorGradientEndKey); } } public static Color DesignerViewShellBarHoverColorGradientBeginColor { get { return GetColor(WorkflowDesignerColors.DesignerViewShellBarHoverColorGradientBeginKey); } } public static Color DesignerViewShellBarHoverColorGradientEndColor { get { return GetColor(WorkflowDesignerColors.DesignerViewShellBarHoverColorGradientEndKey); } } public static Color DesignerViewShellBarControlBackgroundColor { get { return GetColor(WorkflowDesignerColors.DesignerViewShellBarControlBackgroundColorKey); } } public static Color DesignerViewShellBarCaptionActiveColor { get { return GetColor(WorkflowDesignerColors.DesignerViewShellBarCaptionActiveColorKey); } } public static Color DesignerViewShellBarCaptionColor { get { return GetColor(WorkflowDesignerColors.DesignerViewShellBarCaptionColorKey); } } public static Brush DesignerViewExpandAllCollapseAllButtonBrush { get { return GetBrush(WorkflowDesignerColors.DesignerViewExpandAllCollapseAllButtonColorKey); } } public static Brush DesignerViewExpandAllCollapseAllButtonMouseOverBrush { get { return GetBrush(WorkflowDesignerColors.DesignerViewExpandAllCollapseAllButtonMouseOverColorKey); } } public static Brush DesignerViewExpandAllCollapseAllPressedBrush { get { return GetBrush(WorkflowDesignerColors.DesignerViewExpandAllCollapseAllPressedColorKey); } } public static Color ContextMenuBackgroundGradientBeginColor { get { return GetColor(WorkflowDesignerColors.ContextMenuBackgroundGradientBeginColorKey); } } public static Color ContextMenuBackgroundGradientEndColor { get { return GetColor(WorkflowDesignerColors.ContextMenuBackgroundGradientEndColorKey); } } public static Color ContextMenuBorderColor { get { return GetColor(WorkflowDesignerColors.ContextMenuBorderColorKey); } } public static Color ContextMenuIconAreaColor { get { return GetColor(WorkflowDesignerColors.ContextMenuIconAreaColorKey); } } public static Color ContextMenuMouseOverBeginColor { get { return GetColor(WorkflowDesignerColors.ContextMenuMouseOverBeginColorKey); } } public static Color ContextMenuMouseOverMiddle1Color { get { return GetColor(WorkflowDesignerColors.ContextMenuMouseOverMiddle1ColorKey); } } public static Color ContextMenuMouseOverMiddle2Color { get { return GetColor(WorkflowDesignerColors.ContextMenuMouseOverMiddle2ColorKey); } } public static Color ContextMenuMouseOverEndColor { get { return GetColor(WorkflowDesignerColors.ContextMenuMouseOverEndColorKey); } } public static Color ContextMenuMouseOverBorderColor { get { return GetColor(WorkflowDesignerColors.ContextMenuMouseOverBorderColorKey); } } public static Color ContextMenuItemTextColor { get { return GetColor(WorkflowDesignerColors.ContextMenuItemTextColorKey); } } public static Color ContextMenuItemTextHoverColor { get { return GetColor(WorkflowDesignerColors.ContextMenuItemTextHoverColorKey); } } public static Color ContextMenuItemTextSelectedColor { get { return GetColor(WorkflowDesignerColors.ContextMenuItemTextSelectedColorKey); } } public static Color ContextMenuItemTextDisabledColor { get { return GetColor(WorkflowDesignerColors.ContextMenuItemTextDisabledColorKey); } } public static Color ContextMenuSeparatorColor { get { return GetColor(WorkflowDesignerColors.ContextMenuSeparatorColorKey); } } public static Brush FlowchartExpressionButtonBrush { get { return GetBrush(WorkflowDesignerColors.FlowchartExpressionButtonColorKey); } } public static Brush FlowchartExpressionButtonMouseOverBrush { get { return GetBrush(WorkflowDesignerColors.FlowchartExpressionButtonMouseOverColorKey); } } public static Brush FlowchartExpressionButtonPressedBrush { get { return GetBrush(WorkflowDesignerColors.FlowchartExpressionButtonPressedColorKey); } } public static FontFamily FontFamily { get { return GetFontFamily(FontFamilyKey); } } public static double FontSize { get { return GetFontSize(FontSizeKey); } } public static FontWeight FontWeight { get { return GetFontWeight(FontWeightKey); } } static Brush GetBrush(string colorKey) { SolidColorBrush brush = null; if (IsHighContrastEnabled) { brush = (SolidColorBrush)WorkflowDesignerColors.HighContrastColors[colorKey]; } else if (WorkflowDesignerColors.ColorServiceColors.Contains(colorKey)) { brush = (SolidColorBrush)WorkflowDesignerColors.ColorServiceColors[colorKey]; } else { brush = (SolidColorBrush)WorkflowDesignerColors.DefaultColors[colorKey]; } if (brush.CanFreeze) { brush.Freeze(); } return brush; } static Color GetColor(string colorKey) { SolidColorBrush brush = (SolidColorBrush)GetBrush(colorKey); return brush.Color; } static Color GetColor(string colorKey, byte alpha) { Color color = GetColor(colorKey); color.A = alpha; return color; } static FontFamily GetFontFamily(string key) { if (IsHighContrastEnabled) { return SystemFonts.MessageFontFamily; } return WorkflowDesignerColors.FontResources.Contains(key) ? (FontFamily)WorkflowDesignerColors.FontResources[key] : SystemFonts.MessageFontFamily; } static double GetFontSize(string key) { if (IsHighContrastEnabled) { return SystemFonts.MessageFontSize; } return WorkflowDesignerColors.FontResources.Contains(key) ? (double)WorkflowDesignerColors.FontResources[key] : SystemFonts.MessageFontSize; } static FontWeight GetFontWeight(string key) { if (IsHighContrastEnabled) { return SystemFonts.MessageFontWeight; } return WorkflowDesignerColors.FontResources.Contains(key) ? (FontWeight)WorkflowDesignerColors.FontResources[key] : SystemFonts.MessageFontWeight; } static string CreateKey(string name) { //return AdornerResources.CreateResourceKey(typeof(PropertyInspectorMergedResources), name); return name; } } } // 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
- CodeDelegateCreateExpression.cs
- XmlName.cs
- AVElementHelper.cs
- Component.cs
- ResourceManagerWrapper.cs
- ScrollItemPatternIdentifiers.cs
- EncoderParameters.cs
- ProjectionCamera.cs
- Crc32.cs
- HttpCookieCollection.cs
- DateTimeSerializationSection.cs
- DataViewManager.cs
- JsonByteArrayDataContract.cs
- ECDiffieHellmanPublicKey.cs
- ToolStripGripRenderEventArgs.cs
- XsltQilFactory.cs
- DetailsViewModeEventArgs.cs
- AppDomainUnloadedException.cs
- WindowHideOrCloseTracker.cs
- StringAnimationBase.cs
- CommonDialog.cs
- SqlParameter.cs
- PageWrapper.cs
- Domain.cs
- DbDataRecord.cs
- CompoundFileReference.cs
- DurableEnlistmentState.cs
- UrlPropertyAttribute.cs
- ClientScriptItem.cs
- JapaneseLunisolarCalendar.cs
- LogSwitch.cs
- SynchronizationLockException.cs
- WindowsListViewGroup.cs
- SymDocumentType.cs
- Helpers.cs
- SHA1.cs
- UITypeEditor.cs
- SaveLedgerEntryRequest.cs
- MediaTimeline.cs
- DefaultProxySection.cs
- SafeViewOfFileHandle.cs
- PackageDigitalSignatureManager.cs
- ApplicationServiceManager.cs
- AttributeQuery.cs
- Point3DAnimationBase.cs
- TouchPoint.cs
- XsltContext.cs
- PageTheme.cs
- ProcessHost.cs
- StoreItemCollection.Loader.cs
- SharedConnectionInfo.cs
- ObjectQuery_EntitySqlExtensions.cs
- CacheRequest.cs
- DBSqlParserTableCollection.cs
- MasterPageCodeDomTreeGenerator.cs
- precedingsibling.cs
- ErrorStyle.cs
- AssociationEndMember.cs
- XPathAncestorIterator.cs
- GetImportFileNameRequest.cs
- RankException.cs
- TypeViewSchema.cs
- ManagementObject.cs
- SqlClientMetaDataCollectionNames.cs
- RuntimeCompatibilityAttribute.cs
- SimplePropertyEntry.cs
- recordstatefactory.cs
- PenThread.cs
- DataViewManager.cs
- CookieProtection.cs
- Parsers.cs
- ProfileSection.cs
- PolicyException.cs
- IisTraceListener.cs
- UnmanagedMemoryAccessor.cs
- XmlSubtreeReader.cs
- FilterableAttribute.cs
- Visual3D.cs
- SqlCacheDependencyDatabase.cs
- TextBoxLine.cs
- EntryWrittenEventArgs.cs
- CheckoutException.cs
- WorkflowNamespace.cs
- InputManager.cs
- PtsContext.cs
- DesignerFrame.cs
- TypefaceMap.cs
- ListViewGroupItemCollection.cs
- GuidConverter.cs
- Missing.cs
- Themes.cs
- MonthChangedEventArgs.cs
- CatalogPartCollection.cs
- KeyFrames.cs
- PasswordTextNavigator.cs
- Column.cs
- Properties.cs
- XmlReflectionMember.cs
- TypeBuilderInstantiation.cs
- ServiceAuthorizationElement.cs