Exemplo n.º 1
0
            public RichTextBoxRangeElement Instantiate(IViewTextRange textRange, SceneViewModel viewModel, ITypeId targetType)
            {
                RichTextBoxRangeElement textBoxRangeElement = (RichTextBoxRangeElement)this.Instantiate(viewModel, targetType);

                textBoxRangeElement.SetTextRange(textRange);
                return(textBoxRangeElement);
            }
Exemplo n.º 2
0
            public RichTextBoxRangeElement Instantiate(TextEditProxy textEditProxy, SceneViewModel viewModel, ITypeId targetType)
            {
                RichTextBoxRangeElement textBoxRangeElement = (RichTextBoxRangeElement)this.Instantiate(viewModel, targetType);

                textBoxRangeElement.TextEditProxy = textEditProxy;
                return(textBoxRangeElement);
            }
Exemplo n.º 3
0
        public object GetTextValue(IViewTextRange textRange, PropertyReference propertyReference)
        {
            object textRangeValue = RichTextBoxRangeElement.GetTextRangeValue(textRange, propertyReference);

            if (DependencyProperty.UnsetValue == textRangeValue)
            {
                return(MixedProperty.Mixed);
            }
            return(textRangeValue);
        }
Exemplo n.º 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);
        }
Exemplo n.º 5
0
        private static object GetTextRangeValue(IViewTextRange textRange, PropertyReference propertyReference)
        {
            object        target    = (object)null;
            ReferenceStep firstStep = propertyReference.FirstStep;
            IProperty     property  = textRange.Platform.Metadata.ResolveProperty((IPropertyId)firstStep);

            if (property != null)
            {
                target = textRange.GetPropertyValue((IPropertyId)property, true);
                if (target == DependencyProperty.UnsetValue || propertyReference.Count <= 1)
                {
                    return(target);
                }
                target = RichTextBoxRangeElement.CreateSubReference(propertyReference).GetValue(target);
            }
            return(target);
        }
Exemplo n.º 6
0
        public static bool IsTextProperty(SceneNode targetNode, PropertyReference propertyReference)
        {
            bool flag = false;

            foreach (IPropertyId propertyId in RichTextBoxRangeElement.GetTextRangeProperties(targetNode.ProjectContext))
            {
                ReferenceStep referenceStep1 = (ReferenceStep)targetNode.Platform.Metadata.ResolveProperty(propertyId);
                if (referenceStep1 != null)
                {
                    ReferenceStep referenceStep2 = targetNode.DesignerContext.PropertyManager.FilterProperty(targetNode, referenceStep1);
                    if (propertyReference.FirstStep.Equals((object)referenceStep2))
                    {
                        flag = true;
                    }
                }
            }
            return(flag);
        }
Exemplo n.º 7
0
        public static bool ShouldClearPropertyOnTextRuns(SceneNode targetNode, PropertyReference propertyReference)
        {
            ReferenceStep referenceStep1 = (ReferenceStep)targetNode.Platform.Metadata.ResolveProperty(RichTextBoxRangeElement.BackgroundProperty);
            bool          flag           = false;

            if (referenceStep1 != null)
            {
                ReferenceStep referenceStep2 = targetNode.DesignerContext.PropertyManager.FilterProperty(targetNode, referenceStep1);
                if (referenceStep2 != null)
                {
                    flag = propertyReference.FirstStep.Equals((object)referenceStep2);
                }
            }
            if (!flag)
            {
                return(RichTextBoxRangeElement.IsTextProperty(targetNode, propertyReference));
            }
            return(false);
        }
Exemplo n.º 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();
        }
Exemplo n.º 9
0
 public PropertyState IsValueSetOnTextRange(IViewTextRange textRange, PropertyReference propertyReference)
 {
     return(RichTextBoxRangeElement.GetTextRangeValue(textRange, propertyReference) == null ? PropertyState.Unset : PropertyState.Set);
 }