private void MoveFolderNode(TreeNodeMovePattern move, TreeNode node) { switch (move) { case TreeNodeMovePattern.Up: int index = node.Index - 1; if (0 <= index) { MoveNode(index, Nodes, node); } break; case TreeNodeMovePattern.Down: index = node.Index + 1; if (Nodes.Count - 1 >= index) { MoveNode(index, Nodes, node); } break; } }
private void MovePatternNode(TreeNodeMovePattern move, TreeNode node) { switch (move) { case TreeNodeMovePattern.Up: int index = node.Index - 1; if (0 <= index) { MoveNode(index, node.Parent.Nodes, node); } else if (node.Parent.PrevNode != null) { MoveNode(node.Parent.PrevNode.Nodes.Count, node.Parent.PrevNode.Nodes, node); } break; case TreeNodeMovePattern.Down: index = node.Index + 1; if (node.Parent.Nodes.Count - 1 >= index) { MoveNode(index, node.Parent.Nodes, node); } else if (node.Parent.NextNode != null) { MoveNode(0, node.Parent.NextNode.Nodes, node); } break; } }
public void MoveNode(TreeNodeMovePattern direction) { if (SelectedNode == null) { throw new InvalidOperationException("移動対象が選択されていません"); } switch (SelectedNode.Level) { case FolderLevel: MoveFolderNode(direction, SelectedNode); break; case PatternLevel: MovePatternNode(direction, SelectedNode); break; } }