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); } } } } }
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); }
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(); }
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(); }
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 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); }
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); }