Esempio n. 1
0
        public static Type CreateNewClrObject(SceneViewModel viewModel, Type propertyType, bool showSystemTypesByDefault)
        {
            ClrNewObjectDialog clrNewObjectDialog = new ClrNewObjectDialog(viewModel, propertyType);
            IList <Type>       types = clrNewObjectDialog.Types;

            if (types.Count == 0)
            {
                viewModel.DesignerContext.MessageDisplayService.ShowError(StringTable.CollectionEditorCannotAddObjectMessage);
                return((Type)null);
            }
            if (types.Count == 1)
            {
                clrNewObjectDialog.Close();
                return(types[0]);
            }
            if (showSystemTypesByDefault || clrNewObjectDialog.SystemTypes.Count > 0 && clrNewObjectDialog.CustomTypes.Count == 0)
            {
                clrNewObjectDialog.ShowAllAssemblies = true;
            }
            bool?nullable = clrNewObjectDialog.ShowDialog();

            if ((!nullable.GetValueOrDefault() ? 0 : (nullable.HasValue ? 1 : 0)) != 0 && clrNewObjectDialog.SelectionContext.PrimarySelection != null)
            {
                return(clrNewObjectDialog.SelectionContext.PrimarySelection.Type);
            }
            return((Type)null);
        }
        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();
        }
Esempio n. 3
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()));
        }
Esempio n. 4
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));
        }
Esempio n. 5
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();
            }
        }
Esempio n. 6
0
 public static Type CreateNewClrObject(SceneViewModel viewModel, Type propertyType)
 {
     return(ClrNewObjectDialog.CreateNewClrObject(viewModel, propertyType, false));
 }