Is it possible
to highlight specific days, such as weekend days and
holidays for instance, in the Time Line Ruler of Solutions
Schedule .NET?
Working with the Time Types demo that ships with Solutions
Schedule .NET Enterprise, we can modify the demo code and using
the new User Drawn functionality found in Solutions Schedule
.NET v6.0 there is a fairly straight forward process for
creating a highlighted feature of unique / specific days in the Time Line Ruler.
Following
are the steps you can use for Setting Highlighted Days in
Solutions Schedule .NET Enterprise Time Line
Ruler:
Private
Sub
DbiSchedule1_UserDrawnRuler(sender
As Object, e
As Dbi.WinControl.Schedule.UserDrawnRulerEventArgs)
Handles
DbiSchedule1.UserDrawnRuler
'Test that the dbiScheduleObject
the ruler belongs to, is displaying Days
If
e.ScheduleObject.TimeType = Dbi.WinControl.Schedule.enumTimeType.Days
Then
'Check that this is the first
pass (drawing the background)
If e.FirstDraw
Then
'Declare some variables for
tracking and drawing the colored in area
Dim DayLeft
As
Integer = e.Rect.Left
'The first day will be at the left most edge.
Dim DayWidth
As
Integer =
Me.DbiSchedule1.TimeDistance
'Each day is as wide as the
TimeDistance property of the control.
Dim DayHeight
As
Integer = e.Rect.Height / 2
'The colored areas will be set to
half the height of the total ruler area.
Dim DayTop
As
Integer = e.Rect.Top +
DayHeight
'The colored area will be in the
bottom half of the ruler.
'Each day displayed in the ruler
will need to be tested
Dim dayLoop
As
DateTime = e.Start
'Loop through all the displayed
dates, from left/start to right/end
While dayLoop < e.End
'Test for a weekend
In this case, a test is performed
to determine if the WeekendDays collection of the control
contains the DayOfWeek of the current day in the loop
If (Me.DbiSchedule1.WeekendDays.Contains(dayLoop.DayOfWeek))
Then
'The current loop day is
considered a weekend. The background for the date in
the ruler will be colored accordingly
e.Graphics.FillRectangle(New
SolidBrush(e.ScheduleObject.WeekendColor),
New
Rectangle(DayLeft,
DayTop, DayWidth, DayHeight))
End
If
'Increment the dayLoop to the
next displayed date
dayLoop = dayLoop.AddDays(1)
'Increment the variable for the
left edge of the rectangle, by the width of a date
DayLeft += DayWidth
End
While
End
If
End
If
End
Sub
Complete information about Solutions Schedule .NET
can be found
here:
(
https://www.dbi-tech.com/ProductPage_SolutionsScheduleNET.aspx
)
|