public void DrawGalaxyMap() { if (MainData.GetGalaxyMap() != null) { foreach (Cluster mapCluster in MainData.GetGalaxyMap().Clusters) { MainData.AddChildToCanvas(CanvasElementType.CLUSTER, mapCluster.Polygon, mapCluster.UId.ToString()); } MainData.Canvas.UpdateLayout(); foreach (CanvasConnection con in MainData.GetGalaxyMap().CanvasConnections) { con.GenerateLine(); } } }
public void GenerateLine() { Point cluster1Pos = MainData.GetGalaxyMap().Clusters.First(c => c.Id == ConnectionId1).Polygon.TransformToAncestor(MainData.Canvas).Transform(new Point(0, 0)); Point cluster2Pos = MainData.GetGalaxyMap().Clusters.First(c => c.Id == ConnectionId2).Polygon.TransformToAncestor(MainData.Canvas).Transform(new Point(0, 0)); Console.WriteLine("1: " + cluster1Pos.ToString()); cluster1Pos = GetPoint(cluster1Pos, 55, Connection1Type); cluster2Pos = GetPoint(cluster2Pos, 55, Connection2Type); Line = new Line(); Line.X1 = cluster1Pos.X; Line.Y1 = cluster1Pos.Y; Line.X2 = cluster2Pos.X; Line.Y2 = cluster2Pos.Y; Line.Stroke = Brushes.Orange; Line.StrokeThickness = 5; Line.Tag = UId; MainData.AddChildToCanvas(CanvasElementType.CONNECTION, Line, UId.ToString()); }