Example #1
0
        private void GenerateDataGridColumnsIfNeeded(DataGridElement dataGridElement, IProperty targetProperty)
        {
            if (!DataGridElement.ItemsSourceProperty.Equals((object)targetProperty) && !ItemsControlElement.ItemsSourceProperty.Equals((object)targetProperty) || this.DragModel.RelativeDropSchemaPath.IsProperty)
            {
                return;
            }
            IList <DataSchemaNodePath> relativeSchemaPaths = this.GetRelativeSchemaPaths();

            if (relativeSchemaPaths.Count == 0)
            {
                return;
            }
            using (SceneEditTransaction editTransaction = this.DragModel.Document.CreateEditTransaction(StringTable.UndoUnitCreateTemplate))
            {
                dataGridElement.SetValue(DataGridElement.AutoGenerateColumnsProperty, (object)false);
                ISceneNodeCollection <SceneNode> columnCollection = dataGridElement.ColumnCollection;
                for (int index = 0; index < relativeSchemaPaths.Count; ++index)
                {
                    DataSchemaNodePath schemaPath = relativeSchemaPaths[index];
                    IType type = schemaPath.Type;
                    if (type.NullableType != null)
                    {
                        type = type.NullableType;
                    }
                    SceneNode sceneNode = !PlatformTypes.Boolean.IsAssignableFrom((ITypeId)type) ? (!PlatformTypes.IConvertible.IsAssignableFrom((ITypeId)type) ? this.CreateDataGridTemplateColumn(schemaPath) : this.CreateDataGridBoundColumn(schemaPath, ProjectNeutralTypes.DataGridTextColumn)) : this.CreateDataGridBoundColumn(schemaPath, ProjectNeutralTypes.DataGridCheckBoxColumn);
                    columnCollection.Add(sceneNode);
                }
                editTransaction.Commit();
            }
        }
Example #2
0
        public static SceneNode CreateTrigger(SceneNode targetNode, IType triggerType)
        {
            ProjectContext projectContext = ProjectContext.GetProjectContext(targetNode.ProjectContext);

            BehaviorHelper.EnsureSystemWindowsInteractivityReferenced((ITypeResolver)projectContext);
            targetNode.DesignerContext.ViewUpdateManager.RebuildPostponedViews();
            using (SceneEditTransaction editTransaction = targetNode.ViewModel.CreateEditTransaction(StringTable.CreateTriggerActionUndoString))
            {
                SceneNode sceneNode1 = targetNode;
                ISceneNodeCollection <SceneNode> collectionForProperty   = sceneNode1.GetCollectionForProperty(BehaviorHelper.BehaviorTriggersProperty);
                BehaviorTriggerBaseNode          behaviorTriggerBaseNode = (BehaviorTriggerBaseNode)null;
                SceneViewModel viewModel        = targetNode.ViewModel;
                object         triggerAttribute = BehaviorHelper.CreateTriggerFromDefaultTriggerAttribute((IEnumerable)TypeUtilities.GetAttributes(triggerType.RuntimeType), targetNode.TargetType);
                if (triggerAttribute != null)
                {
                    behaviorTriggerBaseNode = (BehaviorTriggerBaseNode)viewModel.CreateSceneNode(triggerAttribute);
                }
                if (behaviorTriggerBaseNode == null)
                {
                    BehaviorEventTriggerNode eventTriggerNode = (BehaviorEventTriggerNode)sceneNode1.ViewModel.CreateSceneNode(ProjectNeutralTypes.BehaviorEventTrigger);
                    string result;
                    if (!PlatformNeutralAttributeHelper.TryGetAttributeValue <string>(targetNode.TargetType, PlatformTypes.DefaultEventAttribute, "Name", out result))
                    {
                        result = "Loaded";
                    }
                    eventTriggerNode.EventName = result;
                    behaviorTriggerBaseNode    = (BehaviorTriggerBaseNode)eventTriggerNode;
                }
                bool flag = false;
                viewModel.BehaviorSelectionSet.Clear();
                foreach (SceneNode sceneNode2 in (IEnumerable <SceneNode>)collectionForProperty)
                {
                    if (BehaviorHelper.CompareTriggerNodes(behaviorTriggerBaseNode.DocumentNode as DocumentCompositeNode, sceneNode2.DocumentNode as DocumentCompositeNode))
                    {
                        behaviorTriggerBaseNode = (BehaviorTriggerBaseNode)sceneNode2;
                        flag = true;
                        break;
                    }
                }
                if (!flag)
                {
                    collectionForProperty.Add((SceneNode)behaviorTriggerBaseNode);
                }
                BehaviorTriggerActionNode triggerActionNode = (BehaviorTriggerActionNode)sceneNode1.ViewModel.CreateSceneNode((ITypeId)triggerType);
                if (projectContext.IsCapabilitySet(PlatformCapability.SupportsAttachingToRootElements) && ProjectNeutralTypes.BehaviorTargetedTriggerAction.IsAssignableFrom((ITypeId)triggerActionNode.Type) && targetNode.ViewModel.ActiveEditingContainer.Equals((object)targetNode))
                {
                    IProperty property = projectContext.ResolveProperty(BehaviorTargetedTriggerActionNode.BehaviorTargetObjectProperty);
                    if (property != null)
                    {
                        BehaviorHelper.CreateAndSetElementNameBinding((IPropertyId)property, (SceneNode)triggerActionNode, targetNode);
                    }
                }
                behaviorTriggerBaseNode.Actions.Add((SceneNode)triggerActionNode);
                viewModel.BehaviorSelectionSet.SetSelection((BehaviorBaseNode)triggerActionNode);
                editTransaction.Commit();
                return((SceneNode)triggerActionNode);
            }
        }
Example #3
0
        internal static SceneElement ApplyChildren(SceneElement destinationElement, Dictionary <IPropertyId, List <SceneNode> > storedChildren, Size size)
        {
            SceneElement sceneElement = (SceneElement)null;

            foreach (KeyValuePair <IPropertyId, List <SceneNode> > keyValuePair in storedChildren)
            {
                IPropertyId   childProperty = keyValuePair.Key;
                ReferenceStep referenceStep = childProperty as ReferenceStep;
                if (referenceStep != null)
                {
                    childProperty = (IPropertyId)SceneNodeObjectSet.FilterProperty((SceneNode)destinationElement, referenceStep) ?? (IPropertyId)destinationElement.DefaultContentProperty;
                }
                if (childProperty != null)
                {
                    ISceneNodeCollection <SceneNode> collectionForProperty = destinationElement.GetCollectionForProperty(childProperty);
                    if (collectionForProperty != null)
                    {
                        sceneElement = destinationElement;
                        List <SceneNode> list = keyValuePair.Value;
                        if (collectionForProperty.FixedCapacity.HasValue && list.Count > collectionForProperty.FixedCapacity.Value - collectionForProperty.Count)
                        {
                            SceneNode sceneNode = destinationElement.ViewModel.CreateSceneNode(PlatformTypes.Grid);
                            if (ProjectNeutralTypes.Viewbox.IsAssignableFrom((ITypeId)destinationElement.Type) && !size.IsEmpty)
                            {
                                sceneNode.SetValue(BaseFrameworkElement.WidthProperty, (object)size.Width);
                                sceneNode.SetValue(BaseFrameworkElement.HeightProperty, (object)size.Height);
                            }
                            collectionForProperty.Add(sceneNode);
                            collectionForProperty = sceneNode.GetCollectionForProperty((IPropertyId)sceneNode.DefaultContentProperty);
                            sceneElement          = sceneNode as SceneElement;
                        }
                        if (ProjectNeutralTypes.Viewbox.IsAssignableFrom((ITypeId)destinationElement.Type))
                        {
                            destinationElement.SetValue(ViewboxElement.StretchProperty, (object)Stretch.Fill);
                        }
                        foreach (SceneNode sceneNode in list)
                        {
                            collectionForProperty.Add(sceneNode);
                        }
                    }
                }
            }
            return(sceneElement);
        }
        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 NestContents(SceneNode node)
        {
            SceneElement sceneElement1 = (SceneElement)node;
            ISceneNodeCollection <SceneNode> destinationCollection = this.DestinationCollection;
            int count = destinationCollection.Count;

            SceneElement[]      sceneElementArray      = new SceneElement[count];
            LayoutCacheRecord[] layoutCacheRecordArray = new LayoutCacheRecord[count];
            ILayoutDesigner     designerForParent1     = this.SceneNode.ViewModel.GetLayoutDesignerForParent(this.SceneElement, true);
            Rect empty = Rect.Empty;

            for (int index = 0; index < count; ++index)
            {
                BaseFrameworkElement frameworkElement = destinationCollection[index] as BaseFrameworkElement;
                if (frameworkElement != null)
                {
                    layoutCacheRecordArray[index] = designerForParent1.CacheLayout(frameworkElement);
                    empty.Union(designerForParent1.GetChildRect(frameworkElement));
                }
            }
            for (int index = 0; index < count; ++index)
            {
                SceneNode    child         = destinationCollection[index];
                SceneElement sceneElement2 = child as SceneElement;
                if (sceneElement2 != null)
                {
                    sceneElementArray[index] = sceneElement2;
                }
                this.SceneNode.ViewModel.RemoveElement(child);
            }
            destinationCollection.Add((SceneNode)sceneElement1);
            for (int index = 0; index < count; ++index)
            {
                if (sceneElementArray[index] != null)
                {
                    sceneElement1.DefaultContent.Add((SceneNode)sceneElementArray[index]);
                }
            }
            this.SceneNode.ViewModel.Document.OnUpdatedEditTransaction();
            this.SceneNode.DesignerContext.ActiveView.UpdateLayout();
            ILayoutDesigner designerForParent2 = this.SceneNode.ViewModel.GetLayoutDesignerForParent(sceneElement1, true);

            for (int index = 0; index < count; ++index)
            {
                if (sceneElementArray[index] != null && layoutCacheRecordArray[index] != null)
                {
                    designerForParent2.SetLayoutFromCache((BaseFrameworkElement)sceneElementArray[index], layoutCacheRecordArray[index], empty);
                }
            }
            if (sceneElementArray.Length != 1)
            {
                return;
            }
            VisualStateManagerSceneNode.MoveStates(sceneElementArray[0], sceneElement1);
        }
Example #6
0
        public virtual BaseFrameworkElement BuildPanel(SceneViewModel viewModel, ICollection <BaseFrameworkElement> children)
        {
            BaseFrameworkElement             frameworkElement1     = (BaseFrameworkElement)viewModel.CreateSceneNode(this.PanelType);
            ISceneNodeCollection <SceneNode> collectionForProperty = frameworkElement1.GetCollectionForProperty(PanelElement.ChildrenProperty);

            foreach (BaseFrameworkElement frameworkElement2 in (IEnumerable <BaseFrameworkElement>)children)
            {
                collectionForProperty.Add((SceneNode)frameworkElement2);
            }
            return(frameworkElement1);
        }
Example #7
0
        protected override void ReorderElements(ISceneNodeCollection <SceneNode> childCollection, SceneElementCollection selectedChildren)
        {
            if (childCollection.Count == selectedChildren.Count)
            {
                return;
            }
            int count = childCollection.Count;

            for (int index = 0; index < selectedChildren.Count; ++index)
            {
                SceneElement sceneElement = selectedChildren[index];
                sceneElement.Remove();
                childCollection.Add((SceneNode)sceneElement);
            }
        }
Example #8
0
        protected override SceneNode InternalCreateInstance(ISceneInsertionPoint insertionPoint, Rect rect, OnCreateInstanceAction action)
        {
            ProjectContext projectContext = ProjectContext.GetProjectContext(insertionPoint.SceneNode.ProjectContext);

            if (!this.EnsureTypeReferenced(projectContext))
            {
                return((SceneNode)null);
            }
            BehaviorHelper.EnsureSystemWindowsInteractivityReferenced((ITypeResolver)projectContext);
            insertionPoint.SceneNode.DesignerContext.ViewUpdateManager.RebuildPostponedViews();
            SceneViewModel viewModel = insertionPoint.SceneNode.ViewModel;

            using (SceneEditTransaction editTransaction = viewModel.CreateEditTransaction(string.Format((IFormatProvider)CultureInfo.CurrentCulture, StringTable.UndoUnitCreateControlFormat, new object[1]
            {
                (object)this.Name
            })))
            {
                viewModel.BehaviorSelectionSet.Clear();
                BehaviorBaseNode selectionToSet = (BehaviorBaseNode)base.InternalCreateInstance(insertionPoint, rect, action);
                ISceneNodeCollection <SceneNode> collectionForProperty = selectionToSet.GetCollectionForProperty(BehaviorHelper.BehaviorTriggersProperty);
                foreach (IProperty property in selectionToSet.GetProperties())
                {
                    if (PlatformTypes.ICommand.IsAssignableFrom((ITypeId)property.PropertyType))
                    {
                        object triggerAttribute = BehaviorHelper.CreateTriggerFromDefaultTriggerAttribute((IEnumerable)property.Attributes, insertionPoint.SceneNode.TargetType);
                        if (triggerAttribute != null)
                        {
                            BehaviorTriggerBaseNode behaviorTriggerBaseNode = (BehaviorTriggerBaseNode)viewModel.CreateSceneNode(triggerAttribute);
                            InvokeCommandActionNode commandActionNode       = (InvokeCommandActionNode)viewModel.CreateSceneNode(ProjectNeutralTypes.InvokeCommandAction);
                            commandActionNode.CommandName = property.Name;
                            behaviorTriggerBaseNode.Actions.Add((SceneNode)commandActionNode);
                            if (ProjectNeutralTypes.BehaviorEventTriggerBase.IsAssignableFrom((ITypeId)behaviorTriggerBaseNode.Type))
                            {
                                BehaviorHelper.CreateAndSetElementNameBinding(BehaviorEventTriggerBaseNode.BehaviorSourceObjectProperty, (SceneNode)behaviorTriggerBaseNode, insertionPoint.SceneNode);
                            }
                            collectionForProperty.Add((SceneNode)behaviorTriggerBaseNode);
                        }
                    }
                }
                viewModel.BehaviorSelectionSet.SetSelection(selectionToSet);
                editTransaction.Commit();
                return((SceneNode)selectionToSet);
            }
        }
        public void Insert(SceneNode nodeToInsert)
        {
            ISceneNodeCollection <SceneNode> collectionForProperty = this.SceneNode.GetCollectionForProperty((IPropertyId)this.Property);

            if (collectionForProperty.FixedCapacity.HasValue && collectionForProperty.Count >= collectionForProperty.FixedCapacity.Value)
            {
                PropertySceneInsertionPoint.Cleanup(collectionForProperty[collectionForProperty.Count - 1]);
            }
            collectionForProperty.Add(nodeToInsert);
            ControlTemplateElement controlTemplateElement = this.SceneNode as ControlTemplateElement;

            if (controlTemplateElement == null)
            {
                return;
            }
            ITypeId templateTargetTypeId = controlTemplateElement.ControlTemplateTargetTypeId;

            VisualStateManagerSceneNode.AddDefaultStates(nodeToInsert, (SceneNode)controlTemplateElement, templateTargetTypeId);
        }
 public override void Execute()
 {
     using (SceneEditTransaction editTransaction = this.SceneViewModel.CreateEditTransaction(StringTable.UndoUnitMakeCompoundPath))
     {
         SceneElementSelectionSet elementSelectionSet = this.SceneViewModel.ElementSelectionSet;
         List <PathElement>       otherElements       = new List <PathElement>();
         foreach (SceneElement element in elementSelectionSet.Selection)
         {
             PathElement pathElement = element as PathElement;
             if (pathElement != null)
             {
                 otherElements.Add(pathElement);
             }
             else if (PathConversionHelper.CanConvert(element))
             {
                 otherElements.Add(PathCommandHelper.ConvertToPath((BaseFrameworkElement)element));
             }
         }
         editTransaction.Update();
         this.DesignerContext.ActiveView.UpdateLayout();
         otherElements.Sort((IComparer <PathElement>) new ZOrderComparer <PathElement>(this.SceneViewModel.RootNode));
         elementSelectionSet.Clear();
         PathElement                      mainElement        = otherElements[0];
         BaseFrameworkElement             frameworkElement   = (BaseFrameworkElement)otherElements[otherElements.Count - 1];
         ISceneNodeCollection <SceneNode> collectionForChild = frameworkElement.ParentElement.GetCollectionForChild((SceneNode)frameworkElement);
         int       num       = collectionForChild.IndexOf((SceneNode)frameworkElement);
         SceneNode sceneNode = num + 1 < collectionForChild.Count ? collectionForChild[num + 1] : (SceneNode)null;
         otherElements.RemoveAt(0);
         PathCommandHelper.MakeCompoundPath(mainElement, otherElements, editTransaction);
         mainElement.Remove();
         if (sceneNode == null)
         {
             collectionForChild.Add((SceneNode)mainElement);
         }
         else
         {
             collectionForChild.Insert(collectionForChild.IndexOf(sceneNode), (SceneNode)mainElement);
         }
         elementSelectionSet.SetSelection((SceneElement)mainElement);
         editTransaction.Commit();
     }
 }
Example #11
0
        private SceneNode InsertTrigger(BehaviorTriggerBaseNode triggerNode)
        {
            BehaviorTriggerActionNode triggerActionNode1    = (BehaviorTriggerActionNode)triggerNode.Actions[0];
            DocumentCompositeNode     documentCompositeNode = (DocumentCompositeNode)triggerNode.DocumentNode;
            IProjectContext           projectContext        = triggerNode.ProjectContext;
            SceneNode sceneNode = this.InsertionPoint.SceneNode;
            ISceneNodeCollection <SceneNode> collectionForProperty   = sceneNode.GetCollectionForProperty(BehaviorHelper.BehaviorTriggersProperty);
            BehaviorTriggerBaseNode          behaviorTriggerBaseNode = BehaviorHelper.FindMatchingTriggerNode((DocumentNode)documentCompositeNode, collectionForProperty);

            if (behaviorTriggerBaseNode != null)
            {
                BehaviorTriggerActionNode triggerActionNode2 = (BehaviorTriggerActionNode)this.ViewModel.GetSceneNode(triggerActionNode1.DocumentNode.Clone(this.ViewModel.Document.DocumentContext));
                behaviorTriggerBaseNode.Actions.Add((SceneNode)triggerActionNode2);
                triggerActionNode1 = triggerActionNode2;
            }
            else
            {
                behaviorTriggerBaseNode = triggerNode;
                collectionForProperty.Add((SceneNode)behaviorTriggerBaseNode);
            }
            if (projectContext.IsCapabilitySet(PlatformCapability.SupportsAttachingToRootElements) && sceneNode.ViewModel.ActiveEditingContainer.Equals((object)sceneNode))
            {
                IProperty property = projectContext.ResolveProperty(BehaviorTargetedTriggerActionNode.BehaviorTargetObjectProperty);
                if (property != null)
                {
                    foreach (BehaviorTriggerActionNode triggerActionNode2 in (IEnumerable <SceneNode>)behaviorTriggerBaseNode.Actions)
                    {
                        if (ProjectNeutralTypes.BehaviorTargetedTriggerAction.IsAssignableFrom((ITypeId)triggerActionNode2.Type))
                        {
                            BehaviorHelper.CreateAndSetElementNameBinding((IPropertyId)property, (SceneNode)triggerActionNode2, sceneNode);
                        }
                    }
                }
            }
            BehaviorEventTriggerNode eventTriggerNode = behaviorTriggerBaseNode as BehaviorEventTriggerNode;

            if (eventTriggerNode != null)
            {
                BehaviorEventTriggerNode.FixUpEventName(eventTriggerNode);
            }
            return((SceneNode)triggerActionNode1);
        }
Example #12
0
 public void Insert(SceneNode nodeToInsert)
 {
     if (this.ShouldNestContents(nodeToInsert))
     {
         this.NestContents(nodeToInsert);
     }
     else
     {
         ISceneNodeCollection <SceneNode> destinationCollection = this.DestinationCollection;
         if (destinationCollection.FixedCapacity.HasValue && destinationCollection.Count >= destinationCollection.FixedCapacity.Value)
         {
             PropertySceneInsertionPoint.Cleanup(destinationCollection[destinationCollection.Count - 1]);
         }
         if (this.index >= 0 && this.index < destinationCollection.Count)
         {
             destinationCollection.Insert(this.index, nodeToInsert);
         }
         else
         {
             destinationCollection.Add(nodeToInsert);
         }
     }
 }
Example #13
0
        public void SetDocumentNodeValue(DocumentCompositeNode compositeNode, IPropertyId propertyKey, DocumentNode valueNode)
        {
            string id = this.GetID(compositeNode);

            if (id != null)
            {
                ISceneNodeCollection <SceneNode> setters = this.Setters;
                int index = 0;
                while (index < setters.Count)
                {
                    if (this.IsSetter((DocumentCompositeNode)setters[index].DocumentNode, id, propertyKey))
                    {
                        setters.RemoveAt(index);
                    }
                    else
                    {
                        ++index;
                    }
                }
                if (valueNode == null)
                {
                    return;
                }
                SetterSceneNode setterSceneNode = (SetterSceneNode)this.ViewModel.CreateSceneNode(typeof(Setter));
                if (!this.IsRootNode((DocumentNode)compositeNode))
                {
                    setterSceneNode.Target = id;
                }
                setterSceneNode.Property = (DependencyPropertyReferenceStep)propertyKey;
                ((DocumentCompositeNode)setterSceneNode.DocumentNode).Properties[SetterSceneNode.ValueProperty] = valueNode;
                setters.Add((SceneNode)setterSceneNode);
            }
            else
            {
                compositeNode.Properties[propertyKey] = valueNode;
            }
        }
Example #14
0
        private static void PasteChildProperty(SceneViewModel viewModel, SceneNode childProperty, IList <SceneNode> pastedNodes)
        {
            IList <SceneElement> list = (IList <SceneElement>)null;

            DocumentNodeHelper.StripExtraNamespaces(childProperty.DocumentNode);
            if (viewModel.ElementSelectionSet.Selection.Count != 0)
            {
                list = (IList <SceneElement>)viewModel.ElementSelectionSet.Selection;
            }
            else if (viewModel.ChildPropertySelectionSet.Selection.Count != 0 && !(childProperty is BehaviorBaseNode) && !(childProperty is BehaviorTriggerBaseNode))
            {
                list = (IList <SceneElement>) new List <SceneElement>();
                foreach (SceneNode sceneNode in viewModel.ChildPropertySelectionSet.Selection)
                {
                    SceneElement sceneElement = sceneNode.Parent as SceneElement;
                    list.Add(sceneElement);
                }
            }
            if (list == null)
            {
                return;
            }
            IProperty targetProperty = viewModel.ProjectContext.ResolveProperty(PasteCommand.ChildSceneNodeToPropertyId(childProperty));

            foreach (SceneElement sceneElement in (IEnumerable <SceneElement>)list)
            {
                PropertySceneInsertionPoint sceneInsertionPoint = new PropertySceneInsertionPoint(sceneElement, targetProperty);
                if (sceneInsertionPoint.CanInsert((ITypeId)childProperty.Type))
                {
                    if (ProjectNeutralTypes.BehaviorTriggerBase.IsAssignableFrom((ITypeId)childProperty.Type))
                    {
                        BehaviorTriggerBaseNode behaviorTriggerBaseNode1 = (BehaviorTriggerBaseNode)childProperty;
                        bool flag = true;
                        foreach (SceneNode sceneNode in (IEnumerable <SceneNode>)behaviorTriggerBaseNode1.Actions)
                        {
                            if (!sceneInsertionPoint.CanInsert((ITypeId)sceneNode.Type))
                            {
                                flag = false;
                                break;
                            }
                        }
                        if (flag)
                        {
                            ISceneNodeCollection <SceneNode> collectionForProperty    = sceneElement.GetCollectionForProperty((IPropertyId)targetProperty);
                            BehaviorTriggerBaseNode          behaviorTriggerBaseNode2 = BehaviorHelper.FindMatchingTriggerNode(behaviorTriggerBaseNode1.DocumentNode, collectionForProperty);
                            if (behaviorTriggerBaseNode2 == null)
                            {
                                DocumentNode node = behaviorTriggerBaseNode1.DocumentNode.Clone(behaviorTriggerBaseNode1.DocumentContext);
                                behaviorTriggerBaseNode2 = (BehaviorTriggerBaseNode)viewModel.GetSceneNode(node);
                                collectionForProperty.Add((SceneNode)behaviorTriggerBaseNode2);
                            }
                            else
                            {
                                DocumentNode node = behaviorTriggerBaseNode1.Actions[0].DocumentNode.Clone(behaviorTriggerBaseNode1.Actions[0].DocumentNode.Context);
                                BehaviorTriggerActionNode triggerActionNode = (BehaviorTriggerActionNode)viewModel.GetSceneNode(node);
                                behaviorTriggerBaseNode2.Actions.Add((SceneNode)triggerActionNode);
                            }
                            BehaviorEventTriggerNode eventTriggerNode = behaviorTriggerBaseNode2 as BehaviorEventTriggerNode;
                            if (eventTriggerNode != null)
                            {
                                BehaviorEventTriggerNode.FixUpEventName(eventTriggerNode);
                            }
                        }
                        else
                        {
                            continue;
                        }
                    }
                    else
                    {
                        DocumentNode node      = childProperty.DocumentNode.Clone(childProperty.DocumentNode.Context);
                        SceneNode    sceneNode = viewModel.GetSceneNode(node);
                        sceneInsertionPoint.Insert(sceneNode);
                        if (sceneNode is EffectNode)
                        {
                            pastedNodes.Add(sceneNode);
                        }
                    }
                    TimelineItem timelineItem = viewModel.TimelineItemManager.FindTimelineItem((SceneNode)sceneElement);
                    if (timelineItem != null)
                    {
                        timelineItem.IsExpanded = true;
                    }
                }
            }
        }