コード例 #1
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);
        }
コード例 #2
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);
        }