1. 程式人生 > >DevExpress 行事歷(Scheduler)的常用屬性、事件和方法

DevExpress 行事歷(Scheduler)的常用屬性、事件和方法

sources sch ble cursor 生產 ase art ott blog

一、TcxScheduler
【TcxScheduler常用屬性】
1.Storage - 邦定一個Storage為Scheduler顯示提供數據

2.DateNavigate.ColCount - 顯示日歷的列數
3.DateNavigate.RowCount - 顯示日歷的行數. ColCount x RowCount 即顯示日歷數
4.DateNavigate.FirstWeekOfYear - 一年的第1個星期
5.DateNavigate.ShowWeekNumbers - 是否顯示周數
6.DateNavigate.Visible - 是否顯示日歷

7.OptionsView.ResourcePerPage - 一頁顯示多少個Storage的Resources.Items(任務執行者)

8.OptionsView.WorkDays - 指定一個星期的哪些天要上班
9.OptionsView.StartOfWeek - 指定哪一天作為星期的第一天
10.OptionsView.WorkStart - 一天的上班開始時間
11.OptionsView.WorkFinish - 一天的上班結束時間
12.OptionsView.ViewPosition - View顯示位置(左或右)

13.ViewDay.Active - 以日的形式顯示
14.ViewWeek.Active - 以星期的形式顯示
15.ViewTimeGrid - 以時間橫向顯示
16.ViewYear.Active - 以年的形式顯示


【TcxScheduler常用事件】
1.OnLayoutChanged - 日期改變、顯示形式改變等觸發
2.OnSelectionChanged - 選擇任務觸發
3.DateNavigator.OnSelectionChanged - 選擇的日期變化觸發

【TcxScheduler常用方法】
1.SelectDays[0] - 返回被選中的第1個日期
2.GoToDate(d1, vmMonth) - 選中d1所在的月份, 並以某種形式顯示
3.SelectedDays[n] - 返回選中的第n個日期
4.SelectWorkDays(d1) - 選中d1所在星期的工作日
5.FullRefresh - 刷新


二、TcxSchedulerStorage

【TcxSchedulerStorage常用屬性】
1.Resources.Items - 增加任務的執行者。如:生產線、業務員....
2.Resources.Images - 任務執行者的圖片集(不是必要的)

【TcxSchedulerStorage常用方法】
1.BeginUpdate - 開始增加任務
2.CreateEvent - 增加任務
3.EndUpdate - 結束增加任務

【TcxSchedulerStorage加載任務】
begin
Screen.Cursor := crHourGlass;
Storage.BeginUpdate;
try
//加入任務
with Storage.createEvent do
begin
ResourceID := 執行者的ResourceID;
Caption := ‘測試任務‘;
Start := StrToDateTime(‘2011/12/01 08:00‘); //開始時間
Finish := StrToDateTime(‘2011/12/01 08:30‘); //結束時間
end;
//循環任務
with Storage.createEvent do
begin
ResourceID := 執行者的ResourceID;
Caption := ‘循環任務‘;
Duration := 45 * MinuteToTime; //耗時
MoveTo(Date + (8 + AResourceID) * HourToTime); //開始時間. 當前日期 +8小明
EventType := etPattern; //任務類型
LabelColor := $51B0F7; //改Label顏色
RecurrenceInfo.Count := -1; //循環次數. -1為不限次數
RecurrenceInfo.Recurrence := cxreWeekly; //循環單位
RecurrenceInfo.Periodicity := 1; //循環周期
RecurrenceInfo.OccurDays := [dWednesday, dSaturday]; //循環日期
RecurrenceInfo.DayType := cxdtDay;
end;
finally
Storage.EndUpdate;
Scheduler.FullRefresh;
Screen.Cursor := crDefault;
end;
end;

【給TcxScheduler的日歷加上底圖或文字】
uses dxoffice11

procedure TfrmVSScheduler.SchedulerDateNavigatorCustomDrawContent(Sender: TObject;
ACanvas: TcxCanvas; AViewInfo: TcxSchedulerDateNavigatorMonthContentViewInfo;
var ADone: Boolean);
var
ABitmap: TBitmap;
AColor: TColor;
R: TRect;
begin
if 1 = 1 then
begin
//日歷底圖
case AViewInfo.Month of
3..5:
ABitmap := cxSpringStyle.Bitmap;
6..8:
ABitmap := cxSummerStyle.Bitmap;
9..11:
ABitmap := cxAutumnStyle.Bitmap;
else
ABitmap := cxWinterStyle.Bitmap;
end;
ACanvas.Canvas.StretchDraw(AViewInfo.Bounds, ABitmap);
end
else begin
//寫文字
R := AViewInfo.Bounds;
case AViewInfo.Month of
3..5: AColor := $D0FFD0;
6..8: AColor := $D0D0FF;
9..11: AColor := $D0FFFF;
else
AColor := $FFE7E7;
end;
with ACanvas do
begin
Brush.Color := AColor;
FillRect(R);
Font.Height := R.Bottom - R.Top;
Font.Color := GetMiddleRGB(AColor, 0, 85);
DrawText(IntToStr(AViewInfo.Month), R, cxAlignCenter);
end;
ACanvas.Font := AViewInfo.ViewParams.Font;
end;
//
AViewInfo.Transparent := True;
ADone := True;
end;
---------------------
作者:chelen_jak
來源:CSDN
原文:https://blog.csdn.net/chelen_jak/article/details/7052181
版權聲明:本文為博主原創文章,轉載請附上博文鏈接!

DevExpress 行事歷(Scheduler)的常用屬性、事件和方法