コード例 #1
0
ファイル: MoveModelCommand.cs プロジェクト: shenyczz/ApsimX
        /// <summary>Perform the command.</summary>
        public void Do(CommandHistory commandHistory)
        {
            fromParent = fromModel.Parent as Model;

            // The Move method may rename the FromModel. Go get the original name in case of
            // Undo later.
            originalName = fromModel.Name;
            string originalPath = this.fromModel.FullPath;

            // Move model.
            try
            {
                Structure.Move(fromModel, toParent);
                presenter.Move(originalPath, toParent, nodeDescription);
                commandHistory.InvokeModelStructureChanged(fromParent);
                commandHistory.InvokeModelStructureChanged(toParent);
            }
            catch (Exception err)
            {
                presenter.MainPresenter.ShowError(err);
                modelMoved = false;
            }
        }