1 //-----------------------------------------------------------------------------
2 // Copyright (c) Microsoft Corporation. All rights reserved.
3 //-----------------------------------------------------------------------------
5 namespace System.Activities.Presentation
8 using System.Collections.Generic;
10 using System.Windows.Media;
13 using System.Activities.Presentation.Internal.PropertyEditing;
15 public static class WorkflowDesignerColors
17 static ResourceDictionary defaultColors;
18 static ResourceDictionary highContrastColors;
19 static ResourceDictionary fontAndColorResources;
21 public const string WorkflowViewElementBorderColorKey = "WorkflowViewElementBorderColorKey";
22 public const string WorkflowViewElementBackgroundColorKey = "WorkflowViewElementBackgroundColorKey";
23 public const string WorkflowViewElementSelectedBackgroundColorKey = "WorkflowViewElementSelectedBackgroundColorKey";
24 public const string WorkflowViewElementSelectedBorderColorKey = "WorkflowViewElementSelectedBorderColorKey";
25 public const string DesignerViewStatusBarBackgroundColorKey = "DesignerViewStatusBarBackgroundColorKey";
26 public const string WorkflowViewElementCaptionColorKey = "WorkflowViewElementCaptionBrushColorKey";
27 public const string DesignerViewBackgroundColorKey = "DesignerViewBackgroundColorKey";
28 public const string DesignerViewShellBarColorGradientBeginKey = "DesignerViewShellBarColorGradientBeginKey";
29 public const string DesignerViewShellBarColorGradientEndKey = "DesignerViewShellBarColorGradientEndKey";
30 public const string DesignerViewShellBarSelectedColorGradientBeginKey = "DesignerViewShellBarSelectedColorGradientBeginKey";
31 public const string DesignerViewShellBarSelectedColorGradientEndKey = "DesignerViewShellBarSelectedColorGradientEndKey";
32 public const string DesignerViewShellBarHoverColorGradientBeginKey = "DesignerViewShellBarSelectedHoverGradientBeginKey";
33 public const string DesignerViewShellBarHoverColorGradientEndKey = "DesignerViewShellBarSelectedHoverGradientEndKey";
34 public const string DesignerViewShellBarControlBackgroundColorKey = "DesignerViewShellBarControlBackgroundColorKey";
35 public const string DesignerViewShellBarCaptionActiveColorKey = "DesignerViewShellBarCaptionActiveColorKey";
36 public const string DesignerViewShellBarCaptionColorKey = "DesignerViewShellBarCaptionColorKey";
37 public const string DesignerViewExpandAllCollapseAllButtonColorKey = "DesignerViewExpandAllCollapseAllButtonColorKey";
38 public const string DesignerViewExpandAllCollapseAllButtonMouseOverColorKey = "DesignerViewExpandAllCollapseAllButtonMouseOverColorKey";
39 public const string DesignerViewExpandAllCollapseAllPressedColorKey = "DesignerViewExpandAllCollapseAllPressedColorKey";
41 public const string ContextMenuBackgroundGradientBeginColorKey = "ContextMenuColorGradientBeginColorKey";
42 public const string ContextMenuBackgroundGradientEndColorKey = "ContextMenuColorGradientEndColorKey";
43 public const string ContextMenuBorderColorKey = "ContextMenuBorderColorKey";
44 public const string ContextMenuIconAreaColorKey = "ContextMenuIconAreaColorKey";
45 public const string ContextMenuMouseOverBeginColorKey = "ContextMenuMouseOverBeginColorKey";
46 public const string ContextMenuMouseOverMiddle1ColorKey = "ContextMenuMouseOverMiddle1ColorKey";
47 public const string ContextMenuMouseOverMiddle2ColorKey = "ContextMenuMouseOverMiddle2ColorKey";
48 public const string ContextMenuMouseOverEndColorKey = "ContextMenuMouseOverEndColorKey";
49 public const string ContextMenuMouseOverBorderColorKey = "ContextMenuMouseOverBorderColorKey";
50 public const string ContextMenuItemTextColorKey = "ContextMenuItemTextColorKey";
51 public const string ContextMenuItemTextHoverColorKey = "ContextMenuItemTextHoverColorKey";
52 public const string ContextMenuItemTextSelectedColorKey = "ContextMenuItemTextSelectedColorKey";
53 public const string ContextMenuItemTextDisabledColorKey = "ContextMenuItemTextDisabledColorKey";
54 public const string ContextMenuSeparatorColorKey = "ContextMenuSeparatorColorKey";
56 public static string PropertyInspectorTextBrushKey { get { return PropertyInspectorMergedResources.TextBrushKey; } }
57 public static string PropertyInspectorSelectedForegroundBrushKey { get { return PropertyInspectorMergedResources.SelectedForegroundBrushKey; } }
58 public static string PropertyInspectorSelectedBackgroundBrushKey { get { return PropertyInspectorMergedResources.SelectedBackgroundBrushKey; } }
59 public static string PropertyInspectorBackgroundBrushKey { get { return PropertyInspectorMergedResources.BackgroundBrushKey; } }
60 public static string PropertyInspectorBorderBrushKey { get { return PropertyInspectorMergedResources.BorderBrushKey; } }
61 public static string PropertyInspectorCategoryCaptionTextBrushKey { get { return PropertyInspectorMergedResources.CategoryCaptionTextBrushKey; } }
62 public static string PropertyInspectorPaneBrushKey { get { return PropertyInspectorMergedResources.PaneBrushKey; } }
63 public static string PropertyInspectorPopupBrushKey { get { return PropertyInspectorMergedResources.PopupBrushKey; } }
64 public static string PropertyInspectorToolBarItemHoverBackgroundBrushKey { get { return PropertyInspectorMergedResources.ToolBarItemHoverBackgroundBrushKey; } }
65 public static string PropertyInspectorToolBarItemHoverBorderBrushKey { get { return PropertyInspectorMergedResources.ToolBarItemHoverBorderBrushKey; } }
66 public static string PropertyInspectorToolBarItemSelectedBackgroundBrushKey { get { return PropertyInspectorMergedResources.ToolBarItemSelectedBackgroundBrushKey; } }
67 public static string PropertyInspectorToolBarItemSelectedBorderBrushKey { get { return PropertyInspectorMergedResources.ToolBarItemSelectedBorderBrushKey; } }
68 public static string PropertyInspectorToolBarBackgroundBrushKey { get { return PropertyInspectorMergedResources.ToolBarBackgroundBrushKey; } }
69 public static string PropertyInspectorToolBarSeparatorBrushKey { get { return PropertyInspectorMergedResources.ToolBarSeparatorBrushKey; } }
70 public static string PropertyInspectorToolBarTextBoxBorderBrushKey { get { return PropertyInspectorMergedResources.ToolBarTextBoxBorderBrushKey; } }
73 public const string FlowchartExpressionButtonColorKey = "FlowchartExpressionButtonColorKey";
74 public const string FlowchartExpressionButtonMouseOverColorKey = "FlowchartExpressionButtonMouseOverColorKey";
75 public const string FlowchartExpressionButtonPressedColorKey = "FlowchartExpressionButtonPressedColorKey";
79 public const string AnnotationBackgroundGradientBeginColorKey = "AnnotationBackgroundGradientBeginColorKey";
80 public const string AnnotationBackgroundGradientMiddleColorKey = "AnnotationBackgroundGradientMiddleColorKey";
81 public const string AnnotationBackgroundGradientEndColorKey = "AnnotationBackgroundGradientEndColorKey";
82 public const string AnnotationBorderColorKey = "AnnotationBorderColorKey";
83 public const string AnnotationDockTextColorKey = "AnnotationDockTextColorKey";
84 public const string AnnotationUndockTextColorKey = "AnnotationUndockTextColorKey";
85 public const string AnnotationDockButtonColorKey = "AnnotationDockButtonColorKey";
86 public const string AnnotationDockButtonHoverColorKey = "AnnotationDockButtonHoverColorKey";
87 public const string AnnotationDockButtonHoverBorderColorKey = "AnnotationDockButtonHoverBorderColorKey";
88 public const string AnnotationDockButtonHoverBackgroundColorKey = "AnnotationDockButtonHoverBackgroundColorKey";
90 public const string OutlineViewItemHighlightBackgroundColorKey = "OutlineViewItemHighlightBackgroundColorKey";
91 public const string OutlineViewCollapsedArrowBorderColorKey = "OutlineViewCollapsedArrowBorderColorKey";
92 public const string OutlineViewCollapsedArrowHoverBorderColorKey = "OutlineViewCollapsedArrowHoverBorderColorKey";
93 public const string OutlineViewExpandedArrowColorKey = "OutlineViewExpandedArrowColorKey";
94 public const string OutlineViewExpandedArrowBorderColorKey = "OutlineViewExpandedArrowBorderColorKey";
95 public const string OutlineViewBackgroundColorKey = "OutlineViewBackgroundColorKey";
96 public const string OutlineViewItemSelectedTextColorKey = "OutlineViewTitemSelectedTextColorKey";
97 public const string OutlineViewItemTextColorKey = "OutlineViewItemTextColorKey";
99 public const string RubberBandRectangleColorKey = "RubberBandRectangleColorKey";
101 public static readonly string FontSizeKey = CreateKey("FontSizeKey");
102 public static readonly string FontFamilyKey = CreateKey("FontFamilyKey");
103 public static readonly string FontWeightKey = CreateKey("FontWeightKey");
106 static ResourceDictionary DefaultColors
110 if (defaultColors == null)
112 Uri resourceLocator = new Uri(
114 typeof(WorkflowDesignerColors).Assembly.GetName().Name,
115 @";component/System/Activities/Presentation/DefaultColorResources.xaml"),
116 UriKind.RelativeOrAbsolute);
117 defaultColors = (ResourceDictionary)Application.LoadComponent(resourceLocator);
119 Fx.Assert(defaultColors != null, "Could not load default color resources.");
120 return defaultColors;
124 static ResourceDictionary HighContrastColors
128 if (highContrastColors == null)
130 Uri resourceLocator = new Uri(
132 typeof(WorkflowDesignerColors).Assembly.GetName().Name,
133 @";component/System/Activities/Presentation/HighContrastColorResources.xaml"),
134 UriKind.RelativeOrAbsolute);
135 highContrastColors = (ResourceDictionary)Application.LoadComponent(resourceLocator);
137 Fx.Assert(highContrastColors != null, "Could not load high contrast color resources.");
138 return highContrastColors;
142 internal static ResourceDictionary FontAndColorResources
146 if (WorkflowDesignerColors.fontAndColorResources == null)
148 InitializeDefaultResourceDictionary();
151 return WorkflowDesignerColors.fontAndColorResources;
155 // Trying to figure out whether or not we are in highcontrast mode is a little tricky.
156 // There are two things highcontrast mode and highcontrast color scheme. unfortunately in some platforms ( w2k3) these are not both updated from OS UX
157 // here is a good article on this http://blogs.msdn.com/oldnewthing/archive/2008/12/03/9167477.aspx
158 // highcontrast mode can be detected easily by using
159 // applications in generatel ( e.g. VS) unfortunately handle high contrast color scheme as well, so we are forced to do it
160 // This is code is dervied from the way VS does this.
162 static bool IsHighContrastEnabled
166 if (SystemParameters.HighContrast)
171 if (SystemColors.ControlColor == Colors.Black && SystemColors.ControlTextColor == Colors.White)
176 if (SystemColors.ControlColor == Colors.White && SystemColors.ControlTextColor == Colors.Black)
181 if (SystemColors.ControlColor == Colors.Black && SystemColors.ControlTextColor == Color.FromArgb(0xff, 0x00, 0xff, 0x00))
191 public static Color WorkflowViewElementBorderColor
195 return GetColor(WorkflowDesignerColors.WorkflowViewElementBorderColorKey);
199 public static Color WorkflowViewElementBackgroundColor
203 return GetColor(WorkflowDesignerColors.WorkflowViewElementBackgroundColorKey);
206 public static Color WorkflowViewElementSelectedBackgroundColor
210 return GetColor(WorkflowDesignerColors.WorkflowViewElementSelectedBackgroundColorKey);
214 public static Color GridViewRowHoverColor
218 return GetColor(WorkflowDesignerColors.WorkflowViewElementSelectedBackgroundColorKey, 0xA0);
222 public static Color WorkflowViewElementSelectedBorderColor
226 return GetColor(WorkflowDesignerColors.WorkflowViewElementSelectedBorderColorKey);
229 public static Color DesignerViewStatusBarBackgroundColor
233 return GetColor(WorkflowDesignerColors.DesignerViewStatusBarBackgroundColorKey);
236 public static Color WorkflowViewElementCaptionColor
240 return GetColor(WorkflowDesignerColors.WorkflowViewElementCaptionColorKey);
243 public static Color DesignerViewBackgroundColor
247 return GetColor(WorkflowDesignerColors.DesignerViewBackgroundColorKey);
251 public static Color DesignerViewShellBarColorGradientBeginColor
253 get { return GetColor(WorkflowDesignerColors.DesignerViewShellBarColorGradientBeginKey); }
256 public static Color DesignerViewShellBarColorGradientEndColor
258 get { return GetColor(WorkflowDesignerColors.DesignerViewShellBarColorGradientEndKey); }
261 public static Color DesignerViewShellBarSelectedColorGradientBeginColor
263 get { return GetColor(WorkflowDesignerColors.DesignerViewShellBarSelectedColorGradientBeginKey); }
266 public static Color DesignerViewShellBarSelectedColorGradientEndColor
268 get { return GetColor(WorkflowDesignerColors.DesignerViewShellBarSelectedColorGradientEndKey); }
271 public static Color DesignerViewShellBarHoverColorGradientBeginColor
273 get { return GetColor(WorkflowDesignerColors.DesignerViewShellBarHoverColorGradientBeginKey); }
276 public static Color DesignerViewShellBarHoverColorGradientEndColor
278 get { return GetColor(WorkflowDesignerColors.DesignerViewShellBarHoverColorGradientEndKey); }
281 public static Color DesignerViewShellBarControlBackgroundColor
283 get { return GetColor(WorkflowDesignerColors.DesignerViewShellBarControlBackgroundColorKey); }
286 public static Color DesignerViewShellBarCaptionActiveColor
288 get { return GetColor(WorkflowDesignerColors.DesignerViewShellBarCaptionActiveColorKey); }
291 public static Color DesignerViewShellBarCaptionColor
293 get { return GetColor(WorkflowDesignerColors.DesignerViewShellBarCaptionColorKey); }
296 public static Brush DesignerViewExpandAllCollapseAllButtonBrush
298 get { return GetBrush(WorkflowDesignerColors.DesignerViewExpandAllCollapseAllButtonColorKey); }
301 public static Brush DesignerViewExpandAllCollapseAllButtonMouseOverBrush
303 get { return GetBrush(WorkflowDesignerColors.DesignerViewExpandAllCollapseAllButtonMouseOverColorKey); }
306 public static Brush DesignerViewExpandAllCollapseAllPressedBrush
308 get { return GetBrush(WorkflowDesignerColors.DesignerViewExpandAllCollapseAllPressedColorKey); }
311 public static Color ContextMenuBackgroundGradientBeginColor
313 get { return GetColor(WorkflowDesignerColors.ContextMenuBackgroundGradientBeginColorKey); }
315 public static Color ContextMenuBackgroundGradientEndColor
317 get { return GetColor(WorkflowDesignerColors.ContextMenuBackgroundGradientEndColorKey); }
320 public static Color ContextMenuBorderColor
322 get { return GetColor(WorkflowDesignerColors.ContextMenuBorderColorKey); }
325 public static Color ContextMenuIconAreaColor
327 get { return GetColor(WorkflowDesignerColors.ContextMenuIconAreaColorKey); }
330 public static Color ContextMenuMouseOverBeginColor
332 get { return GetColor(WorkflowDesignerColors.ContextMenuMouseOverBeginColorKey); }
335 public static Color ContextMenuMouseOverMiddle1Color
337 get { return GetColor(WorkflowDesignerColors.ContextMenuMouseOverMiddle1ColorKey); }
340 public static Color ContextMenuMouseOverMiddle2Color
342 get { return GetColor(WorkflowDesignerColors.ContextMenuMouseOverMiddle2ColorKey); }
345 public static Color ContextMenuMouseOverEndColor
347 get { return GetColor(WorkflowDesignerColors.ContextMenuMouseOverEndColorKey); }
350 public static Color ContextMenuMouseOverBorderColor
352 get { return GetColor(WorkflowDesignerColors.ContextMenuMouseOverBorderColorKey); }
355 public static Color ContextMenuItemTextColor
357 get { return GetColor(WorkflowDesignerColors.ContextMenuItemTextColorKey); }
360 public static Color ContextMenuItemTextHoverColor
362 get { return GetColor(WorkflowDesignerColors.ContextMenuItemTextHoverColorKey); }
365 public static Color ContextMenuItemTextSelectedColor
367 get { return GetColor(WorkflowDesignerColors.ContextMenuItemTextSelectedColorKey); }
370 public static Color ContextMenuItemTextDisabledColor
372 get { return GetColor(WorkflowDesignerColors.ContextMenuItemTextDisabledColorKey); }
375 public static Color ContextMenuSeparatorColor
377 get { return GetColor(WorkflowDesignerColors.ContextMenuSeparatorColorKey); }
380 public static Brush FlowchartExpressionButtonBrush
382 get { return GetBrush(WorkflowDesignerColors.FlowchartExpressionButtonColorKey); }
385 public static Brush FlowchartExpressionButtonMouseOverBrush
387 get { return GetBrush(WorkflowDesignerColors.FlowchartExpressionButtonMouseOverColorKey); }
390 public static Brush FlowchartExpressionButtonPressedBrush
392 get { return GetBrush(WorkflowDesignerColors.FlowchartExpressionButtonPressedColorKey); }
395 public static Color AnnotationBackgroundGradientBeginColor
397 get { return GetColor(WorkflowDesignerColors.AnnotationBackgroundGradientBeginColorKey); }
400 public static Color AnnotationBackgroundGradientMiddleColor
402 get { return GetColor(WorkflowDesignerColors.AnnotationBackgroundGradientMiddleColorKey); }
405 public static Color AnnotationBackgroundGradientEndColor
407 get { return GetColor(WorkflowDesignerColors.AnnotationBackgroundGradientEndColorKey); }
410 public static Color AnnotationBorderColor
412 get { return GetColor(WorkflowDesignerColors.AnnotationBorderColorKey); }
415 public static Color AnnotationDockTextColor
417 get { return GetColor(WorkflowDesignerColors.AnnotationDockTextColorKey); }
420 public static Color AnnotationUndockTextColor
422 get { return GetColor(WorkflowDesignerColors.AnnotationUndockTextColorKey); }
425 public static Color AnnotationDockButtonColor
427 get { return GetColor(WorkflowDesignerColors.AnnotationDockButtonColorKey); }
430 public static Color AnnotationDockButtonHoverColor
432 get { return GetColor(WorkflowDesignerColors.AnnotationDockButtonHoverColorKey); }
435 public static Color AnnotationDockButtonHoverBorderColor
437 get { return GetColor(WorkflowDesignerColors.AnnotationDockButtonHoverBorderColorKey); }
440 public static Color AnnotationDockButtonHoverBackgroundColor
442 get { return GetColor(WorkflowDesignerColors.AnnotationDockButtonHoverBackgroundColorKey); }
445 public static Color OutlineViewItemHighlightBackgroundColor
447 get { return GetColor(WorkflowDesignerColors.OutlineViewItemHighlightBackgroundColorKey); }
450 public static Color OutlineViewCollapsedArrowBorderColor
452 get { return GetColor(WorkflowDesignerColors.OutlineViewCollapsedArrowBorderColorKey); }
455 public static Color OutlineViewCollapsedArrowHoverBorderColor
457 get { return GetColor(WorkflowDesignerColors.OutlineViewCollapsedArrowHoverBorderColorKey); }
460 public static Color OutlineViewExpandedArrowColor
462 get { return GetColor(WorkflowDesignerColors.OutlineViewExpandedArrowColorKey); }
465 public static Color OutlineViewExpandedArrowBorderColor
467 get { return GetColor(WorkflowDesignerColors.OutlineViewExpandedArrowBorderColorKey); }
470 public static Color OutlineViewBackgroundColor
472 get { return GetColor(WorkflowDesignerColors.OutlineViewBackgroundColorKey); }
475 public static Color OutlineViewItemSelectedTextColor
477 get { return GetColor(WorkflowDesignerColors.OutlineViewItemSelectedTextColorKey); }
480 public static Color OutlineViewItemTextColor
482 get { return GetColor(WorkflowDesignerColors.OutlineViewItemTextColorKey); }
485 public static FontFamily FontFamily
489 return GetFontFamily(FontFamilyKey);
493 public static double FontSize
497 return GetFontSize(FontSizeKey);
501 public static FontWeight FontWeight
505 return GetFontWeight(FontWeightKey);
509 internal static Brush RubberBandRectangleBrush
511 get { return GetBrush(WorkflowDesignerColors.RubberBandRectangleColorKey); }
514 private static Brush GetBrush(string colorKey)
516 SolidColorBrush brush =
517 (SolidColorBrush)GetFontOrColor(colorKey, WorkflowDesignerColors.DefaultColors[colorKey], WorkflowDesignerColors.HighContrastColors[colorKey]);
526 private static Color GetColor(string colorKey)
528 SolidColorBrush brush = (SolidColorBrush)GetBrush(colorKey);
533 private static Color GetColor(string colorKey, byte alpha)
535 Color color = GetColor(colorKey);
540 private static FontFamily GetFontFamily(string key)
542 return (FontFamily)GetFontOrColor(key, SystemFonts.MessageFontFamily, SystemFonts.MessageFontFamily);
545 private static double GetFontSize(string key)
547 return (double)GetFontOrColor(key, SystemFonts.MessageFontSize, SystemFonts.MessageFontSize);
550 private static FontWeight GetFontWeight(string key)
552 return (FontWeight)GetFontOrColor(key, SystemFonts.MessageFontWeight, SystemFonts.MessageFontWeight);
555 private static object GetFontOrColor(string key, object defaultValue, object valueInHighContrast)
557 if (WorkflowDesignerColors.FontAndColorResources.Contains(key))
559 return WorkflowDesignerColors.FontAndColorResources[key];
561 else if (IsHighContrastEnabled)
563 return valueInHighContrast;
571 static string CreateKey(string name)
573 //return AdornerResources.CreateResourceKey(typeof(PropertyInspectorMergedResources), name);
577 private static void InitializeDefaultResourceDictionary()
579 ResourceDictionary resources = new ResourceDictionary();
580 resources[WorkflowDesignerColors.PropertyInspectorTextBrushKey] = new SolidColorBrush(SystemColors.ControlTextColor);
581 resources[WorkflowDesignerColors.PropertyInspectorBackgroundBrushKey] = new SolidColorBrush(SystemColors.WindowColor);
582 resources[WorkflowDesignerColors.PropertyInspectorBorderBrushKey] = new SolidColorBrush(SystemColors.ControlDarkColor);
583 resources[WorkflowDesignerColors.PropertyInspectorPaneBrushKey] = new SolidColorBrush(SystemColors.ControlColor);
584 resources[WorkflowDesignerColors.PropertyInspectorSelectedBackgroundBrushKey] = new SolidColorBrush(SystemColors.HighlightColor);
585 resources[WorkflowDesignerColors.PropertyInspectorSelectedForegroundBrushKey] = new SolidColorBrush(SystemColors.HighlightTextColor);
586 resources[WorkflowDesignerColors.PropertyInspectorToolBarItemHoverBackgroundBrushKey] = new SolidColorBrush(SystemColors.GradientActiveCaptionColor);
587 resources[WorkflowDesignerColors.PropertyInspectorToolBarItemHoverBorderBrushKey] = new SolidColorBrush(SystemColors.ActiveCaptionTextColor);
588 resources[WorkflowDesignerColors.PropertyInspectorToolBarItemSelectedBackgroundBrushKey] = new SolidColorBrush(SystemColors.GradientInactiveCaptionColor);
589 resources[WorkflowDesignerColors.PropertyInspectorToolBarItemSelectedBorderBrushKey] = new SolidColorBrush(SystemColors.ActiveCaptionTextColor);
590 resources[WorkflowDesignerColors.PropertyInspectorToolBarBackgroundBrushKey] = new SolidColorBrush(SystemColors.ControlColor);
591 resources[WorkflowDesignerColors.PropertyInspectorToolBarSeparatorBrushKey] = new SolidColorBrush(SystemColors.ControlDarkColor);
592 resources[WorkflowDesignerColors.PropertyInspectorToolBarTextBoxBorderBrushKey] = new SolidColorBrush(SystemColors.ControlDarkDarkColor);
594 WorkflowDesignerColors.fontAndColorResources = resources;