/// <summary> /// Routine to localize (make languague-dependent) a WPF/framework element, like a menu. /// </summary> /// <param name="element">The element that is checked for localizable parameters</param> public static void Localize(System.Windows.FrameworkElement element) { foreach (var child in System.Windows.LogicalTreeHelper.GetChildren(element)) { System.Windows.FrameworkElement childAsElement = child as System.Windows.FrameworkElement; if (childAsElement != null) { Localize(childAsElement); } } var objType = element.GetType(); PropertyInfo property; string[] propertyTags = { "Content", "Header", "Text", "Title", "ToolTip" }; foreach (var tag in propertyTags) { property = objType.GetProperty(tag); if (property != null && property.CanRead && property.CanWrite && property.GetValue(element, null) is String) { property.SetValue(element, catalog.GetString(property.GetValue(element, null) as string), null); } } }
/// <summary>Creates a new adapter which wraps the given CoronaPanel control.</summary> /// <param name="coronaPanel"> /// <para>Reference to the CoronaPanel control that this adapter will wrap.</para> /// <para>Cannot be null or else an exception will be thrown.</para> /// </param> public DotNetCoronaControlAdapter(System.Windows.FrameworkElement coronaPanel) : base(coronaPanel) { // Verify that the argument is of type "CoronaPanel", which resides in the "Corona.Controls.DotNet.dll" library. // Note: This must be done via reflection because the CoronaPanel control cannot be in this library. // The reason is because the Visual Studio UI designer will fail to load/display a control from a // library that implements native C++/CX interface like this library does. if (DotNetCoronaControlAdapter.CanWrap(coronaPanel) == false) { throw new ArgumentException("Argument \"coronaPanel\" must be of type \"" + CoronaPanelFullTypeName + "\"."); } // Load the control's properties via reflection, if not already done. if (sRenderSurfaceProperty == null) { sRenderSurfaceProperty = coronaPanel.GetType().GetProperty("RenderSurface"); } if (sRuntimeProperty == null) { sRuntimeProperty = coronaPanel.GetType().GetProperty("Runtime"); } }