/// <summary> /// Translator for Font /// </summary> private static void FontPropertyTranslator(object host, string propertyName, object value) { ElementHost elementHost = host as ElementHost; SD.Font wfFont = value as SD.Font; if (elementHost != null && wfFont != null) { AvalonAdapter adapter = elementHost.HostContainerInternal; if (adapter != null) { adapter.SetValue(SWC.Control.FontSizeProperty, Convert.SystemDrawingFontToSystemWindowsFontSize(wfFont)); adapter.SetValue(SWC.Control.FontFamilyProperty, Convert.ToSystemWindowsFontFamily(wfFont.FontFamily)); adapter.SetValue(SWC.Control.FontWeightProperty, Convert.ToSystemWindowsFontWeight(wfFont)); adapter.SetValue(SWC.Control.FontStyleProperty, Convert.ToSystemWindowsFontStyle(wfFont)); SWC.TextBlock childTextBlock = elementHost.Child as SWC.TextBlock; if (childTextBlock != null) { TextDecorationCollection decorations = new TextDecorationCollection(); if (wfFont.Underline) { decorations.Add(TextDecorations.Underline); } ; if (wfFont.Strikeout) { decorations.Add(TextDecorations.Strikethrough); } childTextBlock.TextDecorations = decorations; } } } }
/// <summary> /// Translator for Enabled /// </summary> private static void EnabledPropertyTranslator(object host, string propertyName, object value) { ElementHost elementHost = host as ElementHost; if (elementHost != null) { AvalonAdapter adapter = elementHost.HostContainerInternal; if (adapter != null && value is bool) { adapter.IsEnabled = (bool)value; } } }
/// <summary> /// Translator for Visible /// </summary> private static void VisiblePropertyTranslator(object host, string propertyName, object value) { ElementHost elementHost = host as ElementHost; if (elementHost != null) { AvalonAdapter adapter = elementHost.HostContainerInternal; if (value is bool && adapter != null) { bool fromVisible = (bool)value; SW.Visibility toVisibility = ((fromVisible) ? SW.Visibility.Visible : SW.Visibility.Hidden); adapter.Visibility = toVisibility; } } }
/// <summary> /// Translator for RightToLeft /// </summary> private static void RightToLeftPropertyTranslator(object host, string propertyName, object value) { ElementHost elementHost = host as ElementHost; if (elementHost != null) { AvalonAdapter adapter = elementHost.HostContainerInternal; if (adapter != null && value is SWF.RightToLeft) { SWF.RightToLeft fromRTL = (SWF.RightToLeft)value; SW.FlowDirection toFlowDirection = ((fromRTL == SWF.RightToLeft.Yes) ? SW.FlowDirection.RightToLeft : SW.FlowDirection.LeftToRight); adapter.FlowDirection = toFlowDirection; } } }
/// <summary> /// Translator for Cursor /// </summary> private static void CursorPropertyTranslator(object host, string propertyName, object value) { ElementHost elementHost = host as ElementHost; if (elementHost != null) { AvalonAdapter adapter = elementHost.HostContainerInternal; if (adapter != null) { //Note: Allow nulls to propagate SWF.Cursor fromCursor = value as SWF.Cursor; SWI.Cursor toCursor = Convert.ToSystemWindowsInputCursor(fromCursor); adapter.Cursor = toCursor; } } }
public ElementHostAutomationPeer(AvalonAdapter owner) : base(owner) { _owner = owner; }