示例#1
0
        private void DeleteModelImpl(DeleteModelCommand command)
        {
            List <ModelBase> modelsToDelete = new List <ModelBase>();

            if (command.ModelGuid != Guid.Empty)
            {
                modelsToDelete.Add(CurrentSpace.GetModelInternal(command.ModelGuid));
            }
            else
            {
                // When nothing is specified then it means all selected models.
                foreach (ISelectable selectable in DynamoSelection.Instance.Selection)
                {
                    if (selectable is ModelBase)
                    {
                        modelsToDelete.Add(selectable as ModelBase);
                    }
                }
            }

            model.DeleteModelInternal(modelsToDelete);

            UndoCommand.RaiseCanExecuteChanged();
            RedoCommand.RaiseCanExecuteChanged();
        }
示例#2
0
            /// <summary>
            /// Call this static method to reconstruct a RecordableCommand-derived
            /// object given an XmlElement that was previously saved with Serialize
            /// method. This method simply redirects the XmlElement to respective
            /// RecordableCommand-derived classes based on its type.
            /// </summary>
            /// <param name="element">The XmlElement from which the RecordableCommand
            /// can be reconstructed.</param>
            /// <returns>Returns the reconstructed RecordableCommand object. If a
            /// RecordableCommand cannot be reconstructed, this method throws a
            /// relevant exception.</returns>
            ///
            internal static RecordableCommand Deserialize(XmlElement element)
            {
                if (string.IsNullOrEmpty(element.Name))
                {
                    throw new ArgumentException("XmlElement without name");
                }

                RecordableCommand command = null;

                switch (element.Name)
                {
                case "CreateNodeCommand":
                    command = CreateNodeCommand.DeserializeCore(element);
                    break;

                case "SelectModelCommand":
                    command = SelectModelCommand.DeserializeCore(element);
                    break;

                case "CreateNoteCommand":
                    command = CreateNoteCommand.DeserializeCore(element);
                    break;

                case "SelectInRegionCommand":
                    command = SelectInRegionCommand.DeserializeCore(element);
                    break;

                case "DragSelectionCommand":
                    command = DragSelectionCommand.DeserializeCore(element);
                    break;

                case "MakeConnectionCommand":
                    command = MakeConnectionCommand.DeserializeCore(element);
                    break;

                case "DeleteModelCommand":
                    command = DeleteModelCommand.DeserializeCore(element);
                    break;

                case "UndoRedoCommand":
                    command = UndoRedoCommand.DeserializeCore(element);
                    break;

                case "UpdateModelValueCommand":
                    command = UpdateModelValueCommand.DeserializeCore(element);
                    break;
                }

                if (null != command)
                {
                    command.IsInPlaybackMode = true;
                    return(command);
                }

                string message = string.Format("Unknown command: {0}", element.Name);

                throw new ArgumentException(message);
            }
示例#3
0
        public async Task ExecuteAsync(DeleteModelCommand command)
        {
            var model = await ModelsDao.FindAsync(command.Id);

            if (model == null)
            {
                throw new ArgumentException($"{typeof(TModel).Name} with given Id not found");
            }
            ModelsDao.Remove(model);
            await SaveAsync();
        }
示例#4
0
        public void Execute(DeleteModelCommand command)
        {
            var model = ModelsDao.Find(command.Id);

            if (model == null)
            {
                throw new ArgumentException($"{typeof(TModel).Name} with given Id not found");
            }
            ModelsDao.Remove(model);
            Save();
        }
示例#5
0
 /// <summary>Deletes the specified model.</summary>
 /// <param name="model">The model to delete.</param>
 public void Delete(IModel model)
 {
     try
     {
         DeleteModelCommand command = new DeleteModelCommand(model, this.GetNodeDescription(model), this.view);
         CommandHistory.Add(command, true);
     }
     catch (Exception err)
     {
         MainPresenter.ShowError(err);
     }
 }
示例#6
0
        private void InitActions()
        {
            AddModCommand = new AddModelCommand <ModItemViewModel>(Mods, new ModItemViewModel(new Mod(), this), ActionsManager);
            AddModCommand.CommandExecuted += ((cmd, param) =>
            {
                SelectedMod = param;
                Status.IsProgressVisible = false;
                Status.Status = string.Format("Added mod with ID = {0}", SelectedMod.Mod.ID);
            });

            DeleteModCommand    = new DeleteModelCommand <ModItemViewModel>(Mods, ActionsManager);
            CheckAllModsCommand = new CheckAllModsCommand(this);
            SaveChangesCommand  = new SaveChangesCommand();
        }
        void DeleteModelImpl(DeleteModelCommand command)
        {
            var modelsToDelete = new List <ModelBase>();

            if (command.ModelGuid == Guid.Empty)
            {
                // When nothing is specified then it means all selected models.
                modelsToDelete.AddRange(DynamoSelection.Instance.Selection.OfType <ModelBase>());
            }
            else
            {
                modelsToDelete.AddRange(command.ModelGuids.Select(guid => CurrentWorkspace.GetModelInternal(guid)));
            }

            DeleteModelInternal(modelsToDelete);
        }
示例#8
0
        private void DeleteModelImpl(DeleteModelCommand command)
        {
            List<ModelBase> modelsToDelete = new List<ModelBase>();
            if (command.ModelGuid != Guid.Empty)
            {
                modelsToDelete.Add(CurrentSpace.GetModelInternal(command.ModelGuid));
            }
            else
            {
                // When nothing is specified then it means all selected models.
                foreach (ISelectable selectable in DynamoSelection.Instance.Selection)
                {
                    if (selectable is ModelBase)
                        modelsToDelete.Add(selectable as ModelBase);
                }
            }

            _model.DeleteModelInternal(modelsToDelete);
        }
示例#9
0
            /// <summary>
            /// Call this static method to reconstruct a RecordableCommand-derived
            /// object given an XmlElement that was previously saved with Serialize
            /// method. This method simply redirects the XmlElement to respective
            /// RecordableCommand-derived classes based on its type.
            /// </summary>
            /// <param name="element">The XmlElement from which the RecordableCommand
            /// can be reconstructed.</param>
            /// <returns>Returns the reconstructed RecordableCommand object. If a
            /// RecordableCommand cannot be reconstructed, this method throws a
            /// relevant exception.</returns>
            ///
            internal static RecordableCommand Deserialize(XmlElement element)
            {
                if (string.IsNullOrEmpty(element.Name))
                {
                    throw new ArgumentException("XmlElement without name");
                }

                switch (element.Name)
                {
                case "CreateNodeCommand":
                    return(CreateNodeCommand.DeserializeCore(element));

                case "SelectModelCommand":
                    return(SelectModelCommand.DeserializeCore(element));

                case "CreateNoteCommand":
                    return(CreateNoteCommand.DeserializeCore(element));

                case "SelectInRegionCommand":
                    return(SelectInRegionCommand.DeserializeCore(element));

                case "DragSelectionCommand":
                    return(DragSelectionCommand.DeserializeCore(element));

                case "MakeConnectionCommand":
                    return(MakeConnectionCommand.DeserializeCore(element));

                case "DeleteModelCommand":
                    return(DeleteModelCommand.DeserializeCore(element));

                case "UndoRedoCommand":
                    return(UndoRedoCommand.DeserializeCore(element));
                }

                string message = string.Format("Unknown command: {0}", element.Name);

                throw new ArgumentException(message);
            }
示例#10
0
        void DeleteModelImpl(DeleteModelCommand command)
        {
            var modelsToDelete = new List<ModelBase>();
            if (command.ModelGuid == Guid.Empty)
            {
                // When nothing is specified then it means all selected models.
                modelsToDelete.AddRange(DynamoSelection.Instance.Selection.OfType<ModelBase>());
            }
            else
            {
                modelsToDelete.AddRange(command.ModelGuids.Select(guid => CurrentWorkspace.GetModelInternal(guid)));
            }

            DeleteModelInternal(modelsToDelete);
        }
示例#11
0
        /// <summary>Deletes the specified model.</summary>
        /// <param name="model">The model to delete.</param>
        public void Delete(IModel model)
        {
            DeleteModelCommand command = new DeleteModelCommand(model, this.GetNodeDescription(model), this.view);

            this.CommandHistory.Add(command, true);
        }
示例#12
0
            /// <summary>
            /// Call this static method to reconstruct a RecordableCommand-derived
            /// object given an XmlElement that was previously saved with Serialize
            /// method. This method simply redirects the XmlElement to respective
            /// RecordableCommand-derived classes based on its type.
            /// </summary>
            /// <param name="element">The XmlElement from which the RecordableCommand
            /// can be reconstructed.</param>
            /// <returns>Returns the reconstructed RecordableCommand object. If a
            /// RecordableCommand cannot be reconstructed, this method throws a
            /// relevant exception.</returns>
            ///
            internal static RecordableCommand Deserialize(XmlElement element)
            {
                if (string.IsNullOrEmpty(element.Name))
                {
                    throw new ArgumentException("XmlElement without name");
                }

                RecordableCommand command = null;

                switch (element.Name)
                {
                case "OpenFileCommand":
                    command = OpenFileCommand.DeserializeCore(element);
                    break;

                case "PausePlaybackCommand":
                    command = PausePlaybackCommand.DeserializeCore(element);
                    break;

                case "RunCancelCommand":
                    command = RunCancelCommand.DeserializeCore(element);
                    break;

                case "CreateNodeCommand":
                    command = CreateNodeCommand.DeserializeCore(element);
                    break;

                case "SelectModelCommand":
                    command = SelectModelCommand.DeserializeCore(element);
                    break;

                case "CreateNoteCommand":
                    command = CreateNoteCommand.DeserializeCore(element);
                    break;

                case "SelectInRegionCommand":
                    command = SelectInRegionCommand.DeserializeCore(element);
                    break;

                case "DragSelectionCommand":
                    command = DragSelectionCommand.DeserializeCore(element);
                    break;

                case "MakeConnectionCommand":
                    command = MakeConnectionCommand.DeserializeCore(element);
                    break;

                case "DeleteModelCommand":
                    command = DeleteModelCommand.DeserializeCore(element);
                    break;

                case "UndoRedoCommand":
                    command = UndoRedoCommand.DeserializeCore(element);
                    break;

                case "ModelEventCommand":
                    command = ModelEventCommand.DeserializeCore(element);
                    break;

                case "UpdateModelValueCommand":
                    command = UpdateModelValueCommand.DeserializeCore(element);
                    break;

                case "ConvertNodesToCodeCommand":
                    command = ConvertNodesToCodeCommand.DeserializeCore(element);
                    break;

                case "CreateCustomNodeCommand":
                    command = CreateCustomNodeCommand.DeserializeCore(element);
                    break;

                case "SwitchTabCommand":
                    command = SwitchTabCommand.DeserializeCore(element);
                    break;
                }

                if (null != command)
                {
                    command.IsInPlaybackMode = true;
                    command.Tag = element.GetAttribute("Tag");
                    return(command);
                }

                string message = string.Format("Unknown command: {0}", element.Name);

                throw new ArgumentException(message);
            }
示例#13
0
 /// <summary>Deletes the specified model.</summary>
 /// <param name="model">The model to delete.</param>
 public void Delete(IModel model)
 {
     DeleteModelCommand command = new DeleteModelCommand(model, GetNodeDescription(model), this.view);
     this.CommandHistory.Add(command, true);
 }