-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathForm1.cs
72 lines (64 loc) · 2.53 KB
/
Form1.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
// Developer Express Code Central Example:
// How to hide weekends in the Timeline view
//
// This example illustrates the use of a custom scale to hide the weekends in the
// Timeline view. The Saturday and Sunday are considered weekend. The Friday column
// actually contains three days - Friday, Saturday and Sunday. So it is painted
// with the color specified for the non-working days. To correct this, the
// CustomDrawTimeCell event can be handled and the time cell can be painted
// manually. The Paint Correction check box is used for switching the event
// handling on and off.
//
// You can find sample updates and versions for different programming languages here:
// http://www.devexpress.com/example=E1214
using System;
using System.Windows.Forms;
using DevExpress.XtraScheduler;
using DevExpress.XtraEditors;
using DevExpress.XtraScheduler.Drawing;
using System.Drawing;
namespace TimelineTimeScales {
public partial class Form1 : Form {
public Form1() {
InitializeComponent();
schedulerControl1.OptionsView.FirstDayOfWeek = FirstDayOfWeek.Monday;
HideWeekends(false);
}
private void schedulerControl1_SelectionChanged(object sender, EventArgs e) {
Text = "Selected interval: " + schedulerControl1.SelectedInterval.ToString();
}
private void checkEdit1_CheckedChanged(object sender, EventArgs e) {
CheckEdit editor = sender as CheckEdit;
HideWeekends(editor.Checked);
}
private void HideWeekends(bool hide) {
TimeScaleCollection scales = schedulerControl1.TimelineView.Scales;
if(hide) {
scales.BeginUpdate();
try {
scales.Clear();
scales.Add(new TimeScaleMonth());
TimeScaleWorkWeekDay customWorkWeekScale = new TimeScaleWorkWeekDay();
customWorkWeekScale.Width = 125;
scales.Add(customWorkWeekScale);
}
finally {
scales.EndUpdate();
}
}
else {
scales.BeginUpdate();
try {
scales.Clear();
scales.Add(new TimeScaleMonth());
TimeScaleDay dayScale = new TimeScaleDay();
dayScale.Width = 125;
scales.Add(dayScale);
}
finally {
scales.EndUpdate();
}
}
}
}
}