Пример #1
0
        /// <summary>Performs the command.</summary>
        /// <param name="CommandHistory">The command history.</param>
        public void Do(CommandHistory CommandHistory)
        {
            string originalPath = Apsim.FullPath(modelToRename);

            // Get original value of property so that we can restore it in Undo if needed.
            originalName = modelToRename.Name;

            // Set the new name.
            this.modelToRename.Name = newName;
            Apsim.EnsureNameIsUnique(this.modelToRename);
            explorerView.Rename(originalPath, this.modelToRename.Name);
        }
Пример #2
0
        /// <summary>
        /// Perform the command
        /// </summary>
        public void Do(CommandHistory CommandHistory)
        {
            Model FromParent = FromModel.Parent as Model;

            // Remove old model.
            ModelMoved = FromParent.Children.Remove(FromModel);

            // Add model to new parent.
            if (ModelMoved)
            {
                // The AddModel method may rename the FromModel. Go get the original name in case of
                // Undo later.
                OriginalName = FromModel.Name;

                ToParent.Children.Add(FromModel);
                FromModel.Parent = ToParent;
                Apsim.EnsureNameIsUnique(FromModel);
                CommandHistory.InvokeModelStructureChanged(FromParent);
                CommandHistory.InvokeModelStructureChanged(ToParent);
            }
        }
Пример #3
0
        /// <summary>
        /// Perform the command
        /// </summary>
        public void Do(CommandHistory CommandHistory)
        {
            FromParent = FromModel.Parent as Model;

            // Remove old model.
            ModelMoved = FromParent.Children.Remove(FromModel);

            // Add model to new parent.
            if (ModelMoved)
            {
                this.explorerView.Tree.Delete(Apsim.FullPath(this.FromModel));
                // The AddModel method may rename the FromModel. Go get the original name in case of
                // Undo later.
                OriginalName = FromModel.Name;

                ToParent.Children.Add(FromModel);
                FromModel.Parent = ToParent;
                Apsim.EnsureNameIsUnique(FromModel);
                nodeDescription.Name = FromModel.Name;
                this.explorerView.Tree.AddChild(Apsim.FullPath(ToParent), nodeDescription);
                CommandHistory.InvokeModelStructureChanged(FromParent);
                CommandHistory.InvokeModelStructureChanged(ToParent);
            }
        }