Completed
Last Updated: 03 Dec 2014 11:57 by ADMIN
ADMIN
Dess | Tech Support Engineer, Sr.
Created on: 07 Oct 2014 10:48
Category: Scheduler/Reminder
Type: Bug Report
1
FIX. RadScheduler - Incorrect PrintPreview after appointment modification
To reproduce:

1. Open Demo application >> Scheduler >> Printing example.

2. Change to Weekly style and return back to Daily style.

3. Modify a random appointment's end time to be half an hour, e.g. 10:30.

4. Change  the rule scale to 5 minute and press PrintPreview button.

You will notice that the rendered appointment in the PrintPreview dialog fills the entire hour interval, instead of half of it.

public Form1()
{
    InitializeComponent();
    this.radScheduler1.PrintStyle = new CustomSchedulerDailyPrintStyle();
}

public class CustomSchedulerDailyPrintStyle :SchedulerDailyPrintStyle
{
    protected override void DrawAppointments(DateTime currentDate, IResource resource, Rectangle appArea, Graphics graphics)
    {
        int rowCount = Math.Max(1, (int)Math.Ceiling((TimeEndRange - TimeSpan.FromHours(TimeStartRange.Hours)).TotalHours));
        float rowHeight = (float)appArea.Height / rowCount;

        List<IEvent> appointments = this.GetAppointments(currentDate, false, resource);

        appointments.Sort(CompareAppointments);
        bool setColumn = true;
        Dictionary<IEvent, int> columns = new Dictionary<IEvent, int>();
        Dictionary<IEvent, int> maxColumns = new Dictionary<IEvent, int>();
        int currentColumn = 0;

        while (setColumn)
        {
            setColumn = false;
            DateTime currentTime = DateTime.MinValue;

            foreach (IEvent app in appointments)
            {
                if (!columns.ContainsKey(app) && DateFloor(app.Start) >= currentTime)
                {
                    setColumn = true;
                    columns.Add(app, currentColumn);
                    currentTime = DateCeiling(app.End);
                }
            }

            currentColumn++;
        }

        DateTime maxEndDate = DateTime.MinValue;
        int lastIndex = 0;
        int maxColumn = 0;

        for (int i = 0; i <= appointments.Count; i++)
        {
            if (i == appointments.Count || DateFloor(appointments[i].Start) >= maxEndDate)
            {
                for (int j = lastIndex; j < i; j++)
                {
                    maxColumns.Add(appointments[j], maxColumn);
                }

                maxColumn = 0;
                lastIndex = i;
            }

            if (i == appointments.Count)
            {
                break;
            }

            maxColumn = Math.Max(maxColumn, columns[appointments[i]]);
            if (maxEndDate < DateCeiling(appointments[i].End))
            {
                maxEndDate = DateCeiling(appointments[i].End);
            }
        }

        foreach (IEvent app in appointments)
        {
            AppointmentPrintElement printedAppointment = new AppointmentPrintElement(app, this.Scheduler);
            printedAppointment.ShowHours = false;
            printedAppointment.DrawBorder = printedAppointment.DrawFill = true;

            float appY = appArea.Y + Math.Max(0, (float)(((DateFloor(printedAppointment.Start) - currentDate.Add(this.TimeStartRange)).TotalHours) * rowHeight));
            float appBottom = appArea.Y + Math.Min(appArea.Height, (float)(((DateCeiling(printedAppointment.End) - currentDate.Add(this.TimeStartRange)).TotalHours) * rowHeight));
            float appHeight = appBottom - appY - app.End.Minute;
            float appWidth = (appArea.Width - HoursColumnWidth) / (maxColumns[app] + 1);
            float appX = appArea.X + HoursColumnWidth + columns[app] * appWidth;

            RectangleF appRect = new RectangleF(appX, appY, appWidth, appHeight);
            appRect.Inflate(-2f, -2f);
            this.DrawAppointment(printedAppointment, graphics, appRect);
        }
    }
}

private void radButton1_Click(object sender, EventArgs e)
{
    this.radScheduler1.PrintPreview();
}
Attached Files:
(Total attached files size should be smaller than 20mb. Allowed extensions: .zip, .rar, .jpg, .png, .gif)
0 comments