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);
        }
Beispiel #2
0
        private void RegisterEditingHandlers(TextEditProxy editingProxy)
        {
            IViewTextBoxBase editingElement = editingProxy.EditingElement;

            editingElement.PreviewTextInput         += new TextCompositionEventHandler(this.editingTextBox_PreviewTextInput);
            editingElement.TextChanged              += new TextChangedEventHandler(this.editingTextBox_TextChanged);
            editingElement.SelectionChanged         += new RoutedEventHandler(this.editingTextBox_SelectionChanged);
            editingElement.LostFocus                += new RoutedEventHandler(this.editingTextBox_LostFocus);
            editingElement.PreviewLostKeyboardFocus += new KeyboardFocusChangedEventHandler(this.editingTextBox_PreviewLostKeyboardFocus);
        }
Beispiel #3
0
        private void BeginTextEdit(BaseFrameworkElement textElement)
        {
            this.FindOrCreateEditProxy(textElement, true);
            if (this.editProxy == null)
            {
                return;
            }
            IViewTextBoxBase editingElement = this.editProxy.EditingElement;

            if (this.isCreatingText)
            {
                editingElement.Focus();
                editingElement.SelectAll();
            }
            this.RegisterEditingHandlers(this.editProxy);
        }