10229 : Changing the snapping functionality

Question

I’ve noticed that when moving TimeItems in GTP.NET that if I have a snap interval specified for both start and end it only obeys the start snap so what I want to do is if the user moves the item to the left it honors the start snap and if the user moves the item to the right it honors the end snap.

This is the code that I have but it doesn’t do what I want it to do.

Private Sub Gantt_OnTimeItem_Move(ByVal aGantt As PlexityHide.GTP.Gantt, ByVal e As PlexityHide.GTP.TimeItemEventArgs) Handles GanttPurchasing.OnTimeItem_Move, GanttProduction.OnTimeItem_Move, GanttPlanning.OnTimeItem_Move
  If e.Diff.TotalSeconds > 0 Then
    e.TimeItem.TimeItemLayout.SnapStartTime = New TimeSpan(0, 0, 0, 0)
    e.TimeItem.TimeItemLayout.SnapStopTime = New TimeSpan(1, 0, 0, 0)
  Else
    e.TimeItem.TimeItemLayout.SnapStartTime = New TimeSpan(1, 0, 0, 0)
    e.TimeItem.TimeItemLayout.SnapStopTime = New TimeSpan(0, 0, 0, 0)
  End If

End Sub

Answer

Yes, move is considered as a change of the start time. The Stop snap comes into play only when the user resize by dragging the east side of a time item (changing length).

Nevertheless it will be no problem to change the snapping functionality to your liking. You need to intercept the values that are about to be applied to the time item and snap them. You can adhere your own rules depending on the MouseMoveKind property of the Gantt. Implement the Gantt.OnTimeItem_StopValueResize event and use the Snapping functionality available here  Gantt.DateScaler.SnapTime and simply update the stop value of the time item that you get access to in the arguments of the event .

 

 

Leave a Reply