📄 jvqscheduleeditorform.pas
字号:
{**************************************************************************************************}
{ WARNING: JEDI preprocessor generated unit. Manual modifications will be lost on next release. }
{**************************************************************************************************}
{-----------------------------------------------------------------------------
The contents of this file are subject to the Mozilla Public License
Version 1.1 (the "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/MPL-1.1.html
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either expressed or implied. See the License for
the specific language governing rights and limitations under the License.
The Original Code is: JvScheduleEditorForm.PAS, released on 2002-05-26.
The Initial Developer of the Original Code is John Doe.
Portions created by John Doe are Copyright (C) 2003 John Doe.
All Rights Reserved.
Contributor(s):
Last Modified: 2003-11-09
You may retrieve the latest version of this file at the Project JEDI's JVCL home page,
located at http://jvcl.sourceforge.net
Known Issues:
-----------------------------------------------------------------------------}
{$I jvcl.inc}
unit JvQScheduleEditorForm;
interface
uses
SysUtils, Classes,
QControls, QForms, QStdCtrls, QComCtrls, QExtCtrls, Types,
JclSchedule;
type
TFrmScheduleEditor = class(TForm)
pnlStartInfo: TPanel;
lblStartDate: TLabel;
lblStartTime: TLabel;
lblStartCaption: TLabel;
dtpStartDate: TDateTimePicker;
dtpStartTime: TDateTimePicker;
pnlEndInfo: TPanel;
lblEndCaption: TLabel;
rbInfinite: TRadioButton;
rbTriggerCount: TRadioButton;
rbDayCount: TRadioButton;
rbDate: TRadioButton;
lblEndTime: TLabel;
dtpEndDate: TDateTimePicker;
dtpEndTime: TDateTimePicker;
edEventCount: TEdit;
edDayCount: TEdit;
pnlRecurringInfo: TPanel;
lblScheduleType: TLabel;
rbSingleShot: TRadioButton;
rbDaily: TRadioButton;
rbWeekly: TRadioButton;
rbMonthly: TRadioButton;
rbYearly: TRadioButton;
bvlSeparation: TBevel;
pnlDailySchedule: TPanel;
lblDailyCaption: TLabel;
rbDailyEveryWeekDay: TRadioButton;
rbDailyInterval: TRadioButton;
edDailyInterval: TEdit;
lblDailyIntervalUnit: TLabel;
pnlWeeklySchedule: TPanel;
lblWeeklyCaption: TLabel;
lblWeeklyInterval: TLabel;
edWeeklyInterval: TEdit;
lblWeeklyInterval2: TLabel;
cbWeeklyMon: TCheckBox;
cbWeeklyTue: TCheckBox;
cbWeeklyWed: TCheckBox;
cbWeeklyThu: TCheckBox;
cbWeeklyFri: TCheckBox;
cbWeeklySat: TCheckBox;
cbWeeklySun: TCheckBox;
pnlMonthlySchedule: TPanel;
lblMonthlyCaption: TLabel;
rbMonthlyDay: TRadioButton;
edMonthlyEveryMonth: TEdit;
lblMonthlyDayIntervalSuffix: TLabel;
rbMonthlyEveryIndex: TRadioButton;
cbMonthlyIndexValue: TComboBox;
cbMonthlyIndexType: TComboBox;
edMonthlyDay: TEdit;
lblMontlhyDayInterval: TLabel;
lblMonthlyIndexInterval: TLabel;
edMonthlyIndexInterval: TEdit;
lblMonthlyIndexIntervalSuffix: TLabel;
bvlScheduleType: TBevel;
pnlYearlySchedule: TPanel;
lblYearlyCaption: TLabel;
lblYearlyIntervalSuffix: TLabel;
lblYearlyDateOf: TLabel;
lblYearlyIndexInterval: TLabel;
lblYearlyIndexIntervalSuffix: TLabel;
rbYearlyDate: TRadioButton;
edYearlyDateInterval: TEdit;
rbYearlyIndex: TRadioButton;
cbYearlyIndexValue: TComboBox;
cbYearlyIndexKind: TComboBox;
edYearlyDateDay: TEdit;
edYearlyIndexInterval: TEdit;
cbYearlyDateMonth: TComboBox;
lblYearlyDateInterval: TLabel;
lblYearlyIndexMonth: TLabel;
cbYearlyIndexMonth: TComboBox;
bvlDailyFreq: TBevel;
pnlDailyFreq: TPanel;
lblDailyFreq: TLabel;
rbFreqOneshot: TRadioButton;
dtpDayFreqOneshot: TDateTimePicker;
rbFreqInterval: TRadioButton;
edFreqInterval: TEdit;
cbFreqIntervalUnit: TComboBox;
lblFreqFrom: TLabel;
dtpFreqFrom: TDateTimePicker;
lblFreqTo: TLabel;
dtpFreqTo: TDateTimePicker;
Bevel1: TBevel;
Bevel2: TBevel;
AppEvents: TApplicationEvents;
gbTestSettings: TGroupBox;
cxStartToday: TCheckBox;
cxCountMissedEvents: TCheckBox;
btnTest: TButton;
mmLog: TMemo;
btnOk: TButton;
btnCancel: TButton;
procedure FormCreate(Sender: TObject);
procedure btnTestClick(Sender: TObject);
procedure AppEventsIdle(Sender: TObject; var Done: Boolean);
procedure btnOkClick(Sender: TObject);
private
FTestSchedule: IJclSchedule;
FSchedule: IJclSchedule;
FBusy: Boolean;
procedure SetSchedule(Value: IJclSchedule);
procedure SelectRecurringInfoPage;
procedure UpdateDailyPageInfo;
procedure UpdateWeeklyPageInfo;
procedure UpdateMonthlyPageInfo;
procedure UpdateYearlyPageInfo;
procedure UpdateFrequencyPageInfo;
procedure UpdateEndPageInfo;
procedure UpdateTestSettings;
procedure InitSchedule(const ASchedule: IJclSchedule);
procedure ScheduleToUI(const ASchedule: IJclSchedule);
public
property Schedule: IJclSchedule read FSchedule write SetSchedule;
end;
implementation
uses
JclDateTime,
JvQDsgnConsts;
{$R *.xfm}
procedure DecodeTimeStampTime(const Stamp: TTimeStamp;
var ADays, AHour, AMinute, ASecond, AMSec: Word);
var
TempTime: Integer;
begin
TempTime := Stamp.Time;
AMSec := TempTime mod 1000;
TempTime := TempTime div 1000;
ASecond := TempTime mod 60;
TempTime := TempTime div 60;
AMinute := TempTime mod 60;
TempTime := TempTime div 60;
AHour := TempTime mod 24;
TempTime := TempTime div 24;
ADays := TempTime;
end;
function IndexOfRBChecked(const Controls: array of TRadioButton): Integer;
begin
Result := High(Controls);
while (Result >= 0) and not Controls[Result].Checked do
Dec(Result);
end;
procedure TFrmScheduleEditor.SetSchedule(Value: IJclSchedule);
begin
FSchedule := Value;
ScheduleToUI(FSchedule);
end;
procedure TFrmScheduleEditor.SelectRecurringInfoPage;
begin
pnlDailySchedule.Visible := rbDaily.Checked;
pnlWeeklySchedule.Visible := rbWeekly.Checked;
pnlMonthlySchedule.Visible := rbMonthly.Checked;
pnlYearlySchedule.Visible := rbYearly.Checked;
end;
procedure TFrmScheduleEditor.UpdateDailyPageInfo;
begin
edDailyInterval.Enabled := rbDailyInterval.Checked;
end;
procedure TFrmScheduleEditor.UpdateWeeklyPageInfo;
begin
end;
procedure TFrmScheduleEditor.UpdateMonthlyPageInfo;
begin
edMonthlyDay.Enabled := rbMonthlyDay.Checked;
edMonthlyEveryMonth.Enabled := rbMonthlyDay.Checked;
cbMonthlyIndexValue.Enabled := rbMonthlyEveryIndex.Checked;
cbMonthlyIndexType.Enabled := rbMonthlyEveryIndex.Checked;
edMonthlyIndexInterval.Enabled := rbMonthlyEveryIndex.Checked;
end;
procedure TFrmScheduleEditor.UpdateYearlyPageInfo;
begin
edYearlyDateDay.Enabled := rbYearlyDate.Checked;
cbYearlyDateMonth.Enabled := rbYearlyDate.Checked;
edYearlyDateInterval.Enabled := rbYearlyDate.Checked;
cbYearlyIndexValue.Enabled := rbYearlyIndex.Checked;
cbYearlyIndexKind.Enabled := rbYearlyIndex.Checked;
cbYearlyIndexMonth.Enabled := rbYearlyIndex.Checked;
edYearlyIndexInterval.Enabled := rbYearlyIndex.Checked;
end;
procedure TFrmScheduleEditor.UpdateFrequencyPageInfo;
begin
pnlDailyFreq.Visible := not rbSingleShot.Checked;
dtpDayFreqOneshot.Enabled := rbFreqOneshot.Checked;
edFreqInterval.Enabled := rbFreqInterval.Checked;
cbFreqIntervalUnit.Enabled := rbFreqInterval.Checked;
dtpFreqFrom.Enabled := rbFreqInterval.Checked;
dtpFreqTo.Enabled := rbFreqInterval.Checked;
end;
procedure TFrmScheduleEditor.UpdateEndPageInfo;
begin
pnlEndInfo.Visible := not rbSingleShot.Checked;
edEventCount.Enabled := rbTriggerCount.Checked;
edDayCount.Enabled := rbDayCount.Checked;
dtpEndDate.Enabled := rbDate.Checked;
dtpEndTime.Enabled := rbDate.Checked;
end;
procedure TFrmScheduleEditor.UpdateTestSettings;
begin
cxCountMissedEvents.Enabled := cxStartToday.Checked;
end;
procedure TFrmScheduleEditor.InitSchedule(const ASchedule: IJclSchedule);
var
TempDOW: TScheduleWeekDays;
begin
with ASchedule do
begin
RecurringType := TScheduleRecurringKind(IndexOfRBChecked([rbSingleShot, rbDaily, rbWeekly,
rbMonthly, rbYearly]));
StartDate := DateTimeToTimeStamp(Trunc(dtpStartDate.Date) + Frac(dtpStartTime.Time));
EndType := TScheduleEndKind(IndexOfRBChecked([rbInfinite, rbDate, rbTriggerCount, rbDayCount]));
if RecurringType = srkOneShot then
begin
EndType := sekDate;
EndDate := StartDate;
with ASchedule as IJclScheduleDayFrequency do
begin
StartTime := StartDate.Time;
EndTime := EndDate.Time;
Interval := 1;
end;
end
else
begin
case RecurringType of
srkDaily:
begin
with ASchedule as IJclDailySchedule do
begin
EveryWeekDay := rbDailyEveryWeekDay.Checked;
if not EveryWeekDay then
Interval := StrToInt64(edDailyInterval.Text);
end;
end;
srkWeekly:
begin
with ASchedule as IJclWeeklySchedule do
begin
TempDOW := [];
if cbWeeklyMon.Checked then
Include(TempDOW, swdMonday);
if cbWeeklyTue.Checked then
Include(TempDOW, swdTuesday);
if cbWeeklyWed.Checked then
Include(TempDOW, swdWednesday);
if cbWeeklyThu.Checked then
Include(TempDOW, swdThursday);
if cbWeeklyFri.Checked then
Include(TempDOW, swdFriday);
if cbWeeklySat.Checked then
Include(TempDOW, swdSaturday);
if cbWeeklySun.Checked then
Include(TempDOW, swdSunday);
DaysOfWeek := TempDOW;
Interval := StrToInt64(edWeeklyInterval.Text);
end;
end;
srkMonthly:
begin
with ASchedule as IJclMonthlySchedule do
begin
if rbMonthlyDay.Checked then
begin
IndexKind := sikNone;
Day := StrToInt64(edMonthlyDay.Text);
Interval := StrToInt64(edMonthlyEveryMonth.Text);
end
else
begin
IndexKind := TScheduleIndexKind(cbMonthlyIndexType.ItemIndex + 1);
if cbMonthlyIndexValue.ItemIndex > -1 then
begin
if cbMonthlyIndexValue.ItemIndex < 4 then
IndexValue := cbMonthlyIndexValue.ItemIndex + 1
else
IndexValue := sivLast;
end
else
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -