Code:
/ 4.0 / 4.0 / untmp / 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.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- Parameter.cs
- RequestCacheManager.cs
- ControlDesignerState.cs
- DecoratedNameAttribute.cs
- RealizationDrawingContextWalker.cs
- ServiceContractAttribute.cs
- XmlSchemaParticle.cs
- DecoderNLS.cs
- CurrentChangedEventManager.cs
- DnsCache.cs
- __ComObject.cs
- ListSourceHelper.cs
- DeflateEmulationStream.cs
- XmlBufferedByteStreamReader.cs
- GridItem.cs
- HttpGetProtocolImporter.cs
- EntityDataSourceEntityTypeFilterItem.cs
- MethodAccessException.cs
- Decoder.cs
- ReleaseInstanceMode.cs
- ToolStripDropDownButton.cs
- InvalidCommandTreeException.cs
- DocumentManager.cs
- ActionItem.cs
- _ChunkParse.cs
- ProxySimple.cs
- ListViewItemMouseHoverEvent.cs
- EncryptedPackage.cs
- MetadataArtifactLoaderFile.cs
- SchemaSetCompiler.cs
- DetailsViewInsertEventArgs.cs
- FastEncoder.cs
- DataService.cs
- TextBounds.cs
- SqlDataSourceSelectingEventArgs.cs
- CombinedGeometry.cs
- TabOrder.cs
- UserControl.cs
- VBIdentifierTrimConverter.cs
- SmiEventSink_Default.cs
- TransformCryptoHandle.cs
- BoundPropertyEntry.cs
- Int32Rect.cs
- HttpCacheVary.cs
- ProvidersHelper.cs
- RecipientInfo.cs
- CqlLexerHelpers.cs
- ZipFileInfo.cs
- SqlNamer.cs
- ConnectionStringsExpressionEditor.cs
- ConfigurationCollectionAttribute.cs
- _WinHttpWebProxyDataBuilder.cs
- CacheForPrimitiveTypes.cs
- AvTraceDetails.cs
- CodeTypeParameterCollection.cs
- DataGridViewComboBoxCell.cs
- OleDbDataReader.cs
- WindowVisualStateTracker.cs
- dataSvcMapFileLoader.cs
- EventWaitHandle.cs
- MatrixIndependentAnimationStorage.cs
- LinqDataSourceUpdateEventArgs.cs
- LocalizationComments.cs
- FromRequest.cs
- FixedFindEngine.cs
- TypeSystemHelpers.cs
- DoubleAnimationClockResource.cs
- Compensate.cs
- SecUtil.cs
- XamlNamespaceHelper.cs
- MachineKeyValidationConverter.cs
- DisplayMemberTemplateSelector.cs
- RangeValueProviderWrapper.cs
- EventlogProvider.cs
- ServiceDescription.cs
- NamespaceCollection.cs
- AvTraceDetails.cs
- Attributes.cs
- BufferBuilder.cs
- StateFinalizationDesigner.cs
- FormatException.cs
- _PooledStream.cs
- EntityContainerAssociationSetEnd.cs
- EntityFrameworkVersions.cs
- EntityClientCacheKey.cs
- PhysicalFontFamily.cs
- WorkItem.cs
- VisualBrush.cs
- IPHostEntry.cs
- GridViewDeletedEventArgs.cs
- DetailsView.cs
- ForeignKeyConstraint.cs
- _KerberosClient.cs
- ValueTable.cs
- InstalledVoice.cs
- TextLineBreak.cs
- DBDataPermissionAttribute.cs
- SoapCodeExporter.cs
- SmtpSpecifiedPickupDirectoryElement.cs
- RSAPKCS1KeyExchangeDeformatter.cs