private void create_lianxu_coor(string code) { List <JToken> myJson = new List <JToken>(); if (code == "cqssc") { myJson = PublicClass.ChongqingJson; } Point next_d = new Point(0, 0); Point next_s = new Point(0, 0); Point cur = new Point(0, 0); int[,] fill_lianxu = new int[121, 7]; for (int i = 0; i < myJson.Count; i++) { string opencode = myJson[i]["opencode"].ToString(); string[] sopencode = opencode.Split(','); int mod = int.Parse(sopencode[4]); mod = mod % 2; int dou = 0; if (sopencode[3] == sopencode[4]) { dou = 10; } if (i == 0) { if (mod == 0) { fill_lianxu[0, 0] = 2 + dou; next_d = new Point(1, 0); next_s = new Point(0, 1); } else { fill_lianxu[0, 0] = 1 + dou; next_d = new Point(0, 1); next_s = new Point(1, 0); } } else if (mod == 0) { fill_lianxu[(int)next_s.X, (int)next_s.Y] = 2 + dou; next_d = new Point(next_s.X + 1, 0); if (fill_lianxu[(int)next_s.X, (int)next_s.Y + 1] == 0) { if (next_s.Y + 1 == 6 || fill_lianxu[(int)next_s.X, (int)next_s.Y + 1] == 1) { next_s = new Point(next_s.X + 1, next_s.Y); for (int b = (int)next_d.X; b > 0; b--) { if (fill_lianxu[b, 0] == 0) { next_d = new Point(b, 0); } } } else { next_s = new Point(next_s.X, next_s.Y + 1); } } else { next_s = new Point(next_s.X, next_s.Y + 1); } } else { fill_lianxu[(int)next_d.X, (int)next_d.Y] = 1 + dou; next_s = new Point(next_d.X + 1, 0); if (fill_lianxu[(int)next_d.X, (int)next_d.Y + 1] == 0) { if (next_d.Y + 1 == 6 || fill_lianxu[(int)next_d.X, (int)next_d.Y + 1] == 2) { next_d = new Point(next_d.X + 1, next_d.Y); for (int b = (int)next_s.X; b > 0; b--) { if (fill_lianxu[b, 0] == 0) { next_s = new Point(b, 0); } } } else { next_d = new Point(next_d.X, next_d.Y + 1); } } else { next_d = new Point(next_d.X, next_d.Y + 1); } } } Dispatcher.Invoke(new Action(delegate { rightlianxu rightcq = MainWindow.FindChild <rightlianxu>(Application.Current.MainWindow, "rightcq"); for (int i = 0; i < 120; i++) { for (int j = 0; j < 6; j++) { rightcq.fill_lianxu[i, j] = fill_lianxu[i, j]; } } rightcq.create_lianxu_coor(); })); }
private void create_lianxu_coor()//正向生成连续坐标 { Point next_d = new Point(0, 0); Point next_s = new Point(0, 0); Point cur = new Point(0, 0); fill_lianxu = new int[121, 7]; for (int i = 0; i < PublicClass.XinjiangJson.Count; i++) { string opencode = PublicClass.XinjiangJson[i]["opencode"].ToString(); string[] sopencode = opencode.Split(','); int mod = int.Parse(sopencode[4]); mod = mod % 2; int dou = 0; if (sopencode[3] == sopencode[4]) { dou = 10; } if (i == 0) { if (mod == 0) { fill_lianxu[0, 0] = 2 + dou; next_d = new Point(1, 0); next_s = new Point(0, 1); } else { fill_lianxu[0, 0] = 1 + dou; next_d = new Point(0, 1); next_s = new Point(1, 0); } } else if (mod == 0) { fill_lianxu[(int)next_s.X, (int)next_s.Y] = 2 + dou; next_d = new Point(next_s.X + 1, 0); if (fill_lianxu[(int)next_s.X, (int)next_s.Y + 1] == 0) { if (next_s.Y + 1 == 6 || fill_lianxu[(int)next_s.X, (int)next_s.Y + 1] == 1) { next_s = new Point(next_s.X + 1, next_s.Y); for (int b = (int)next_d.X; b > 0; b--) { if (fill_lianxu[b, 0] == 0) { next_d = new Point(b, 0); } } } else { next_s = new Point(next_s.X, next_s.Y + 1); } } else { next_s = new Point(next_s.X, next_s.Y + 1); } } else { fill_lianxu[(int)next_d.X, (int)next_d.Y] = 1 + dou; next_s = new Point(next_d.X + 1, 0); if (fill_lianxu[(int)next_d.X, (int)next_d.Y + 1] == 0) { if (next_d.Y + 1 == 6 || fill_lianxu[(int)next_d.X, (int)next_d.Y + 1] == 2) { next_d = new Point(next_d.X + 1, next_d.Y); for (int b = (int)next_s.X; b > 0; b--) { if (fill_lianxu[b, 0] == 0) { next_s = new Point(b, 0); } } } else { next_d = new Point(next_d.X, next_d.Y + 1); } } else { next_d = new Point(next_d.X, next_d.Y + 1); } } } Dispatcher.Invoke(new Action(delegate { for (int i = 0; i < lianxucanvas.Children.Count; i++) { lianxulab dellab = lianxucanvas.Children[i] as lianxulab; if (dellab != null) { lianxucanvas.Children.Remove(dellab); i--; } } for (int i = 0; i < 120; i++) { for (int j = 0; j < 6; j++) { if (fill_lianxu[i, j] != 0) { int type = 0; if (fill_lianxu[i, j] == 1) { type = 1; } else if (fill_lianxu[i, j] > 9) { type = fill_lianxu[i, j]; } lianxulab lianxu = new lianxulab(); lianxu.create_ell(type); lianxu.Margin = new Thickness(i * 40, j * 40, 0, 0); lianxucanvas.Children.Add(lianxu); } } } rightlianxu rightxj = MainWindow.FindChild <rightlianxu>(Application.Current.MainWindow, "rightxj"); for (int i = 0; i < 120; i++) { for (int j = 0; j < 6; j++) { rightxj.fill_lianxu[i, j] = fill_lianxu[i, j]; } } rightxj.create_lianxu_coor(); })); }