Calendar demo
Source of:
Regions.aspx
<%@ Import Namespace="System.Drawing" %>
<script runat="server">
protected override void OnLoad(EventArgs e) {
base.OnLoad(e);
//
// Loads the settings from the page controls
//
Sch.FreeTimeMode = (FreeTimeMode)Enum.Parse(
typeof(FreeTimeMode), FreeTimeModeCombo.SelectedValue);
Sch.Regions.Clear();
if (LunchCheck.Checked) {
Sch.WorkHourEnd = new TimeSpan(18, 0, 0);
//
// Add lunch regions
//
for (int day = 0; day<7; ++day) {
DateTime date = Sch.FirstDateTime.Date.AddDays(day);
SchedulerRegion region = new SchedulerRegion(date.AddHours(12), date.AddHours(14));
region.Collapsed = true;
Sch.Regions.Add(region);
}
}
if (CheckBox1.Checked) {
ResourceRow row = Sch.Rows[0];
SchedulerRegion region = new SchedulerRegion(row.ChildRows[0], row.ChildRows[row.ChildRows.Count-1]);
region.Style.BackColor = Color.Gainsboro;
Sch.Regions.Add(region);
}
if (CheckBox2.Checked) {
ResourceRow row = Sch.Rows[1];
DateTime date = Sch.FirstDateTime.Date.AddDays(1);
SchedulerRegion region = new SchedulerRegion(
date, date.AddDays(1),
row, row.ChildRows[row.ChildRows.Count-1]);
region.Style.BackColor = Color.PapayaWhip;
Sch.Regions.Add(region);
}
if (CheckBox3.Checked) {
DateTime date = Sch.FirstDateTime.Date.AddDays(1);
SchedulerRegion region = new SchedulerRegion(
date.AddHours(12), date.AddHours(60),
Sch.Rows[0].ChildRows[2], Sch.Rows[1].ChildRows[1]);
region.Style.BackColor = Color.Honeydew;
Sch.Regions.Add(region);
}
//
// Force showing the whole week (7 days)
//
Sch.LastDateTime = Sch.FirstDateTime.Date.AddDays(7);
}
protected void Sch_GetDayInfo(object sender, GetDayInfoEventArgs e) {
//
// That code is invoked for every day appearing in the scheduler control
// to get the color of particular times and to establish if the day (hour) is a free (collapsed)
//
if (UseGetDayInfoCheck.Checked)
e.SetColumnColor(TimeSpan.FromHours(8), Color.SpringGreen);
}
</script>
<table>
<tr>
<td valign="top" width="100%">
<gos:Scheduler ID="Sch" runat="server" Height="376px" Width="100%" Caption="Scheduler regions and columns collapsing"
LinkLine="1px Black Solid" BehaviorOptions="AllowOverlapItems, Default" BackColor="Lavender"
EnableViewState="False" Font-Names="Verdana" Font-Size="Small" ForeColor="Navy"
FreeDateColor="LightCoral" FreeTimeColor="LightSteelBlue" HorizontalHeaderLine="1px Black Solid"
HorizontalLine="1px SlateBlue Solid" NumberOfCols="63" SplitterColor="0, 0, 192"
VerticalLine0="2px SlateBlue Solid" VerticalLine1="1px SlateBlue Solid" VerticalLine2="1px LightSteelBlue Dotted"
VerticalResourceLine="1px SlateBlue Solid" FreeDays="None" CellWidth="20px" ResourcesWidth="100px" OnGetDayInfo="Sch_GetDayInfo">
<CaptionStyle Border="1px Navy Solid" Font-Bold="True" Font-Size="X-Small" HorizontalAlign="Center"
ResourceImage="Blue">
</CaptionStyle>
<BodyStyle BackColor="Lavender">
</BodyStyle>
<ResourceListStyle BackColor="AliceBlue">
</ResourceListStyle>
<ResourceHeaderStyle BackColor="AliceBlue">
</ResourceHeaderStyle>
<TimeLineStyle Font-Size="X-Small" ResourceImage="Blue">
</TimeLineStyle>
</gos:Scheduler>
</td>
<td valign="top">
<div style="width: 350px">
<span style="font-size: 8pt">
The collapsing allows to remove or to get stuck together all columns representing
free time. That helps to show the work time only, and appears the bigger time interval
on the screen. The free time is missed. That causes the scheduler fits better for organizing the working time.</span><br />
FreeTimeMode:
<asp:DropDownList ID="FreeTimeModeCombo" runat="server" AutoPostBack="True">
<asp:ListItem>Visible</asp:ListItem>
<asp:ListItem>Hidden</asp:ListItem>
<asp:ListItem Selected="True">Collapsed</asp:ListItem>
</asp:DropDownList><br />
<br />
<span style="font-size: 8pt">
Use the regions for adding the two free hours for the lunch every day(and expand
work time to the 6pm).<br />
</span>
<asp:CheckBox ID="LunchCheck" runat="server" AutoPostBack="True" Text="Add lunch time:"
TextAlign="Left" /><br />
<br />
<span style="font-size: 8pt">
You can use the regions for coloring particulars periods and resources with specified
background color.
<br />
</span>
<asp:CheckBox ID="CheckBox1" runat="server" Text="Add color to the sub-rows of the �Project 1�:"
TextAlign="Left" AutoPostBack="True" /><br />
<asp:CheckBox ID="CheckBox2" runat="server" Text="Color the whole �Second project� of the second day:"
TextAlign="Left" AutoPostBack="True" /><br />
<asp:CheckBox ID="CheckBox3" runat="server" Text="Add third cross resources rectangle:"
TextAlign="Left" AutoPostBack="True" /><br />
<br />
<span style="font-size: 8pt">
The second way to control the columns color is to use the GetDayInfo label. The
scheduler uses that event to give the color for particular day (hours).
<br />
</span>
<asp:CheckBox ID="UseGetDayInfoCheck" runat="server" AutoPostBack="True" Text="Change color of the first work hour:"
TextAlign="Left" />
</div>
</td>
</tr>
</table>
<br />
<span style="font-size: 8pt"></span>