public static ConditionNode CreateDefaultCondition(Type targetType, SceneViewModel viewModel, IDocumentContext documentContext) { PropertyInformation.GetPropertiesForType(targetType, documentContext.TypeResolver).GetEnumerator(); PropertyInformation defaultProperty = TriggersHelper.GetDefaultProperty(targetType, documentContext); if (!((TriggerSourceInformation)defaultProperty != (TriggerSourceInformation)null)) { return((ConditionNode)null); } ConditionNode conditionNode = ConditionNode.Factory.Instantiate(viewModel); conditionNode.PropertyKey = defaultProperty.DependencyProperty; conditionNode.Value = defaultProperty.DependencyProperty.DefaultMetadata.DefaultValue; return(conditionNode); }
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(); } }