/* */ public void UpdateLines() { if (linesCreated == false) { linesCreated = RecreateLines(); if (linesCreated == false) { return; } } Point startPoint = Port1.GetConnectionPoint(); Point endPoint = Port2.GetConnectionPoint(); if (anchors.Count == 0) { lines[0].UpdateCoordinates(startPoint, endPoint); } else { lines[0].UpdateCoordinates(startPoint.X, startPoint.Y, anchors[0].Position.X, startPoint.Y); lines[1].UpdateCoordinates(anchors[0].Position.X, startPoint.Y, anchors[0].Position.X, anchors[0].Position.Y); int lineindex = 1; for (int i = 1; i < anchors.Count; i++) { lines[i + 1].UpdateCoordinates(anchors[i - 1].Position.X, anchors[i - 1].Position.Y, anchors[i].Position.X, anchors[i - 1].Position.Y); lines[i + 2].UpdateCoordinates(anchors[i].Position.X, anchors[i - 1].Position.Y, anchors[i].Position.X, anchors[i].Position.Y); lineindex += 2; } lines[lineindex + 1].UpdateCoordinates(anchors[anchors.Count - 1].Position.X, anchors[anchors.Count - 1].Position.Y, anchors[anchors.Count - 1].Position.X, endPoint.Y); lines[lineindex + 2].UpdateCoordinates(anchors[anchors.Count - 1].Position.X, endPoint.Y, endPoint.X, endPoint.Y); } }
public bool IsClicked(Point point, out Object clickedObject) { Point startPoint = Port1.GetConnectionPoint(); Point endPoint = Port2.GetConnectionPoint(); clickedObject = null; foreach (AnchorPoint anchor in anchors) { if (anchor.IsClicked(point, out clickedObject)) { Select(); return(true); } } if (lines.IsClicked(point, out clickedObject)) { clickedObject = this; Select(); return(true); } return(false); }
public void Render(RenderContext context) { if (!PortPainter2Guid.Equals(Guid.Empty)) { Point startPoint = Port1.GetConnectionPoint(); Point endPoint = Port2.GetConnectionPoint(); if (IsSelected()) { lines.LinesColor = Colors.Red; } else { lines.LinesColor = Colors.Black; } lines.Render(context); if (IsSelected()) { RectanglePainter rectangle = new RectanglePainter(); rectangle.Width = 10; rectangle.Height = 10; rectangle.Left = startPoint.X - rectangle.Width / 2; rectangle.Top = startPoint.Y - rectangle.Height / 2; rectangle.BackgroundColor = Colors.Blue; rectangle.Render(context); rectangle.Width = 10; rectangle.Height = 10; rectangle.Left = endPoint.X - rectangle.Width / 2; rectangle.Top = endPoint.Y - rectangle.Height / 2; rectangle.BackgroundColor = Colors.Blue; rectangle.Render(context); foreach (AnchorPoint point in anchors) { point.Render(context); } } } else { Point startPoint = Port1.GetConnectionPoint(); Point endPoint = SecondPoint; context.DrawLine(startPoint.X, startPoint.Y, endPoint.X, endPoint.Y, LineColor); } }
public Boolean RecreateLines() { lines.Clear(); if ((Port1 == null) || (Port2 == null)) { return(false); } Point startPoint = Port1.GetConnectionPoint(); Point endPoint = Port2.GetConnectionPoint(); if (anchors.Count == 0) { LineRenderer line = new LineRenderer(); line.StartPoint = startPoint; line.EndPoint = endPoint; lines.Add(line); } else { lines.AddNewLine(startPoint.X, startPoint.Y, anchors[0].Position.X, startPoint.Y, LineColor); lines.AddNewLine(anchors[0].Position.X, startPoint.Y, anchors[0].Position.X, anchors[0].Position.Y, LineColor); for (int i = 1; i < anchors.Count; i++) { lines.AddNewLine(anchors[i - 1].Position.X, anchors[i - 1].Position.Y, anchors[i].Position.X, anchors[i - 1].Position.Y, LineColor); lines.AddNewLine(anchors[i].Position.X, anchors[i - 1].Position.Y, anchors[i].Position.X, anchors[i].Position.Y, LineColor); } lines.AddNewLine(anchors[anchors.Count - 1].Position.X, anchors[anchors.Count - 1].Position.Y, anchors[anchors.Count - 1].Position.X, endPoint.Y, LineColor); lines.AddNewLine(anchors[anchors.Count - 1].Position.X, endPoint.Y, endPoint.X, endPoint.Y, LineColor); } if (IsSelected()) { lines.LinesColor = Colors.Black; lines.LinesColor = Colors.Red; } return(true); }