Page 1 of 1

Gantt Resize and Drag events fire continuously

Posted: Wed Oct 06, 2004 2:17 pm
by 8122476
I have a Gantt Chart with Gantt Drag and Resize allowed. I have event handlers for GanttResizeEventArgs and GanttDragEventArgs. With these event handlers I update my database to reflect changes by the user. However, this event appears to fire continuously as the bar is clicked. Is there anyway to change the timing of this event such that it only fires once the date actually changes?

Here is some debug from the click and drag bar #2 with a start of 10/8 and end and of 10/12:

Drag #2 Jay
Start: 10/8/2004 10:09:13 PM
End: 10/12/2004 10:09:13 PM
Next: -1

Drag #2 Jay
Start: 10/8/2004 10:09:13 PM
End: 10/12/2004 10:09:13 PM
Next: -1

Drag #2 Jay
Start: 10/8/2004 11:04:36 AM
End: 10/12/2004 11:04:36 AM
Next: -1

Drag #2 Jay
Start: 10/8/2004 11:04:36 AM
End: 10/12/2004 11:04:36 AM
Next: -1

Drag #2 Jay
Start: 10/7/2004 12:00:00 PM
End: 10/11/2004 12:00:00 PM
Next: -1

Drag #2 Jay
Start: 10/7/2004 12:00:00 PM
End: 10/11/2004 12:00:00 PM
Next: -1

Drag #2 Jay
Start: 10/7/2004 2:46:09 AM
End: 10/11/2004 2:46:09 AM
Next: -1

Drag #2 Jay
Start: 10/7/2004 2:46:09 AM
End: 10/11/2004 2:46:09 AM
Next: -1

Drag #2 Jay
Start: 10/6/2004 8:18:27 PM
End: 10/10/2004 8:18:27 PM
Next: -1

Drag #2 Jay
Start: 10/6/2004 8:18:27 PM
End: 10/10/2004 8:18:27 PM
Next: -1

Drag #2 Jay
Start: 10/6/2004 11:04:36 AM
End: 10/10/2004 11:04:36 AM
Next: -1

Drag #2 Jay
Start: 10/6/2004 11:04:36 AM
End: 10/10/2004 11:04:36 AM
Next: -1

Drag #2 Jay
Start: 10/6/2004 9:13:50 AM
End: 10/10/2004 9:13:50 AM
Next: -1

Drag #2 Jay
Start: 10/6/2004 9:13:50 AM
End: 10/10/2004 9:13:50 AM
Next: -1

Drag #2 Jay
Start: 10/6/2004 5:32:18 AM
End: 10/10/2004 5:32:18 AM
Next: -1

Drag #2 Jay
Start: 10/6/2004 5:32:18 AM
End: 10/10/2004 5:32:18 AM
Next: -1

Drag #2 Jay
Start: 10/6/2004 5:32:18 AM
End: 10/10/2004 5:32:18 AM
Next: -1

Drag #2 Jay
Start: 10/6/2004 5:32:18 AM
End: 10/10/2004 5:32:18 AM
Next: -1

Drag #2 Jay
Start: 10/6/2004 5:32:18 AM
End: 10/10/2004 5:32:18 AM
Next: -1

Drag #2 Jay
Start: 10/6/2004 5:32:18 AM
End: 10/10/2004 5:32:18 AM
Next: -1

Drag #2 Jay
Start: 10/6/2004 5:32:18 AM
End: 10/10/2004 5:32:18 AM
Next: -1

Drag #2 Jay
Start: 10/6/2004 5:32:18 AM
End: 10/10/2004 5:32:18 AM
Next: -1

Drag #2 Jay
Start: 10/6/2004 5:32:18 AM
End: 10/10/2004 5:32:18 AM
Next: -1

Drag #2 Jay
Start: 10/6/2004 5:32:18 AM
End: 10/10/2004 5:32:18 AM
Next: -1

Drag #2 Jay
Start: 10/6/2004 5:32:18 AM
End: 10/10/2004 5:32:18 AM
Next: -1

Drag #2 Jay
Start: 10/6/2004 5:32:18 AM
End: 10/10/2004 5:32:18 AM
Next: -1

Drag #2 Jay
Start: 10/6/2004 5:32:18 AM
End: 10/10/2004 5:32:18 AM
Next: -1

Drag #2 Jay
Start: 10/6/2004 5:32:18 AM
End: 10/10/2004 5:32:18 AM
Next: -1

Drag #2 Jay
Start: 10/6/2004 5:32:18 AM
End: 10/10/2004 5:32:18 AM
Next: -1

Drag #2 Jay
Start: 10/6/2004 5:32:18 AM
End: 10/10/2004 5:32:18 AM
Next: -1

Drag #2 Jay
Start: 10/6/2004 5:32:18 AM
End: 10/10/2004 5:32:18 AM
Next: -1

Drag #2 Jay
Start: 10/6/2004 5:32:18 AM
End: 10/10/2004 5:32:18 AM
Next: -1

Drag #2 Jay
Start: 10/6/2004 5:32:18 AM
End: 10/10/2004 5:32:18 AM
Next: -1

Drag #2 Jay
Start: 10/6/2004 5:32:18 AM
End: 10/10/2004 5:32:18 AM
Next: -1

Drag #2 Jay
Start: 10/6/2004 5:32:18 AM
End: 10/10/2004 5:32:18 AM
Next: -1

Drag #2 Jay
Start: 10/6/2004 5:32:18 AM
End: 10/10/2004 5:32:18 AM
Next: -1

Drag #2 Jay
Start: 10/6/2004 5:32:18 AM
End: 10/10/2004 5:32:18 AM
Next: -1

Drag #2 Jay
Start: 10/6/2004 5:32:18 AM
End: 10/10/2004 5:32:18 AM
Next: -1

I would like to see something like this:

Drag #2 Jay
Start: 10/6/2004 5:32:18 AM
End: 10/10/2004 5:32:18 AM
Next: -1

Both drag and resize events fire in the same way.

Here are my event handlers:

#region Drag & Resize

/// <summary>
/// Event handler when a bar is dragged
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ganttTool1_DragBar(object sender, Steema.TeeChart.Tools.GanttDragEventArgs e)
{
DateTime start = DateTime.FromOADate(gantt1.StartValues[e.Bar]);
DateTime end = DateTime.FromOADate(gantt1.EndValues[e.Bar]);

if (this.chkShowDebug.Checked)
{
this.txbOutput.AppendText("\r\n" +
"Drag #" + e.Bar.ToString() + " " + gantt1.Labels[e.Bar] + "\r\n" +
"Start: " + start.ToString() + "\r\n" +
"End: " + end.ToString() + "\r\n" +
"Next: " + gantt1.NextTasks[e.Bar].ToString() + "\r\n");
}
else
{
// Debug.WriteLine("Drag #" + e.Bar.ToString() + " " + gantt1.Labels[e.Bar]);
// Debug.WriteLine("Start: " + start.ToString());
// Debug.WriteLine("End: " + end.ToString());
// Debug.WriteLine("Next: " + gantt1.NextTasks[e.Bar].ToString());
}

UpdateDatabase(e.Bar,gantt1.Labels[e.Bar],start,end);
DataTable table = GetData();
fillDataGrid(table);
}

/// <summary>
/// Event handler when a bar is resized
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ganttTool1_ResizeBar(object sender, Steema.TeeChart.Tools.GanttResizeEventArgs e)
{
DateTime start = DateTime.FromOADate(gantt1.StartValues[e.Bar]);
DateTime end = DateTime.FromOADate(gantt1.EndValues[e.Bar]);

if (this.chkShowDebug.Checked)
{
this.txbOutput.AppendText("\r\n" +
"Resize #" + e.Bar.ToString() + " " + gantt1.Labels[e.Bar] + "\r\n" +
"Start: " + start.ToString() + "\r\n" +
"End: " + end.ToString() + "\r\n" +
"Next: " + gantt1.NextTasks[e.Bar].ToString() + "\r\n");
}
else
{
// Debug.WriteLine("Resize #" + e.Bar.ToString() + " " + gantt1.Labels[e.Bar]);
// Debug.WriteLine("Start: " + start.ToString());
// Debug.WriteLine("End: " + end.ToString());
// Debug.WriteLine("Next: " + gantt1.NextTasks[e.Bar].ToString());
}

UpdateDatabase(e.Bar,gantt1.Labels[e.Bar],start,end);
DataTable table = GetData();
fillDataGrid(table);
}

#endregion

Thanks
Brian

Posted: Thu Oct 07, 2004 4:33 pm
by Chris
Hi --
With these event handlers I update my database to reflect changes by the user. However, this event appears to fire continuously as the bar is clicked. Is there anyway to change the timing of this event such that it only fires once the date actually changes?
I guess you can check for changes by iterating through the valuelist class instances in the Steema.TeeChart.Styles.Series.ValuesLists Property.

Posted: Thu Oct 07, 2004 7:23 pm
by 8122476
Chris-

I don't see how your suggestion will help me. Isn't the ValuesLists property just a collection of the the ValueList of StartValues, EndValues, etc.?

If you look at the event handler I posted in my original post, you will see that I use the StartValues and EndValues ValueList to get the new value after the drag or resize. If I use the ValuesLists property as you suggest, I will just end up comparing a value to itself. For your suggestion to work, I would have to be able to compare the StartValues and EndValues before the drag and after the drag. I either don't understand what you are saying or I have no way of doing that.

Is there no way to change how often the event fires, for instance having it fire only after a drag or resize of a whole day is performed?

Thank you for your suggestion, but could you provide a little more explanation with your next post and possibly a code snippet.

Thanks
Brian

Posted: Fri Oct 08, 2004 6:37 am
by Chris
Hi Brian,
Thank you for your suggestion, but could you provide a little more explanation with your next post
Sure.

My understanding of your situation is that you have a database with Gantt values which you want to update with uer changes. The problem is that the Gantt Tool events fire continuously and so so can't tell when a value has actually been changed.

I agree that events such as DraggedBar and ResizedBar would be useful to you in these circumstances. I will add these ideas to the feature request list.

My suggestion is that you compare the values in the Gantt series' valuelists with those in your database. For example, the GanttDragEventArgs has a Bar property which tells you which bar has been clicked. You can then compare the values in the series point (e.g. gantt1.StartValues[e.Bar]) with the values in your database and update the database record if the value is changed.

You obviously won't want to be doing this tens of times a second, so I suggest you only do so when a mouseup event is fired over the gantt point being dragged or resized (i.e. when the user has finished either dragging or resizing), e.g.

Code: Select all

  
private void tChart1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e) {
      int ganttSeriesPoint = gantt1.Clicked(e.X, e.Y);
      if(ganttSeriesPoint != -1)
        label5.Text=ganttSeriesPoint.ToString();

    }