/// <summary> ///判断鼠标点位,生成选中列车和冲突点信息 /// </summary> private void TimetableViewCtrl_MouseMove(object sender, MouseEventArgs e) { pictureBox2.Size = new Size(TD_Width, TD_Height); float precision = 5f; int n = -1; int c = -1; if (checkBox1.Checked) { foreach (Train train in dm.upTrainList) { Graphics gs; gs = Graphics.FromImage(bmp); if (checkBox1.Checked) { for (int i = 0; i < ci.ConflictList.Count; i++) { if (ci.ConflictList[i].FrontTrain.Dir == "up") { c = PaintTool.PointInCircle(e.Location, ci.ConflictList[i].ConflictLocation, 5f); if (c == 0) { dataGridView1.Visible = false; this.pictureBox2.Refresh(); DrawPicture(); int k = pt.border2.Count; for (int i1 = 0; i1 < k; i1++) { int ii = i1 + 1; double total1 = pt.Mile1[ii].Last(); if (YesOrNo) { pt.ConflictDrawUp(gs, ConflictTable, dm.TrainDic, dm.stationStringList); } } ShowInfoTooltip(ci.ConflictList[i], e.Location); Pen SelectedPen = new Pen(Color.Blue, 2); if (YesOrNo) { gs.DrawEllipse(SelectedPen, ci.ConflictList[i].ConflictLocation.X - 2, ci.ConflictList[i].ConflictLocation.Y - 2, 5, 5); } break; } } } } if (c != 0) { dataGridView2.Visible = false; for (int i = 0; i < train.TrainPointList.Count; i++) { for (int s = 0; s < pt.str1.Count; s++) { for (int m = 0; m < train.staList.Count - 1; m++) { if ((train.TrainPointList[s].ContainsKey(train.staList[m])) && (train.TrainPointList[s].ContainsKey(train.staList[m + 1]))) { n = PaintTool.PointInLine(e.Location, train.TrainPointList[s][train.staList[m]][1], train.TrainPointList[s][train.staList[m + 1]][0], precision); if (n == 0) { break; } } } if (n == 0) { break; } } if (n == 0) { this.pictureBox2.Refresh(); DrawPicture(); if (checkBox1.Checked) { int k = pt.border2.Count; for (int i1 = 0; i1 < k; i1++) { int ii = i1 + 1; double total1 = pt.Mile1[ii].Last(); if (YesOrNo) { pt.ConflictDrawUp(gs, ConflictTable, dm.TrainDic, dm.stationStringList); } } } if (checkBox2.Checked) { int k = pt.border2.Count; for (int i1 = 0; i1 < k; i1++) { int ii = i1 + 1; double total1 = pt.Mile1[ii].Last(); if (YesOrNo) { pt.ConflictDrawDown(gs, ConflictTable, dm.TrainDic, dm.stationStringList); } } } ShowInfoTooltip(train, e.Location); Pen SelectedPen = new Pen(Color.Blue, 2); for (int j = 1; j < pt.str1.Count + 1; j++) { for (int p = 0; p < pt.str1[j].Count - 1; p++) { if (train.TrainPointList[j - 1].Count <= 1) { break; } if ((train.staList.Contains(pt.str1[j][p])) && (train.staList.Contains(pt.str1[j][p + 1]))) { gs.DrawLine(SelectedPen, train.TrainPointList[j - 1][pt.str1[j][p]][0], train.TrainPointList[j - 1][pt.str1[j][p + 1]][1]); } } for (int p = 1; p < pt.str1[j].Count - 1; p++) { if (train.TrainPointList[j - 1].Count <= 1) { break; } if (train.staList.Contains(pt.str1[j][p])) { gs.DrawLine(SelectedPen, train.TrainPointList[j - 1][pt.str1[j][p]][1], train.TrainPointList[j - 1][pt.str1[j][p]][0]); } } } break; } } } if ((c == 0) || (n == 0)) { break; } } Refresh(); } if (checkBox2.Checked) { foreach (Train train in dm.downTrainList) { Graphics gs; gs = Graphics.FromImage(bmp); if (checkBox2.Checked) { for (int i = 0; i < ci.ConflictList.Count; i++) { if (ci.ConflictList[i].FrontTrain.Dir == "down") { c = PaintTool.PointInCircle(e.Location, ci.ConflictList[i].ConflictLocation, 5f); if (c == 0) { dataGridView1.Visible = false; this.pictureBox2.Refresh(); DrawPicture(); int k = pt.border2.Count; for (int i1 = 0; i1 < k; i1++) { int ii = i1 + 1; double total1 = pt.Mile1[ii].Last(); if (YesOrNo) { pt.ConflictDrawDown(gs, ConflictTable, dm.TrainDic, dm.stationStringList); } } ShowInfoTooltip(ci.ConflictList[i], e.Location); Pen SelectedPen = new Pen(Color.Blue, 2); if (YesOrNo) { gs.DrawEllipse(SelectedPen, ci.ConflictList[i].ConflictLocation.X - 2, ci.ConflictList[i].ConflictLocation.Y - 2, 5, 5); } break; } } } } if (c != 0) { dataGridView2.Visible = false; for (int i = 0; i < train.TrainPointList.Count - 1; i++) { for (int s = 0; s < pt.str1.Count; s++) { for (int m = 0; m < train.staList.Count - 1; m++) { if ((train.TrainPointList[s].ContainsKey(train.staList[m])) && (train.TrainPointList[s].ContainsKey(train.staList[m + 1]))) { n = PaintTool.PointInLine(e.Location, train.TrainPointList[s][train.staList[m]][1], train.TrainPointList[s][train.staList[m + 1]][0], precision); if (n == 0) { break; } } } if (n == 0) { break; } } if (n == 0) { this.pictureBox2.Refresh(); DrawPicture(); if (checkBox1.Checked) { int k = pt.border2.Count; for (int i1 = 0; i1 < k; i1++) { int ii = i1 + 1; double total1 = pt.Mile1[ii].Last(); if (YesOrNo) { pt.ConflictDrawUp(gs, ConflictTable, dm.TrainDic, dm.stationStringList); } } } if (checkBox2.Checked) { int k = pt.border2.Count; for (int i1 = 0; i1 < k; i1++) { int ii = i1 + 1; double total1 = pt.Mile1[ii].Last(); if (YesOrNo) { pt.ConflictDrawDown(gs, ConflictTable, dm.TrainDic, dm.stationStringList); } } } ShowInfoTooltip(train, e.Location); Pen SelectedPen = new Pen(Color.Blue, 2); for (int j = 1; j < pt.str1.Count + 1; j++) { for (int p = 0; p < pt.str1[j].Count - 1; p++) { if (train.TrainPointList[j - 1].Count <= 0) { break; } if (train.staList.Contains(pt.str1[j][p]) && train.staList.Contains(pt.str1[j][p + 1])) { gs.DrawLine(SelectedPen, train.TrainPointList[j - 1][pt.str1[j][p]][1], train.TrainPointList[j - 1][pt.str1[j][p + 1]][0]); } } for (int p = 1; p < pt.str1[j].Count - 1; p++) { if (train.TrainPointList[j - 1].Count <= 1) { break; } if (train.staList.Contains(pt.str1[j][p])) { gs.DrawLine(SelectedPen, train.TrainPointList[j - 1][pt.str1[j][p]][1], train.TrainPointList[j - 1][pt.str1[j][p]][0]); } } } break; } } } if ((c == 0) || (n == 0)) { break; } } Refresh(); } }