Пример #1
0
 public ISceneInsertionPoint Create(object data)
 {
     if (this.Element != null)
     {
         IType            type             = (IType)null;
         TypeAsset        typeAsset        = data as TypeAsset;
         BehaviorBaseNode behaviorBaseNode = data as BehaviorBaseNode;
         if (typeAsset != null)
         {
             type = typeAsset.Type;
         }
         if (typeof(DocumentNodeMarkerSortedList).IsAssignableFrom(data.GetType()))
         {
             type = ((DocumentNodeMarkerSortedListBase)data).MarkerAt(0).Node.Type;
         }
         else if (behaviorBaseNode != null)
         {
             type = behaviorBaseNode.Type;
         }
         IProperty targetProperty = (IProperty)null;
         if (ProjectNeutralTypes.BehaviorTriggerAction.IsAssignableFrom((ITypeId)type))
         {
             targetProperty = this.Element.ProjectContext.ResolveProperty(BehaviorHelper.BehaviorTriggersProperty);
         }
         else if (ProjectNeutralTypes.Behavior.IsAssignableFrom((ITypeId)type))
         {
             targetProperty = this.Element.ProjectContext.ResolveProperty(BehaviorHelper.BehaviorsProperty);
         }
         if (targetProperty != null)
         {
             return((ISceneInsertionPoint) new PropertySceneInsertionPoint(this.Element, targetProperty));
         }
     }
     return((ISceneInsertionPoint)null);
 }
Пример #2
0
            public string GetUndoString(object obj)
            {
                BehaviorBaseNode behaviorBaseNode = obj as BehaviorBaseNode;

                if (behaviorBaseNode != null)
                {
                    return(behaviorBaseNode.Type.Name);
                }
                return("");
            }
Пример #3
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);
            }
        }
Пример #4
0
 public BehaviorTimelineItem(TimelineItemManager timelineItemManager, BehaviorBaseNode behaviorNode)
     : base(timelineItemManager)
 {
     this.behaviorNode = behaviorNode;
     this.TimelineItemManager.RegisterTimelineItem((SceneNode)behaviorNode, (TimelineItem)this);
 }
Пример #5
0
        public static void DeleteBehavior(BehaviorBaseNode node)
        {
            Stack <ReferenceStep> input   = new Stack <ReferenceStep>();
            SceneNode             parent1 = node.Parent;
            SceneNode             child1  = (SceneNode)node;

            while (true)
            {
                ReferenceStep referenceStep = (ReferenceStep)parent1.GetPropertyForChild(child1);
                if (parent1.IsCollectionProperty((IPropertyId)referenceStep))
                {
                    int index = parent1.GetCollectionForProperty((IPropertyId)referenceStep).IndexOf(child1);
                    input.Push((ReferenceStep)IndexedClrPropertyReferenceStep.GetReferenceStep((ITypeResolver)node.ProjectContext, (ITypeId)referenceStep.PropertyType, index));
                }
                input.Push(referenceStep);
                if (!(parent1 is SceneElement))
                {
                    child1  = parent1;
                    parent1 = parent1.Parent;
                }
                else
                {
                    break;
                }
            }
            SceneElement      sceneElement      = (SceneElement)parent1;
            SceneNode         parent2           = node.Parent;
            PropertyReference propertyReference = new PropertyReference(input);

            node.ViewModel.AnimationEditor.DeleteAllAnimations((SceneNode)sceneElement, propertyReference.ToString());
            SceneNode child2 = (SceneNode)node;
            int       num    = propertyReference.Count - 1;
            ISceneNodeCollection <SceneNode> collectionForChild;
            int endIndex;

            while (true)
            {
                SceneNode parent3 = child2.Parent;
                if (sceneElement != child2 && parent3 != null)
                {
                    ReferenceStep referenceStep = (ReferenceStep)parent3.GetPropertyForChild(child2);
                    collectionForChild = parent3.GetCollectionForChild(child2);
                    DocumentNodeHelper.PreserveFormatting(child2.DocumentNode);
                    endIndex = propertyReference.ReferenceSteps.IndexOf(referenceStep);
                    if (collectionForChild.Count == 1)
                    {
                        child2.Remove();
                        child2 = parent3;
                    }
                    else
                    {
                        goto label_10;
                    }
                }
                else
                {
                    break;
                }
            }
            sceneElement.ClearValue((IPropertyId)propertyReference.FirstStep);
            goto label_11;
label_10:
            int index1 = collectionForChild.IndexOf(child2);

            child2.ViewModel.AnimationEditor.ValidateAnimations((SceneNode)sceneElement, propertyReference.Subreference(0, endIndex), index1, false);
            child2.Remove();
label_11:
            node.ViewModel.Document.OnUpdatedEditTransaction();
        }