/// <summary> /// подготавливает построенный маршрут, для его отобпражения на карте /// </summary> public void MakeStaticRoute() { Map.Way = new List <Vertex>(); int k = 0; while (k != Route.Way.Count - 1) { Vertex first = null, second = null; for (int i = 0; i < Map.vertexes.GetCountElements(); i++) { if (Map.vertexes.GetElement(i).ID == Route.Way[k]) { first = Map.vertexes.GetElement(i); break; } } k++; for (int i = 0; i < Map.vertexes.GetCountElements(); i++) { if (Map.vertexes.GetElement(i).ID == Route.Way[k]) { second = Map.vertexes.GetElement(i); break; } } Edge edge = Route.GetEdge(first, second, Map.edges); if (edge.GetHead().ID == Route.Way.ElementAt(k - 1)) { Map.Way.Add(edge.GetHead()); Map.Way.Add(edge.GetEnd()); edge.IsInWay = true; } else { Map.Way.Add(edge.GetEnd()); Map.Way.Add(edge.GetHead()); edge.IsInWay = true; } } string criterial = (Route.Criterial == Main.Criterial.Length) ? "Длина" : (Route.Criterial == Main.Criterial.Price) ? "Цена" : "Время"; string message = string.Format("{0} пути {1}", criterial, Math.Round(Route.Value, 2).ToString(), "Цена маршрута"); MakeMap.ViewPort.StatusLabel.Text = message; MessageBox.Show(message); ViewPort.Invalidate(); }
private void View_Paint(object sender, PaintEventArgs e) { int dX = StaticViewer.Width; if (selectedLabel != null) { e.Graphics.FillEllipse(PensCase.SelectedVertex, selectedLabel.X.UnScaling(), selectedLabel.Y.UnScaling(), dX, dX); } e.Graphics.FillEllipse(PensCase.Point, callibrationEdge.GetHead().X.UnScaling(), callibrationEdge.GetHead().Y.UnScaling(), dX, dX); e.Graphics.FillEllipse(PensCase.Point, callibrationEdge.GetEnd().X.UnScaling(), callibrationEdge.GetEnd().Y.UnScaling(), dX, dX); if (callibrationEdge != null) { int x1 = callibrationEdge.GetHead().X.UnScaling() + dX / 2; int x2 = callibrationEdge.GetEnd().X.UnScaling() + dX / 2; int y1 = callibrationEdge.GetHead().Y.UnScaling() + dX / 2; e.Graphics.DrawLine(PensCase.SelectedEdgeBilater, x1, y1, x2, y1); Brush b = new SolidBrush(Color.Black); e.Graphics.DrawString(100.ToString(), new Font(Font.FontFamily, 10f, FontStyle.Italic | FontStyle.Bold, GraphicsUnit.Point, Font.GdiCharSet), b, (x1 + (x2 - x1) / 2 - 25), (y1 - 16)); } }
public void AddEdge(Edge <NodeData, EdgeData> edge) { Assert.IsTrue(Contains(edge.GetStart()) && Contains(edge.GetEnd())); m_Edges.Add(edge); }
public bool Equals(Edge e) { return (Begin.Equals(e.GetBegin()) && End.Equals(e.GetEnd()) && Length == e.GetLength()); }