This repository has been archived by the owner on Sep 11, 2023. It is now read-only.
/
Time Cell Examples.cs
83 lines (78 loc) · 3.73 KB
/
Time Cell Examples.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
using DevExpress.XtraScheduler;
using DevExpress.XtraScheduler.Drawing;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SchedulerAPISample.CodeExamples {
class TimeCellExamples {
static void TimeCellTypes(SchedulerControl scheduler) {
#region #TimeCellTypes
scheduler.CustomDrawTimeCell += scheduler_CustomDrawTimeCell;
scheduler.CustomDrawDayViewAllDayArea += Scheduler_CustomDrawDayViewAllDayArea;
scheduler.TimelineView.GetBaseTimeScale().Width = 150;
scheduler.WeekView.Enabled = true;
scheduler.DayView.DayCount = 3;
scheduler.ActiveViewType = SchedulerViewType.Day;
scheduler.GroupType = SchedulerGroupType.Date;
scheduler.DateNavigationBar.Visible = false;
scheduler.LookAndFeel.UseDefaultLookAndFeel = false;
scheduler.LookAndFeel.Style = DevExpress.LookAndFeel.LookAndFeelStyle.Skin;
scheduler.LookAndFeel.SkinName = "DevExpress Style";
#endregion #TimeCellTypes
}
#region #@TimeCellTypes
public static void scheduler_CustomDrawTimeCell(object sender, CustomDrawObjectEventArgs e) {
e.DrawDefault();
DrawCellInfo(e);
e.Handled = true;
}
private static void Scheduler_CustomDrawDayViewAllDayArea(object sender, CustomDrawObjectEventArgs e) {
e.DrawDefault();
DrawCellInfo(e);
e.Handled = true;
}
readonly static Font textFont = new Font("Tahoma", 10);
private static void DrawCellInfo(CustomDrawObjectEventArgs e) {
string s = e.ObjectInfo.GetType().ToString().Substring("DevExpress.XtraScheduler.Drawing.".Length);
SchedulerViewCellBase cell = e.ObjectInfo as SchedulerViewCellBase;
if (cell != null) {
using(var sf = new StringFormat()) {
sf.Alignment = StringAlignment.Center;
sf.LineAlignment = StringAlignment.Center;
e.Cache.DrawString(s, textFont, SystemBrushes.GrayText, cell.Bounds, sf);
}
}
}
#endregion #@TimeCellTypes
static void HorizontalSingleWeekCellType(SchedulerControl scheduler) {
#region #HorizontalSingleWeekCellType
scheduler.CustomDrawTimeCell += scheduler_CustomDrawTimeCell_01;
scheduler.ActiveViewType = SchedulerViewType.Month;
scheduler.GroupType = SchedulerGroupType.Date;
scheduler.DateNavigationBar.Visible = false;
scheduler.LookAndFeel.UseDefaultLookAndFeel = false;
scheduler.LookAndFeel.Style = DevExpress.LookAndFeel.LookAndFeelStyle.Skin;
scheduler.LookAndFeel.SkinName = "DevExpress Style";
#endregion #HorizontalSingleWeekCellType
}
#region #@HorizontalSingleWeekCellType
readonly static Font textFont_ = new Font("Tahoma", 8);
public static void scheduler_CustomDrawTimeCell_01(object sender, CustomDrawObjectEventArgs e) {
e.DrawDefault();
HorizontalSingleWeekCell cell = e.ObjectInfo as HorizontalSingleWeekCell;
if (cell != null) {
using(var sf = new StringFormat()) {
sf.LineAlignment = StringAlignment.Center;
e.Cache.DrawRectangle(SystemPens.ActiveBorder, cell.Bounds);
if(cell.FirstVisible) e.Cache.DrawString("First Visible Cell", textFont_,
Brushes.Blue, cell.Bounds, sf);
}
}
e.Handled = true;
}
#endregion #@HorizontalSingleWeekCellType
}
}