private static void ConvertToPathGeometriesViaProxy(BaseFrameworkElement frameworkElement, List <PathGeometry> pathList) { TextEditProxy editProxy = TextEditProxyFactory.CreateEditProxy(frameworkElement); IViewTextBoxBase editingElement = editProxy.EditingElement; UIElement uiElement = editingElement.PlatformSpecificObject as UIElement; if (uiElement == null) { return; } frameworkElement.DesignerContext.ActiveView.AddLiveControl((IViewControl)editingElement); editProxy.ForceLoadOnInstantiate = true; editProxy.Instantiate(); Rect computedTightBounds = frameworkElement.GetComputedTightBounds(); editingElement.Width = computedTightBounds.Width; editingElement.Height = computedTightBounds.Height; if (uiElement is RichTextBox) { PathConversionHelper.ConvertRichTextBoxToGeometry(uiElement as RichTextBox, pathList); } else if (uiElement is TextBox) { PathConversionHelper.ConvertTextBoxToGeometry(uiElement as TextBox, pathList); } frameworkElement.DesignerContext.ActiveView.RemoveLiveControl((IViewControl)editingElement); }
public static PathGeometry[] ConvertToPathGeometries(SceneElement element) { if (!PathConversionHelper.CanConvert(element)) { return(new PathGeometry[0]); } object platformSpecificObject = element.ViewObject.PlatformSpecificObject; ITypeId type = (ITypeId)element.ViewObject.GetIType((ITypeResolver)element.ProjectContext); List <PathGeometry> pathList = new List <PathGeometry>(); if (PlatformTypes.Shape.IsAssignableFrom(type)) { PathGeometry pathGeometry = PathConversionHelper.SimplifyGeometry(element.ViewModel.DefaultView.GetRenderedGeometryAsWpf(element), true, ProjectNeutralTypes.PrimitiveShape.IsAssignableFrom((ITypeId)element.Type)); pathList.Add(pathGeometry); } else if (platformSpecificObject is TextBlock) { TextBlock textBlock = platformSpecificObject as TextBlock; if (!textBlock.IsArrangeValid) { textBlock.UpdateLayout(); } PathConversionHelper.ConvertTextRangeToGeometry(new TextRange(textBlock.ContentStart, textBlock.ContentEnd), textBlock.FlowDirection, pathList); } else if (platformSpecificObject is RichTextBox) { PathConversionHelper.ConvertRichTextBoxToGeometry(platformSpecificObject as RichTextBox, pathList); } else if (platformSpecificObject is TextBox) { PathConversionHelper.ConvertTextBoxToGeometry(platformSpecificObject as TextBox, pathList); } else { PathConversionHelper.ConvertToPathGeometriesViaProxy(element as BaseFrameworkElement, pathList); } return(pathList.ToArray()); }