protected override DocumentNode CreateValue(BaseFrameworkElement source) { object tileBrush = this.CreateTileBrush(source); if (tileBrush == null) { return((DocumentNode)null); } ITypeResolver typeResolver = (ITypeResolver)source.ProjectContext; IViewObject visual = source.Visual; if (visual != null) { object platformSpecificObject = visual.PlatformSpecificObject; if (platformSpecificObject != null && PlatformTypes.Image.IsAssignableFrom((ITypeId)visual.GetIType((ITypeResolver)this.SceneViewModel.ProjectContext))) { ReferenceStep referenceStep = typeResolver.ResolveProperty(TileBrushNode.StretchProperty) as ReferenceStep; object obj = referenceStep.GetValue(tileBrush); object valueToSet = (typeResolver.ResolveProperty(ImageElement.StretchProperty) as ReferenceStep).GetValue(platformSpecificObject); if (!obj.Equals(valueToSet)) { referenceStep.SetValue(tileBrush, valueToSet); } } } return(this.SceneViewModel.Document.DocumentContext.CreateNode(typeResolver.ResolveType(PlatformTypes.TileBrush).RuntimeType, tileBrush)); }
private object ConvertImageBrush(object value, object result, ITypeResolver sourceTypeResolver, ITypeResolver targetTypeResolver) { ReferenceStep referenceStep1 = (ReferenceStep)sourceTypeResolver.ResolveProperty(TileBrushNode.StretchProperty); ReferenceStep referenceStep2 = (ReferenceStep)targetTypeResolver.ResolveProperty(TileBrushNode.StretchProperty); object valueToSet1 = this.ConvertInternalFast(referenceStep1.GetValue(value), sourceTypeResolver, targetTypeResolver); referenceStep2.SetValue(result, valueToSet1); object objToInspect = ((ReferenceStep)sourceTypeResolver.ResolveProperty(ImageBrushNode.ImageSourceProperty)).GetValue(value); if (!PlatformTypes.IsInstance(objToInspect, PlatformTypes.BitmapImage, sourceTypeResolver)) { return(result); } object obj1 = ((ReferenceStep)sourceTypeResolver.ResolveProperty(BitmapImageNode.UriSourceProperty)).GetValue(objToInspect); if (obj1 == null) { return(result); } Type type1 = obj1.GetType(); IType type2 = targetTypeResolver.ResolveType(PlatformTypes.Uri); string text = Microsoft.Expression.DesignModel.Metadata.MetadataStore.GetTypeConverter(type1).ConvertToInvariantString(obj1); if (string.IsNullOrEmpty(text)) { return(result); } object valueToSet2 = Microsoft.Expression.DesignModel.Metadata.MetadataStore.GetTypeConverter(type2.RuntimeType).ConvertFromInvariantString(text); ReferenceStep referenceStep3 = (ReferenceStep)targetTypeResolver.ResolveProperty(ImageBrushNode.ImageSourceProperty); object obj2 = InstanceBuilderOperations.InstantiateType(targetTypeResolver.ResolveType(PlatformTypes.BitmapImage).RuntimeType, true); referenceStep3.SetValue(result, obj2); try { BitmapImage bitmapImage = obj2 as BitmapImage; if (bitmapImage != null) { bitmapImage.BeginInit(); bitmapImage.CacheOption = BitmapCacheOption.OnLoad; } ((ReferenceStep)targetTypeResolver.ResolveProperty(BitmapImageNode.UriSourceProperty)).SetValue(obj2, valueToSet2); if (bitmapImage != null) { bitmapImage.EndInit(); } } catch (Exception ex) { result = (object)null; } return(result); }
public static PropertyReference ResolvePropertyPath(ITypeResolver typeResolver, IViewObject propertyPath, SceneNode pathRoot) { if (propertyPath == null) { return((PropertyReference)null); } string path = (string)propertyPath.GetCurrentValue(typeResolver.ResolveProperty(typeResolver.PlatformMetadata.KnownProperties.PropertyPathPath)); if (path == null) { return((PropertyReference)null); } IProperty propertyKey = typeResolver.ResolveProperty(typeResolver.PlatformMetadata.KnownProperties.PropertyPathPathParameters); Collection <object> parameters = propertyKey == null ? new Collection <object>() : (Collection <object>)propertyPath.GetCurrentValue(propertyKey); return(TimelineSceneNode.ResolvePropertyPathParts(typeResolver, path, parameters, pathRoot)); }
public GradientStopEditor(BrushEditor brushEditor, SceneNodeProperty basisProperty, int propertyIndex) : base(brushEditor, basisProperty) { ITypeResolver typeResolver = (ITypeResolver)basisProperty.SceneNodeObjectSet.ProjectContext; IType type = typeResolver.ResolveType(PlatformTypes.GradientStopCollection); if (type == null) { return; } IndexedClrPropertyReferenceStep referenceStep = IndexedClrPropertyReferenceStep.GetReferenceStep(typeResolver, type.RuntimeType, propertyIndex); PropertyReference propertyReference = basisProperty.Reference.Append((ReferenceStep)referenceStep); this.gradientStopProperty = basisProperty.SceneNodeObjectSet.CreateSceneNodeProperty(propertyReference, (AttributeCollection)null); ReferenceStep step1 = (ReferenceStep)typeResolver.ResolveProperty(GradientStopNode.ColorProperty); ReferenceStep step2 = (ReferenceStep)typeResolver.ResolveProperty(GradientStopNode.OffsetProperty); this.colorProperty = this.RequestUpdates(propertyReference.Append(step1), new PropertyChangedEventHandler(this.OnColorChanged)); this.offsetProperty = this.RequestUpdates(propertyReference.Append(step2), new PropertyChangedEventHandler(this.OnOffsetChanged)); this.propertyIndex = propertyIndex; }
private static void RestoreProperties(ITypeResolver typeResolver, IViewObject viewObject, IEnumerable <IPropertyId> storedProperties, Dictionary <IPropertyId, object> values) { foreach (IPropertyId propertyId in storedProperties) { IProperty propertyKey = typeResolver.ResolveProperty(propertyId); if (propertyKey != null) { object obj; if (values.TryGetValue((IPropertyId)propertyKey, out obj)) { viewObject.SetValue(typeResolver, propertyKey, obj); } else { viewObject.ClearValue(propertyKey); } } } }
public void UpdatePropertyContainers(TransformPropertyLookup propertyLookup) { AttributeCollection attributes = new AttributeCollection(new Attribute[2] { (Attribute) new NumberRangesAttribute(new double?(double.NegativeInfinity), new double?(0.0), new double?(1.0), new double?(double.PositiveInfinity), new bool?()), (Attribute) new NumberIncrementsAttribute(new double?(0.01), new double?(0.05), new double?(0.1)) }); ITypeResolver typeResolver = (ITypeResolver)propertyLookup.TransformProperty.SceneNodeObjectSet.ProjectContext; PropertyReference propertyReference = new PropertyReference(typeResolver.ResolveProperty(Base2DElement.RenderTransformOriginProperty) as ReferenceStep); ReferenceStep property1 = PlatformTypeHelper.GetProperty(typeResolver, PlatformTypes.Point, MemberType.LocalProperty, "X"); ReferenceStep property2 = PlatformTypeHelper.GetProperty(typeResolver, PlatformTypes.Point, MemberType.LocalProperty, "Y"); this.renderTransformOriginXProperty = propertyReference.Append(property1); this.renderTransformOriginYProperty = propertyReference.Append(property2); PropertyReference reference = propertyLookup.TransformProperty.Reference; if (reference.Count == 1 && reference.FirstStep.Equals((object)Base2DElement.RenderTransformProperty)) { if (propertyLookup.Relative) { this.CenterPointXEditor.PropertyEntry = (PropertyEntry)null; this.CenterPointYEditor.PropertyEntry = (PropertyEntry)null; } else { this.CenterPointXEditor.PropertyEntry = (PropertyEntry)propertyLookup.CreateNormalProperty(this.renderTransformOriginXProperty, attributes); this.CenterPointYEditor.PropertyEntry = (PropertyEntry)propertyLookup.CreateNormalProperty(this.renderTransformOriginYProperty, attributes); } } else { this.CenterPointXEditor.PropertyEntry = (PropertyEntry)propertyLookup.CreateProperty("CenterX", attributes); this.CenterPointYEditor.PropertyEntry = (PropertyEntry)propertyLookup.CreateProperty("CenterY", attributes); } if (propertyLookup.TransformType == TransformType.Transform3D) { this.CenterPointZEditor.PropertyEntry = (PropertyEntry)propertyLookup.CreateProperty("CenterZ", attributes); } else { this.CenterPointZEditor.PropertyEntry = (PropertyEntry)null; } }
public object GetCurrentValue(ITypeResolver typeResolver, IPropertyId propertyId) { return(this.GetCurrentValue(typeResolver.ResolveProperty(propertyId))); }
public void ClearValue(ITypeResolver typeResolver, IPropertyId propertyId) { this.ClearValue(typeResolver.ResolveProperty(propertyId)); }
public void SetValue(ITypeResolver typeResolver, IPropertyId propertyId, object value) { this.SetValue(typeResolver, typeResolver.ResolveProperty(propertyId), value); }
public bool IsSet(ITypeResolver typeResolver, IPropertyId propertyId) { return(this.IsSet(typeResolver.ResolveProperty(propertyId))); }
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); }
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; ITypeResolver typeResolver = (ITypeResolver)sceneNodeObjectSet.ProjectContext; ((PropertyEntry)this.editingProperty).get_PropertyType(); IPropertyId propertyId1; IPropertyId propertyId2; if (PlatformTypes.Vector.IsAssignableFrom((ITypeId)this.editingProperty.PropertyTypeId)) { propertyId1 = Point2DEditor.VectorXProperty; propertyId2 = Point2DEditor.VectorYProperty; } else if (PlatformTypes.Point.IsAssignableFrom((ITypeId)this.editingProperty.PropertyTypeId)) { propertyId1 = Point2DEditor.PointXProperty; propertyId2 = Point2DEditor.PointYProperty; } else { Type nullableType = PlatformTypeHelper.GetNullableType(((PropertyEntry)this.editingProperty).get_PropertyType()); if (nullableType == (Type)null) { return; } IType type = typeResolver.GetType(nullableType); if (PlatformTypes.Vector.IsAssignableFrom((ITypeId)type)) { propertyId1 = Point2DEditor.VectorXProperty; propertyId2 = Point2DEditor.VectorYProperty; } else { if (!PlatformTypes.Point.IsAssignableFrom((ITypeId)type)) { return; } propertyId1 = Point2DEditor.PointXProperty; propertyId2 = Point2DEditor.PointYProperty; } } ReferenceStep step1 = (ReferenceStep)typeResolver.ResolveProperty(propertyId1); ReferenceStep step2 = (ReferenceStep)typeResolver.ResolveProperty(propertyId2); this.xProperty = (PropertyReferenceProperty)sceneNodeObjectSet.CreateSceneNodeProperty(reference.Append(step1), step1.Attributes); this.yProperty = (PropertyReferenceProperty)sceneNodeObjectSet.CreateSceneNodeProperty(reference.Append(step2), step2.Attributes); this.XPropertyContainer.set_PropertyEntry((PropertyEntry)this.xProperty); this.YPropertyContainer.set_PropertyEntry((PropertyEntry)this.yProperty); ValueEditorParameters.OverrideValueEditorParameters(this.editingProperty, this.xProperty, "X"); ValueEditorParameters.OverrideValueEditorParameters(this.editingProperty, this.yProperty, "Y"); }