Exemplo n.º 1
0
 protected override object GetComputedValueInternal(PropertyReference propertyReference)
 {
     if (this.IsTextRangeProperty(propertyReference))
     {
         if (!this.ShouldForwardPropertyChangeToControl(propertyReference))
         {
             PropertyReference propertyReference1 = this.ConvertToPlatformPropertyReference(propertyReference);
             object            textValue          = this.GetTextValue(this.TextRange, propertyReference1);
             object            obj = textValue;
             if (textValue != MixedProperty.Mixed)
             {
                 PropertyReference propertyReference2 = DesignTimeProperties.GetShadowPropertyReference(propertyReference1, (ITypeId)null);
                 if (propertyReference2 != null)
                 {
                     IViewObject parent = this.TextRange.Start.Parent;
                     obj = DesignTimeProperties.UseShadowPropertyForInstanceBuilding(this.DocumentContext.TypeResolver, (IPropertyId)propertyReference[0]) ? parent.GetCurrentValue(propertyReference2) : SceneNode.GetComputedValueWithShadowCoercion(propertyReference1, propertyReference2, parent.PlatformSpecificObject);
                 }
             }
             return(this.ConvertFromWpfValue(obj));
         }
         propertyReference = this.DesignerContext.PropertyManager.FilterProperty((SceneNode)this.TextEditProxy.TextSource, propertyReference);
     }
     if (propertyReference != null)
     {
         return(this.TextEditProxy.TextSource.GetComputedValue(propertyReference));
     }
     return((object)null);
 }
Exemplo n.º 2
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();
        }