public TestOneline() { //0 1 0 0 //1 1 1 1 //1 1 2 1 one.SetStart(2, 2); one.SetState(0, 0, State.None); one.SetState(0, 1, State.Avaliable); one.SetState(0, 2, State.None); one.SetState(0, 3, State.None); one.SetState(1, 0, State.Avaliable); one.SetState(1, 1, State.Avaliable); one.SetState(1, 2, State.Avaliable); one.SetState(1, 3, State.Avaliable); one.SetState(2, 0, State.Avaliable); one.SetState(2, 1, State.Avaliable); one.SetState(2, 2, State.Avaliable); one.SetState(2, 3, State.Avaliable); one.SetState(3, 0, State.None); one.SetState(3, 1, State.Avaliable); one.SetState(3, 2, State.Avaliable); one.SetState(3, 3, State.Avaliable); one.InitCaculate(); one.Caculate(); }
private void Run(object sender, RoutedEventArgs e) { uint x = Convert.ToUInt16(start_x.Text); uint y = Convert.ToUInt16(start_y.Text); if (x > w || y > h || x < 0 || y < 0) { MessageBox.Show("起点不合法"); return; } line.SetStart(x, y); line.InitCaculate(); line.Caculate(); if (line.Road.Count == 0) { MessageBox.Show("oops"); return; } for (int i = 0; i < line.Road.Count - 1; i++) { Line l = new Line(); // l.Width = 10; l.Stroke = new SolidColorBrush(Colors.Red); l.StrokeThickness = 10; l.X1 = line.Road[i].X * 51 + 26; l.Y1 = line.Road[i].Y * 51 + 26; l.X2 = line.Road[i + 1].X * 51 + 26; l.Y2 = line.Road[i + 1].Y * 51 + 26; canvas.Children.Add(l); } }