private void D_calc() { for (int i = 0; i < drp_matr.GetLength(1); i++) { for (int j = 0; j < drp_matr.GetLength(0); j++) { for (int a = 0; a < drp_matr.GetLength(1); a++) { for (int b = 0; b < drp_matr.GetLength(0); b++) { if (drp_matr[a, b] != 0 && drp_matr[i, j] != 0) { int x = search_pos(drp_matr[i, j], 0), y = search_pos(drp_matr[a, b], 0); d_matr[x, y] = d_matr[y, x] = Math.Abs(Math.Abs(a - i) + Math.Abs(b - j)); } } } } } string probel = " ", str = ""; int c = 0; dr.Text = dr2.Text = D_tb.Text = ""; for (int i = 0; i < d_matr.GetLength(0); i++) { if (positions[0, i] != 0) { if (i == 15) { dr.AppendText("D" + positions[0, i].ToString()); dr2.AppendText("D" + positions[0, i].ToString()); } else { dr.AppendText("D" + positions[0, i].ToString() + "\n"); dr2.AppendText("D" + positions[0, i].ToString() + "\n"); } c++; } } for (int i = 0; i < c; i++) //d_matr.GetLength(0) { for (int j = 0; j < c; j++) //d_matr.GetLength(1) { str += d_matr[i, j].ToString() + probel; } if (i != 15) { D_tb.AppendText(str + "\n"); } else { D_tb.AppendText(str); } str = ""; } }
private void Clear_Click(object sender, RoutedEventArgs e) { ex_tb.Clear(); tb.Clear(); for (int i = 0; i < 16; i++) { pos_unvisible(i); p[i].Fill = new SolidColorBrush(System.Windows.Media.Colors.White); } auto_fl = demo_fl = false; ffl = true; s_bt.IsEnabled = n_bt.IsEnabled = c_bt.IsEnabled = false; step = pos_max[0, 0] = pos_max[0, 1] = pos_max[0, 2] = pos_max[1, 1] = pos_max[1, 2] = 0; rd.Clear(); rd2.Clear(); dr.Clear(); dr2.Clear(); D_tb.Clear(); R_tb.Clear(); }