Katalogerna
PlexityHide

Home 

Products 

Downloads 

Our Shop 

Support 

Contact 


GTP.NET FAQ 10927


We are using user drawn links in the Gantt_ASP and it is too hard to the links Please note that this article refers to the GTP.NET
Jump to article- 2008-07-03 17:26:00 - Email plexityHide

Question


We are using user drawn links in the Gantt_ASP and i
t is too hard to select the links, especially when they are above

TimeItems or have a length of 0. Is there a easy way to get a larger

selection area and to have a preference of links above TimeItems?

 

Answer

When investigating this we found that the comment on the UserDrawLink was very brief, and we have extended it to this:


/// <summary>

/// Fired when link with drawstyle=user need to be drawn.

/// There are two passes to link drawing. First there is the normal draw, the e.G is assigned,

/// and you simply draw the Graphics object supplied. Second there is the selection region pass,

/// this is recongnised by e.G==null and e.BoundingRegion is assigned. Now you can fill the region

/// that is used to decide if a click is on a link or not.

/// </summary>

public event UserDrawLinkEvent OnUserDrawLink;

 

This gives that your code can/should look like this to enable the selection shadow of userdrawn timeitemlinks:

 

    private void OnUserDrawLink(Gantt aGantt, UserDrawLinkEventArgs e)

    {

        Rectangle startItemRect = e.Link.Start.DrawRect();

        Point start = new Point();

        start.Y = e.StartPoint.Y;

        start.X = startItemRect.X + (int)(startItemRect.Width * ((double)e.Link.UserReference) / 100.0);

 

        if (e.G==null)

        {

          ASPGantt.Gantt.TimeItemLinks.DrawCommonLinks(e.G, start, e.TargetPoint, e.Link,e.BoundingRegion);

        }

        else

        {

          ASPGantt.Gantt.TimeItemLinks.DrawCommonLinks(e.G, start, e.TargetPoint, e.Link);

        }

    }

 

... This will give a better feedback of clicked links.

Mind you that we currently have no solution for editable timeitems taking precedence over link clicks, other than making those time items not editable.

 

 

And this also explains how you can increase the sensitive of user drawn links when it comes to selection: Just make the region bigger! Try this in the code above:

        if (e.G==null)

        {

          ASPGantt.Gantt.TimeItemLinks.DrawCommonLinks(e.G, start, e.TargetPoint, e.Link,e.BoundingRegion);

          // To make the region bigger so that the selection can be made easier try this:

          Point p1=start;

          Point p2=e.TargetPoint;

          p1.Offset(2,2);

          p2.Offset(2,2);

          ASPGantt.Gantt.TimeItemLinks.DrawCommonLinks(e.G, p1, p2, e.Link, e.BoundingRegion);

         

        }

        else

        {

          ASPGantt.Gantt.TimeItemLinks.DrawCommonLinks(e.G, start, e.TargetPoint, e.Link);

        }

 

 

 

Another question on user drawn links is: Maybe I only want to do some slight change to where the link start or end on a time item, but I do not want to implement the whole Z-style drawing on my own. Can I do that?

 

Yes; go like this

 

        void gantt1_OnUserDrawLink(Gantt aGantt, UserDrawLinkEventArgs e)

        {

            // When drawing links on your own, you may want to be totally free,

            //or you may want to make a few changes and then call the standard drawing:

           

           

            // When sending in null on Link value , the attributes for style and color are taken from these properties

            aGantt.TimeItemLinks.CreationTimeItemLinkDrawStyle=TimeItemLinkDrawStyle.ZStyle;

            aGantt.TimeItemLinks.CreationTimeItemLinkColor=Color.Green;

 

            if (aGantt.MouseMoveKind == MouseMoveKind.none)

                e.TargetPoint = new Point(e.TargetPoint.X, e.TargetPoint.Y + 10);

 

            // When sending null on LinkValue to aGantt.TimeItemLinks.DrawCommonLinks the logic will go only on pixel points

            if (e.G == null)

                aGantt.TimeItemLinks.DrawCommonLinks(e.G, e.StartPoint, e.TargetPoint, e.Link, e.BoundingRegion);

            else

                aGantt.TimeItemLinks.DrawCommonLinks(e.G, e.StartPoint, e.TargetPoint, null);

 

        }

 

 

 

Google
WWW plexityHide GTP.NET FAQ
Support

Support intro

Knowledgebase

FAQ phGantTimePackage

FAQ GTP.NET

FAQ general

Testimonials

"This is too GREAT. I must say you have strong support and really good programmers at your place. Your entire team is good. Just Fantastic! – 100%"
Gaurav Patole,
WebTechDevelopers
More testimonials...