I have an issue with Winschedule Dayview. Here are the steps to reproduce:
1) Create an appointment
2) Create another appointment, back-to-back with the first one
3) Create a 3rd appointment which overlaps the time of the 2nd appointment
4) The 2nd appointment adjusts its width to 50%, to accomodate the display of the double-booked one
5) PROBLEM: the 1st appointment also adjust to 50% width, even though it really isn't double booked
(see attachment)
Our Infragistics library version is 7.1.20071.40
Your help is appreciated to provide a workaround (CreationFilter etc) or suggest a different Infragistics version in which this issue is fixed.
Here is the solution. I spent a day writing this improvement to how DayView handles double booking. I wish Infragistics would have taken the time to a) write this correctly to begin with, or at least b) test their code or even c) responded to my post.
public class DayViewCreationFilter : IUIElementCreationFilter { public void AfterCreateChildElements(UIElement parent) { if (parent is DayUIElement) { foreach (UIElement uie in parent.ChildElements) { AppointmentUIElement aui = uie as AppointmentUIElement; if (aui != null) { bool isDoubleBooked = false; foreach (UIElement uieInner in parent.ChildElements) { AppointmentUIElement auieInner = uieInner as AppointmentUIElement; if ((auieInner != null) && (auieInner != aui)) { if ((auieInner.Rect.Y == aui.Rect.Y) || // side by side ((auieInner.Rect.Y >= aui.Rect.Y) && (auieInner.Rect.Bottom <= aui.Rect.Bottom)) || // inside ((auieInner.Rect.Y <= aui.Rect.Y) && (auieInner.Rect.Bottom >= aui.Rect.Bottom)) || // outside ((auieInner.Rect.Y < aui.Rect.Y) && (auieInner.Rect.Bottom > aui.Rect.Y)) || // over top ((auieInner.Rect.Y < aui.Rect.Bottom) && (auieInner.Rect.Bottom >= aui.Rect.Bottom))) // over bottom { isDoubleBooked = true; break; } } } if (!isDoubleBooked) { // look for this appointment's shadow and adjust it too foreach (UIElement shuie in parent.ChildElements) { AppointmentShadowUIElement asui = shuie as AppointmentShadowUIElement; if ((asui != null) && (asui.Rect.X == aui.Rect.X + 5) && (asui.Rect.Y == aui.Rect.Y + 5)) asui.Rect = new Rectangle(asui.Rect.X, asui.Rect.Y, parent.Rect.Width - 10, asui.Rect.Height); } aui.Rect = new Rectangle(aui.Rect.X, aui.Rect.Y, parent.Rect.Width - 10, aui.Rect.Height); } } } } } public bool BeforeCreateChildElements(UIElement parent) { return false; } }
UPDATE: This is still a problem for appointments that take up 1 row only. For example, in the picture, the interval is 15 minutes. If I have a stack of appointments that are 15 minutes each, the workaround I posted, of adding -1 milliseconds does NOT fix the problem.
In that case, the DayView does not draw the rounded corners, it draws the left side of each appointment slightly squared, representing that the appointment does not fill the entire slot.
When it is like that, the same annoying double-booking problem exists, every item in the stack of back-to-back appointments is squished to half size. If there are 10 appointments booked back-to-back, each of which is 15 minutes, then if I double book just one slot, then all 10 appointments will display half-size. Fudging the end time has no effect in this condition, so we still need help from Infragistics to troubleshoot.
We need a fix for this, in the form of perhaps a Filter or please suggest an Infragistics version in which this problem does not exist.
Hey, I just figured out a workaround!
I just add -1 milliseconds to the end time of each Appointment. That way an appointment that goes "from 2:00 to 3:00" actually just goes from 2:00 to 2:59.59.999. This alleviates the problem with the 1st appointment's width.
No worries! :)