public HexLine AddGridLine(Site origin, Site target, int lineId, BaseGrid grid) { var line = new HexLine(origin, target, lineId, Grid); GridLines.Add(lineId, line); return(line); }
public HexLine AddGridLine(Dimension dimension, Site origin, int lineId, BaseGrid grid) { var line = new HexLine(dimension, origin, lineId, Grid); GridLines.Add(lineId, line); return(line); }
} = new List <UIElement>(); // holds the collection of text elements public void DrawGrid(int firstHour, int hours) { foreach (var line in GridLines) { GraphCanvas.Children.Remove(line); // TODO Try block? } GridLines.Clear(); foreach (var location in LocationUiElements) { GraphCanvas.Children.Remove(location); // TODO try block? } LocationUiElements.Clear(); double margin = 0; // TODO remove this? double width = GraphCanvas.Width - 2 * margin; double height = GraphCanvas.Height - 2 * margin; // vertical hours per 15 minutes, so divide by 96 // alt is per hour a grid line double gridHeight = height / hours; double gridWidth = width / LocationList.Count; // Horizontal for (int i = 0; i < hours + 1; i++) { var line = GetLine(margin); line.X1 = 0; line.X2 = width; line.Y1 = i * gridHeight; line.Y2 = line.Y1; var hour = $"{i+firstHour:D2}:00"; GridLines.Add(line); UIElement item = Text(line.X1 - 28, line.Y1 - 5, hour, GraphCanvasSettings.TextColor); LocationUiElements.Add(item); GraphCanvas.Children.Add(item); GraphCanvas.Children.Add(line); } int j = 0; foreach (var item in LocationList) { var line = GetLine(margin); line.X1 = j * gridWidth; line.X2 = line.X1; line.Y1 = 0; line.Y2 = height; GridLines.Add(line); UIElement locationUI = Text(line.X1, line.Y1 - 15, item, GraphCanvasSettings.TextColor); GraphCanvas.Children.Add(locationUI); GraphCanvas.Children.Add(line); j++; } }
private void AddGridLine(StockData data) { if (dgvData.InvokeRequired) { AddGridLineDelegate func = new AddGridLineDelegate(AddGridLine); Invoke(func, new object[] { data }); } else { gridLines.Add(new GridLine { Low = data.StockPriceLow, High = data.StockPriceHigh, Volume = data.stockVolume, rawData = data }); } }
//based on http://answers.unity.com/answers/1108340/view.html internal void CreateGridLine(int startX, int startY, int startZ, int endX, int endY, int endZ) { Color color = new Color(0.505f, 0.145f, 0.552f); Vector3 start = GetGridScaledVector(startX, startY, startZ); Vector3 end = GetGridScaledVector(endX, endY, endZ); GameObject myLine = new GameObject(); myLine.transform.position = start; myLine.AddComponent <LineRenderer>(); LineRenderer lr = myLine.GetComponent <LineRenderer>(); lr.material = new Material(Shader.Find("Standard")); lr.startColor = lr.endColor = color; lr.startWidth = lr.endWidth = 0.2f; lr.SetPosition(0, start); lr.SetPosition(1, end); GridLines.Add(myLine); }
public void drawGridlines() { if (Points.Count != 4) { return; } Point p1, p2, p1h, p2h; Line newLine; double x; double y; // Vertical Lines x = ((Points[0].X * 2) + Points[1].X) / 3; y = ((Points[0].Y * 2) + Points[1].Y) / 3; p1 = new Point(x, y); x = ((Points[3].X * 2) + Points[2].X) / 3; y = ((Points[3].Y * 2) + Points[2].Y) / 3; p2 = new Point(x, y); newLine = createLine(p1, p2); GridLines.Add(newLine); x = (Points[0].X + (Points[1].X) * 2) / 3; y = (Points[0].Y + (Points[1].Y) * 2) / 3; p1 = new Point(x, y); x = (Points[3].X + (Points[2].X) * 2) / 3; y = (Points[3].Y + (Points[2].Y) * 2) / 3; p2 = new Point(x, y); newLine = createLine(p1, p2); GridLines.Add(newLine); // Horizontal Lines // Mid x = (Points[1].X + Points[2].X) / 2; y = (Points[1].Y + Points[2].Y) / 2; p1h = new Point(x, y); x = (Points[0].X + Points[3].X) / 2; y = (Points[0].Y + Points[3].Y) / 2; p2h = new Point(x, y); newLine = createLine(p1h, p2h); GridLines.Add(newLine); // 1/3 Top x = (Points[0].X * 2 + p2h.X) / 3; y = (Points[0].Y * 2 + p2h.Y) / 3; p1 = new Point(x, y); x = (Points[1].X * 2 + p1h.X) / 3; y = (Points[1].Y * 2 + p1h.Y) / 3; p2 = new Point(x, y); newLine = createLine(p1, p2); GridLines.Add(newLine); // 2/3 Top x = (Points[0].X + p2h.X * 2) / 3; y = (Points[0].Y + p2h.Y * 2) / 3; p1 = new Point(x, y); x = (Points[1].X + p1h.X * 2) / 3; y = (Points[1].Y + p1h.Y * 2) / 3; p2 = new Point(x, y); newLine = createLine(p1, p2); GridLines.Add(newLine); // 1/3 Bottom x = (p2h.X * 2 + Points[3].X) / 3; y = (p2h.Y * 2 + Points[3].Y) / 3; p1 = new Point(x, y); x = (p1h.X * 2 + Points[2].X) / 3; y = (p1h.Y * 2 + Points[2].Y) / 3; p2 = new Point(x, y); newLine = createLine(p1, p2); GridLines.Add(newLine); // 2/3 Bottom x = (p2h.X + Points[3].X * 2) / 3; y = (p2h.Y + Points[3].Y * 2) / 3; p1 = new Point(x, y); x = (p1h.X + Points[2].X * 2) / 3; y = (p1h.Y + Points[2].Y * 2) / 3; p2 = new Point(x, y); newLine = createLine(p1, p2); GridLines.Add(newLine); foreach (Line l in GridLines) { l.IsHitTestVisible = false; l.StrokeThickness = 1.5; } isGridlinesVisible = true; }