Hollow Link

Hi,

I would like to know how to create a diagram in which the link line is hollow. Meaning that the line connecting two nodes will have, say a black outer line and red interior fill.



Something like this:



this is black=> -------------------------

| This is red |

this is black=> -------------------------/



I can do it by setting the following:



PenColor = Color.Red;

PenWidth = 2;

HighlightPenColor = Color.Black;

HighlightPenWidth = 3;

Highlight = true;



but then I cannot give the user feedback when the link is selected.



Thank you,

Ido.

If you haven’t set HighlightWhenSelected, you should be getting selection handles.

you could create a Golink Class that has these overrides.

This allows you to use Highlight in the design of the link, yet still have color for selection.
[code]
public override void AddSelectionHandles(GoSelection sel, GoObject selectedObj) {
bool oldskips = this.SkipsUndoManager;
this.SkipsUndoManager = true;
this.HighlightPenColor = System.Drawing.Color.Chartreuse;
this.SkipsUndoManager = oldskips;
}
public override void RemoveSelectionHandles(GoSelection sel) {
bool oldskips = this.SkipsUndoManager;
this.SkipsUndoManager = true;
this.HighlightPenColor = Color.Black; // whatever color you want the link to be when not selected
this.SkipsUndoManager = oldskips;
}
[/code]
or... if you care about Primary / Secondary selection colors, a more complicated version:
[code]
public override void AddSelectionHandles(GoSelection sel, GoObject selectedObj) {
bool oldskips = this.SkipsUndoManager;
this.SkipsUndoManager = true;
Color selColor = Color.LightGray;
GoView view = sel.View;
if (view != null) {
if (sel.Focused) {
if (sel.Primary != null &&
sel.Primary.SelectionObject == this) {
selColor = view.PrimarySelectionColor;
} else {
selColor = view.SecondarySelectionColor;
}
} else {
selColor = view.NoFocusSelectionColor;
}
}
this.HighlightPenColor = selColor;
this.SkipsUndoManager = oldskips;
}
[/code]

Thank Jake, your answer seem to solve it.

The method names are not intuitive.

I’m also looking to do something similar, but instead of filling with another color, is it possible to have it transparent? In other words just have an outline of a link?

Create a Pen with a CompoundArray, which is a float[] of fractions from 0.0f to 1.0f of alternating pen line color and nothing, and set the GoShape.Pen property.