コード例 #1
0
        internal void AddTriggerNode()
        {
            Type newClrObject = ClrNewObjectDialog.CreateNewClrObject(this.sceneViewModel, this.sceneViewModel.ProjectContext.ResolveType(ProjectNeutralTypes.BehaviorTriggerBase).RuntimeType, true);

            if (!(newClrObject != (Type)null))
            {
                return;
            }
            using (SceneEditTransaction editTransaction = this.sceneViewModel.CreateEditTransaction(StringTable.AddBehaviorCommandTriggerUndo))
            {
                BehaviorTriggerBaseNode behaviorTriggerBaseNode = (BehaviorTriggerBaseNode)this.sceneViewModel.CreateSceneNode(newClrObject);
                InvokeCommandActionNode commandActionNode       = (InvokeCommandActionNode)this.sceneViewModel.CreateSceneNode(ProjectNeutralTypes.InvokeCommandAction);
                commandActionNode.CommandName = this.CategoryName;
                behaviorTriggerBaseNode.Actions.Add((SceneNode)commandActionNode);
                if (ProjectNeutralTypes.BehaviorEventTriggerBase.IsAssignableFrom((ITypeId)behaviorTriggerBaseNode.Type))
                {
                    SceneNode sceneNode = (SceneNode)this.behaviorNode;
                    while (sceneNode != null && !(sceneNode is SceneElement))
                    {
                        sceneNode = sceneNode.Parent;
                    }
                    if (sceneNode != null)
                    {
                        sceneNode.EnsureNamed();
                        ((BehaviorEventTriggerBaseNode)behaviorTriggerBaseNode).SourceName = sceneNode.Name;
                    }
                }
                this.behaviorNode.GetCollectionForProperty(BehaviorHelper.BehaviorTriggersProperty).Add((SceneNode)behaviorTriggerBaseNode);
                editTransaction.Commit();
            }
            this.Rebuild();
            this.TriggerNodeView.MoveCurrentToLast();
        }
コード例 #2
0
        public Type PromptForClrType()
        {
            if (this.PropertyValue == null)
            {
                return((Type)null);
            }
            SceneNodeProperty sceneNodeProperty = (SceneNodeProperty)this.PropertyValue.get_ParentProperty();

            return(ClrNewObjectDialog.CreateNewClrObject(sceneNodeProperty.SceneNodeObjectSet.ViewModel, ((PropertyEntry)sceneNodeProperty).get_PropertyType()));
        }
コード例 #3
0
        private SceneNode CreateTypeForProperty(SceneViewModel viewModel, Type propertyType)
        {
            Type newClrObject = ClrNewObjectDialog.CreateNewClrObject(viewModel, propertyType);

            if (newClrObject == (Type)null)
            {
                return((SceneNode)null);
            }
            Type type = newClrObject;

            if (typeof(string).Equals(type))
            {
                return(viewModel.CreateSceneNode((object)StringTable.DefaultCollectionEditorString));
            }
            return(viewModel.CreateSceneNode(type));
        }
コード例 #4
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();
            }
        }
コード例 #5
0
 public static Type CreateNewClrObject(SceneViewModel viewModel, Type propertyType)
 {
     return(ClrNewObjectDialog.CreateNewClrObject(viewModel, propertyType, false));
 }