1 //----------------------------------------------------------------
2 // Copyright (c) Microsoft Corporation. All rights reserved.
3 //----------------------------------------------------------------
4 namespace System.Activities.Presentation.Internal.PropertyEditing.Resources
8 using System.Activities.Presentation;
11 // Helper utilities for accessing values in ResourceDictionaries of controls
13 internal static class ResourceUtilities
16 private const string TypeIconWidthKey = "TypeIconWidth";
17 private const string TypeIconHeightKey = "TypeIconHeight";
20 // Looks up a double based on the specified key, returning specified fallback value if not found
22 // <param name="element">Element to use as the starting point</param>
23 // <param name="key">Key to look up</param>
24 // <param name="fallbackValue">Fallback value to return if key is not found</param>
25 // <returns>Double from the resource or fallback value if not found</returns>
26 public static double GetDouble(FrameworkElement element, string key, double fallbackValue)
30 throw FxTrace.Exception.ArgumentNull("element");
32 if (string.IsNullOrEmpty(key))
34 throw FxTrace.Exception.ArgumentNull("key");
36 return (double)(element.FindResource(key) ?? fallbackValue);
39 public static Size GetDesiredTypeIconSize(FrameworkElement queryRoot)
41 return new Size(ResourceUtilities.GetDouble(queryRoot, TypeIconWidthKey, 16),
42 ResourceUtilities.GetDouble(queryRoot, TypeIconHeightKey, 16));