private void CleanConditionBehaviorReferences()
 {
     this.ClearConditionList();
     this.conditions = (ISceneNodeCollection <SceneNode>)null;
     this.conditionalExpressionNode = (ConditionalExpressionNode)null;
     this.conditionBehaviorNode     = (ConditionBehaviorNode)null;
 }
        internal void AddConditionNode()
        {
            if (!this.EnsureInteractionsAssemblyReferenced() || this.behaviorTriggerBaseNode == null)
            {
                return;
            }
            BehaviorTriggerBaseNode newTriggerParent = this.CloneCurrentTrigger();

            using (SceneEditTransaction editTransaction = this.sceneViewModel.CreateEditTransaction(StringTable.AddConditionUndo))
            {
                ISceneNodeCollection <SceneNode> collectionForProperty = newTriggerParent.GetCollectionForProperty(BehaviorHelper.BehaviorsProperty);
                this.conditionalExpressionNode = (ConditionalExpressionNode)null;
                this.conditionBehaviorNode     = (ConditionBehaviorNode)null;
                foreach (SceneNode sceneNode in (IEnumerable <SceneNode>)collectionForProperty)
                {
                    if (ProjectNeutralTypes.ConditionBehavior.IsAssignableFrom((ITypeId)sceneNode.TrueTargetTypeId))
                    {
                        ConditionBehaviorNode     conditionBehaviorNode     = (ConditionBehaviorNode)sceneNode;
                        ConditionalExpressionNode conditionalExpressionNode = conditionBehaviorNode.ConditionAsConditionalExpressionNode;
                        if (conditionalExpressionNode != null)
                        {
                            this.conditionBehaviorNode     = conditionBehaviorNode;
                            this.conditionalExpressionNode = conditionalExpressionNode;
                            break;
                        }
                    }
                }
                if (this.conditionBehaviorNode == null)
                {
                    this.conditionBehaviorNode = (ConditionBehaviorNode)this.sceneViewModel.CreateSceneNode(ProjectNeutralTypes.ConditionBehavior);
                    collectionForProperty.Add((SceneNode)this.conditionBehaviorNode);
                    this.conditionalExpressionNode = (ConditionalExpressionNode)this.sceneViewModel.CreateSceneNode(ProjectNeutralTypes.ConditionalExpression);
                    this.conditionBehaviorNode.ConditionAsConditionalExpressionNode = this.conditionalExpressionNode;
                }
                this.conditions = this.conditionalExpressionNode.Conditions;
                if (this.conditions != null)
                {
                    this.conditions.Add(this.sceneViewModel.CreateSceneNode(ProjectNeutralTypes.ComparisonCondition));
                }
                if (this.behaviorTriggerBaseNode.Actions.Count > 1)
                {
                    this.objectSet.ReparentActionAndCopyBehaviors(newTriggerParent);
                    this.behaviorTriggerBaseNode = newTriggerParent;
                }
                else
                {
                    SceneNode valueAsSceneNode = newTriggerParent.GetLocalValueAsSceneNode(BehaviorHelper.BehaviorsProperty);
                    valueAsSceneNode.Remove();
                    this.behaviorTriggerBaseNode.SetValueAsSceneNode(BehaviorHelper.BehaviorsProperty, valueAsSceneNode);
                }
                editTransaction.Commit();
            }
            this.Rebuild();
            this.Expanded = true;
        }
 private void Rebuild()
 {
     if (this.behaviorTriggerBaseNode == null)
     {
         return;
     }
     this.CleanConditionBehaviorReferences();
     if (this.behaviorTriggerBaseNode.IsSet(BehaviorHelper.BehaviorsProperty) == PropertyState.Set)
     {
         foreach (SceneNode sceneNode in (IEnumerable <SceneNode>) this.behaviorTriggerBaseNode.GetCollectionForProperty(BehaviorHelper.BehaviorsProperty))
         {
             if (ProjectNeutralTypes.ConditionBehavior.IsAssignableFrom((ITypeId)sceneNode.Type))
             {
                 this.conditionBehaviorNode = (ConditionBehaviorNode)sceneNode;
                 ConditionalExpressionNode conditionalExpressionNode = this.conditionBehaviorNode.ConditionAsConditionalExpressionNode;
                 if (conditionalExpressionNode != null)
                 {
                     this.conditionalExpressionNode = conditionalExpressionNode;
                     this.conditions = this.conditionalExpressionNode.Conditions;
                     break;
                 }
             }
         }
     }
     this.ConditionUIAvailable = true;
     if (this.ConditionsNodeView != null && this.conditions != null)
     {
         foreach (SceneNode condition in (IEnumerable <SceneNode>) this.conditions)
         {
             PropertyEntry entryForCondition = this.CreatePropertyEntryForCondition(condition);
             this.ConditionNodes.Add(entryForCondition);
             if (entryForCondition.PropertyValue.SubProperties.Count == 0)
             {
                 this.ConditionUIAvailable = false;
                 this.CleanConditionBehaviorReferences();
                 break;
             }
         }
     }
     this.ConditionsNodeView.MoveCurrentToLast();
     this.OnPropertyChanged("ConditionsNodeView");
     this.OnPropertyChanged("ForwardChainingSetToOr");
     this.OnPropertyChanged("ForwardChainingSetToOrEnabled");
     this.OnPropertyChanged("ConditionUIAvailable");
 }