public static IndexedClrPropertyReferenceStep GetReferenceStep(ITypeResolver typeResolver, Type declaringType, int index, bool throwOnFailure)
        {
            Type[] typeArray = new Type[] { typeof(int) };
            string str       = "Item";

            System.Reflection.PropertyInfo property = declaringType.GetProperty(str, BindingFlags.Instance | BindingFlags.Public, null, null, typeArray, null);
            if (property == null)
            {
                if (typeof(IList).IsAssignableFrom(declaringType))
                {
                    property = typeof(IList).GetProperty(str, BindingFlags.Instance | BindingFlags.Public, null, null, typeArray, null);
                }
                if (property == null)
                {
                    if (throwOnFailure)
                    {
                        CultureInfo currentCulture = CultureInfo.CurrentCulture;
                        string      typeDoesNotDeclareAnIndexer = ExceptionStringTable.TypeDoesNotDeclareAnIndexer;
                        object[]    name = new object[] { declaringType.Name };
                        throw new ArgumentException(string.Format(currentCulture, typeDoesNotDeclareAnIndexer, name), "declaringType");
                    }
                    return(null);
                }
            }
            IType             type             = typeResolver.GetType(declaringType);
            IType             propertyTypeId   = PlatformTypeHelper.GetPropertyTypeId(typeResolver, property);
            IPlatformMetadata platformMetadata = typeResolver.PlatformMetadata;

            object[] objArray = new object[] { index };
            ClrPropertyImplementationBase localClrPropertyImplementation = new LocalClrPropertyImplementation(platformMetadata, property, null, objArray);

            return(new IndexedClrPropertyReferenceStep(type, str, propertyTypeId, localClrPropertyImplementation, index));
        }
        public IEnumerable <TriggerActionNode> GetActions()
        {
            DocumentCompositeNode compositeNode = this.DocumentNode as DocumentCompositeNode;

            if (compositeNode != null)
            {
                IPlatformMetadata metadata = compositeNode.TypeResolver.PlatformMetadata;
                if (compositeNode.Properties.Contains(metadata.ResolveProperty(TriggerBaseNode.EnterActionsProperty)))
                {
                    foreach (TriggerActionNode triggerActionNode in (IEnumerable <TriggerActionNode>) this.EnterActions)
                    {
                        yield return(triggerActionNode);
                    }
                }
                if (compositeNode.Properties.Contains(metadata.ResolveProperty(TriggerBaseNode.ExitActionsProperty)))
                {
                    foreach (TriggerActionNode triggerActionNode in (IEnumerable <TriggerActionNode>) this.ExitActions)
                    {
                        yield return(triggerActionNode);
                    }
                }
                if (compositeNode.Properties.Contains(metadata.ResolveProperty(EventTriggerNode.ActionsProperty)))
                {
                    EventTriggerNode eventTrigger = this as EventTriggerNode;
                    if (eventTrigger != null)
                    {
                        foreach (TriggerActionNode triggerActionNode in (IEnumerable <SceneNode>)eventTrigger.Actions)
                        {
                            yield return(triggerActionNode);
                        }
                    }
                }
            }
        }
Exemple #3
0
        public GradientBrushEditor(BrushEditor brushEditor, ITypeId brushType, SceneNodeProperty basisProperty)
            : base(brushEditor, basisProperty)
        {
            IPlatformMetadata platformMetadata = basisProperty.SceneNodeObjectSet.DocumentContext.TypeResolver.PlatformMetadata;

            if (PlatformTypes.LinearGradientBrush.Equals((object)brushType))
            {
                this.brushCategory = BrushCategory.LinearGradient;
            }
            else if (PlatformTypes.RadialGradientBrush.Equals((object)brushType))
            {
                this.brushCategory = BrushCategory.RadialGradient;
            }
            this.editorTemplate            = new DataTemplate();
            this.editorTemplate.VisualTree = new FrameworkElementFactory(typeof(GradientBrushEditorControl));
            this.gradientStopsProperty     = this.RegisterProperty(GradientBrushNode.GradientStopsProperty, (PropertyChangedEventHandler)null);
            this.gradientStopsProperty.PropertyReferenceChanged += new Microsoft.Expression.DesignSurface.Documents.PropertyReferenceChangedEventHandler(this.OnGradientStopsChange);
            basisProperty.SceneNodeObjectSet.DesignerContext.GradientToolSelectionService.PropertyChanged += new PropertyChangedEventHandler(this.OnGradientStopSelectionChange);
            this.gradientStops           = new ObservableCollection <GradientStopEditor>();
            this.gradientStopsView       = (ListCollectionView)CollectionViewSource.GetDefaultView((object)this.gradientStops);
            this.sortedGradientStopsView = new ListCollectionView((IList)this.gradientStops);
            this.sortedGradientStopsView.SortDescriptions.Add(new SortDescription("Offset", ListSortDirection.Ascending));
            this.sortedGradientStopsView.SortDescriptions.Add(new SortDescription("PropertyIndex", ListSortDirection.Ascending));
            this.gradientStops.CollectionChanged  += new NotifyCollectionChangedEventHandler(this.OnGradientStopsChanged);
            this.gradientStopsView.CurrentChanged += new EventHandler(this.OnCurrentStopChanged);
            this.RebuildAdvancedProperties();
            this.RebuildModel(-1);
        }
Exemple #4
0
        private void ApplyEyedropperTextElement(BaseTextElement textElement)
        {
            PropertyManager   propertyManager   = (PropertyManager)this.ToolBehaviorContext.PropertyManager;
            IPlatform         platform          = this.ActiveDocument.ProjectContext.Platform;
            IPlatformMetadata platformMetadata  = (IPlatformMetadata)platform.Metadata;
            Artboard          artboard          = this.ActiveView.Artboard;
            Matrix            matrix            = artboard.CalculateTransformFromArtboardToContent().Value;
            Matrix            transformFromRoot = this.ActiveView.GetComputedTransformFromRoot((SceneElement)textElement);
            Point             position          = this.MouseDevice.GetPosition((IInputElement)artboard);
            Point             point1            = matrix.Transform(position);
            Point             point2            = transformFromRoot.Transform(point1);

            this.EnsureEditTransaction();
            foreach (IPropertyId propertyId in PropertyToolBehavior.PropertyList)
            {
                ReferenceStep singleStep = platformMetadata.ResolveProperty(propertyId) as ReferenceStep;
                if (singleStep != null && singleStep.PropertyType.PlatformMetadata == platform.Metadata)
                {
                    PropertyReference propertyReference1 = new PropertyReference(singleStep);
                    PropertyReference propertyReference2 = propertyManager.FilterProperty((SceneNode)textElement, propertyReference1);
                    if (propertyReference2 != null)
                    {
                        object textValueAtPoint = textElement.GetTextValueAtPoint(point2, true, propertyReference2);
                        propertyManager.SetValue(propertyReference2, textValueAtPoint);
                    }
                }
            }
            this.UpdateEditTransaction();
        }
Exemple #5
0
        private void ApplyEyedropperSceneElement(SceneElement hitElement)
        {
            PropertyManager   propertyManager  = (PropertyManager)this.ToolBehaviorContext.PropertyManager;
            IPlatform         platform         = this.ActiveDocument.ProjectContext.Platform;
            IPlatformMetadata platformMetadata = (IPlatformMetadata)platform.Metadata;

            this.EnsureEditTransaction();
            foreach (IPropertyId propertyId in PropertyToolBehavior.PropertyList)
            {
                ReferenceStep singleStep = platformMetadata.ResolveProperty(propertyId) as ReferenceStep;
                if (singleStep != null && singleStep.PropertyType.PlatformMetadata == platform.Metadata)
                {
                    PropertyReference propertyReference1 = new PropertyReference(singleStep);
                    PropertyReference propertyReference2 = propertyManager.FilterProperty((SceneNode)hitElement, propertyReference1);
                    if (propertyReference2 != null)
                    {
                        object second        = propertyManager.GetValue(propertyReference2);
                        object computedValue = hitElement.GetComputedValue(propertyReference2);
                        if (computedValue != MixedProperty.Mixed && !PropertyUtilities.Compare(computedValue, second, hitElement.ViewModel.DefaultView))
                        {
                            propertyManager.SetValue(propertyReference2, computedValue);
                        }
                    }
                }
            }
            this.UpdateEditTransaction();
        }
        public AttachedClrPropertyImplementation(IPlatformMetadata platformMetadata, string name, MethodInfo getMethod, MethodInfo setMethod) : base(platformMetadata)
        {
            Type valueType;
            Type type;

            if (getMethod == null && setMethod == null)
            {
                throw new ArgumentNullException();
            }
            this.name      = name;
            this.getMethod = getMethod;
            this.setMethod = setMethod;
            if (this.getMethod == null)
            {
                ParameterInfo[] parameters = this.setMethod.GetParameters();
                valueType = PlatformTypeHelper.GetValueType(parameters[0]);
                type      = PlatformTypeHelper.GetValueType(parameters[1]);
            }
            else
            {
                valueType = PlatformTypeHelper.GetValueType(this.getMethod.GetParameters()[0]);
                type      = PlatformTypeHelper.GetValueType(this.getMethod);
            }
            this.targetType = (valueType != null ? valueType : typeof(DependencyObject));
            this.valueType  = (type != null ? type : typeof(object));
            this.isResolved = type != null;
        }
 public PlatformTypesValidationExtension(IPlatformMetadata platformMetadata)
 {
     this.platformMetadata = platformMetadata;
     this.collectionTypes  = new List <Type>((int)PlatformTypesValidationExtension.CollectionTypes.Length);
     for (int i = 0; i < (int)PlatformTypesValidationExtension.CollectionTypes.Length; i++)
     {
         Type runtimeType = platformMetadata.ResolveType(PlatformTypesValidationExtension.CollectionTypes[i]).RuntimeType;
         if (runtimeType != null)
         {
             this.collectionTypes.Add(runtimeType);
         }
     }
     this.objectTypes = new List <Type>((int)PlatformTypesValidationExtension.ObjectTypes.Length);
     for (int j = 0; j < (int)PlatformTypesValidationExtension.ObjectTypes.Length; j++)
     {
         Type type = platformMetadata.ResolveType(PlatformTypesValidationExtension.ObjectTypes[j]).RuntimeType;
         if (type != null)
         {
             this.objectTypes.Add(type);
         }
     }
     this.replacementCollectionType = this.platformMetadata.ResolveType(PlatformTypes.ObservableCollection).RuntimeType;
     this.baseCollectionType        = this.platformMetadata.ResolveType(PlatformTypes.IList).RuntimeType;
     this.objectType = this.platformMetadata.ResolveType(PlatformTypes.Object).RuntimeType;
 }
Exemple #8
0
        private IProperty ConvertPropertyKey(IProperty propertyKey, IPlatformMetadata targetPlatformMetadata)
        {
            ITypeId typeId = (ITypeId)propertyKey.DeclaringType;

            if (typeId.Equals((object)PlatformTypes.TextElement))
            {
                typeId = PlatformTypes.Inline;
            }
            ITypeId   type      = (ITypeId)PlatformTypeHelper.ConvertTypeId(typeId, targetPlatformMetadata);
            IProperty property1 = type.GetMember(propertyKey.MemberType, propertyKey.Name, (MemberAccessTypes)(propertyKey.ReadAccess | propertyKey.WriteAccess)) as IProperty;

            if (property1 == null && targetPlatformMetadata.IsCapabilitySet(PlatformCapability.SupportsProxyProperties))
            {
                IEnumerable <IProperty> proxyProperties = targetPlatformMetadata.GetProxyProperties(this.StandaloneWpfDocumentContext.TypeResolver);
                if (proxyProperties != null)
                {
                    string name = propertyKey.Name;
                    foreach (IProperty property2 in proxyProperties)
                    {
                        if (name == property2.Name && property2.DeclaringType.IsAssignableFrom(type))
                        {
                            property1 = property2;
                            break;
                        }
                    }
                }
            }
            return(property1);
        }
Exemple #9
0
        public static DocumentCompositeNode GetStyleSetter(DocumentCompositeNode styleNode, IPropertyId property)
        {
            DocumentCompositeNode documentCompositeNode;

            if (styleNode != null && property != null)
            {
                IPlatformMetadata     platformMetadata = styleNode.Context.TypeResolver.PlatformMetadata;
                IProperty             property1        = styleNode.Context.TypeResolver.ResolveProperty(property);
                DocumentCompositeNode item             = styleNode.Properties[platformMetadata.KnownProperties.StyleSetters] as DocumentCompositeNode;
                if (item != null && item.SupportsChildren && property1 != null)
                {
                    using (IEnumerator <DocumentNode> enumerator = item.Children.GetEnumerator())
                    {
                        while (enumerator.MoveNext())
                        {
                            DocumentCompositeNode current = enumerator.Current as DocumentCompositeNode;
                            if (current == null)
                            {
                                continue;
                            }
                            IMemberId valueAsMember = DocumentNodeHelper.GetValueAsMember(current, KnownProperties.SetterPropertyProperty);
                            if (valueAsMember == null || !property1.Equals(valueAsMember))
                            {
                                continue;
                            }
                            documentCompositeNode = current;
                            return(documentCompositeNode);
                        }
                        return(null);
                    }
                    return(documentCompositeNode);
                }
            }
            return(null);
        }
Exemple #10
0
        public static IType GetStyleOrTemplateTypeAndTargetType(DocumentNode node, out IType styleOrTemplateType)
        {
            IPlatformMetadata   platformMetadata   = node.TypeResolver.PlatformMetadata;
            ITargetTypeMetadata targetTypeMetadata = node.Type.Metadata as ITargetTypeMetadata;

            if (platformMetadata.KnownTypes.Style.IsAssignableFrom((ITypeId)node.Type))
            {
                styleOrTemplateType = node.TypeResolver.ResolveType(platformMetadata.KnownTypes.Style);
                IType type1 = DocumentNodeHelper.GetValueAsMember(node as DocumentCompositeNode, targetTypeMetadata.TargetTypeProperty) as IType;
                if (type1 == null)
                {
                    IType type2 = node.TypeResolver.ResolveType(platformMetadata.KnownTypes.IFrameworkInputElement);
                    type1 = !platformMetadata.IsNullType((ITypeId)type2) ? type2 : (IType)null;
                }
                return(type1);
            }
            if (platformMetadata.KnownTypes.DataTemplate.IsAssignableFrom((ITypeId)node.Type))
            {
                styleOrTemplateType = node.TypeResolver.ResolveType(platformMetadata.KnownTypes.DataTemplate);
                return(node.TypeResolver.ResolveType(platformMetadata.KnownTypes.ContentPresenter));
            }
            if (platformMetadata.KnownTypes.ControlTemplate.IsAssignableFrom((ITypeId)node.Type))
            {
                styleOrTemplateType = node.TypeResolver.ResolveType(platformMetadata.KnownTypes.ControlTemplate);
                return(DocumentNodeHelper.GetValueAsMember(node as DocumentCompositeNode, targetTypeMetadata.TargetTypeProperty) as IType ?? node.TypeResolver.ResolveType(platformMetadata.KnownTypes.Control));
            }
            if (platformMetadata.KnownTypes.FrameworkTemplate.IsAssignableFrom((ITypeId)node.Type))
            {
                styleOrTemplateType = node.TypeResolver.ResolveType(platformMetadata.KnownTypes.FrameworkTemplate);
                return(node.TypeResolver.ResolveType(platformMetadata.KnownTypes.FrameworkElement));
            }
            styleOrTemplateType = (IType)null;
            return((IType)null);
        }
Exemple #11
0
 internal static IMember AddMemberIfPossible(IPlatformMetadata platformMetadata, IType typeId, MemberType memberType, string memberName)
 {
     if (!typeId.IsResolvable)
     {
         return(platformMetadata.CreateUnknownMember(typeId, memberType, memberName));
     }
     return((IMember)null);
 }
 public LocalClrPropertyImplementation(IPlatformMetadata platformMetadata, System.Reflection.PropertyInfo propertyInfo, Type declaringType, object[] indexParameters) : base(platformMetadata)
 {
     this.declaringType   = declaringType ?? propertyInfo.DeclaringType;
     this.propertyInfo    = propertyInfo;
     this.getMethod       = this.propertyInfo.GetGetMethod(true);
     this.setMethod       = this.propertyInfo.GetSetMethod(true);
     this.indexParameters = indexParameters;
     this.isResolved      = PlatformTypeHelper.GetPropertyType(this.propertyInfo) != null;
 }
Exemple #13
0
        internal static CanAssignResult CanAssignTo(ITypeResolver typeResolver, ITypeId destinationTypeId, ITypeId sourceTypeId)
        {
            IPlatformMetadata platformMetadata = typeResolver.PlatformMetadata;
            IType             type1            = typeResolver.ResolveType(destinationTypeId);
            IType             type2            = typeResolver.ResolveType(sourceTypeId);

            if (platformMetadata.KnownTypes.NullExtension.IsAssignableFrom((ITypeId)type2))
            {
                return(!type1.SupportsNullValues ? CanAssignResult.NotNullable : CanAssignResult.CanAssign);
            }
            if (type2 == type1)
            {
                return(CanAssignResult.CanAssign);
            }
            if (platformMetadata.KnownTypes.ArrayExtension.IsAssignableFrom((ITypeId)type2))
            {
                if (type1.IsArray)
                {
                    return(CanAssignResult.CanAssign);
                }
                System.Type runtimeType = type1.RuntimeType;
                if (runtimeType == (System.Type)null)
                {
                    return(CanAssignResult.Unknown);
                }
                if (runtimeType.IsAssignableFrom(typeof(Array)))
                {
                    return(CanAssignResult.CanAssign);
                }
            }
            else
            {
                if (type2.IsExpression)
                {
                    return(CanAssignResult.Expression);
                }
                if (platformMetadata.KnownTypes.XData.Equals((object)type2))
                {
                    return(type1.Metadata.SupportsInlineXml ? CanAssignResult.CanAssign : CanAssignResult.NotXmlSerializable);
                }
                System.Type runtimeType1 = type2.RuntimeType;
                System.Type runtimeType2 = type1.RuntimeType;
                if (runtimeType2 == (System.Type)null || runtimeType1 == (System.Type)null)
                {
                    return(CanAssignResult.Unknown);
                }
                if (platformMetadata.KnownTypes.Expression.IsAssignableFrom((ITypeId)type2))
                {
                    return(CanAssignResult.Expression);
                }
                if (runtimeType2.IsAssignableFrom(runtimeType1))
                {
                    return(CanAssignResult.CanAssign);
                }
            }
            return(CanAssignResult.CannotAssign);
        }
 public CollectionGenerator(IPlatformMetadata platformMetadata, BuildingTypeInfo typeInfo)
 {
     this.platformMetadata         = platformMetadata;
     this.typeInfo                 = typeInfo;
     this.designType               = (TypeBuilder)typeInfo.DesignType;
     this.sourceType               = typeInfo.SourceType;
     this.ctorGenerator            = ((ConstructorBuilder)typeInfo.Constructor).GetILGenerator();
     this.observableCollectionType = this.platformMetadata.ResolveType(PlatformTypes.ObservableCollection).RuntimeType;
 }
Exemple #15
0
        public static DocumentCompositeNode NewStaticNode(IDocumentContext documentContext, IMember memberId)
        {
            IPlatformMetadata     platformMetadata = documentContext.TypeResolver.PlatformMetadata;
            DocumentCompositeNode node             = documentContext.CreateNode((ITypeId)documentContext.TypeResolver.ResolveType(platformMetadata.KnownTypes.StaticExtension));
            DocumentNode          documentNode     = (DocumentNode)documentContext.CreateNode(memberId.MemberTypeId, (IDocumentNodeValue) new DocumentNodeMemberValue(memberId));

            node.Properties[platformMetadata.KnownProperties.StaticExtensionMember] = documentNode;
            return(node);
        }
Exemple #16
0
 public DocumentPropertyContentReference(IPlatformMetadata platformMetadata, IDocumentNodeReference parent, IProperty property)
 {
     this.parent   = parent;
     this.property = property;
     if (!platformMetadata.GetIsTypeItsOwnNameScope((ITypeId)this.property.PropertyType))
     {
         return;
     }
     this.nameScope = new DocumentNodeNameScope();
 }
        public static IType ConvertTypeId(ITypeId typeId, IPlatformMetadata targetPlatform)
        {
            IType type = typeId as IType;

            if (type != null && targetPlatform == type.PlatformMetadata)
            {
                return(type);
            }
            return(((PlatformTypes)targetPlatform).GetPlatformType(typeId.FullName));
        }
Exemple #18
0
        public static IProperty GetProperty(string name, IPlatformMetadata platformMetadata)
        {
            XamlProcessingAttributes.Initialize(platformMetadata);
            IPropertyId propertyId;

            if (!XamlProcessingAttributes.properties.TryGetValue(name, out propertyId))
            {
                return((IProperty)null);
            }
            return(platformMetadata.ResolveProperty(propertyId));
        }
        private DataViewTemplateEntry GetOrCreateTemplateEntry(IPlatformMetadata platformMetadata, string typeName)
        {
            IType platformType = ((IPlatformTypes)platformMetadata).GetPlatformType(typeName);
            DataViewTemplateEntry viewTemplateEntry = this.TemplateEntries.Find((Predicate <DataViewTemplateEntry>)(t => t.DataType == platformType));

            if (viewTemplateEntry == null)
            {
                viewTemplateEntry = new DataViewTemplateEntry((ITypeId)platformType);
                this.TemplateEntries.Add(viewTemplateEntry);
            }
            return(viewTemplateEntry);
        }
        public ReferenceStep GetTargetProperty(ITypeId resourceTypeId)
        {
            IPlatformMetadata platformMetadata = (IPlatformMetadata)this.ViewModel.ProjectContext.Platform.Metadata;

            if (PlatformTypes.Style.IsAssignableFrom(resourceTypeId))
            {
                return(platformMetadata.ResolveProperty(BaseFrameworkElement.StyleProperty) as ReferenceStep);
            }
            if (PlatformTypes.Page.IsAssignableFrom((ITypeId)this.TargetElement.Type))
            {
                return(platformMetadata.ResolveProperty(PageElement.TemplateProperty) as ReferenceStep);
            }
            return(this.ViewModel.ProjectContext.ResolveProperty(ControlElement.TemplateProperty) as ReferenceStep);
        }
Exemple #21
0
 private static void Initialize(IPlatformMetadata platformMetadata)
 {
     if (XamlProcessingAttributes.isInitialized)
     {
         return;
     }
     XamlProcessingAttributes.isInitialized = true;
     XamlProcessingAttributes.AddProperty(platformMetadata.KnownProperties.DesignTimeXName);
     XamlProcessingAttributes.AddProperty(platformMetadata.KnownProperties.DictionaryEntryKey);
     XamlProcessingAttributes.AddProperty(platformMetadata.KnownProperties.DesignTimeShared);
     XamlProcessingAttributes.AddProperty(platformMetadata.KnownProperties.DesignTimeUid);
     XamlProcessingAttributes.AddProperty(platformMetadata.KnownProperties.DesignTimeClass);
     XamlProcessingAttributes.AddProperty(platformMetadata.KnownProperties.DesignTimeSubclass);
     XamlProcessingAttributes.AddProperty(platformMetadata.KnownProperties.DesignTimeClassModifier);
     XamlProcessingAttributes.AddProperty(platformMetadata.KnownProperties.DesignTimeFieldModifier);
 }
Exemple #22
0
 protected static int ComparePlatforms(IPlatformMetadata thisPlatform, IPlatformMetadata otherPlatform)
 {
     if (thisPlatform == otherPlatform)
     {
         return(0);
     }
     if (thisPlatform == null)
     {
         return(-1);
     }
     if (otherPlatform == null)
     {
         return(1);
     }
     return(string.CompareOrdinal((string)thisPlatform.GetCapabilityValue(PlatformCapability.PlatformSimpleName), (string)otherPlatform.GetCapabilityValue(PlatformCapability.PlatformSimpleName)));
 }
        public static DesignTypeResult GetTypeToInstantiate(IPlatformMetadata platformMetadata, Type sourceType, bool createList, bool isDesignTimeCreatable)
        {
            Type designType = sourceType;
            DesignTypeGenerator designTypeGenerator = new DesignTypeGenerator(platformMetadata);

            if (!isDesignTimeCreatable)
            {
                DesignTypeResult designTypeResult = designTypeGenerator.GetDesignType(sourceType);
                if (designTypeResult.IsFailed)
                {
                    return(designTypeResult);
                }
                designType = designTypeResult.DesignType;
            }
            if (!(designType != null) || !createList)
            {
                return(new DesignTypeResult(sourceType, designType));
            }
            return(designTypeGenerator.GetXamlFriendlyListType(designType));
        }
Exemple #24
0
        private void Rebuild()
        {
            PropertyValue             propertyValue     = this.DataContext as PropertyValue;
            PropertyReferenceProperty referenceProperty = (PropertyReferenceProperty)null;

            if (propertyValue != null)
            {
                referenceProperty = (PropertyReferenceProperty)propertyValue.get_ParentProperty();
            }
            if (referenceProperty == this.editingProperty)
            {
                return;
            }
            this.Unhook();
            this.editingProperty = referenceProperty;
            if (this.editingProperty == null)
            {
                return;
            }
            PropertyReference  reference          = this.editingProperty.Reference;
            SceneNodeObjectSet sceneNodeObjectSet = (SceneNodeObjectSet)this.editingProperty.ObjectSet;
            IPlatformMetadata  platformMetadata   = reference.PlatformMetadata;
            ReferenceStep      step1 = (ReferenceStep)platformMetadata.ResolveProperty(ThicknessNode.TopProperty);
            ReferenceStep      step2 = (ReferenceStep)platformMetadata.ResolveProperty(ThicknessNode.LeftProperty);
            ReferenceStep      step3 = (ReferenceStep)platformMetadata.ResolveProperty(ThicknessNode.RightProperty);
            ReferenceStep      step4 = (ReferenceStep)platformMetadata.ResolveProperty(ThicknessNode.BottomProperty);
            Type runtimeType         = platformMetadata.ResolveType(PlatformTypes.Thickness).RuntimeType;

            this.top    = (PropertyReferenceProperty)sceneNodeObjectSet.CreateSceneNodeProperty(reference.Append(step1), step1.Attributes);
            this.left   = (PropertyReferenceProperty)sceneNodeObjectSet.CreateSceneNodeProperty(reference.Append(step2), step2.Attributes);
            this.right  = (PropertyReferenceProperty)sceneNodeObjectSet.CreateSceneNodeProperty(reference.Append(step3), step3.Attributes);
            this.bottom = (PropertyReferenceProperty)sceneNodeObjectSet.CreateSceneNodeProperty(reference.Append(step4), step4.Attributes);
            ValueEditorParameters.OverrideValueEditorParameters(this.editingProperty, this.left, "Left");
            ValueEditorParameters.OverrideValueEditorParameters(this.editingProperty, this.top, "Top");
            ValueEditorParameters.OverrideValueEditorParameters(this.editingProperty, this.right, "Right");
            ValueEditorParameters.OverrideValueEditorParameters(this.editingProperty, this.bottom, "Bottom");
            this.TopPropertyContainer.set_PropertyEntry((PropertyEntry)this.top);
            this.LeftPropertyContainer.set_PropertyEntry((PropertyEntry)this.left);
            this.RightPropertyContainer.set_PropertyEntry((PropertyEntry)this.right);
            this.BottomPropertyContainer.set_PropertyEntry((PropertyEntry)this.bottom);
        }
Exemple #25
0
        private static string GetNameFromNearestNonEmptyContentPropertyAttribute(IPlatformMetadata platformMetadata, Type type, out bool anySkipped)
        {
            anySkipped = false;
            IType         type1              = platformMetadata.ResolveType(PlatformTypes.ContentPropertyAttribute);
            ReferenceStep member             = (ReferenceStep)type1.GetMember(MemberType.Property, "Name", MemberAccessTypes.Public);
            string        valueFromAttribute = ClrObjectMetadata.GetValueFromAttribute(type1, member, type, true) as string;

            if (!string.IsNullOrEmpty(valueFromAttribute))
            {
                return(valueFromAttribute);
            }
            while (type != null)
            {
                valueFromAttribute = ClrObjectMetadata.GetValueFromAttribute(type1, member, type, false) as string;
                if (!string.IsNullOrEmpty(valueFromAttribute))
                {
                    anySkipped = true;
                    return(valueFromAttribute);
                }
                type = type.BaseType;
            }
            return(null);
        }
Exemple #26
0
 private static bool IsComplexProperty(IPlatformMetadata platformMetadata, IProperty property)
 {
     return(property.Equals((object)RichTextBoxRangeElement.TextElementForegroundProperty) || property.Equals((object)RichTextBoxRangeElement.TextElementBackgroundProperty) || property.Equals((object)RichTextBoxRangeElement.PaddingPropertyId) || !platformMetadata.IsCapabilitySet(PlatformCapability.SupportsTextElementProperties) && (property.Equals((object)RichTextBoxRangeElement.ForegroundProperty) || property.Equals((object)RichTextBoxRangeElement.BackgroundProperty)));
 }
Exemple #27
0
        private PropertyReference ConvertToPlatformPropertyReference(PropertyReference propertyReference)
        {
            IPlatformMetadata destinationPlatformMetadata = (IPlatformMetadata)this.TextRange.Platform.Metadata;

            return(this.DesignerContext.PlatformConverter.ConvertFromWpfPropertyReference(this.ConvertToWpfPropertyReference(propertyReference), destinationPlatformMetadata));
        }
Exemple #28
0
        public bool Instantiate(IInstanceBuilderContext context, ViewNode viewNode)
        {
            DocumentNode          documentNode          = viewNode.DocumentNode;
            DocumentCompositeNode documentCompositeNode = documentNode as DocumentCompositeNode;
            bool flag = false;

            if (!PlatformTypes.FrameworkElement.IsAssignableFrom(viewNode.Type))
            {
                if (documentCompositeNode != null && documentCompositeNode.SupportsChildren && documentCompositeNode.Children.Count > 0)
                {
                    IList listAdapter = InstanceBuilderOperations.GetListAdapter(viewNode.Instance);
                    if (listAdapter != null)
                    {
                        listAdapter.Clear();
                    }
                }
                flag = true;
                viewNode.Instance = null;
            }
            else
            {
                IPlatformMetadata platformMetadata = documentNode.TypeResolver.PlatformMetadata;
                if (!context.IsSerializationScope)
                {
                    try
                    {
                        ViewNode            viewNode1           = viewNode;
                        FallbackControlType fallbackControlType = default(FallbackControlType);
                        viewNode1.Instance = (fallbackControlType == null ? Activator.CreateInstance <FallbackControlType>() : default(FallbackControlType));
                    }
                    catch (Exception exception)
                    {
                        viewNode.Instance = null;
                        flag = true;
                    }
                }
                else
                {
                    DocumentCompositeNode documentCompositeNode1 = context.DocumentContext.CreateNode(typeof(FallbackControlType));
                    ViewNodeId            id = context.SerializationContext.GetId(viewNode);
                    documentCompositeNode1.Properties[DesignTimeProperties.ViewNodeIdProperty] = context.DocumentContext.CreateNode(typeof(string), ViewNodeManager.ViewNodeIdConverter.ConvertToInvariantString(id));
                    viewNode.Instance = documentCompositeNode1;
                }
                if (viewNode.Instance != null && documentCompositeNode != null)
                {
                    if (documentCompositeNode != null)
                    {
                        DocumentNode exceptionSource = context.ExceptionDictionary.GetExceptionSource(viewNode);
                        Type         runtimeType     = documentNode.TypeResolver.ResolveType(PlatformTypes.FrameworkElement).RuntimeType;
                        foreach (IProperty property in context.GetProperties(viewNode))
                        {
                            try
                            {
                                ViewNode viewNode2 = InstanceBuilderOperations.UpdatePropertyWithoutApply(context, viewNode, property, documentCompositeNode.Properties[property]);
                                if (viewNode2 != null && viewNode2.Instance != null && viewNode2.DocumentNode != exceptionSource)
                                {
                                    Type          type          = (context.IsSerializationScope ? ((DocumentNode)viewNode2.Instance).TargetType : viewNode2.Instance.GetType());
                                    ReferenceStep referenceStep = property as ReferenceStep;
                                    if (referenceStep != null && referenceStep.TargetType.IsAssignableFrom(runtimeType) && PlatformTypeHelper.GetPropertyType(referenceStep).IsAssignableFrom(type))
                                    {
                                        InstanceBuilderOperations.SetValue(viewNode.Instance, referenceStep, viewNode2.Instance);
                                    }
                                }
                            }
                            catch
                            {
                            }
                        }
                    }
                    IProperty property1 = platformMetadata.ResolveProperty(KnownProperties.FrameworkElementMinWidthProperty);
                    InstanceBuilderOperations.SetValue(viewNode.Instance, property1, FallbackInstanceBuilder <FallbackControlType> .MinSize(context));
                    IProperty property2 = platformMetadata.ResolveProperty(KnownProperties.FrameworkElementMinHeightProperty);
                    InstanceBuilderOperations.SetValue(viewNode.Instance, property2, FallbackInstanceBuilder <FallbackControlType> .MinSize(context));
                }
            }
            if (flag)
            {
                viewNode.Instance = ClrObjectInstanceBuilder.InvalidObjectSentinel;
            }
            viewNode.InstanceState = InstanceState.Valid;
            return(true);
        }
Exemple #29
0
 public ShadowPropertyType(IPlatformMetadata platformMetadata, Type type)
 {
     this.platformMetadata = platformMetadata;
     this.type             = type;
 }
 protected ClrPropertyImplementationBase(IPlatformMetadata platformMetadata)
 {
     this.platformMetadata = platformMetadata;
 }