protected override DocumentNode ProvideValue(out IList <DocumentCompositeNode> auxillaryResources) { auxillaryResources = (IList <DocumentCompositeNode>)null; FrameworkTemplateElement frameworkTemplateElement = (FrameworkTemplateElement)this.SceneViewModel.CreateSceneNode((ITypeId)this.TargetProperty.PropertyType); if (ControlStylingOperations.DoesPropertyAffectRoot((IPropertyId)this.TargetProperty)) { ControlTemplateElement controlTemplateElement = frameworkTemplateElement as ControlTemplateElement; if (controlTemplateElement != null) { controlTemplateElement.ControlTemplateTargetTypeId = (ITypeId)this.Type; } } BaseFrameworkElement frameworkElement = !PlatformTypes.ItemsPanelTemplate.Equals((object)frameworkTemplateElement.Type) ? (BaseFrameworkElement)this.SceneViewModel.CreateSceneNode(PlatformTypes.Grid) : (BaseFrameworkElement)this.SceneViewModel.CreateSceneNode(PlatformTypes.StackPanel); frameworkTemplateElement.DefaultInsertionPoint.Insert((SceneNode)frameworkElement); return(frameworkTemplateElement.DocumentNode); }
public void CreateNewPropertyTrigger() { if (this.CurrentContainer == null) { return; } ITriggerContainer currentContainer = this.CurrentContainer; SceneViewModel activeSceneViewModel = this.ActiveSceneViewModel; SceneDocument document = activeSceneViewModel.Document; StyleNode styleNode = currentContainer as StyleNode; FrameworkTemplateElement frameworkTemplateElement = currentContainer as FrameworkTemplateElement; using (SceneEditTransaction editTransaction = document.CreateEditTransaction(StringTable.TriggerChangeUndoUnit)) { TriggerSourceInformation triggerSource = (TriggerSourceInformation)null; if (styleNode != null || frameworkTemplateElement != null) { triggerSource = (TriggerSourceInformation)TriggersHelper.GetDefaultProperty(currentContainer.TargetElementType, document.DocumentContext); } if (triggerSource != (TriggerSourceInformation)null) { TriggerBaseNode trigger = TriggersHelper.CreateTrigger(triggerSource, activeSceneViewModel); if (trigger != null) { int index = currentContainer.VisualTriggers.Count; if (this.selectedItem != null) { index = this.selectedItem != this.noneTrigger ? currentContainer.VisualTriggers.IndexOf(this.selectedItem.SceneNode) + 1 : 0; } currentContainer.VisualTriggers.Insert(index, trigger); activeSceneViewModel.SetActiveTrigger(trigger); } } editTransaction.Commit(); } }
public static bool GetUseLayoutRounding(SceneElement element) { if (element != null && element.Type != null) { IProperty propertyKey = LayoutRoundingHelper.ResolveUseLayoutRoundingProperty((SceneNode)element); if (propertyKey != null) { if (propertyKey.DeclaringType.IsAssignableFrom((ITypeId)element.Type)) { return((bool)element.GetComputedValue((IPropertyId)propertyKey)); } FrameworkTemplateElement frameworkTemplateElement = element as FrameworkTemplateElement; if (frameworkTemplateElement != null) { IViewObject viewTargetElement = frameworkTemplateElement.ViewTargetElement; if (viewTargetElement != null && propertyKey.DeclaringType.IsAssignableFrom((ITypeId)viewTargetElement.GetIType((ITypeResolver)element.ProjectContext))) { return((bool)viewTargetElement.GetCurrentValue(propertyKey)); } } } } return(false); }
public TemplateTimelineItem(TimelineItemManager timelineItemManager, FrameworkTemplateElement element) : base(timelineItemManager, (SceneElement)element) { this.IsExpanded = true; }
protected DocumentNode ProvideCurrentTemplate(SceneElement targetElement, PropertyReference targetPropertyReference, out IList <DocumentCompositeNode> auxillaryResources) { IPlatform platform = this.SceneViewModel.ProjectContext.Platform; FrameworkTemplateElement frameworkTemplateElement1 = (FrameworkTemplateElement)null; auxillaryResources = (IList <DocumentCompositeNode>)null; if (targetElement.IsSet(targetPropertyReference) == PropertyState.Set) { FrameworkTemplateElement frameworkTemplateElement2 = targetElement.GetLocalValueAsSceneNode(targetPropertyReference) as FrameworkTemplateElement; if (frameworkTemplateElement2 != null) { frameworkTemplateElement1 = targetElement.ClonePropertyValueAsSceneNode(targetPropertyReference) as FrameworkTemplateElement; if (frameworkTemplateElement1 != null) { auxillaryResources = Microsoft.Expression.DesignSurface.Utility.ResourceHelper.FindReferencedResources(frameworkTemplateElement2.DocumentNode); } } } if (frameworkTemplateElement1 == null) { object computedValue = targetElement.GetComputedValue(targetPropertyReference); DocumentNode root = computedValue == null ? (DocumentNode)null : this.SceneView.GetCorrespondingDocumentNode(platform.ViewObjectFactory.Instantiate(computedValue), true); IPropertyId targetProperty = (IPropertyId)targetElement.Platform.Metadata.ResolveProperty(BaseFrameworkElement.StyleProperty); DocumentCompositeNode documentCompositeNode1 = targetElement.DocumentNode as DocumentCompositeNode; if (!targetElement.ProjectContext.IsCapabilitySet(PlatformCapability.IsWpf) && documentCompositeNode1 != null && (root == null && targetPropertyReference.ReferenceSteps.Count == 1)) { ITypeId styleTargetType = (ITypeId)targetElement.Type; DocumentNode currentStyle = (DocumentNode)null; ReferenceStep referenceStep = targetPropertyReference.ReferenceSteps[0]; object defaultStyleKey = this.GetDefaultStyleKey(targetElement, styleTargetType, targetProperty); if (defaultStyleKey != null) { bool isThemeStyle; IList <DocumentCompositeNode> auxillaryResources1; this.ResolveDefaultStyle(targetElement, defaultStyleKey, true, out currentStyle, out isThemeStyle, out auxillaryResources1); } DocumentCompositeNode documentCompositeNode2 = currentStyle as DocumentCompositeNode; if (documentCompositeNode2 != null) { DocumentCompositeNode documentCompositeNode3 = documentCompositeNode2.Properties[StyleNode.SettersProperty] as DocumentCompositeNode; if (documentCompositeNode3 != null) { foreach (DocumentNode documentNode1 in (IEnumerable <DocumentNode>)documentCompositeNode3.Children) { DocumentCompositeNode documentCompositeNode4 = documentNode1 as DocumentCompositeNode; if (documentCompositeNode4 != null) { IMemberId memberId = (IMemberId)DocumentPrimitiveNode.GetValueAsMember(documentCompositeNode4.Properties[SetterSceneNode.PropertyProperty]); DocumentNode documentNode2 = documentCompositeNode4.Properties[SetterSceneNode.ValueProperty]; if (memberId != null && documentNode2 != null && referenceStep.Equals((object)memberId)) { root = documentNode2; break; } } } } } } if (root != null) { frameworkTemplateElement1 = this.SceneViewModel.GetSceneNode(root.Clone(this.SceneViewModel.Document.DocumentContext)) as FrameworkTemplateElement; auxillaryResources = Microsoft.Expression.DesignSurface.Utility.ResourceHelper.FindReferencedResources(root); } else { frameworkTemplateElement1 = this.SceneViewModel.CreateSceneNode(computedValue) as FrameworkTemplateElement; } } if (frameworkTemplateElement1 == null) { return((DocumentNode)null); } return(frameworkTemplateElement1.DocumentNode); }