//---------------------------------------------------------------- // Copyright (c) Microsoft Corporation. All rights reserved. //---------------------------------------------------------------- namespace System.Activities.Presentation.Internal.PropertyEditing.Resources { using System; using System.Windows; using System.Activities.Presentation; // // Helper utilities for accessing values in ResourceDictionaries of controls // internal static class ResourceUtilities { private const string TypeIconWidthKey = "TypeIconWidth"; private const string TypeIconHeightKey = "TypeIconHeight"; // // Looks up a double based on the specified key, returning specified fallback value if not found // // Element to use as the starting point // Key to look up // Fallback value to return if key is not found // Double from the resource or fallback value if not found public static double GetDouble(FrameworkElement element, string key, double fallbackValue) { if (element == null) { throw FxTrace.Exception.ArgumentNull("element"); } if (string.IsNullOrEmpty(key)) { throw FxTrace.Exception.ArgumentNull("key"); } return (double)(element.FindResource(key) ?? fallbackValue); } public static Size GetDesiredTypeIconSize(FrameworkElement queryRoot) { return new Size(ResourceUtilities.GetDouble(queryRoot, TypeIconWidthKey, 16), ResourceUtilities.GetDouble(queryRoot, TypeIconHeightKey, 16)); } } }