Calendar demo
Source of:
Layers.aspx
<%@ Import Namespace="ComponentGo.Web" %>
<%@ Import Namespace="System.Drawing" %>
<script runat="server">
//
// The date used for initialization scheduler item objects
//
private DateTime startDate = new DateTime(DateTime.Today.Year, 1, 1);
protected override void OnLoad(EventArgs e) {
base.OnLoad(e);
if (!IsPostBack) {
//
// Initialization of the scheduler control with default settings and scheduler item objects.
//
Sch.FirstDateTime = startDate;
SchedulerItem item;
DateTime dt;
//
// Layer 0
//
dt = startDate.AddMonths(1);
item = new SchedulerItem("L0", dt, dt.AddMonths(10));
item.Layer = 0; // this is not required because the zero is the default value.
item.ItemID = "1";
item.Style.BackColor = Color.Yellow;
Sch.Rows[1].Items.Add(item);
//
// Layer 1
//
dt = startDate.AddMonths(2);
item = new SchedulerItem("L1 - first", dt, dt.AddMonths(7));
item.Layer = 1;
item.ItemID = "2";
item.Style.BackColor = Color.Lavender;
Sch.Rows[1].Items.Add(item);
dt = startDate.AddMonths(3);
item = new SchedulerItem("L1- second", dt, dt.AddMonths(7));
item.Layer = 1;
item.ItemID = "3";
item.Style.BackColor = Color.LightSteelBlue;
Sch.Rows[1].Items.Add(item);
//
// Layer 2
//
dt = startDate.AddMonths(4);
item = new SchedulerItem("L2- first", dt, dt.AddMonths(3));
item.Layer = 2;
item.ItemID = "4";
item.Style.BackColor = Color.LightCoral;
Sch.Rows[1].Items.Add(item);
dt = startDate.AddMonths(5);
item = new SchedulerItem("L2- second", dt, dt.AddMonths(3));
item.Layer = 2;
item.ItemID = "5";
item.Style.BackColor = Color.MistyRose;
Sch.Rows[1].Items.Add(item);
dt = startDate.AddMonths(6);
item = new SchedulerItem("L2- third", dt, dt.AddMonths(3));
item.Layer = 2;
item.ItemID = "6";
item.Style.BackColor = Color.PeachPuff;
Sch.Rows[1].Items.Add(item);
dt = startDate.AddMonths(8);
item = new SchedulerItem("L2- fourth", dt, dt.AddMonths(2));
item.Layer = 2;
item.ItemID = "7";
item.Style.BackColor = Color.NavajoWhite;
Sch.Rows[1].Items.Add(item);
}
//
// Sets or resets the SchedulerViewOptions.OverlappedBesideSelf flag of the scheduler view options property.
//
if (BesideCheck.Checked)
Sch.ViewOptions |= SchedulerViewOptions.OverlappedBesideSelf;
else
Sch.ViewOptions &= ~SchedulerViewOptions.OverlappedBesideSelf;
//
// Depending on the selected option assigns the layer values to scheduler items.
//
if (LayerRadio.SelectedValue=="One") {
//
// All item just in one layer.
//
foreach (SchedulerItem item in Sch.Items)
item.Layer = 0;
}
else {
//
// Assigns three different layers to the scheduler item objects.
//
Sch.Items[0].Layer = 0;
Sch.Items[1].Layer = 1;
Sch.Items[2].Layer = 1;
Sch.Items[3].Layer = 2;
Sch.Items[4].Layer = 2;
Sch.Items[5].Layer = 2;
Sch.Items[6].Layer = 2;
}
}
</script>
<gos:Scheduler ID="Sch" runat="server" Height="205px" Width="100%" Caption="Overlapping layers"
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" VerticalLine0="2px SlateBlue Solid" VerticalLine1="1px SlateBlue Solid"
VerticalResourceLine="1px SlateBlue Solid" CellWidth="40px" SplitterColor="0, 0, 192"
TimeResolution="Month" VerticalLine2="1px LightSteelBlue Dotted" NumberOfCols="12"
ViewOptions="Default, InvisibleVerticalScrollBar, InvisibleHorizontalScrollBar">
<CaptionStyle HorizontalAlign="Center" Font-Bold="True" Font-Size="X-Small" Border="1px Navy Solid"
ResourceImage="Blue">
</CaptionStyle>
<BodyStyle BackColor="Lavender">
</BodyStyle>
<ResourceListStyle BackColor="AliceBlue">
</ResourceListStyle>
<ResourceHeaderStyle BackColor="AliceBlue">
</ResourceHeaderStyle>
<TimeLineStyle Font-Size="X-Small" ResourceImage="Blue">
</TimeLineStyle>
<Rows>
<gos:ResourceRow ResourceID="#0" Texts="First resource">
</gos:ResourceRow>
<gos:ResourceRow ResourceID="#1" Texts="Second resource">
</gos:ResourceRow>
<gos:ResourceRow ResourceID="#2" Texts="Third resource">
</gos:ResourceRow>
</Rows>
<Columns>
<gos:ResourceColumn Text="Name" Width="200px">
</gos:ResourceColumn>
</Columns>
</gos:Scheduler>
<br />
The <em>OverlappedBesideSelf</em> flag controls placing scheduler item rectangles
side by side. The flag is contained by the <em>Scheduler.ViewOptions</em> property.
The default <em>true</em> value means the item rectangles will be placed side by
side. Otherwise, if you reset one all rectangles will take the same place and cover
themselves.<br />
<asp:CheckBox ID="BesideCheck" runat="server" AutoPostBack="True" Text="SchedulerViewOptions.OverlappedBesideSelf:"
Checked="True" TextAlign="Left" /><br />
<br />
The <em>SchedulerItem.Layer</em> property helps to control placing overlapped items
on the scheduler grid. If two or more items will be situated on the same layer (they
have the same layer number value), rectangles will be placed side by side. Otherwise,
if you assign items to different layers, the scheduler items will cover themselves.<br />
<asp:RadioButtonList ID="LayerRadio" runat="server" AutoPostBack="True">
<asp:ListItem Selected="True" Value="Different">Assign items to three different layers</asp:ListItem>
<asp:ListItem Value="One">All items placed in just one layer.</asp:ListItem>
</asp:RadioButtonList><br />
<span style="font-size: 8pt">Notice, the scheduler displays item rectangles in the ResourceRow.Items
collection order. Therefore, if you want to present the small item rectangle above
another, bigger one, you have to add first the bigger item, next the smaller one.
That means the index of the smaller item in the ResourceRow.Items collection has
to be greater than the index of the bigger one. Otherwise, the smaller scheduler
item will be placed below the bigger one (will be covered), and it will be invisible.<br />
<br />
Second note: If you need to set or reset the <em>OverlappedBesideSelf </em>flag
you should use the & and | bitwise operators, like:<br />
[C#]<br />
for setting: Sch.ViewOptions |= SchedulerViewOptions.OverlappedBesideSelf;<br />
for resetting: Sch.ViewOptions &= ~SchedulerViewOptions.OverlappedBesideSelf;<br />
[VB]<br />
for setting: Sch.ViewOptions = Sch.ViewOptions Or SchedulerViewOptions.OverlappedBesideSelf
<br />
for resetting: Sch.ViewOptions = Sch.ViewOptions And Not SchedulerViewOptions.OverlappedBesideSelf</span>