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;
        }
        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);
        }
示例#3
0
 public override void DeleteSelection()
 {
     if (this.richTextBox.Selection.IsEmpty)
     {
         IViewTextPointer insertionPosition = this.richTextBox.Selection.End.GetNextInsertionPosition(LogicalDirection.Forward);
         if (insertionPosition != null)
         {
             this.richTextBox.Selection.Select(this.richTextBox.Selection.Start, insertionPosition);
         }
     }
     this.richTextBox.Selection.Text = string.Empty;
 }
示例#4
0
        private static object GetUpdatedComplexProperty(IViewTextRange target, PropertyReference propertyReference, int index, object value, SceneNode.Modification modification)
        {
            ReferenceStep firstStep = propertyReference.FirstStep;
            IProperty     property  = target.Platform.Metadata.ResolveProperty((IPropertyId)firstStep);

            if (property != null && RichTextBoxRangeElement.IsComplexProperty((IPlatformMetadata)target.Platform.Metadata, property) && propertyReference.Count > 1)
            {
                PropertyReference subReference = RichTextBoxRangeElement.CreateSubReference(propertyReference);
                object            target1;
                if (target.IsEmpty)
                {
                    target1 = target.GetPropertyValue((IPropertyId)property);
                }
                else
                {
                    IViewTextPointer viewTextPointer = target.Start;
                    if (!viewTextPointer.IsAtInsertionPosition)
                    {
                        viewTextPointer = viewTextPointer.GetNextInsertionPosition(LogicalDirection.Forward);
                    }
                    target1 = !RichTextBoxElement.IsParagraphProperty(propertyReference) ? viewTextPointer.Parent.GetValue(property) : viewTextPointer.Paragraph.GetValue(property);
                }
                Freezable freezable = target1 as Freezable;
                if (freezable != null)
                {
                    target1 = (object)freezable.Clone();
                }
                if (target1 != null)
                {
                    switch (modification)
                    {
                    case SceneNode.Modification.SetValue:
                        target1 = subReference.SetValue(target1, value);
                        break;

                    case SceneNode.Modification.InsertValue:
                        subReference.Insert(target1, index, value);
                        break;

                    case SceneNode.Modification.RemoveValue:
                        subReference.RemoveAt(target1, index);
                        break;

                    default:
                        throw new InvalidEnumArgumentException("modification", (int)modification, typeof(SceneNode.Modification));
                    }
                }
                value = target1;
            }
            return(value);
        }
        protected override bool GetInsertionInfo(SceneElement container, int insertionIndex, bool isCursorAtEnd, out Point position, out double length, out Orientation orientation)
        {
            orientation = Orientation.Horizontal;
            IViewTextPointer pointerFromIndex = this.GetTextPointerFromIndex(insertionIndex, isCursorAtEnd);

            if (pointerFromIndex != null && pointerFromIndex.HasValidLayout)
            {
                Rect characterRect = pointerFromIndex.GetCharacterRect(LogicalDirection.Forward);
                position = characterRect.TopLeft;
                length   = characterRect.Height;
                return(true);
            }
            position = new Point();
            length   = 0.0;
            return(false);
        }
示例#6
0
        internal override object GetTextValueAtPoint(Point point, bool snapToText, PropertyReference propertyReference)
        {
            IViewTextPointer  positionFromPoint  = this.RichTextBox.GetPositionFromPoint(point);
            PropertyReference propertyReference1 = this.DesignerContext.PropertyManager.FilterProperty((ITypeResolver)this.ProjectContext, positionFromPoint.Parent.GetIType((ITypeResolver)this.ProjectContext), propertyReference);

            if (propertyReference1 == null)
            {
                return(this.GetComputedValue(propertyReference));
            }
            object textPointerValue = RichTextBoxRangeElement.GetTextPointerValue(positionFromPoint, propertyReference1);

            if (DependencyProperty.UnsetValue == textPointerValue)
            {
                return(MixedProperty.Mixed);
            }
            return(textPointerValue);
        }
        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);
            }
        }
示例#8
0
        private void ModifyTextValue(IViewTextRange textRange, PropertyReference propertyReference, int index, object value, SceneNode.Modification modification)
        {
            if (value is Microsoft.Expression.DesignModel.DocumentModel.DocumentNode || value is MarkupExtension)
            {
                return;
            }
            PerformanceUtility.MeasurePerformanceUntilRender(PerformanceEvent.TextSetProperty);
            value = RichTextBoxRangeElement.GetUpdatedComplexProperty(textRange, propertyReference, index, value, modification);
            ReferenceStep firstStep = propertyReference.FirstStep;
            IProperty     property  = textRange.Platform.Metadata.ResolveProperty((IPropertyId)firstStep);

            if (property != null)
            {
                if (modification == SceneNode.Modification.ClearValue)
                {
                    value = this.ViewModel.DefaultView.ConvertToWpfValue(this.ViewModel.DefaultView.ConvertFromWpfPropertyReference(propertyReference).LastStep.GetDefaultValue(typeof(object)));
                }
                if (property.Equals((object)RichTextBoxRangeElement.TextIndentPropertyId) && (double)value < 0.0)
                {
                    value = (object)0.0;
                }
                textRange.ApplyPropertyValue((IPropertyId)property, value);
                bool flag = RichTextBoxElement.IsParagraphProperty(propertyReference);
                PropertyReference propertyReference1 = DesignTimeProperties.GetShadowPropertyReference(propertyReference, (ITypeId)this.Type);
                if (propertyReference1 != null && !DesignTimeProperties.UseShadowPropertyForInstanceBuilding(this.ViewModel.Document.DocumentContext.TypeResolver, (IPropertyId)propertyReference1.FirstStep))
                {
                    propertyReference1 = (PropertyReference)null;
                }
                if (modification == SceneNode.Modification.ClearValue && propertyReference1 == null)
                {
                    propertyReference1 = propertyReference;
                }
                if (propertyReference1 != null)
                {
                    IViewTextElement viewTextElement1 = (IViewTextElement)null;
                    if (textRange.Start.CompareTo(textRange.End) != 0 || textRange.Start.CompareTo(((IViewTextElement)textRange.Start.Parent).ContentStart) != 0 && textRange.Start.CompareTo(((IViewTextElement)textRange.Start.Parent).ContentEnd) != 0)
                    {
                        for (IViewTextPointer viewTextPointer = textRange.Start; viewTextPointer != null && viewTextPointer.CompareTo(textRange.End) <= 0; viewTextPointer = viewTextPointer.GetNextInsertionPosition(LogicalDirection.Forward))
                        {
                            IViewTextElement viewTextElement2 = viewTextPointer.Parent as IViewTextElement;
                            if (viewTextElement2 != null && (viewTextElement1 == null || viewTextElement1.PlatformSpecificObject != viewTextElement2.PlatformSpecificObject))
                            {
                                viewTextElement1 = viewTextElement2;
                                if (viewTextElement1 != null && (flag && viewTextElement1 is Paragraph || !flag && viewTextElement1 is Run))
                                {
                                    if (modification == SceneNode.Modification.ClearValue)
                                    {
                                        propertyReference1.ClearValue((object)viewTextElement1);
                                    }
                                    else
                                    {
                                        propertyReference1.SetValue((object)viewTextElement1, value);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            if (property.Equals((object)RichTextBoxRangeElement.ForegroundProperty) || property.Equals((object)RichTextBoxRangeElement.TextElementForegroundProperty))
            {
                TextBlockEditProxy textBlockEditProxy = this.TextEditProxy as TextBlockEditProxy;
                if (textBlockEditProxy != null)
                {
                    textBlockEditProxy.UpdateCaretBrush();
                }
            }
            if (this.TextEditProxy == null)
            {
                return;
            }
            this.TextEditProxy.Serialize();
            this.TextEditProxy.UpdateDocumentModel();
        }
示例#9
0
 public static object GetTextPointerValue(IViewTextPointer textPointer, PropertyReference propertyReference)
 {
     return(textPointer.Parent.GetValue(propertyReference));
 }