10025 : Collisiondetect


I am interested in using GTP.NET for a Gantt chart like view of some data.  The only problem is, I would like the Gantt chart to display when there is an overlap in the tasks (a conflict) a vertical “stripe” that indicates where the overlap occurs.  Is this possible using your product?



There is no simple property to set to achieve this, but you will probably be able to extend the functionality to solve this task.

First you need to implement the OnCollisionDetect event. This will signal whenever there is a collision detected or the collision previously detected is resolved. Then you will want to implement OnTimeItem_UserDraw to actually draw your special line at the point of conflict. In order for you to remember the time items that are currently in a colliding position I suggest that you keep a list of the TimeItems as a member variable in your form that has been signaled in OnCollisionDetect, and before drawing a time item in the OnTimeItem_UserDraw event you check if it is present in this list. Or you could make use of the UserReference property of the timeItem to put a new object with additional information that you need into the time item.

Note: in order to make the OnTimeItem_UserDraw event fire you need to declare the time items with the TimeItemLayout.TimeItemStyle=TimeItemStyle.User. When you do this you take complete responsibility for drawing the time item, if you want a mix of the user draw, and some standard style you can call the PlexityHide.GTP.TimeItemDraw.Draw method inside the OnTimeItem_UserDraw.


Leave a Reply