GoLabeled Link with Beizer style

Hi, to all

I have GoLabeledLink with beizer style. User may move label, but it move some wrong. What I do wrong? Looks that:

The control points for a Bezier style stroke don’t fall on the line. That’s not a GoDiagram thing, that’s just how Beziers work.

You could try this approach: http://www.nwoods.com/forum/forum_posts.asp?TID=2095

Can do that All points will curve GoLabeledLink with Beizer style?

Thank you


Sorry, I don’t understand the question.

I would guess that you need to modify the LinkLabelConnectionPoint to return a Point computed from calling GoStroke.GetNearestIntersectionPoint.

The existing code assumes the stroke’s (i.e. the GoLabeledLink.RealLink’s) GoStroke.Style is not GoStrokeStyle.Bezier.

GoStroke.GetNearestIntersectionPoint return only [start] and [end] point. May I do some like that. There red line, it`s what I want to do.


I don`t know how do it. Please, help me!

Implement the LinkLabelConnectionPoint to be the result of the GoLabeledLink.RealLink.GetNearestIntersectionPoint, passing it the center of the LinkLabel and the center of the RealLink.

Basically you’ll be ignoring the segment index and percentage associated with the LinkLabel.

Thank you Walter your reply realy help me. When I moving GoLabeledLink its look bad <br /><img src="UserUploads/20080603_102015_23.PNG" border="0" /> <br />Im underline its with red. Its do, because can`t be redrawn. How be here?

That looks like a update problem, where there is an override of GoObject.Paint without the corresponding correct implementation of GoObject.ExpandPaintBounds.

Are you using the implementation of LinkLabel that came from the Processor sample? If so, I would have thought that that implementation overrides both Paint and ExpandPaintBounds correctly. Are the only two things you have changed to that sample LinkLabel class the initialization of the Style to be GoStrokeStyle.Bezier, and the implementation of the LinkLabelConnectionPoint?

Also it occurs to me that using GetNearestIntersectionPoint going to the Center of the stroke isn’t the best thing. What you really want is GetNearestPoint, but GoObject and GoShape do not provide such a method.

Yes, I get from Processor sample. And after your reply LinkLabel class looks that

Public Interface IvSyncGoLinkLabel

ReadOnly Property LinkLabelConnectionPoint() As PointF

'Property Offset() As SizeF

'Property Segment() As Integer

'Property SegmentPercentage() As Single

'Property LinkResizing() As Boolean

End Interface

<System.Serializable()> Public Class vSyncGoTaskLabel

Inherits GoText

Implements IvSyncGoLinkLabel

'Public Const ChangedOffset As Integer = LastChangedHint + 3214

'Public Const ChangedSegment As Integer = LastChangedHint + 3215

'Public Const ChangedSegmentPercentage As Integer = LastChangedHint + 3216

Public Const ChangedConnectionColor As Integer = LastChangedHint + 3217

'Private myOffset As SizeF = New SizeF(0, 0)

'Private mySegment As Integer = 3

'Private mySegmentPercentage As Single = 50

Private myConnectionColor As Color = Color.Gray

'Private fLinkResizing As Boolean = True

Sub New()

Me.Alignment = GoObject.MiddleCenter

Me.Copyable = False

Me.Deletable = False

Me.Selectable = True

Me.Editable = True

Me.Movable = True

'Me.Text = “label”

Me.TextColor = Color.DarkBlue

Me.FontSize = 8.5

Me.FamilyName = “Arial”

Me.TransparentBackground = False

End Sub

Public Overrides Sub Paint(ByVal g As Graphics, ByVal view As GoView)

Dim l As GoLabeledLink = Me.LabeledLink

Dim c As Color = Me.ConnectionColor

'If Not Me.LinkResizing Then

If (Not (l Is Nothing) AndAlso Not (c.Equals(Color.Empty))) Then

Dim Pen As Pen = New Pen©

Dim cp As PointF = Me.LinkLabelConnectionPoint

Dim Center As PointF = Me.Center

GoShape.DrawLine(g, view, Pen, Center.X, Center.Y, cp.X, cp.Y)


End If

'End If

MyBase.Paint(g, view)

End Sub

Public Overrides Function ExpandPaintBounds(ByVal rect As RectangleF, ByVal view As GoView) As RectangleF

Dim c As Color = Me.ConnectionColor

rect = MyBase.ExpandPaintBounds(rect, view)

If (Not c.Equals(Color.Empty)) Then

Dim cp As PointF = Me.LinkLabelConnectionPoint

rect = RectangleF.Union(rect, New RectangleF(cp.X, cp.Y, 2, 2))

End If

Return rect

End Function

Public Overrides Sub DoMove(ByVal view As Northwoods.Go.GoView, ByVal origLoc As System.Drawing.PointF, ByVal newLoc As System.Drawing.PointF)

MyBase.DoMove(view, origLoc, newLoc)

End Sub

Public ReadOnly Property LinkLabelConnectionPoint() As PointF Implements IvSyncGoLinkLabel.LinkLabelConnectionPoint


Dim l As GoLabeledLink = Me.LabeledLink

Dim r As PointF

l.RealLink.GetNearestIntersectionPoint(Me.Center, l.RealLink.Center, r)

Return r

End Get

End Property

Public ReadOnly Property LabeledLink() As GoLabeledLink


Return CType(Me.Parent, GoLabeledLink)

End Get

End Property

'Public Property Offset() As SizeF Implements IvSyncGoLinkLabel.Offset

’ Get

’ Return myOffset

’ End Get

’ Set(ByVal Value As SizeF)

’ Dim old As SizeF = myOffset

’ If Not (old.Equals(Value)) Then

’ myOffset = Value

’ Changed(ChangedOffset, 0, Nothing, MakeRect(old), 0, Nothing, MakeRect(Value))

’ End If

’ End Set

'End Property

'Public Property Segment() As Integer Implements IvSyncGoLinkLabel.Segment

’ Get

’ Return mySegment

’ End Get

’ Set(ByVal Value As Integer)

’ Dim old As Integer = mySegment

’ If Not (old = Value) Then

’ mySegment = Value

’ Changed(ChangedSegment, old, Nothing, NullRect, Value, Nothing, NullRect)

’ End If

’ End Set

'End Property

'Public Property SegmentPercentage() As Single Implements IvSyncGoLinkLabel.SegmentPercentage

’ Get

’ Return mySegmentPercentage

’ End Get

’ Set(ByVal Value As Single)

’ Dim old As Single = mySegmentPercentage

’ If Not (old = Value) Then

’ mySegmentPercentage = Value

’ Changed(ChangedSegmentPercentage, 0, Nothing, MakeRect(old), 0, Nothing, MakeRect(Value))

’ End If

’ End Set

'End Property

Public Property ConnectionColor() As Color


Return myConnectionColor

End Get

Set(ByVal Value As Color)

Dim old As Color = myConnectionColor

If Not (old.Equals(Value)) Then

myConnectionColor = Value

Changed(ChangedConnectionColor, 0, old, NullRect, 0, Value, NullRect)

End If

End Set

End Property

Walter, please help me, how right solve problem with update

Here are the two updated methods in LinkLabel.cs:

[code] public override RectangleF ExpandPaintBounds(RectangleF rect, GoView view) {
GoLabeledLink l = this.LabeledLink;
Color c = this.ConnectionColor;
rect = base.ExpandPaintBounds(rect, view);
if (l != null && c != Color.Empty) {
rect = RectangleF.Union(rect, l.Bounds);
return rect;

public PointF LinkLabelConnectionPoint {
  get {
    GoLabeledLink l = this.LabeledLink;
    if (l != null && l.RealLink != null) {
      GoLink rl = l.RealLink;
      PointF result;
      rl.GetNearestIntersectionPoint(this.Center, rl.Center, out result);
      return result;
    } else {
      return this.Center;

And in FlowLink.cs:

[code] public FlowLink() {
this.AdjustingStyle = GoLinkAdjustingStyle.Stretch;
//this.Orthogonal = true;
//this.AvoidsNodes = true;
this.Style = GoStrokeStyle.Bezier;
. . .

private void PositionLinkLabel(IGoLinkLabel l, GoObject childchanged) {
  if (l == null) return;
  GoStroke s = this.RealLink;
  PointF cp = s.Center;
  if (l == childchanged) {
    PointF center = childchanged.Center;
    l.Offset = new SizeF(center.X - cp.X, center.Y - cp.Y);
  } else {
    SizeF off = l.Offset;
    ((GoObject)l).Center = new PointF(cp.X + off.Width, cp.Y + off.Height);

As you have already done, you can also remove the Segment and SegmentPercentage properties from LinkLabel. (And from the interface, if you should choose to keep using IGoLinkLabel, which is not necessary in any application with a single usage of the LinkLabel class).

However, I believe you really need to keep the Offset property. Otherwise it can’t remember how far away the user has dragged that LinkLabel.

Thank You, Walter! Yo are Good friend