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); }
internal static ReferenceStep FilterProperty(SceneNode node, ReferenceStep referenceStep) { if (node is RichTextBoxRangeElement) { return(referenceStep); } RichTextBoxElement richTextBoxElement = node as RichTextBoxElement; if (richTextBoxElement != null) { foreach (IPropertyId propertyId in !node.ProjectContext.IsCapabilitySet(PlatformCapability.IsWpf) ? RichTextBoxParagraphsRangeElement.SilverlightTextParagraphProperties : RichTextBoxParagraphsRangeElement.WpfTextParagraphProperties) { if (referenceStep.Equals((object)richTextBoxElement.ProjectContext.ResolveProperty(propertyId))) { return(referenceStep); } } } StyleNode styleNode = node as StyleNode; IType typeId = styleNode == null || styleNode.Platform.Metadata.IsNullType((ITypeId)styleNode.StyleTargetTypeId) ? node.Type : styleNode.StyleTargetTypeId; Type runtimeType = typeId.NearestResolvedType.RuntimeType; if (referenceStep.TargetType.IsAssignableFrom(runtimeType) && (PlatformTypeHelper.GetDeclaringType((IMember)referenceStep) == runtimeType || referenceStep.MemberType == MemberType.DesignTimeProperty)) { return(referenceStep); } ReferenceStep referenceStep1; if (typeId == SceneNodeObjectSet.FilteredPropertiesType) { if (SceneNodeObjectSet.FilteredProperties.TryGetValue(referenceStep, out referenceStep1)) { return(referenceStep1); } } else { SceneNodeObjectSet.FilteredPropertiesType = (ITypeId)typeId; SceneNodeObjectSet.FilteredProperties.Clear(); } referenceStep1 = SceneNodeObjectSet.FilterPropertyInternal((ITypeResolver)node.ProjectContext, typeId, referenceStep); SceneNodeObjectSet.FilteredProperties.Add(referenceStep, referenceStep1); return(referenceStep1); }
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(); }