PocketPlanner Programmer's Guide

Calendar.CustomDraw Property

See Also

Gets or sets which UI elements of the calendar should be custom drawn.

Namespace: MindFusion.Scheduling.Compact
Assembly: PocketPlanner

 Syntax

C#

public CustomDrawElements CustomDraw { get; set; }

Visual Basic

Public Property CustomDraw As CustomDrawElements

 Property Value

A combination of CustomDrawElements enumeration members. The default is None.

 Remarks

Use the bitwise or operation to combine members of CustomDrawElements specifying which elements of the view must be custom drawn. Handle the Draw event to perform custom drawing.

 Example

The following example demonstrates how to use the CustomDraw property in conjunction with the Draw event. The example assumes that calendar references a valid Calendar instance.

The example draws a red ellipse around specific dates in a SingleMonth view.

C#

calendar.CurrentView = CalendarView.SingleMonth;
calendar.CustomDraw = CustomDrawElements.CellHeader;
calendar.Draw += new CustomDraw(calendar_Draw);

// ...

private bool IsHoliday(DateTime date)
{
    if (date.Day == 31 && date.Month == 12)
        return true;
    if (date.Day == 24 && date.Month == 5)
        return true;

    return false;
}

// ...

private void calendar_Draw(object sender, CustomDrawArgs e)
{
    if (e.Element == CustomDrawElements.CellHeader)
    {
        if (IsHoliday(e.Date))
            e.Graphics.DrawEllipse(Pens.Red, e.Bounds);
    }
}

Visual Basic

calendar.CurrentView = CalendarView.SingleMonth
calendar.CustomDraw = CustomDrawElements.CellHeader
AddHandler calendar.Draw, AddressOf calendar_Draw

' ...

Private Function IsHoliday(ByVal ddate As DateTime) As Boolean

    If ddate.Day = 31 And ddate.Month = 12 Then
        Return True
    End If

    If ddate.Day = 24 And ddate.Month = 5 Then
        Return True
    End If

    Return False

End Function

' ...

Private Sub calendar_Draw(ByVal sender As Object, ByVal e As CustomDrawArgs)

    If e.Element = CustomDrawElements.CellHeader Then

        If IsHoliday(e.Date) Then
            e.Graphics.DrawEllipse(Pens.Red, e.Bounds)
        End If

    End If

End Sub

 See Also