Problems with vertical line in a group

In my program, user can create a GoGroup with only a GoStroke in it, simplified sample which illustrate the problems:

  GoGroup linegroup = new GoGroup();
  GoStroke line = new GoStroke();
  line.AddPoint(100, 10);
  line.AddPoint(100, 100);
  line.Style = GoStrokeStyle.Line;
  linegroup.Add(line);
  linegroup.Selectable = false;
  doc.Add(linegroup);

So, the line can be moved, resized, etc… by the user everything work fine except 2 bugs which occurs when the line is perfectly vertical:

1- If user zoom in at maximum (or change the zoom a couple of time), the line become not selectable when user try to click on it (still selectable by dragging a rectangle around it).
The “DoSelect” in GoToolSelecting do not detect anything. If the line is not vertical, this strange behavior not occurs and the behavior is ok.

2-When saving this Gogroup and reloading with your xml class (GoXmlReaderWriterBase), vertical line was always reloaded with only a lentgh of 10 instead of the previously saved GoGroup size…again if the line is not vertical, the line correctly take the good size (one point at the top-left of the group and the other at the bottom-right).
In my sample, the line reload with this 2 point:
line.AddPoint(100, 10);
line.AddPoint(100, 20);
instead of
line.AddPoint(100, 10);
line.AddPoint(100, 100);

What can i do to avoid that?

I made many test if the line is 1 pixel width, everything works great.

I made many test if the line is 1 pixel width, everything works great.



does that mean the rest of your note above is for a PenWidth less than 1? you don’t say that anywhere.



I think something similar to this is what is happening.

hum, no the PenWidth is unchanged and stay at default (= 1), in fact the problems occurs even if line have PenWidth of 10. Sorry, what i mean by line is at least 1 pixel width is the line Start and End point do not have the same “Y” axis. I forgot to mention i am using v3.0.3.3 and i can reproduce the problems when adding my 8 lines of code (of my first post) in the Godocument of many sample like function “public static void AddStuff(GoDocument doc, bool palette)” of GraphDoc in Demo13 or like the constructor of GraphDoc in Demo13 in ProtoApp3. When i do not zoom (Ctrl+mouse wheel) everything work fine but after some zoom i cannot select my line when clicking on it.

GoGroup linegroup = new GoGroup();
GoStroke line = new GoStroke();
line.PenWidth = 10; //if you want :)
line.AddPoint(100, 10);
line.AddPoint(100, 100);
line.Style = GoStrokeStyle.Line;
linegroup.Add(line);
linegroup.Selectable = false;
doc.Add(linegroup);

OK, the stroke has a height, but no width. (Width = 0)



So, the bounding box for the GoGroup is H=90, W=0.



So, the pick code skips the GoGroup.



You’ll have to override the ComputeBounds for the GoGroup, call the base.ComputeBounds, then make sure width is at least 1.

Thanks, i cannot test it today but your solution seems perfect :).