/// <summary> /// Moves a test case or group to a new position. /// </summary> /// <param name="node">The moved node.</param> /// <param name="destNode">The destination.</param> public void MoveTestCase(TreeNodeAdv node, TreeNodeAdv destNode) { TestCaseGroup destGroup = destNode.Tag as TestCaseGroup; if (destNode.Tag == null) { // Move to root destGroup = CoreData.Instance.TestCaseModel.Root; } if (destGroup == null) { return; } TreePath oldPath = treeView.GetPath(node.Parent); if (node.Tag is TestCase) { CoreData.Instance.TestCaseModel.MoveTestCase(node.Tag as TestCase, destGroup); } else if (node.Tag is TestCaseGroup) { CoreData.Instance.TestCaseModel.MoveTestCaseGroup(node.Tag as TestCaseGroup, destGroup); } OnNodesRemoved(new TreeModelEventArgs(oldPath, new[] { node.Tag })); OnNodesInserted(new TreeModelEventArgs(treeView.GetPath(destNode), new[] { node.Tag })); }
/// <summary> /// Refreshes this model /// </summary> public override void Refresh() { //We have to override this because the base impl does not //preserve the tree path of the selected node (and thus expand //all the nodes from the root to this node) // //Which is also why we need to pass a reference to //the TreeViewAdv in the ctor var selected = _tree.GetPath(_tree.SelectedNode); OnStructureChanged(new TreePathEventArgs(selected)); }
/// <summary> /// Gets the <see cref="TreePath"/> of the specified <see cref="ObjectField"/>. /// </summary> /// <param name="field">The <see cref="TreePath"/> of this <see cref="ObjectField"/> is returned.</param> /// <returns>The <see cref="TreePath"/> of the <see cref="ObjectField"/> or <c>null</c> if no <see cref="TreePath"/> could be found.</returns> private TreePath GetPath(ObjectField field) { return(treeView.GetPath(treeView.FindNodeByTag(field))); }