public virtual void AddInlineTextChild(DocumentNode child)
        {
            ITextFlowSceneNode textFlowSceneNode = this.HostElement as ITextFlowSceneNode;

            if (textFlowSceneNode == null)
            {
                return;
            }
            textFlowSceneNode.AddInlineTextChild(child);
        }
        public virtual void InsertInlineTextChild(int index, DocumentNode child)
        {
            ITextFlowSceneNode textFlowSceneNode = this.HostElement as ITextFlowSceneNode;

            if (textFlowSceneNode == null)
            {
                return;
            }
            textFlowSceneNode.InsertInlineTextChild(index, child);
        }
        public IViewTextPointer GetPositionFromPoint(Point point)
        {
            ITextFlowSceneNode textFlowSceneNode = this.HostElement as ITextFlowSceneNode;

            if (textFlowSceneNode != null)
            {
                return(textFlowSceneNode.GetPositionFromPoint(point));
            }
            return(this.ContentEnd);
        }
Esempio n. 4
0
        protected override void AdjustIndexAfterRemovingFromSceneView()
        {
            ITextFlowSceneNode textFlowSceneNode = this.InsertionPoint.Element as ITextFlowSceneNode;

            if (textFlowSceneNode != null && textFlowSceneNode.ContentStart != null && (this.insertionPositionToAdjust != null && this.insertionPositionToAdjust.IsInSameDocument(textFlowSceneNode.ContentStart)))
            {
                this.InsertionPoint.Index = textFlowSceneNode.ContentStart.GetOffsetToPosition(this.insertionPositionToAdjust);
            }
            this.insertionPositionToAdjust = (IViewTextPointer)null;
        }
Esempio n. 5
0
        protected override void AdjustIndexBeforeRemovingFromSceneView()
        {
            ITextFlowSceneNode textFlowSceneNode = this.InsertionPoint.Element as ITextFlowSceneNode;

            if (textFlowSceneNode == null || textFlowSceneNode.ContentStart == null)
            {
                return;
            }
            this.insertionPositionToAdjust = textFlowSceneNode.ContentStart.GetPositionAtOffset(this.InsertionPoint.Index);
        }
Esempio n. 6
0
        protected override IPropertyId GetInsertionPointChildProperty()
        {
            IPropertyId        propertyId        = (IPropertyId)null;
            ITextFlowSceneNode textFlowSceneNode = this.InsertionPoint.Element as ITextFlowSceneNode;

            if (textFlowSceneNode != null)
            {
                propertyId = textFlowSceneNode.TextChildProperty;
            }
            return(propertyId);
        }
        private IViewTextPointer GetTextPointerFromIndex(int insertionIndex, bool isCursorAtEnd)
        {
            if (!this.Element.IsViewObjectValid)
            {
                return((IViewTextPointer)null);
            }
            ITextFlowSceneNode textFlowSceneNode = this.Element as ITextFlowSceneNode;

            if (textFlowSceneNode == null)
            {
                return((IViewTextPointer)null);
            }
            if (isCursorAtEnd)
            {
                return(textFlowSceneNode.ContentEnd.GetInsertionPosition(LogicalDirection.Backward));
            }
            return(textFlowSceneNode.ContentStart.GetPositionAtOffset(insertionIndex, LogicalDirection.Forward));
        }
Esempio n. 8
0
        protected override void UpdateInsertionPoint()
        {
            this.ClearAdorner();
            this.InsertionPoint.Element = this.LayoutContainer;
            ITextFlowSceneNode textFlowSceneNode = this.InsertionPoint.Element as ITextFlowSceneNode;
            Point            mousePosition       = this.InsertionPoint.Element.ViewModel.DefaultView.GetMousePosition(this.Pointer, MoveStrategy.GetContainerHost((SceneElement)this.InsertionPoint.Element));
            IViewTextPointer positionFromPoint   = textFlowSceneNode.GetPositionFromPoint(mousePosition);
            IViewTextPointer position            = positionFromPoint != null?positionFromPoint.GetInsertionPosition(LogicalDirection.Forward) : textFlowSceneNode.ContentEnd.GetNextInsertionPosition(LogicalDirection.Backward);

            this.InsertionPoint.IsCursorAtEnd = false;
            if (textFlowSceneNode.ContentStart == null)
            {
                this.InsertionPoint.IsCursorAtEnd = true;
            }
            else
            {
                this.InsertionPoint.Index = textFlowSceneNode.ContentStart.GetOffsetToPosition(position);
                this.AdornerSet           = (AdornerSet) new TextFlowInsertionPointAdornerSet(this.ToolContext, this.LayoutContainer, (TextFlowInsertionPoint)this.InsertionPoint);
                this.ActiveView.AdornerLayer.Add((IAdornerSet)this.AdornerSet);
            }
        }
        public override void Instantiate()
        {
            base.Instantiate();
            this.CopyProperty(RichTextBoxElement.VerticalScrollBarVisibilityProperty);
            this.CopyProperty(RichTextBoxElement.HorizontalScrollBarVisibilityProperty);
            this.CopyProperty(RichTextBoxRangeElement.TextBlockTextAlignmentPropertyId);
            if (this.TextSource.ProjectContext.ResolveProperty(RichTextBoxElement.CaretBrushProperty) != null)
            {
                this.CopyProperty(RichTextBoxElement.CaretBrushProperty);
            }
            ITextFlowSceneNode textFlowSceneNode = (ITextFlowSceneNode)this.TextSource;
            DocumentNodePath   documentNodePath  = this.TextSource.DocumentNodePath;
            SceneViewModel     viewModel         = this.TextSource.ViewModel;
            IDocumentContext   documentContext   = viewModel.Document.DocumentContext;
            IProjectContext    projectContext    = viewModel.Document.ProjectContext;

            using (InstanceBuilderContext instanceBuilderContext = new InstanceBuilderContext(projectContext, viewModel, true, (Microsoft.Expression.DesignModel.DocumentModel.DocumentNode)null))
            {
                using (instanceBuilderContext.DisablePostponedResourceEvaluation())
                {
                    instanceBuilderContext.ViewNodeManager.RootNodePath = documentNodePath;
                    instanceBuilderContext.ViewNodeManager.Instantiate(instanceBuilderContext.ViewNodeManager.Root);
                }
                this.UpdateUIChildrenInstances((IInstanceBuilderContext)instanceBuilderContext);
                ReferenceStep referenceStep = (ReferenceStep)projectContext.ResolveProperty(textFlowSceneNode.TextChildProperty);
                bool          flag1         = false;
                bool          flag2         = false;
                bool          flag3         = false;
                FlowDocument  flowDocument  = (FlowDocument)referenceStep.GetCurrentValue(instanceBuilderContext.ViewNodeManager.Root.Instance);
                DependencyPropertyReferenceStep shadowProperty = DesignTimeProperties.GetShadowProperty(projectContext.ResolveProperty(TextElementSceneElement.FontFamilyProperty), (ITypeId)null);
                if (flowDocument == null)
                {
                    flowDocument = new FlowDocument();
                }
                else
                {
                    flag1 = ((ReferenceStep)projectContext.ResolveProperty(TextElementSceneElement.FontSizeProperty)).IsSet((object)flowDocument);
                    flag2 = ((ReferenceStep)projectContext.ResolveProperty(ParagraphElement.TextAlignmentProperty)).IsSet((object)flowDocument);
                    flag3 = shadowProperty.IsSet((object)flowDocument);
                }
                double        fontSize      = flowDocument.FontSize;
                FontFamily    fontFamily    = (FontFamily)shadowProperty.GetValue((object)flowDocument);
                Thickness     pagePadding   = flowDocument.PagePadding;
                TextAlignment textAlignment = flowDocument.TextAlignment;
                referenceStep.SetValue(instanceBuilderContext.ViewNodeManager.Root.Instance, (object)new FlowDocument());
                this.RichTextBox.Document = (IViewFlowDocument)this.TextSource.Platform.ViewObjectFactory.Instantiate((object)flowDocument);
                if (flag1)
                {
                    flowDocument.FontSize = fontSize;
                }
                if (flag3)
                {
                    if (!DesignTimeProperties.UseShadowPropertyForInstanceBuilding(this.TypeResolver, ControlElement.FontFamilyProperty))
                    {
                        flowDocument.FontFamily = fontFamily;
                    }
                    else
                    {
                        shadowProperty.SetValue((object)flowDocument, (object)fontFamily);
                    }
                }
                if (flag2)
                {
                    flowDocument.TextAlignment = textAlignment;
                }
                flowDocument.PagePadding = pagePadding;
            }
        }