/// <summary>A node has been dropped.</summary> /// <param name="sender">Sending object</param> /// <param name="e">Drop arguments</param> private void OnDrop(object sender, DropArgs e) { string toParentPath = e.NodePath; Model toParent = Apsim.Get(this.ApsimXFile, toParentPath) as Model; DragObject dragObject = e.DragObject as DragObject; if (dragObject != null && toParent != null) { string fromModelXml = dragObject.Xml; string fromParentPath = StringUtilities.ParentName(dragObject.NodePath); ICommand cmd = null; if (e.Copied) { this.Add(fromModelXml, toParentPath); } else if (e.Moved) { if (fromParentPath != toParentPath) { Model fromModel = Apsim.Get(this.ApsimXFile, dragObject.NodePath) as Model; if (fromModel != null) { cmd = new MoveModelCommand(fromModel, toParent, this.GetNodeDescription(fromModel), this.view); CommandHistory.Add(cmd); } } } } }
/// <summary>A node has been dropped.</summary> /// <param name="sender">Sending object</param> /// <param name="e">Drop arguments</param> private void OnDrop(object sender, DropArgs e) { try { string toParentPath = e.NodePath; Model toParent = this.ApsimXFile.FindByPath(toParentPath)?.Value as Model; DragObject dragObject = e.DragObject as DragObject; if (dragObject != null && toParent != null) { string modelString = dragObject.ModelString; string fromParentPath = StringUtilities.ParentName(dragObject.NodePath); ICommand cmd = null; if (e.Moved) { if (fromParentPath != toParentPath) { Model fromModel = this.ApsimXFile.FindByPath(dragObject.NodePath)?.Value as Model; if (fromModel != null) { cmd = new MoveModelCommand(fromModel, toParent, GetNodeDescription); CommandHistory.Add(cmd); } } } else if (e.Copied) { var command = new AddModelCommand(toParent, modelString, GetNodeDescription); CommandHistory.Add(command, true); } else if (e.Linked) { // tbi MainPresenter.ShowMessage("Linked models TBI", Simulation.MessageType.Information); } view.Tree.ExpandChildren(toParent.FullPath, false); } } catch (Exception err) { MainPresenter.ShowError(err); } }
/// <summary>A node has been dropped.</summary> /// <param name="sender">Sending object</param> /// <param name="e">Drop arguments</param> private void OnDrop(object sender, DropArgs e) { try { string toParentPath = e.NodePath; Model toParent = Apsim.Get(this.ApsimXFile, toParentPath) as Model; DragObject dragObject = e.DragObject as DragObject; if (dragObject != null && toParent != null) { string modelString = dragObject.ModelString; string fromParentPath = StringUtilities.ParentName(dragObject.NodePath); ICommand cmd = null; if (e.Copied) { var command = new AddModelCommand(toParentPath, modelString, this); CommandHistory.Add(command, true); } else if (e.Moved) { if (fromParentPath != toParentPath) { Model fromModel = Apsim.Get(this.ApsimXFile, dragObject.NodePath) as Model; if (fromModel != null) { cmd = new MoveModelCommand(fromModel, toParent, this.GetNodeDescription(fromModel), this); CommandHistory.Add(cmd); } } } } } catch (Exception err) { MainPresenter.ShowError(err); } }
/// <summary>A node has been dropped.</summary> /// <param name="sender">Sending object</param> /// <param name="e">Drop arguments</param> private void OnDrop(object sender, DropArgs e) { string toParentPath = e.NodePath; Model toParent = Apsim.Get(this.ApsimXFile, toParentPath) as Model; DragObject dragObject = e.DragObject as DragObject; if (dragObject != null && toParent != null) { string fromModelXml = dragObject.Xml; string fromParentPath = StringUtilities.ParentName(dragObject.NodePath); ICommand cmd = null; if (e.Copied) Add(fromModelXml, toParentPath); else if (e.Moved) { if (fromParentPath != toParentPath) { Model fromModel = Apsim.Get(this.ApsimXFile, dragObject.NodePath) as Model; if (fromModel != null) { cmd = new MoveModelCommand(fromModel, toParent); } } } if (cmd != null) { CommandHistory.Add(cmd); } } }