private void SomethingDropped(object sender, DragEventArgs e) { if (!e.Data.GetDataPresent(DataFormats.FileDrop)) { return; } string[] array = e.Data.GetData(DataFormats.FileDrop) as string[]; if (array != null && array.Length >= 1) { string text = array[0]; if (pathValidator.IsValid(text)) { path.Text = text; } } }
private void SomethingDropped(object sender, DragEventArgs e) { if (e.Data.GetDataPresent(DataFormats.FileDrop)) { var files = e.Data.GetData(DataFormats.FileDrop) as string[]; if (files == null || files.Length < 1) { return; } var filename = files[0]; if (pathValidator.IsValid(filename)) { path.Text = filename; } } }
public PathFinderResult FindAllPaths(Piece piece, IPathValidator <Key> validator) { List <Path> paths = new List <Path>(); foreach (var startPosition in _keypad.Graph.Vertices) { if (!startPosition.Item.IsCharacter) { var tree = new Tree <Key>(startPosition.Item); _uniquePaths.Add(tree.Root.Item, tree); piece.MoveTo(startPosition); BuildPathsTree(piece, validator, _uniquePaths[startPosition.Item].Root, 1); if (validator.IsValid(tree)) { paths.AddRange(BuildAllPathsForStartPosition(piece, startPosition.Item)); } } } return(new PathFinderResult(paths, (from t in _uniquePaths.Values where validator.IsValid(t) select t))); }
private void BuildPathsTree(Piece piece, IPathValidator <Key> validator, TreeNode <Key> currentPosition, int currentDepth) { if (!validator.IsValid(currentPosition, currentDepth)) { return; } var moves = piece.GetPossibleMoves(); foreach (var move in moves) { piece.MoveTo(move); var destinationChildTreeNode = currentPosition.AddChild(move.Item); BuildPathsTree(piece, validator, destinationChildTreeNode, currentDepth + 1); } }