Hello all,
I'm new to Infragistics, c#, and windows forms, so please excuse me if this question is too simple.
The first answer that may pop into your head when reading my subject may be: Just bind the same UltraCalanderInfo to both your UltraGanttView and your UltraTimelineView and it is done.
But if I understand correctly, I don't think that works for me. Here's is what I want to do. I want to have a gantt view and a timeline view which are two different ways of seeing the same data. The problem is that the ganttview displays tasks, while the timeline view displays appointments.
So, I'm thinking that I can create a class that is composed of both a Task data member, and a Schedule data member, and somehow do code to keep each in sync whenever the other changes.
Is that the right approach? If so do any of your samples solutions do something like this (with any two classes, not necessarily Task and Appointment)
Note: I only want to keep the data members that have the same name and type in sync between instance pairs of the two types (Task and Appointment), I would not try to keep non-common data members in sync. For example: StartDateTime is a commonly named and typed member for both Task and Appointment classes, therefore, for a given task/appointment pair, I do want the task.StartDateTime and the appointment.StartDateTime to always be the same. This is not true for Task.Deadline because there is no corresponding member in the Task class.
Thanks, app3lam
Correction, I meant to say:
So, I'm thinking that I can create a class that is composed of both a Task data member, and an Appointment data member, and somehow do code to keep each in sync whenever the other changes.
(correction was to change Schedule to Appointment)
Yes, that sounds feasible. This means that you would have a Task instance for each Appointment instance, and have to maintain both of those instance whenever a property on your "hybrid" class changes.
Hi,
Let me know if you need any further assistance.
Regards,
Stefaniya
app3lam said:Can you comment on why it does not have an endless circular event cycle?
Brian, thank you for your reply.
Here is my first attempt at a class to do this, inherting from SubObjectBase.
I thought there would be a need to detect and handle a circular event cycle. For example:
However, I'm happy to say the circular event cycle does not seem to be a problem, although I'm not sure why at this point. Can you comment on why it does not have an endless circular event cycle?
Would anybody have any suggestions for improvement(s) to the below?
----------
using System;using Infragistics.Win.UltraWinSchedule;using Infragistics.Shared;using System.Diagnostics; // for Debug
public class TaskAppt : SubObjectBase{ public Task task; public Appointment appt; private Guid guid;
public TaskAppt(string name) { task = new Task(); appt = new Appointment(System.DateTime.Now, System.DateTime.Now + System.TimeSpan.FromDays(1)); guid = System.Guid.NewGuid(); task.Tag = this; appt.Tag = this; Name = name; task.StartDateTime = appt.StartDateTime; task.Duration = (TimeSpan)(appt.EndDateTime - appt.StartDateTime);
this.task.SubObjectPropChanged += this.SubObjectPropChangeHandler; this.appt.SubObjectPropChanged += this.SubObjectPropChangeHandler;
Debug.WriteLine(guid, " guid for newly created TaskAppt "); }
public override string ToString() { System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append("TaskAppt: Task "); sb.Append(task.Name); sb.Append(" "); sb.Append(task.StartDateTime.ToString()); sb.Append(" "); sb.Append(task.Duration.ToString()); sb.Append(" "); DateTime taskEnd = task.StartDateTime + task.Duration; sb.Append(taskEnd.ToString()); sb.Append("; Appt "); sb.Append(appt.ToString()); return sb.ToString(); }
public string Name { get { return task.Name; } set { Debug.WriteLine("In update Name"); //Debug.WriteLine(guid, " before update name of TaskAppt "); //Debug.WriteLine(task.Name, " before update name of TaskAppt "); appt.Subject = task.Name = value; //Debug.WriteLine(guid, " after update name of TaskAppt "); //Debug.WriteLine(task.Name, " after update name of TaskAppt "); } } public DateTime StartDateTime { get { return appt.StartDateTime; } set { Debug.WriteLine("In update StartDateTime"); appt.StartDateTime = task.StartDateTime = value; } } public DateTime EndDateTime { get { return appt.EndDateTime; } set { Debug.WriteLine("In update EndDateTime"); appt.EndDateTime = value; TimeSpan ts = (TimeSpan)(appt.EndDateTime - appt.StartDateTime); task.Duration = ts; Debug.WriteLine(task.Duration, "in update EndDateTime set task.Duratoin "); } }
public TimeSpan Duration { get { return task.Duration; } set { Debug.WriteLine("In update Duration"); task.Duration = value; appt.EndDateTime = appt.StartDateTime + value; } }
private void walkPci(PropChangeInfo pci) { int save = Debug.IndentLevel; while (pci != null) { System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append("### Property Id: "); sb.Append(pci.PropId.ToString()); sb.Append(", source: "); sb.Append(pci.Source.ToString()); sb.Append(". type: "); sb.Append(pci.Source.GetType().ToString()); sb.Append(", trigger: "); sb.Append(null == pci.Trigger ? "null" : pci.Trigger.ToString());
Debug.WriteLine(sb.ToString()); Debug.Indent();
// Get the next PropChangeInfo object in the chain pci = pci.Trigger; } Debug.IndentLevel = save; } // Listens for property change notifications of the object's sub objects. protected override void OnSubObjectPropChanged(PropChangeInfo pci) { walkPci(pci); if (null != this.task && pci.Source == this.task) { Debug.Write("--- Source is task: "); Debug.Write(guid); Debug.WriteLine(this.task); switch ((TaskPropertyIds)pci.PropId) { case TaskPropertyIds.Name: { this.Name = this.task.Name; //this.appt.Subject = this.task.Name; break; } case TaskPropertyIds.StartDateTime: { this.StartDateTime = this.task.StartDateTime; //this.appt.Subject = this.task.Name; break; } case TaskPropertyIds.Duration: { this.Duration = this.task.Duration; //this.appt.Subject = this.task.Name; break; } default: break; } } else if (null != this.appt && pci.Source == this.appt) { Debug.Write("--- Source is appt: "); Debug.WriteLine(this.appt); switch ((PropertyIds)pci.PropId) { case PropertyIds.Subject: { this.Name = this.appt.Subject; //this.task.Name = this.appt.Subject; break; } case PropertyIds.StartDateTime: { this.StartDateTime = this.appt.StartDateTime; //this.task.Name = this.appt.Subject; break; } case PropertyIds.EndDateTime: { this.EndDateTime = this.appt.EndDateTime; //this.task.Name = this.appt.Subject; break; } default: break;
} }
// There is an overload to the 'NotifyPropChange' method // that just takes the passed in PropChangeInfo object. // This is useful if you want to pass the notification // along to this object's listeners 'as is'. In other words, // without creating a new PropChangeInfo to add to the // head of the chain (refer to above comments). this.NotifyPropChange(pci); }}