10152 : user sees 2 timeitems on the screen and wants to link them using mouse and clicking on one timeitem and dragging link to the other timeitem. how shuld I do this?

Question

user sees 2 timeitems on the screen and wants to link them using mouse and clicking on one timeitem and dragging link to the other timeitem. how shuld I do this?

BTW thx for great control. Having source is very helpful.

Answer

You can but a tool button on your menu allowing the user to enter the special mouse mode for creating time item links;

gantt1.EnterLinkCreateMode(checkBox1.Checked);

When this mode is active clicks will be handled as link create and not as move or resize operation in timeitem area.

Thomas Reinberger contributed with this code and comment, Thank you Thomas:

The trick is to allow TimeItem moves and to check the x value of the mouse click. Then, if the mouse click is nearby the right or left border of a TimeItem (but not exactly at the border since we also want to let the user resize the timeItem. See code below.

private void gantt1_OnTimeItem_BeforeMove(PlexityHide.GTP.Gantt aGantt, PlexityHide.GTP.TimeItemEventArgs e)
  {
   TimeItem ti = e.TimeItem;

   if (ti != null)
   {
    if (e.x >= ti.DrawRect().Right-15 && e.x <= ti.DrawRect().Right-4)
    {
 ti.TimeItemLayout.AllowMove = false;
    this.gantt1.EnterLinkCreateMode(true);
    }
    else if (e.x >= ti.DrawRect().Left+4 && e.x <= ti.DrawRect().Left+15)
    {
     ti.TimeItemLayout.AllowMove = false;
     this.gantt1.EnterLinkCreateMode(true);
    }
    else
    {
     ti.TimeItemLayout.AllowMove = true;
     this.gantt1.EnterLinkCreateMode(false);

    }
   }
  }

 

Leave a Reply