Add Ons - DevSource
DevSource: Microsoft Developer Resource DevSource Home Sponsored by Microsoft Home Add Ons Architecture Languages Techniques Using VS Forums
Home arrow Add Ons arrow Page 2 - Tracking Time with ILog Gantt
Tracking Time with ILog Gantt
By John Mueller

Rate This Article: Add This Article To:

Tracking Time with ILog Gantt - ' A Simple Application '
( Page 2 of 3 )

A practical application always includes four concepts:

  • Model (determines how to work with the data)
  • Reservation (an entry within the model)
  • Resource (an entity requiring reservation such as a meeting room)
  • Activity (a task performed during the reserved time using the available resources)

You combine the four concepts in various ways, using the supplied presentations to provide the user with a visual representation of time usage. Presentation is anything you want to make it. For example, the Table Editors sample presents the data as a grid view. The application tracks the arrivals and departures at a fictional airport.

ADVERTISEMENT

The model (the data container) is always separated from the view. Consequently, you can create applications that display the same data in multiple ways without having to modify the data in any way. In some respects, this part of ILog Gantt works similarly to the Visual C++ document/view architecture originally created by Microsoft.

A Simple Application

The first application I created was a simple appointment scheduler. I placed a SimpleGanttModel (SGM), and CalendarView (CalView) control on the form, along with a MainMenu control and a few other odds and ends. To connect SGM to CalView, I simply selected SGM in the CalView.GanttModule property. I didn't add a database to this application, which I'd ordinarily do, because I only wanted to see ILog Gantt in action.

Adding a new entry is relatively simple. To perform this task, I created another form that contains the required field entries for the appointment. I then added the code shown in Listing 1 to add a new entry to CalView.

Listing 1: Creating a New Appointment

private void mnuAppointmentsAdd_Click(
   object sender, System.EventArgs e)
{
   MakeAppt       Dlg;  // Make an appointment.
   IActivity      Act;  // New activity.
   IResource      Res;  // New resource requirement.
   IReservation   Appt; // Reserve resource/activity.

   // Display the appointment dialog and
   // exit if user cancels.
   Dlg = new MakeAppt();
   if (Dlg.ShowDialog(this) == DialogResult.Cancel)
      return;

   // Define the required resource.
   Res = SGM.NewResource();
   Res.Name = Dlg.txtName.Text;

   // Create an activity.
   Act = SGM.NewActivity();
   Act.Name = Dlg.txtActivity.Text;
   Act.TimeInterval = 
      new DateTimeInterval(
         DateTime.Parse(
            Dlg.txtDate.Text + " " + 
            Dlg.txtTime.Text), 
         TimeSpan.FromMinutes(
            Double.Parse(Dlg.txtLength.Text)));

   // Define the reservation.
   Appt = SGM.NewReservation(Act, Res);

   // Add the reservation to the model.
   SGM.Resources.Add(Res);
   SGM.Activities.Add(Act);
   SGM.Reservations.Add(Appt);
}

The code begins by displaying a dialog box that requests the appointment information. When the user clicks Make Appointment, the code begins creating the appointment by defining a resource (in this case, a person's name), an activity that the person will perform, and a reservation that contains both the resource and the activity. To create the appointment, the code adds the resource, the activity, and the reservation to SGM. You can remove reservations from SGM by locating the appropriate reservation in the SGM.Reservations collection and using the Remove() method to remove it. Figure 2 shows my simple calendar implementation.




Discuss Tracking Time with ILog Gantt
 
>>> Be the FIRST to comment on this article!
 


 
 
>>> More Add Ons Articles          >>> More By John Mueller
 



HD VOIP Has Arrived (with Tony Konstner)

Play Video >

All Videos >

Google and blonde jokes?

Read now >

Favorite books!

Read now >

View Now
DevSource RSS FEEDS
XML Want an easy way to keep up with breaking tech news? And the Get DevSource headlines delivered to your desktop with RSS.