示例#1
0
        public static void CopyBehaviorNodes(SceneViewModel viewModel, IList <BehaviorBaseNode> behaviorNodes)
        {
            PastePackage pastePackage = new PastePackage(viewModel);

            using (viewModel.ForceBaseValue())
            {
                foreach (SceneNode childPropertyNode in (IEnumerable <BehaviorBaseNode>)behaviorNodes)
                {
                    if (ProjectNeutralTypes.Behavior.IsAssignableFrom((ITypeId)childPropertyNode.Type))
                    {
                        pastePackage.AddChildPropertyNode(childPropertyNode);
                    }
                    else
                    {
                        BehaviorTriggerActionNode triggerActionNode1      = (BehaviorTriggerActionNode)childPropertyNode;
                        BehaviorTriggerBaseNode   behaviorTriggerBaseNode = (BehaviorTriggerBaseNode)triggerActionNode1.Parent;
                        if (behaviorTriggerBaseNode.Actions.Count > 1)
                        {
                            DocumentNode node1 = triggerActionNode1.DocumentNode.Clone(viewModel.Document.DocumentContext);
                            BehaviorTriggerActionNode triggerActionNode2 = (BehaviorTriggerActionNode)viewModel.GetSceneNode(node1);
                            DocumentNode node2 = behaviorTriggerBaseNode.DocumentNode.Clone(viewModel.Document.DocumentContext);
                            behaviorTriggerBaseNode = (BehaviorTriggerBaseNode)viewModel.GetSceneNode(node2);
                            behaviorTriggerBaseNode.Actions.Clear();
                            behaviorTriggerBaseNode.Actions.Add((SceneNode)triggerActionNode2);
                        }
                        pastePackage.AddChildPropertyNode((SceneNode)behaviorTriggerBaseNode);
                    }
                }
            }
            pastePackage.SendToClipboard();
        }
示例#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);
            }
        }
示例#3
0
        private BehaviorTriggerBaseNode CopyTriggerAndActionNode(BehaviorTriggerActionNode actionNode)
        {
            SceneViewModel            viewModel = this.InsertionPoint.SceneNode.ViewModel;
            DocumentNode              node1     = actionNode.DocumentNode.Clone(viewModel.Document.DocumentContext);
            DocumentNode              node2     = actionNode.Parent.DocumentNode.Clone(viewModel.Document.DocumentContext);
            BehaviorTriggerBaseNode   behaviorTriggerBaseNode = (BehaviorTriggerBaseNode)viewModel.GetSceneNode(node2);
            BehaviorTriggerActionNode triggerActionNode       = (BehaviorTriggerActionNode)viewModel.GetSceneNode(node1);

            behaviorTriggerBaseNode.Actions.Clear();
            behaviorTriggerBaseNode.Actions.Add((SceneNode)triggerActionNode);
            return(behaviorTriggerBaseNode);
        }
示例#4
0
        private SceneNode Copy(SceneNode node)
        {
            BehaviorTriggerActionNode actionNode = node as BehaviorTriggerActionNode;
            BehaviorNode behaviorNode            = node as BehaviorNode;

            if (actionNode != null)
            {
                return(this.InsertTrigger(this.CopyTriggerAndActionNode(actionNode)));
            }
            if (behaviorNode != null)
            {
                return(this.InsertBehavior((BehaviorNode)this.ViewModel.GetSceneNode(behaviorNode.DocumentNode.Clone(this.ViewModel.Document.DocumentContext))));
            }
            return((SceneNode)null);
        }
        public override void OnSelectionChanged(SceneNode[] selectedObjects)
        {
            this.CleanBehaviorTriggerReferences();
            this.UnhookSelectionManagerEarlySceneUpdate();
            BehaviorTriggerActionNode actionNode = Enumerable.FirstOrDefault <BehaviorTriggerActionNode>(Enumerable.OfType <BehaviorTriggerActionNode>((IEnumerable)selectedObjects));

            if (actionNode == null || actionNode.Parent == null || !(actionNode.Parent is BehaviorTriggerBaseNode))
            {
                return;
            }
            this.behaviorTriggerBaseNode = (BehaviorTriggerBaseNode)actionNode.Parent;
            this.objectSet      = new TriggerObjectSet(actionNode);
            this.sceneViewModel = this.behaviorTriggerBaseNode.ViewModel;
            this.HookSelectionManagerEarlySceneUpdate();
            this.Rebuild();
        }
示例#6
0
        private SceneNode Move(SceneNode node)
        {
            BehaviorTriggerActionNode actionNode = node as BehaviorTriggerActionNode;
            BehaviorNode behaviorNode            = node as BehaviorNode;

            if (actionNode != null)
            {
                BehaviorTriggerBaseNode triggerNode = this.CopyTriggerAndActionNode(actionNode);
                this.DeleteBehaviorNode((BehaviorBaseNode)actionNode);
                return(this.InsertTrigger(triggerNode));
            }
            if (behaviorNode == null)
            {
                return((SceneNode)null);
            }
            this.DeleteBehaviorNode((BehaviorBaseNode)behaviorNode);
            return(this.InsertBehavior(behaviorNode));
        }
示例#7
0
        internal void OnTriggerTypeButtonClicked(object sender, RoutedEventArgs args)
        {
            SceneNode sceneNode1   = this.selectedObjects[0];
            Type      runtimeType  = sceneNode1.ProjectContext.ResolveType(ProjectNeutralTypes.BehaviorTriggerBase).RuntimeType;
            Type      newClrObject = ClrNewObjectDialog.CreateNewClrObject(sceneNode1.ViewModel, runtimeType, true);

            if (!(newClrObject != (Type)null))
            {
                return;
            }
            BehaviorTriggerActionNode triggerActionNode = (BehaviorTriggerActionNode)sceneNode1;

            using (SceneEditTransaction editTransaction = triggerActionNode.ViewModel.CreateEditTransaction(StringTable.ChangeBehaviorTriggerTypeUndoDescription))
            {
                SceneNode sceneNode2 = triggerActionNode.ViewModel.CreateSceneNode(newClrObject);
                this.objectSet.ReparentActionAndCopyBehaviors(this.objectSet.FindExistingTriggerMatchingDocumentNode(sceneNode2.DocumentNode) ?? (BehaviorTriggerBaseNode)sceneNode2);
                editTransaction.Commit();
            }
        }
示例#8
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);
        }
示例#9
0
 public TriggerObjectSet(BehaviorTriggerActionNode actionNode)
     : base(actionNode.DesignerContext, (IPropertyInspector)actionNode.DesignerContext.PropertyInspectorModel)
 {
     this.actionNode = actionNode;
 }
示例#10
0
        private void FireSelectivePropertyChangedEvents(SceneUpdatePhaseEventArgs args)
        {
            SceneNode[] selectedNodes = this.designerContext.SelectionManager.SelectedNodes;
            DocumentNodeMarkerSortedList markerSortedList;

            if (selectedNodes == null)
            {
                markerSortedList = new DocumentNodeMarkerSortedList();
            }
            else
            {
                markerSortedList = new DocumentNodeMarkerSortedList(selectedNodes.Length);
                foreach (SceneNode sceneNode in selectedNodes)
                {
                    TextRangeElement          textRangeElement  = sceneNode as TextRangeElement;
                    BehaviorTriggerActionNode triggerActionNode = sceneNode as BehaviorTriggerActionNode;
                    if (textRangeElement != null)
                    {
                        this.FireAllPropertyChangedEvents(args);
                        return;
                    }
                    if (triggerActionNode != null && triggerActionNode.Parent != null)
                    {
                        markerSortedList.Add(triggerActionNode.Parent.DocumentNode.Marker);
                    }
                    markerSortedList.Add(sceneNode.DocumentNode.Marker);
                }
            }
            foreach (DocumentNodeChange documentNodeChange in args.DocumentChanges.DistinctChanges)
            {
                if (SceneView.HandleAnimationChanges(args.ViewModel, documentNodeChange, new SceneView.HandleAnimationChange(this.InvalidatePropertyFromAnimationChange)) == SceneView.AnimationChangeResult.InvalidateAll)
                {
                    this.FireAllPropertyChangedEvents(args);
                    return;
                }
            }
            if (this.designerContext.SelectionManager.SecondarySelectedNodes != null)
            {
                foreach (SceneNode sceneNode in this.designerContext.SelectionManager.SecondarySelectedNodes)
                {
                    if (sceneNode.DocumentNode.Marker != null)
                    {
                        markerSortedList.Add(sceneNode.DocumentNode.Marker);
                    }
                }
            }
            foreach (DocumentNodeMarkerSortedListBase.IntersectionResult intersectionResult in args.DocumentChanges.Intersect((DocumentNodeMarkerSortedListBase)markerSortedList, DocumentNodeMarkerSortedListBase.Flags.ContainedBy))
            {
                Stack <ReferenceStep> input = DocumentNodeMarkerUtilities.PropertyReferencePath(args.DocumentChanges.MarkerAt(intersectionResult.LeftHandSideIndex), markerSortedList.MarkerAt(intersectionResult.RightHandSideIndex));
                if (input.Count > 0)
                {
                    PropertyReference propertyReference1 = new PropertyReference(input);
                    this.AddPropertyReferenceToSortedList(propertyReference1, this.changedPropertyReferences);
                    if (PlatformTypes.Style.IsAssignableFrom(propertyReference1.FirstStep.DeclaringTypeId))
                    {
                        int startIndex;
                        for (startIndex = 0; startIndex < propertyReference1.Count; ++startIndex)
                        {
                            if (PlatformTypes.Setter.IsAssignableFrom(propertyReference1.ReferenceSteps[startIndex].DeclaringTypeId))
                            {
                                ++startIndex;
                                break;
                            }
                        }
                        foreach (SceneChange sceneChange in SceneChange.ChangesOfType <SceneChange>(args.DocumentChanges, args.ViewModel.RootNode))
                        {
                            PropertyReferenceSceneChange referenceSceneChange = sceneChange as PropertyReferenceSceneChange;
                            if (referenceSceneChange != null && referenceSceneChange.PropertyChanged != null)
                            {
                                PropertyReference propertyReference2 = referenceSceneChange.PropertyChanged.Subreference(0);
                                if (startIndex < propertyReference1.Count)
                                {
                                    propertyReference2 = propertyReference2.Append(propertyReference1.Subreference(startIndex));
                                }
                                this.AddPropertyReferenceToSortedList(propertyReference2, this.changedPropertyReferences);
                            }
                        }
                    }
                }
            }
            this.FireSelectivePropertyChangedEventsWorker(args.DirtyViewState);
        }
示例#11
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;
                    }
                }
            }
        }