Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
725
Appointement Color
posted

Hi,

I want to know if there is any way to display the appointement Bar with more than one color Example :

I have period of 4 weeks in this period i have one week for cleaning purpose; so i want to display the first 3 weeks with a color and the fourth week with another color.

Thx

  • 53790
    Verified Answer
    posted

    Hello Lahmar,

    One possible approach to acheive desired behavior could be if you are using DrawFilter. I`m not sure what is your control into your application, that`s why I made small sample using UltratimeLineView, but you could use the same approach for UltraDatView and UltraMonthView controls

    Please take a look at the attached sample for more details and let me know if you have any questions.

    Regards

      public class MyDraw1 : IUIElementDrawFilter
        {
            public bool DrawElement(DrawPhase drawPhase, ref UIElementDrawParams drawParams)
            {
                Infragistics.Win.UltraWinSchedule.TimelineView.AppointmentUIElement AppElement = drawParams.Element as Infragistics.Win.UltraWinSchedule.TimelineView.AppointmentUIElement;

                if (drawPhase == DrawPhase.AfterDrawElement && AppElement != null)
                {
                    foreach (Appointment app in Form1.CalendarInfo.Appointments)
                    {
                        if ((app.EndDateTime - app.StartDateTime).TotalDays > 2)
                        {
                            AppearanceData DrawColor = new AppearanceData();
                            DrawColor.BackColor = Color.Red;
                           drawParams.DrawBackColor(ref DrawColor, new Rectangle(AppElement.Rect.X, AppElement.Rect.Y, 85, 10), new Rectangle(AppElement.Rect.X, AppElement.Rect.Y, 85, 10), true);
                        }
                    }
                }
                return false;
            }

            public DrawPhase GetPhasesToFilter(ref UIElementDrawParams drawParams)
            {
                Infragistics.Win.UltraWinSchedule.TimelineView.AppointmentUIElement slot = drawParams.Element as Infragistics.Win.UltraWinSchedule.TimelineView.AppointmentUIElement;
                if (slot != null)
                    return DrawPhase.AfterDrawElement;
                else
                    return DrawPhase.None;
            }
        }