private void renderBoard(String fen, int index) { string pattern = "([a-z|A-Z|/|0-9]*)[\\s]{1}([w|b])"; if (!Regex.IsMatch(fen, pattern) || !fen.Contains("/")) { MessageBox.Show(fen); this.txbExplain.Text = fen; return; // End of explaination or game } this.ContentBoard.Children.Clear(); touchItems = new TouchItem[10, 9]; MatchCollection matches = Regex.Matches(fen, pattern); Match match = matches[0]; string boardFen = match.Groups[1].Value; string start = match.Groups[2].Value; string[] boardLines = boardFen.Split('/'); int row = 0; foreach (string line in boardLines) { int col = 0; foreach (char c in line) { if (Char.IsNumber(c)) { int space = int.Parse(c.ToString()); for (int i = 0; i < space; i++) col++; } else { TouchItem item = new TouchItem(c, "intella"); item.R = row; item.C = col; item.Width = item.Height = 48; item.VerticalAlignment = 0; item.HorizontalAlignment = 0; item.Margin = new Thickness(5 + col * 53.1, 0 + row * 54, 0, 0); item.Visibility = Visibility.Visible; this.ContentBoard.Children.Add(item); touchItems[row, col] = item; touchItems[row, col].setVisibleForTouch(false); col++; } } row++; } }
private void renderBoard(char[,] bArr) { this.ContentBoard.Children.Clear(); touchItems = new TouchItem[10, 9]; for (int i = 0; i < 10; i++) { for (int j = 0; j < 9; j++) { TouchItem item = new TouchItem(bArr[i, j]); item.R = i; item.C = j; item.Width = item.Height = 48; item.VerticalAlignment = 0; item.HorizontalAlignment = 0; item.Margin = new Thickness(5 + j * 53.1, 0 + i * 54, 0, 0); item.Visibility = System.Windows.Visibility.Visible; this.ContentBoard.Children.Add(item); item.MouseLeftButtonDown += item_MouseLeftButtonDown; touchItems[i, j] = item; } } }