Example #1
0
        public void ClearTextProperty(IProperty property)
        {
            DependencyPropertyReferenceStep propertyReferenceStep = (DependencyPropertyReferenceStep)this.TypeResolver.ResolveProperty(this.TextSource.DesignerContext.PlatformConverter.ConvertToWpfPropertyKey(property));
            DependencyPropertyReferenceStep shadowProperty        = DesignTimeProperties.GetShadowProperty((IProperty)propertyReferenceStep, (ITypeId)this.TextSource.Type);

            if (shadowProperty != null && DesignTimeProperties.UseShadowPropertyForInstanceBuilding(this.TypeResolver, (IPropertyId)shadowProperty))
            {
                propertyReferenceStep = shadowProperty;
            }
            DependencyProperty dependencyProperty = (DependencyProperty)propertyReferenceStep.DependencyProperty;

            foreach (TextElement textElement in (TextElementCollection <Block>)((FlowDocument)this.RichTextBox.Document.PlatformSpecificObject).Blocks)
            {
                this.ClearPropertyOnInlines(textElement, dependencyProperty);
            }
            ((DependencyObject)this.richTextBox.Document.PlatformSpecificObject).ClearValue(dependencyProperty);
        }
Example #2
0
        protected override object GetComputedValueInternal(PropertyReference propertyReference)
        {
            PropertyReference propertyReference1 = this.GetMediaTimelinePropertyReference(propertyReference);

            if (propertyReference1 != null)
            {
                MediaTimelineSceneNode owningTimeline = this.OwningTimeline;
                if (owningTimeline != null)
                {
                    ViewState viewState = ViewState.ElementValid | ViewState.AncestorValid | ViewState.SubtreeValid;
                    if (!owningTimeline.ViewModel.DefaultView.IsValid || (owningTimeline.ViewModel.DefaultView.GetViewState((SceneNode)owningTimeline) & viewState) != viewState || propertyReference1.LastStep == MediaTimelineSceneNode.SourceProperty)
                    {
                        return(owningTimeline.GetLocalOrDefaultValue(propertyReference1));
                    }
                    IViewObject viewObject = owningTimeline.ViewModel.GetViewObject(owningTimeline.DocumentNodePath);
                    propertyReference = DesignTimeProperties.GetAppliedShadowPropertyReference(propertyReference, (ITypeId)owningTimeline.TargetElement.Type);
                    return(propertyReference1.GetCurrentValue(viewObject.PlatformSpecificObject));
                }
            }
            return(base.GetComputedValueInternal(propertyReference));
        }
Example #3
0
        protected override object GetRawComputedValueInternal(PropertyReference propertyReference)
        {
            if (this.IsStyleProperty(propertyReference))
            {
                return(base.GetRawComputedValueInternal(propertyReference));
            }
            IViewObject viewTargetElement = this.ViewTargetElement;

            if (viewTargetElement == null || !PlatformTypes.FrameworkElement.IsAssignableFrom((ITypeId)viewTargetElement.GetIType((ITypeResolver)this.ProjectContext)))
            {
                ReferenceStep referenceStep = propertyReference[propertyReference.Count - 1];
                return(referenceStep.GetDefaultValue(PlatformTypeHelper.GetDeclaringType((IMember)referenceStep)));
            }
            PropertyReference propertyReference1 = DesignTimeProperties.GetAppliedShadowPropertyReference(propertyReference, (ITypeId)this.Type);

            if (propertyReference1 != propertyReference && !DesignTimeProperties.UseShadowPropertyForInstanceBuilding(this.DocumentContext.TypeResolver, (IPropertyId)propertyReference[0]))
            {
                return(SceneNode.GetComputedValueWithShadowCoercion(propertyReference, propertyReference, viewTargetElement.PlatformSpecificObject));
            }
            return(this.GetCurrentValueFromPropertyReference(propertyReference1, viewTargetElement.PlatformSpecificObject));
        }
Example #4
0
        protected virtual void CopyProperty(IPropertyId propertyId)
        {
            DependencyPropertyReferenceStep propertyReferenceStep = this.TextSource.DesignerContext.DesignerDefaultPlatformService.DefaultPlatform.Metadata.ResolveProperty(propertyId) as DependencyPropertyReferenceStep;
            ReferenceStep referenceStep1 = PlatformTypes.IsExpressionInteractiveType(PlatformTypeHelper.GetDeclaringType((IMember)propertyReferenceStep)) ? (ReferenceStep)propertyReferenceStep : PlatformTypeHelper.GetProperty((ITypeResolver)this.TextSource.ProjectContext, (ITypeId)this.TextSource.Type, MemberType.LocalProperty, propertyReferenceStep.Name);

            if (referenceStep1 == null)
            {
                return;
            }
            object computedValueAsWpf = this.TextSource.GetComputedValueAsWpf((IPropertyId)referenceStep1);

            if (!this.TextSource.ProjectContext.IsCapabilitySet(PlatformCapability.IsWpf))
            {
                if (DesignTimeProperties.GetShadowProperty((IProperty)referenceStep1, (ITypeId)this.TextSource.Type) != null)
                {
                    for (SceneNode sceneNode = (SceneNode)this.TextSource; sceneNode != null; sceneNode = sceneNode.Parent)
                    {
                        IProperty property = PlatformTypes.IsExpressionInteractiveType(PlatformTypeHelper.GetDeclaringType((IMember)referenceStep1)) ? (IProperty)referenceStep1 : (IProperty)PlatformTypeHelper.GetProperty((ITypeResolver)this.TextSource.ProjectContext, (ITypeId)sceneNode.Type, MemberType.LocalProperty, referenceStep1.Name);
                        if (property != null && sceneNode.IsSet((IPropertyId)property) == PropertyState.Set)
                        {
                            computedValueAsWpf = sceneNode.GetComputedValueAsWpf((IPropertyId)property);
                            break;
                        }
                    }
                }
            }
            try
            {
                ReferenceStep referenceStep2 = referenceStep1;
                if (!this.TextSource.ProjectContext.IsCapabilitySet(PlatformCapability.IsWpf))
                {
                    referenceStep2 = (ReferenceStep)propertyReferenceStep;
                }
                referenceStep2.SetValue(this.EditingElement.PlatformSpecificObject, computedValueAsWpf);
            }
            catch
            {
            }
        }
Example #5
0
        public void ReverseKeyFrames(double startTime, double endTime)
        {
            if (this.KeyFrameCount == 0)
            {
                return;
            }
            this.ConvertKeySplineResourcesToLocalValues();
            int capacity = 0;
            IList <KeyFrameSceneNode> keyFrameCollection = this.KeyFrameCollection;
            int index1 = 0;

            while (index1 < keyFrameCollection.Count && keyFrameCollection[index1].Time < startTime)
            {
                ++index1;
            }
            int index2 = index1;

            for (; index1 < keyFrameCollection.Count && keyFrameCollection[index1].Time <= endTime; ++index1)
            {
                ++capacity;
            }
            if (capacity == 0)
            {
                return;
            }
            bool flag = startTime == 0.0 && keyFrameCollection[0].Time != 0.0;

            if (flag)
            {
                ++capacity;
            }
            List <KeyFrameSceneNode> list1 = new List <KeyFrameSceneNode>(capacity);
            List <Point?>            list2 = new List <Point?>(capacity);

            if (flag)
            {
                KeyFrameSceneNode keyFrameSceneNode = this.IsDiscreteOnly ? (KeyFrameSceneNode)KeyFrameSceneNode.Factory.Instantiate(this.ViewModel, this.GetKeyFrameType(KeyFrameInterpolationType.Discrete)) : (KeyFrameSceneNode)KeyFrameSceneNode.Factory.Instantiate(this.ViewModel, this.GetKeyFrameType(KeyFrameInterpolationType.Spline));
                keyFrameSceneNode.Time = 0.0;
                SceneElement sceneElement = this.TargetElement as SceneElement;
                IViewObject  viewObject   = sceneElement.ViewTargetElement;
                if (PlatformTypes.Viewport3D.Equals((object)viewObject.GetIType((ITypeResolver)this.ProjectContext)))
                {
                    viewObject = sceneElement.ViewObject;
                }
                PropertyReference propertyReference = DesignTimeProperties.GetAppliedShadowPropertyReference(this.TargetProperty, (ITypeId)this.Type);
                keyFrameSceneNode.Value = viewObject.GetBaseValue(propertyReference);
                list1.Add(keyFrameSceneNode);
                if (keyFrameCollection[0].InterpolationType == KeyFrameInterpolationType.Spline && keyFrameCollection[0].KeySpline != null)
                {
                    list2.Add(new Point?(keyFrameCollection[0].KeySpline.ControlPoint1));
                }
                else if (!this.IsDiscreteOnly)
                {
                    list2.Add(new Point?(new Point()));
                }
                else
                {
                    list2.Add(new Point?());
                }
            }
            int num1 = 0;

            while (list1.Count < capacity)
            {
                if (keyFrameCollection[index2].InterpolationType != KeyFrameInterpolationType.Discrete)
                {
                    list2.Add(new Point?(keyFrameCollection[index2].EaseOutControlPoint));
                }
                else
                {
                    list2.Add(new Point?());
                }
                list1.Add(keyFrameCollection[index2]);
                keyFrameCollection.RemoveAt(index2);
                ++num1;
            }
            for (int index3 = 0; index3 < list1.Count; ++index3)
            {
                KeyFrameSceneNode keyFrameSceneNode1 = list1[index3];
                Point?            nullable1          = list2[index3];
                Point?            nullable2          = new Point?();
                if (keyFrameSceneNode1.InterpolationType != KeyFrameInterpolationType.Discrete)
                {
                    nullable2 = new Point?(keyFrameSceneNode1.EaseInControlPoint);
                }
                double            num2 = endTime - (keyFrameSceneNode1.Time - startTime);
                KeyFrameSceneNode node;
                if (nullable1.HasValue)
                {
                    KeyFrameSceneNode keyFrameSceneNode2 = (KeyFrameSceneNode)KeyFrameSceneNode.Factory.Instantiate(this.ViewModel, this.GetKeyFrameType(KeyFrameInterpolationType.Spline));
                    keyFrameSceneNode2.ValueNode = keyFrameSceneNode1.ValueNode.Clone(keyFrameSceneNode2.DocumentContext);
                    node = keyFrameSceneNode2;
                    node.EaseInControlPoint = new Point(1.0 - nullable1.Value.X, 1.0 - nullable1.Value.Y);
                }
                else
                {
                    KeyFrameSceneNode keyFrameSceneNode2 = (KeyFrameSceneNode)KeyFrameSceneNode.Factory.Instantiate(this.ViewModel, this.GetKeyFrameType(KeyFrameInterpolationType.Discrete));
                    keyFrameSceneNode2.ValueNode = keyFrameSceneNode1.ValueNode.Clone(keyFrameSceneNode2.DocumentContext);
                    node = keyFrameSceneNode2;
                }
                node.Time = num2;
                keyFrameCollection.Insert(index2, node);
                if (nullable2.HasValue)
                {
                    Point newEaseOut = new Point(1.0 - nullable2.Value.X, 1.0 - nullable2.Value.Y);
                    KeyFrameSceneNode.SetEaseOutControlPoint(node, newEaseOut);
                }
            }
            if (!flag)
            {
                return;
            }
            Point?nullable = new Point?(keyFrameCollection[0].EaseOutControlPoint);

            if (nullable.HasValue)
            {
                this.SetHandoffKeyFrameEaseOutPoint(nullable.Value);
            }
            this.RemoveKeyFrame(0.0);
        }
Example #6
0
 public void OnInitialized(IInstanceBuilderContext context, ViewNode target, object instance)
 {
     if (instance != null && this.targetType.IsAssignableFrom(instance.GetType()))
     {
         ITypeResolver typeResolver = target.DocumentNode.TypeResolver;
         IPlatform     platform     = context.Platform;
         platform.ViewObjectFactory.Instantiate(instance).SetValue(typeResolver, typeResolver.ResolveProperty(DesignTimeProperties.InstanceBuilderContextProperty), (object)new WeakReference((object)context));
         IDesignModeValueProviderContext valueProviderContext = context as IDesignModeValueProviderContext;
         if (valueProviderContext != null)
         {
             ValueTranslationService valueTranslationService = valueProviderContext.ValueTranslationService;
             foreach (PropertyIdentifier identifier in valueTranslationService.GetProperties(this.targetType))
             {
                 if (valueTranslationService.HasValueTranslation(this.targetType, identifier))
                 {
                     ReferenceStep referenceStep = target.Type.GetMember(MemberType.Property, identifier.Name, MemberAccessTypes.All) as ReferenceStep;
                     if (referenceStep != null)
                     {
                         if (!target.Properties.ContainsKey((IProperty)referenceStep))
                         {
                             ReferenceStep referenceStep1 = (ReferenceStep)DesignTimeProperties.GetShadowProperty((IProperty)referenceStep, (ITypeId)target.Type);
                             object        valueToSet     = referenceStep.GetValue(instance);
                             if (typeResolver.IsCapabilitySet(PlatformCapability.IsWpf) || valueToSet != null)
                             {
                                 referenceStep1.SetValue(instance, valueToSet);
                             }
                         }
                         PropertyIdentifier localProperty = identifier;
                         UIThreadDispatcherHelper.BeginInvoke(DispatcherPriority.Send, (Delegate)(o =>
                         {
                             if (target.Parent != null)
                             {
                                 DesignModeValueProviderService.RunDesignModeValueProvider(instance, platform, valueTranslationService, target.Type, this.targetType, localProperty, referenceStep, true);
                             }
                             return((object)null);
                         }), (object)null);
                     }
                 }
             }
         }
     }
     if (!context.IsSerializationScope)
     {
         return;
     }
     this.builder.OnInitialized(context, target, instance);
 }
        public override void Instantiate()
        {
            base.Instantiate();
            this.CopyProperty(RichTextBoxElement.VerticalScrollBarVisibilityProperty);
            this.CopyProperty(RichTextBoxElement.HorizontalScrollBarVisibilityProperty);
            this.CopyProperty(RichTextBoxRangeElement.TextBlockTextAlignmentPropertyId);
            if (this.TextSource.ProjectContext.ResolveProperty(RichTextBoxElement.CaretBrushProperty) != null)
            {
                this.CopyProperty(RichTextBoxElement.CaretBrushProperty);
            }
            ITextFlowSceneNode textFlowSceneNode = (ITextFlowSceneNode)this.TextSource;
            DocumentNodePath   documentNodePath  = this.TextSource.DocumentNodePath;
            SceneViewModel     viewModel         = this.TextSource.ViewModel;
            IDocumentContext   documentContext   = viewModel.Document.DocumentContext;
            IProjectContext    projectContext    = viewModel.Document.ProjectContext;

            using (InstanceBuilderContext instanceBuilderContext = new InstanceBuilderContext(projectContext, viewModel, true, (Microsoft.Expression.DesignModel.DocumentModel.DocumentNode)null))
            {
                using (instanceBuilderContext.DisablePostponedResourceEvaluation())
                {
                    instanceBuilderContext.ViewNodeManager.RootNodePath = documentNodePath;
                    instanceBuilderContext.ViewNodeManager.Instantiate(instanceBuilderContext.ViewNodeManager.Root);
                }
                this.UpdateUIChildrenInstances((IInstanceBuilderContext)instanceBuilderContext);
                ReferenceStep referenceStep = (ReferenceStep)projectContext.ResolveProperty(textFlowSceneNode.TextChildProperty);
                bool          flag1         = false;
                bool          flag2         = false;
                bool          flag3         = false;
                FlowDocument  flowDocument  = (FlowDocument)referenceStep.GetCurrentValue(instanceBuilderContext.ViewNodeManager.Root.Instance);
                DependencyPropertyReferenceStep shadowProperty = DesignTimeProperties.GetShadowProperty(projectContext.ResolveProperty(TextElementSceneElement.FontFamilyProperty), (ITypeId)null);
                if (flowDocument == null)
                {
                    flowDocument = new FlowDocument();
                }
                else
                {
                    flag1 = ((ReferenceStep)projectContext.ResolveProperty(TextElementSceneElement.FontSizeProperty)).IsSet((object)flowDocument);
                    flag2 = ((ReferenceStep)projectContext.ResolveProperty(ParagraphElement.TextAlignmentProperty)).IsSet((object)flowDocument);
                    flag3 = shadowProperty.IsSet((object)flowDocument);
                }
                double        fontSize      = flowDocument.FontSize;
                FontFamily    fontFamily    = (FontFamily)shadowProperty.GetValue((object)flowDocument);
                Thickness     pagePadding   = flowDocument.PagePadding;
                TextAlignment textAlignment = flowDocument.TextAlignment;
                referenceStep.SetValue(instanceBuilderContext.ViewNodeManager.Root.Instance, (object)new FlowDocument());
                this.RichTextBox.Document = (IViewFlowDocument)this.TextSource.Platform.ViewObjectFactory.Instantiate((object)flowDocument);
                if (flag1)
                {
                    flowDocument.FontSize = fontSize;
                }
                if (flag3)
                {
                    if (!DesignTimeProperties.UseShadowPropertyForInstanceBuilding(this.TypeResolver, ControlElement.FontFamilyProperty))
                    {
                        flowDocument.FontFamily = fontFamily;
                    }
                    else
                    {
                        shadowProperty.SetValue((object)flowDocument, (object)fontFamily);
                    }
                }
                if (flag2)
                {
                    flowDocument.TextAlignment = textAlignment;
                }
                flowDocument.PagePadding = pagePadding;
            }
        }
        public override void ModifyValue(IInstanceBuilderContext context, ViewNode target, object onlyThisInstance, IProperty propertyKey, object value, PropertyModification modification)
        {
            IProperty shadowProperty;

            if (!context.IsSerializationScope)
            {
                IInstantiatedElementViewNode instantiatedElementViewNode = target as IInstantiatedElementViewNode;
                if (instantiatedElementViewNode != null && onlyThisInstance == null && instantiatedElementViewNode.InstantiatedElements.First != null)
                {
                    if (context.UseShadowProperties)
                    {
                        shadowProperty = DesignTimeProperties.GetShadowProperty(propertyKey, target.DocumentNode.Type);
                    }
                    else
                    {
                        shadowProperty = null;
                    }
                    IProperty property = shadowProperty;
                    if (property != null && DesignTimeProperties.UseShadowPropertyForInstanceBuilding(target.TypeResolver, property))
                    {
                        propertyKey = property;
                    }
                    ReferenceStep referenceStep = propertyKey as ReferenceStep;
                    if (referenceStep != null)
                    {
                        foreach (object instantiatedElement in instantiatedElementViewNode.InstantiatedElements)
                        {
                            if (modification != PropertyModification.Set)
                            {
                                referenceStep.ClearValue(instantiatedElement);
                            }
                            else
                            {
                                InstanceBuilderOperations.SetValue(instantiatedElement, referenceStep, value);
                            }
                        }
                        return;
                    }
                }
            }
            if (propertyKey.DeclaringType.Metadata.IsNameProperty(propertyKey))
            {
                string valueAsString = null;
                if (context.IsSerializationScope)
                {
                    DocumentPrimitiveNode documentPrimitiveNode = value as DocumentPrimitiveNode;
                    if (documentPrimitiveNode != null)
                    {
                        valueAsString = DocumentPrimitiveNode.GetValueAsString(documentPrimitiveNode);
                    }
                }
                else
                {
                    valueAsString = value as string;
                    if (string.IsNullOrEmpty(valueAsString) && (ProjectNeutralTypes.VisualStateGroup.IsAssignableFrom(target.Type) || ProjectNeutralTypes.VisualState.IsAssignableFrom(target.Type)))
                    {
                        valueAsString = ((DocumentCompositeNode)target.DocumentNode).GetValueAsString(target.DocumentNode.NameProperty);
                    }
                }
                if (valueAsString != null && string.IsNullOrEmpty(valueAsString))
                {
                    CultureInfo currentCulture = CultureInfo.CurrentCulture;
                    string      instanceBuilderNamePropertyNotValid = ExceptionStringTable.InstanceBuilderNamePropertyNotValid;
                    object[]    objArray = new object[] { valueAsString };
                    throw new InstanceBuilderException(string.Format(currentCulture, instanceBuilderNamePropertyNotValid, objArray), target.DocumentNode);
                }
            }
            base.ModifyValue(context, target, onlyThisInstance, propertyKey, value, modification);
        }
        public override void UpdateProperty(IInstanceBuilderContext context, ViewNode viewNode, IProperty propertyKey, DocumentNode valueNode)
        {
            string        instance;
            string        str;
            IPropertyId   shadowProperty;
            ReferenceStep referenceStep = propertyKey as ReferenceStep;
            ViewNode      item          = viewNode.Properties[propertyKey];

            if (item != null && DocumentNodeUtilities.IsBinding(item.DocumentNode) && referenceStep != null)
            {
                ReferenceStep referenceStep1 = referenceStep;
                if (context.UseShadowProperties)
                {
                    shadowProperty = DesignTimeProperties.GetShadowProperty(propertyKey, viewNode.DocumentNode.Type);
                }
                else
                {
                    shadowProperty = null;
                }
                IPropertyId propertyId = shadowProperty;
                if (propertyId != null && DesignTimeProperties.UseShadowPropertyForInstanceBuilding(context.DocumentContext.TypeResolver, propertyId))
                {
                    referenceStep1 = propertyId as ReferenceStep;
                }
                if (referenceStep1 != null)
                {
                    IInstantiatedElementViewNode instantiatedElementViewNode = viewNode as IInstantiatedElementViewNode;
                    if (instantiatedElementViewNode == null)
                    {
                        referenceStep1.ClearValue(viewNode.Instance);
                    }
                    else
                    {
                        foreach (object instantiatedElement in instantiatedElementViewNode.InstantiatedElements)
                        {
                            referenceStep1.ClearValue(instantiatedElement);
                        }
                    }
                }
            }
            if (propertyKey.DeclaringType.Metadata.IsNameProperty(propertyKey) && InstanceBuilderOperations.GetIsInlinedResourceWithoutNamescope(viewNode))
            {
                InstanceBuilderOperations.UpdatePropertyWithoutApply(context, viewNode, propertyKey, valueNode);
                return;
            }
            INameScope nameScope = context.NameScope;
            bool       flag      = (nameScope == null ? false : propertyKey.DeclaringType.Metadata.IsNameProperty(propertyKey));

            if (flag)
            {
                ViewNode item1 = viewNode.Properties[propertyKey];
                if (item1 != null)
                {
                    str = item1.Instance as string;
                }
                else
                {
                    str = null;
                }
                string str1 = str;
                if (!string.IsNullOrEmpty(str1) && nameScope.FindName(str1) != null)
                {
                    context.NameScope.UnregisterName(str1);
                }
            }
            if ((!context.IsSerializationScope || !(propertyKey is Event)) && (context.IsSerializationScope || !DesignTimeProperties.IsDocumentOnlyDesignTimeProperty(propertyKey)))
            {
                base.UpdateProperty(context, viewNode, propertyKey, valueNode);
            }
            else
            {
                InstanceBuilderOperations.UpdatePropertyWithoutApply(context, viewNode, propertyKey, valueNode);
            }
            if (flag)
            {
                ViewNode viewNode1 = viewNode.Properties[propertyKey];
                if (viewNode1 != null)
                {
                    instance = viewNode1.Instance as string;
                }
                else
                {
                    instance = null;
                }
                string str2 = instance;
                if (!string.IsNullOrEmpty(str2))
                {
                    try
                    {
                        if (!str2.StartsWith("~", StringComparison.Ordinal) && !str2.Contains("."))
                        {
                            if (nameScope.FindName(str2) != null)
                            {
                                nameScope.UnregisterName(str2);
                            }
                            nameScope.RegisterName(str2, viewNode.Instance);
                        }
                    }
                    catch (ArgumentException argumentException1)
                    {
                        ArgumentException argumentException = argumentException1;
                        ViewNodeManager   viewNodeManager   = viewNode1.ViewNodeManager;
                        CultureInfo       currentCulture    = CultureInfo.CurrentCulture;
                        string            instanceBuilderUnableToRegisterName = ExceptionStringTable.InstanceBuilderUnableToRegisterName;
                        object[]          objArray = new object[] { str2 };
                        viewNodeManager.OnException(viewNode1, new InstanceBuilderException(string.Format(currentCulture, instanceBuilderUnableToRegisterName, objArray), argumentException, viewNode1.DocumentNode, viewNode), false);
                    }
                }
            }
        }
Example #10
0
        public static DocumentNode GetShadowPropertyNode(IInstanceBuilderContext context, ViewNode viewNode, IProperty propertyKey, DocumentNode valueNode)
        {
            IType valueAsType;
            DocumentNodeMemberValue value;
            ReferenceStep           member;

            if (!context.UseShadowProperties || propertyKey == null || !KnownProperties.SetterPropertyProperty.Equals(propertyKey))
            {
                return(null);
            }
            if (context.ContainerRoot == null || !PlatformTypes.Style.IsAssignableFrom(context.ContainerRoot.Type))
            {
                return(null);
            }
            DocumentCompositeNode documentNode = (DocumentCompositeNode)context.ContainerRoot.DocumentNode;
            DocumentPrimitiveNode item         = documentNode.Properties[KnownProperties.StyleTargetTypeProperty] as DocumentPrimitiveNode;

            if (item != null)
            {
                valueAsType = DocumentPrimitiveNode.GetValueAsType(item);
            }
            else
            {
                valueAsType = null;
            }
            IType type = valueAsType;

            if (type == null)
            {
                return(null);
            }
            DocumentPrimitiveNode documentPrimitiveNode = valueNode as DocumentPrimitiveNode;

            if (documentPrimitiveNode != null)
            {
                value = documentPrimitiveNode.Value as DocumentNodeMemberValue;
            }
            else
            {
                value = null;
            }
            DocumentNodeMemberValue documentNodeMemberValue = value;

            if (documentNodeMemberValue != null)
            {
                member = documentNodeMemberValue.Member as ReferenceStep;
            }
            else
            {
                member = null;
            }
            ReferenceStep referenceStep = member;

            if (referenceStep == null)
            {
                return(null);
            }
            if (context.RootTargetTypeReplacement != null)
            {
                ViewNode viewNode1 = StyleControlTemplateHelper.FindStyleTemplateOwningViewNode(viewNode);
                if (viewNode1 == null || viewNode1 == viewNode.ViewNodeManager.Root)
                {
                    IProperty replacementProperty = context.RootTargetTypeReplacement.GetReplacementProperty(referenceStep);
                    if (replacementProperty != null && replacementProperty != referenceStep)
                    {
                        return(context.DocumentContext.CreateNode(valueNode.Type, new DocumentNodeMemberValue(replacementProperty)));
                    }
                }
            }
            IProperty shadowProperty = DesignTimeProperties.GetShadowProperty(referenceStep, type);

            if (shadowProperty == null)
            {
                return(null);
            }
            if (!DesignTimeProperties.UseShadowPropertyForInstanceBuilding(context.DocumentContext.TypeResolver, shadowProperty))
            {
                return(null);
            }
            DocumentPrimitiveNode documentPrimitiveNode1 = context.DocumentContext.CreateNode(valueNode.Type, new DocumentNodeMemberValue(shadowProperty));

            return(documentPrimitiveNode1);
        }
Example #11
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();
        }
 internal static void Initialize(DesignerContext designerContext)
 {
     CanonicalTransform3D.EulerAnglesProperty = (DependencyProperty)DesignTimeProperties.ResolveDesignTimeReferenceStep(DesignTimeProperties.EulerAnglesProperty, (IPlatformMetadata)designerContext.DesignerDefaultPlatformService.DefaultPlatform.Metadata).DependencyProperty;
 }
Example #13
0
        public static void SetName(object target, string name, IPlatformMetadata platformMetadata)
        {
            DependencyPropertyReferenceStep dependencyPropertyReferenceStep = DesignTimeProperties.ResolveDesignTimeReferenceStep(DesignTimeProperties.XNameProperty, platformMetadata);

            dependencyPropertyReferenceStep.SetValue(target, name);
        }
Example #14
0
        public static string GetName(object target, IPlatformMetadata platformMetadata)
        {
            DependencyPropertyReferenceStep dependencyPropertyReferenceStep = DesignTimeProperties.ResolveDesignTimeReferenceStep(DesignTimeProperties.XNameProperty, platformMetadata);

            return((string)dependencyPropertyReferenceStep.GetValue(target));
        }
Example #15
0
        public override void Serialize()
        {
            IDocumentContext documentContext = this.TextSource.DocumentContext;
            IPlatformTypes   metadata        = this.ProxyPlatform.Metadata;
            DependencyPropertyReferenceStep propertyReferenceStep = DesignTimeProperties.ResolveDesignTimeReferenceStep(DesignTimeProperties.UpdateContextProperty, (IPlatformMetadata)metadata);

            switch (this.SerializationType)
            {
            case RichTextSerializationType.FlowDocument:
                this.richTextBox.SetValue(metadata.DefaultTypeResolver, (IProperty)propertyReferenceStep, (object)this.instanceDictionary);
                this.flowDocumentNode = (DocumentCompositeNode)documentContext.CreateNode(typeof(FlowDocument), (object)(FlowDocument)this.richTextBox.Document.PlatformSpecificObject);
                this.richTextBox.ClearValue((IProperty)propertyReferenceStep);
                break;

            case RichTextSerializationType.BlockCollection:
                this.richTextBox.SetValue(metadata.DefaultTypeResolver, (IProperty)propertyReferenceStep, (object)this.instanceDictionary);
                this.blockCollectionNode = documentContext.CreateNode(PlatformTypes.BlockCollection);
                foreach (IViewBlock viewBlock in (IEnumerable <IViewBlock>) this.richTextBox.BlockContainer.Blocks)
                {
                    IViewParagraph viewParagraph = viewBlock as IViewParagraph;
                    if (viewParagraph == null)
                    {
                        IViewTextRange textRange = this.ProxyPlatform.ViewTextObjectFactory.CreateTextRange(this.richTextBox.BlockContainer, viewBlock.ContentStart, viewBlock.ContentEnd);
                        viewParagraph = this.ProxyPlatform.ViewTextObjectFactory.CreateParagraph();
                        IViewRun run = this.ProxyPlatform.ViewTextObjectFactory.CreateRun();
                        run.Text = textRange.Text;
                        viewParagraph.Inlines.Add((IViewInline)run);
                    }
                    this.blockCollectionNode.Children.Add(this.PostProcessDocumentNodeFromEditProxy(this.TextSource.ViewModel.DefaultView.ConvertFromWpfValueAsDocumentNode(viewParagraph.PlatformSpecificObject)));
                }
                this.richTextBox.ClearValue((IProperty)propertyReferenceStep);
                break;

            case RichTextSerializationType.InlineCollection:
                this.inlinesCollectionNode = documentContext.CreateNode(PlatformTypes.InlineCollection);
                using (IEnumerator <IViewBlock> enumerator = this.richTextBox.Document.Blocks.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        IViewBlock     current       = enumerator.Current;
                        IViewParagraph viewParagraph = current as IViewParagraph;
                        if (viewParagraph != null)
                        {
                            this.ProcessInlinesForSerialization(viewParagraph.Inlines);
                            if (current.PlatformSpecificObject != ((FlowDocument)this.richTextBox.Document.PlatformSpecificObject).Blocks.LastBlock)
                            {
                                this.inlinesCollectionNode.Children.Add(this.TextSource.ViewModel.DefaultView.ConvertFromWpfValueAsDocumentNode((object)new LineBreak()));
                            }
                        }
                        else
                        {
                            Microsoft.Expression.DesignModel.DocumentModel.DocumentNode documentNode = this.TextSource.ViewModel.DefaultView.ConvertFromWpfValueAsDocumentNode((object)new Run(new TextRange(((TextElement)current.PlatformSpecificObject).ContentStart, ((TextElement)current.PlatformSpecificObject).ContentEnd).Text));
                            if (documentNode != null)
                            {
                                this.inlinesCollectionNode.Children.Add(documentNode);
                            }
                        }
                    }
                    break;
                }
            }
        }