//////////////////////////////////////////////////// #region Visual /// <summary> /// Creates a visual which renders the edge. /// </summary> /// <remarks> /// Creates a VisualGroup which contains the actual edge rendering visual and /// the visuals which represent the arrows. /// </remarks> /// <param name="context">The render context.</param> /// <param name="edge">The edge to render.</param> /// <returns>A visual which renders the edge.</returns> protected override VisualGroup CreateVisual(IRenderContext context, IEdge edge) { var color = GetColor(context, edge); var group = new VisualGroup(); // Create the path to be drawn GeneralPath gp = GetPath(edge); var edgeVisual = new EdgeVisual(); edgeVisual.Update(gp, PathThickness, color); group.Add(edgeVisual); // add arrow visuals to the group AddArrows(context, group, edge, gp, Arrows, Arrows); return(group); }
/// <summary> /// Creates a visual which renders the edge. /// </summary> /// <remarks> /// Creates a VisualGroup which contains the actual edge rendering visual and /// the visuals which represent the arrows. /// </remarks> /// <param name="context">The render context.</param> /// <param name="edge">The edge to render.</param> /// <returns>A visual which renders the edge.</returns> protected override VisualGroup CreateVisual(IRenderContext context, IEdge edge) { var color = GetColor(context, edge); var group = new VisualGroup(); //////////////// New in this sample //////////////// // the cached path is updated with bridges (if there are any) GeneralPath gp = CreatePathWithBridges(GetPath(edge), context); //////////////////////////////////////////////////// var edgeVisual = new EdgeVisual(); edgeVisual.Update(gp, PathThickness, color); group.Add(edgeVisual); // add arrow visuals to the group AddArrows(context, group, edge, gp, Arrows, Arrows); return(group); }
protected override VisualGroup CreateVisual(IRenderContext context, IEdge edge) { bool selected = false; // Check if edge is selected var graphControl = context.CanvasControl as GraphControl; if (graphControl != null) { selected = graphControl.Selection.SelectedEdges.IsSelected(edge); } // Get default color from MySimpleNodeStyle Color color = MySimpleNodeStyle.Color; // Check if the ownernode has stored a color in it's tag INode owner = edge.SourcePort.Owner as INode; if (!selected && owner != null) { if (owner.Tag is Color) { color = (Color)owner.Tag; } } else if (selected) { // if edge is selected, draw with different color color = Color.DarkGoldenrod; } var group = new VisualGroup(); // Create the path to be drawn GeneralPath gp = GetPath(edge); var edgeVisual = new EdgeVisual(); edgeVisual.Update(gp, PathThickness, color); group.Add(edgeVisual); AddArrows(context, group, edge, gp, Arrows, Arrows); return(group); }