ueditevent.pas
来自「FMA is a free1 powerful phone editing to」· PAS 代码 · 共 567 行 · 第 1/2 页
PAS
567 行
TntDatePickerStart.DateTime := DateTimeStart;
TntTimePickerStart.DateTime := DateTimeStart;
// Restrict end date time
TntDatePickerEnd.MinDate:= DateTimeStart;
TntTimePickerEnd.MinDate := DateTimeStart;
DurationChange(Self);
UpdateAlarm;
UpdateWeekDays;
end;
procedure TfrmEditEvent.EndDateTimeChange(Sender: TObject);
var
DateTimeEnd: TDateTime;
begin
// End date was changed, so change duration on other
TntComboBoxDuration.ItemIndex := 4;
// Synchronize DateTime of pickers
DateTimeEnd := DateOf(TntDatePickerEnd.DateTime) + TimeOf(TntTimePickerEnd.DateTime);
TntDatePickerEnd.DateTime := DateTimeEnd;
TntTimePickerEnd.DateTime := DateTimeEnd;
// UpdateDudation;
end;
procedure TfrmEditEvent.txtSubjectChange(Sender: TObject);
begin
lblName.Caption := txtSubject.Text;
lblName2.Caption := lblName.Caption;
lblName3.Caption := lblName.Caption;
lblName4.Caption := lblName.Caption;
end;
procedure TfrmEditEvent.TntDatePickerReminderChange(Sender: TObject);
var
DateTimeStart: TDateTime;
begin
// Synchronize DateTime of pickers
DateTimeStart := DateOf(TntDatePickerReminder.DateTime) + TimeOf(TntTimePickerReminder.DateTime);
TntDatePickerReminder.DateTime := DateTimeStart;
TntTimePickerReminder.DateTime := DateTimeStart;
TntRadioGroupReminder.ItemIndex := 7;
end;
procedure TfrmEditEvent.UpdateAlarm;
var
StartTime,AdvanceTime,AlarmTime: TDateTime;
begin
if not Visible then exit;
StartTime := DateOf(TntDatePickerStart.DateTime) + TimeOf(TntTimePickerStart.DateTime);
if TntRadioGroupReminder.ItemIndex <> 0 then begin
AdvanceTime := GetAlarmAdvanceTime(FAlarmAdv, FAlarmAdvType);
case FAlarmAdvType of
atMinutes: begin
if FAlarmAdv = 0 then TntRadioGroupReminder.ItemIndex := 1;
if FAlarmAdv = 5 then TntRadioGroupReminder.ItemIndex := 2;
if FAlarmAdv = 10 then TntRadioGroupReminder.ItemIndex := 3;
if FAlarmAdv = 15 then TntRadioGroupReminder.ItemIndex := 4;
if FAlarmAdv = 30 then TntRadioGroupReminder.ItemIndex := 5;
end;
atHours:
if FAlarmAdv = 1 then TntRadioGroupReminder.ItemIndex := 6;
end;
AlarmTime := StartTime - AdvanceTime;
end
else
AlarmTime := StartTime;
TntRadioGroupReminderClick(Self);
TntDatePickerReminder.DateTime := AlarmTime;
TntTimePickerReminder.DateTime := AlarmTime;
end;
procedure TfrmEditEvent.UpdateAlarmAdv;
begin
if not Visible then exit;
case TntRadioGroupReminder.ItemIndex of
1: begin
FAlarmAdvType := atMinutes;
FAlarmAdv := 0;
end;
2: begin
FAlarmAdvType := atMinutes;
FAlarmAdv := 5;
end;
3: begin
FAlarmAdvType := atMinutes;
FAlarmAdv := 10;
end;
4: begin
FAlarmAdvType := atMinutes;
FAlarmAdv := 15;
end;
5: begin
FAlarmAdvType := atMinutes;
FAlarmAdv := 30;
end;
6: begin
FAlarmAdvType := atHours;
FAlarmAdv := 1;
end;
7: begin
FAlarmAdvType := atMinutes;
FAlarmAdv := Round(((DateOf(TntDatePickerStart.DateTime) + TimeOf(TntTimePickerStart.DateTime)) -
(DateOf(TntDatePickerReminder.DateTime) + TimeOf(TntTimePickerReminder.DateTime)))*MinsPerDay);
end;
end;
end;
procedure TfrmEditEvent.TntRadioGroupReccurenceClick(Sender: TObject);
begin
TntLabel3.Enabled := TntRadioGroupReccurence.ItemIndex <> 0;
DoSetStatus(TntComboBoxRangeEnd,TntLabel3.Enabled);
TntComboBoxRangeEndChange(nil);
ReccuWeekDaysVisible := TntRadioGroupReccurence.ItemIndex = 2;
end;
procedure TfrmEditEvent.TntComboBoxRangeEndChange(Sender: TObject);
begin
ReccurenceEndVisible := TntComboBoxRangeEnd.Enabled and (TntComboBoxRangeEnd.ItemIndex <> 0);
end;
function TfrmEditEvent.GetReminderStartVisible: boolean;
begin
Result := TntDatePickerReminder.Enabled;
end;
procedure TfrmEditEvent.SetReminderStartVisible(const Value: boolean);
begin
DoSetStatus(TntDatePickerReminder,Value);
DoSetStatus(TntTimePickerReminder,Value);
Label26.Enabled := Value;
Label10.Enabled := Value;
end;
function TfrmEditEvent.GetReccurenceEndVisible: boolean;
begin
Result := TntDatePickerReccurence.Enabled;
end;
procedure TfrmEditEvent.SetReccurenceEndVisible(const Value: boolean);
begin
DoSetStatus(TntDatePickerReccurence,Value);
DoSetStatus(TntTimePickerReccurence,Value);
TntLabel2.Enabled := Value;
TntLabel1.Enabled := Value;
end;
procedure TfrmEditEvent.TntDatePickerReccurenceChange(Sender: TObject);
var
DateTimeStart: TDateTime;
begin
// Synchronize DateTime of pickers
DateTimeStart := DateOf(TntDatePickerReccurence.DateTime) + TimeOf(TntTimePickerReccurence.DateTime);
TntDatePickerReccurence.DateTime := DateTimeStart;
TntTimePickerReccurence.DateTime := DateTimeStart;
end;
function TfrmEditEvent.GetReccuWeekDaysVisible: boolean;
begin
Result := TntLabel4.Enabled;
end;
procedure TfrmEditEvent.SetReccuWeekDaysVisible(const Value: boolean);
var
i: Integer;
begin
TntLabel4.Enabled := Value;
for i := 1 to 7 do
DoSetStatus(GetDayCheck(i),Value);
if Value then UpdateWeekDays; // restore current week day settings
end;
procedure TfrmEditEvent.UpdateWeekDays;
var
i: Integer;
begin
if FPrevWeekDay <> 0 then
with GetDayCheck(FPrevWeekDay) do
Checked := Tag <> 0; // restore Checked state
for i := 1 to 7 do begin
DoSetStatus(GetDayCheck(i),TntRadioGroupReccurence.ItemIndex = 2);
GetDayCheck(i).Tag := 0; // clean-up Checked state
end;
FPrevWeekDay := DayOfTheWeek(TntDatePickerStart.DateTime);
with GetDayCheck(FPrevWeekDay) do begin
Tag := byte(Checked); // remember Checked state
Checked := True;
end;
DoSetStatus(GetDayCheck(FPrevWeekDay),False);
end;
function TfrmEditEvent.GetWeekDays: WideString;
var
i: Integer;
procedure AddDay(Day: WideString);
begin
if Result <> '' then Result := Result + ' ';
Result := Result + Day;
end;
begin
Result := '';
for i := 1 to 7 do
with GetDayCheck(i) do
if Checked then AddDay(ReccurenceDayNames[(i mod 7) + 1]);
end;
procedure TfrmEditEvent.SetWeekDays(const Value: WideString);
var
i: Integer;
begin
for i := 1 to 7 do
with GetDayCheck(i) do begin
Checked := Pos(ReccurenceDayNames[(i mod 7) + 1],Value) <> 0;
Tag := 0;
end;
end;
procedure TfrmEditEvent.UpdateDudation;
var
DateTimeStart: TDateTime;
begin
DateTimeStart := TntDatePickerStart.DateTime;
// 30 minutes
if TntDatePickerEnd.DateTime = IncMinute(DateTimeStart, 30) then
TntComboBoxDuration.ItemIndex := 0;
// 1 hour
if TntDatePickerEnd.DateTime = IncHour(DateTimeStart) then
TntComboBoxDuration.ItemIndex := 1;
// 2 hours
if TntDatePickerEnd.DateTime = IncHour(DateTimeStart, 2) then
TntComboBoxDuration.ItemIndex := 2;
// 4 hours
if TntDatePickerEnd.DateTime = IncHour(DateTimeStart, 4) then
TntComboBoxDuration.ItemIndex := 3;
DurationChange(nil);
end;
function TfrmEditEvent.GetDayCheck(Day: Integer): TTntCheckbox;
begin
Result := TTntCheckBox(FindComponent('TntCheckBox'+IntToStr(Day)));
end;
procedure TfrmEditEvent.TntButton1Click(Sender: TObject);
begin
{ TODO: Reminder WAV file support }
end;
procedure TfrmEditEvent.CancelButtonClick(Sender: TObject);
begin
{if not btnApply.Enabled or (MessageDlgW(_('Discard current changes?'),
mtConfirmation, MB_YESNO or MB_DEFBUTTON2) = ID_YES) then}
ModalResult := mrCancel;
end;
procedure TfrmEditEvent.DoSetStatus(Sender: TObject; IsEnabled: boolean);
begin
with THackControl(Sender) do begin
Enabled := IsEnabled;
if Enabled then
Color := clWindow
else
Color := clBtnFace;
end;
end;
end.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?