2008-02-03 12:05:55 +00:00
|
|
|
{*********************************************************}
|
|
|
|
{* VPEVNTEDITDLG.PAS 1.03 *}
|
|
|
|
{*********************************************************}
|
|
|
|
|
|
|
|
{* ***** BEGIN LICENSE BLOCK ***** *}
|
|
|
|
{* Version: MPL 1.1 *}
|
|
|
|
{* *}
|
|
|
|
{* 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/ *}
|
|
|
|
{* *}
|
|
|
|
{* Software distributed under the License is distributed on an "AS IS" basis, *}
|
|
|
|
{* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License *}
|
|
|
|
{* for the specific language governing rights and limitations under the *}
|
|
|
|
{* License. *}
|
|
|
|
{* *}
|
|
|
|
{* The Original Code is TurboPower Visual PlanIt *}
|
|
|
|
{* *}
|
|
|
|
{* The Initial Developer of the Original Code is TurboPower Software *}
|
|
|
|
{* *}
|
|
|
|
{* Portions created by TurboPower Software Inc. are Copyright (C) 2002 *}
|
|
|
|
{* TurboPower Software Inc. All Rights Reserved. *}
|
|
|
|
{* *}
|
|
|
|
{* Contributor(s): *}
|
|
|
|
{* *}
|
|
|
|
{* ***** END LICENSE BLOCK ***** *}
|
|
|
|
|
|
|
|
{$I Vp.INC}
|
|
|
|
|
|
|
|
unit VpEvntEditDlg;
|
|
|
|
{ The default event edit dialog }
|
|
|
|
|
|
|
|
interface
|
|
|
|
|
|
|
|
uses
|
|
|
|
{$IFDEF LCL}
|
2016-06-12 13:20:21 +00:00
|
|
|
LMessages, LCLProc, LCLType, LCLIntf, LResources, EditBtn,
|
2008-02-03 12:05:55 +00:00
|
|
|
{$ELSE}
|
|
|
|
Windows, Messages, Mask,
|
|
|
|
{$ENDIF}
|
|
|
|
SysUtils, {$IFDEF VERSION6}Variants,{$ENDIF} Classes,
|
2016-06-12 13:20:21 +00:00
|
|
|
Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls, ComCtrls, Buttons,
|
|
|
|
VpData, VpBase, VpBaseDS, VpDlg, VpConst; //VpEdPop,
|
2008-02-03 12:05:55 +00:00
|
|
|
|
|
|
|
type
|
|
|
|
{ forward declarations }
|
|
|
|
TVpEventEditDialog = class;
|
|
|
|
|
|
|
|
TEventEditDlgRtnType = (rtCommit, rtAbandon);
|
|
|
|
|
|
|
|
TVpRightAlignedEdit = class(TEdit)
|
|
|
|
public
|
2016-06-12 18:11:04 +00:00
|
|
|
constructor Create(AOwner: TComponent); override;
|
2008-02-03 12:05:55 +00:00
|
|
|
procedure CreateParams(var Params : TCreateParams); override;
|
|
|
|
end;
|
|
|
|
|
2008-02-05 23:55:30 +00:00
|
|
|
{ TDlgEventEdit }
|
|
|
|
|
2008-02-03 12:05:55 +00:00
|
|
|
TDlgEventEdit = class(TForm)
|
2008-02-08 15:07:26 +00:00
|
|
|
AlarmAdvance: TEdit;
|
2016-06-11 14:09:10 +00:00
|
|
|
LocationEdit: TEdit;
|
|
|
|
LocationLbl: TLabel;
|
2008-02-08 15:07:26 +00:00
|
|
|
NotesMemo: TMemo;
|
2008-02-05 23:55:30 +00:00
|
|
|
StartDate: TDateEdit;
|
|
|
|
EndDate: TDateEdit;
|
|
|
|
RepeatUntil: TDateEdit;
|
2008-02-03 12:05:55 +00:00
|
|
|
Panel1: TPanel;
|
|
|
|
OKBtn: TButton;
|
|
|
|
CancelBtn: TButton;
|
|
|
|
ResourceNameLbl: TLabel;
|
|
|
|
FileDialog: TOpenDialog;
|
|
|
|
pgEvent: TPageControl;
|
|
|
|
tabEvent: TTabSheet;
|
|
|
|
AppointmentGroupBox: TGroupBox;
|
|
|
|
DescriptionLbl: TLabel;
|
|
|
|
Bevel1: TBevel;
|
|
|
|
Bevel2: TBevel;
|
|
|
|
CategoryLbl: TLabel;
|
|
|
|
StartTimeLbl: TLabel;
|
|
|
|
EndTimeLbl: TLabel;
|
|
|
|
Image2: TImage;
|
|
|
|
RecurringLbl: TLabel;
|
|
|
|
Bevel3: TBevel;
|
|
|
|
IntervalLbl: TLabel;
|
|
|
|
Image1: TImage;
|
2016-06-13 10:06:54 +00:00
|
|
|
SoundFinderBtn: TSpeedButton;
|
2008-02-03 12:05:55 +00:00
|
|
|
DescriptionEdit: TEdit;
|
|
|
|
AlarmSet: TCheckBox;
|
|
|
|
Category: TComboBox;
|
|
|
|
RecurringType: TComboBox;
|
|
|
|
IntervalUpDown: TUpDown;
|
2016-06-12 12:53:26 +00:00
|
|
|
AlarmAdvanceType: TComboBox;
|
2008-02-03 12:05:55 +00:00
|
|
|
AdvanceUpDown: TUpDown;
|
|
|
|
CBAllDay: TCheckBox;
|
|
|
|
edtUnusedPlaceholder: TEdit;
|
|
|
|
imgClock: TImage;
|
|
|
|
RecurrenceEndsLbl: TLabel;
|
2009-12-24 22:41:52 +00:00
|
|
|
procedure CategoryDrawItem(Control: TWinControl; Index: Integer;
|
|
|
|
ARect: TRect; State: TOwnerDrawState);
|
2008-02-03 12:05:55 +00:00
|
|
|
procedure OKBtnClick(Sender: TObject);
|
|
|
|
procedure CancelBtnClick(Sender: TObject);
|
|
|
|
procedure FormCreate(Sender: TObject);
|
|
|
|
procedure StartDateChange(Sender: TObject);
|
|
|
|
procedure StartTimeChange(Sender: TObject);
|
|
|
|
procedure EndTimeChange(Sender: TObject);
|
|
|
|
procedure AlarmAdvanceChange(Sender: TObject);
|
|
|
|
procedure AdvanceUpDownClick(Sender: TObject; Button: TUDBtnType);
|
|
|
|
procedure CustomIntervalChange(Sender: TObject);
|
|
|
|
procedure IntervalUpDownClick(Sender: TObject; Button: TUDBtnType);
|
|
|
|
procedure RecurringTypeChange(Sender: TObject);
|
|
|
|
procedure AlarmSetClick(Sender: TObject);
|
|
|
|
procedure EndDateChange(Sender: TObject);
|
|
|
|
procedure CBAllDayClick(Sender: TObject);
|
2016-06-13 10:06:54 +00:00
|
|
|
procedure SoundFinderBtnClick(Sender: TObject);
|
2008-02-03 12:05:55 +00:00
|
|
|
procedure FormShow(Sender: TObject);
|
|
|
|
procedure StartTimeExit(Sender: TObject);
|
|
|
|
procedure EndTimeExit(Sender: TObject);
|
|
|
|
private { Private declarations }
|
2016-06-12 13:20:21 +00:00
|
|
|
{$IFDEF LCL}
|
|
|
|
StartTime: TTimeEdit;
|
|
|
|
EndTime: TTimeEdit;
|
|
|
|
{$ENDIF}
|
|
|
|
{$IFDEF DELPHI}
|
|
|
|
StartTime: TComboBox;
|
|
|
|
EndTime: TComboBox;
|
|
|
|
{$ENDIF}
|
2016-06-13 12:57:00 +00:00
|
|
|
FDatastore: TVpCustomDatastore;
|
2008-02-03 12:05:55 +00:00
|
|
|
AAVerifying: Boolean;
|
|
|
|
CIVerifying: Boolean;
|
|
|
|
FCustomInterval : TVpRightAlignedEdit;
|
|
|
|
procedure PopLists;
|
|
|
|
procedure LoadCaptions;
|
2016-06-13 12:57:00 +00:00
|
|
|
procedure DoPlaySound(Sender: TObject; const AWavFile: String; AMode: TVpPlaySoundMode);
|
|
|
|
protected
|
|
|
|
property Datastore: TVpCustomDatastore read FDatastore write FDatastore;
|
2008-02-03 12:05:55 +00:00
|
|
|
public { Public declarations }
|
|
|
|
Event: TVpEvent;
|
|
|
|
CatColorMap: TVpCategoryColorMap;
|
|
|
|
Resource: TVpResource;
|
|
|
|
ReturnCode: TEventEditDlgRtnType;
|
|
|
|
Conflicts : Integer;
|
|
|
|
TimeFormat: TVpTimeFormat;
|
|
|
|
AlarmWavPath: string;
|
|
|
|
FLastEndTime : TDateTime;
|
|
|
|
|
|
|
|
procedure PopulateDialog;
|
|
|
|
procedure DePopulateDialog;
|
|
|
|
end;
|
|
|
|
|
|
|
|
TVpEventEditDialog = class(TVpBaseDialog)
|
|
|
|
protected {private}
|
2016-06-12 18:11:04 +00:00
|
|
|
ceEditDlg: TDlgEventEdit;
|
|
|
|
FTimeFormat: TVpTimeFormat;
|
|
|
|
ceEvent: TVpEvent;
|
2008-02-03 12:05:55 +00:00
|
|
|
public
|
|
|
|
constructor Create(AOwner : TComponent); override;
|
2016-06-12 18:11:04 +00:00
|
|
|
function Execute(Event: TVpEvent; TimeFormat: TVpTimeFormat = tf12Hour): Boolean; reintroduce;
|
2008-02-03 12:05:55 +00:00
|
|
|
function AddNewEvent(StartTime, EndTime: TDateTime): Boolean;
|
|
|
|
published
|
|
|
|
{properties}
|
2016-06-12 18:11:04 +00:00
|
|
|
property TimeFormat: TVpTimeFormat read FTimeFormat write FTimeFormat default tf12Hour;
|
2008-02-03 12:05:55 +00:00
|
|
|
property DataStore;
|
|
|
|
property Options;
|
|
|
|
property Placement;
|
|
|
|
end;
|
|
|
|
|
|
|
|
implementation
|
|
|
|
|
|
|
|
uses
|
2016-06-12 18:11:04 +00:00
|
|
|
VpSR, VpMisc, VpWavDlg;
|
2008-02-03 12:05:55 +00:00
|
|
|
|
2016-06-07 16:34:18 +00:00
|
|
|
{$IFDEF LCL}
|
|
|
|
{$R *.lfm}
|
|
|
|
{$ELSE}
|
|
|
|
{$R *.dfm}
|
2008-02-03 12:05:55 +00:00
|
|
|
{$ENDIF}
|
|
|
|
|
|
|
|
{ TVpRightAlignedEdit }
|
|
|
|
|
2016-06-12 18:11:04 +00:00
|
|
|
constructor TVpRightAlignedEdit.Create(AOwner: TComponent);
|
|
|
|
begin
|
|
|
|
inherited Create(AOwner);
|
|
|
|
{$IFDEF LCL}
|
|
|
|
Alignment := taRightJustify;
|
|
|
|
{$ENDIF}
|
|
|
|
end;
|
|
|
|
|
2008-02-03 12:05:55 +00:00
|
|
|
procedure TVpRightAlignedEdit.CreateParams(var Params: TCreateParams);
|
|
|
|
begin
|
|
|
|
inherited;
|
|
|
|
{$IFNDEF LCL}
|
|
|
|
Params.Style := Params.Style or ES_MULTILINE or ES_RIGHT;
|
|
|
|
{$ENDIF}
|
|
|
|
end;
|
|
|
|
|
|
|
|
{=====}
|
|
|
|
|
|
|
|
{ TDlgEventEdit }
|
|
|
|
|
|
|
|
procedure TDlgEventEdit.FormCreate(Sender: TObject);
|
2016-06-12 18:11:04 +00:00
|
|
|
const
|
|
|
|
DELTA = 8;
|
2008-02-03 12:05:55 +00:00
|
|
|
begin
|
2016-06-12 13:20:21 +00:00
|
|
|
{$IFDEF LCL}
|
|
|
|
StartTime := TTimeEdit.Create(self);
|
|
|
|
{$ELSE}
|
|
|
|
StartTime := TCombobox.Create(self);
|
|
|
|
StartTime.Width := 93;
|
|
|
|
StartTime.ItemIndex := -1;
|
|
|
|
{$ENDIF}
|
|
|
|
StartTime.Parent := AppointmentGroupbox;
|
|
|
|
StartTime.Left := AlarmAdvanceType.Left;
|
|
|
|
StartTime.Top := StartDate.Top;
|
2016-06-13 17:26:15 +00:00
|
|
|
StartTime.TabOrder:= StartDate.TabOrder+ 1;
|
2016-06-12 13:20:21 +00:00
|
|
|
|
|
|
|
{$IFDEF LCL}
|
|
|
|
EndTime := TTimeEdit.Create(self);
|
|
|
|
{$ELSE}
|
|
|
|
EndTime := TCombobox.Create(self);
|
|
|
|
EndTime.Width := 93;
|
|
|
|
EndTime.ItemIndex := -1;
|
|
|
|
{$ENDIF}
|
|
|
|
EndTime.Parent := AppointmentGroupbox;
|
|
|
|
EndTime.Left := AlarmAdvanceType.Left;
|
|
|
|
EndTime.Top := EndDate.Top;
|
2016-06-13 17:26:15 +00:00
|
|
|
EndTime.TabOrder := EndDate.TabOrder + 1;
|
|
|
|
|
|
|
|
SoundFinderBtn.Top := AlarmAdvanceType.Top;
|
|
|
|
SoundFinderBtn.Height := AlarmAdvanceType.Height;
|
|
|
|
SoundFinderBtn.Width := SoundFinderBtn.Height;
|
2016-06-12 13:20:21 +00:00
|
|
|
|
2008-02-03 12:05:55 +00:00
|
|
|
ReturnCode := rtAbandon;
|
|
|
|
PopLists;
|
|
|
|
LoadCaptions;
|
|
|
|
EndDate.Enabled := False;
|
|
|
|
|
|
|
|
FCustomInterval := TVpRightAlignedEdit.Create(Self);
|
|
|
|
with FCustomInterval do begin
|
|
|
|
Parent := AppointmentGroupbox;
|
|
|
|
Top := IntervalUpDown.Top + 1;
|
|
|
|
Left := IntervalUpDown.Left - 65;
|
|
|
|
Height := IntervalUpDown.Height - 1;
|
|
|
|
Width := 65;
|
|
|
|
MaxLength := 5;
|
|
|
|
OnChange := CustomIntervalChange;
|
|
|
|
TabOrder := edtUnusedPlaceholder.TabOrder;
|
|
|
|
end;
|
|
|
|
IntervalUpDown.Associate := FCustomInterval;
|
2016-06-12 18:11:04 +00:00
|
|
|
|
|
|
|
DescriptionLbl.Left := DescriptionEdit.Left - GetLabelWidth(DescriptionLbl) - DELTA;
|
|
|
|
LocationLbl.Left := LocationEdit.Left - GetLabelWidth(LocationLbl) - DELTA;
|
|
|
|
CategoryLbl.Left := Category.Left - GetLabelWidth(CategoryLbl) - DELTA;
|
|
|
|
StartTimeLbl.Left := StartDate.Left - GetLabelWidth(StartTimeLbl) - DELTA;
|
|
|
|
EndTimeLbl.Left := EndDate.Left - GetLabelWidth(EndTimeLbl) - DELTA;
|
|
|
|
RecurrenceEndsLbl.Left := RepeatUntil.Left - GetLabelWidth(RecurrenceEndsLbl) - DELTA;
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
|
|
|
procedure TDlgEventEdit.OKBtnClick(Sender: TObject);
|
|
|
|
begin
|
|
|
|
ReturnCode := rtCommit;
|
|
|
|
Close;
|
|
|
|
end;
|
2009-12-24 22:41:52 +00:00
|
|
|
|
|
|
|
procedure TDlgEventEdit.CategoryDrawItem(Control: TWinControl; Index: Integer;
|
|
|
|
ARect: TRect; State: TOwnerDrawState);
|
|
|
|
var
|
|
|
|
Color, SaveColor: TColor;
|
|
|
|
Name: string;
|
|
|
|
ColorRect: TRect;
|
|
|
|
begin
|
|
|
|
Category.Canvas.FillRect(ARect);
|
|
|
|
Color := clBlack;
|
|
|
|
case Index of
|
|
|
|
0: begin
|
2016-06-12 18:11:04 +00:00
|
|
|
Color := CatColorMap.Category0.Color;
|
|
|
|
Name := CatColorMap.Category0.Description;
|
|
|
|
end;
|
|
|
|
1: begin
|
|
|
|
Color := CatColorMap.Category1.Color;
|
|
|
|
Name := CatColorMap.Category1.Description;
|
|
|
|
end;
|
|
|
|
2: begin
|
|
|
|
Color := CatColorMap.Category2.Color;
|
|
|
|
Name := CatColorMap.Category2.Description;
|
|
|
|
end;
|
|
|
|
3: begin
|
|
|
|
Color := CatColorMap.Category3.Color;
|
|
|
|
Name := CatColorMap.Category3.Description;
|
|
|
|
end;
|
|
|
|
4: begin
|
|
|
|
Color := CatColorMap.Category4.Color;
|
|
|
|
Name := CatColorMap.Category4.Description;
|
|
|
|
end;
|
|
|
|
5: begin
|
|
|
|
Color := CatColorMap.Category5.Color;
|
|
|
|
Name := CatColorMap.Category5.Description;
|
|
|
|
end;
|
|
|
|
6: begin
|
|
|
|
Color := CatColorMap.Category6.Color;
|
|
|
|
Name := CatColorMap.Category6.Description;
|
|
|
|
end;
|
|
|
|
7: begin
|
|
|
|
Color := CatColorMap.Category7.Color;
|
|
|
|
Name := CatColorMap.Category7.Description;
|
|
|
|
end;
|
|
|
|
8: begin
|
|
|
|
Color := CatColorMap.Category8.Color;
|
|
|
|
Name := CatColorMap.Category8.Description;
|
|
|
|
end;
|
|
|
|
9: begin
|
|
|
|
Color := CatColorMap.Category9.Color;
|
|
|
|
Name := CatColorMap.Category9.Description;
|
|
|
|
end;
|
2009-12-24 22:41:52 +00:00
|
|
|
end; {Case}
|
|
|
|
|
|
|
|
SaveColor := Category.Canvas.Brush.Color;
|
|
|
|
Category.Canvas.Brush.Color := Color;
|
|
|
|
Category.Canvas.Pen.Color := clBlack;
|
|
|
|
ColorRect.Left := ARect.Left + 3;
|
|
|
|
ColorRect.Top := ARect.Top + 2;
|
|
|
|
ColorRect.Bottom := ARect.Bottom - 2;
|
|
|
|
ColorRect.Right := ColorRect.Left + 20;
|
|
|
|
Category.Canvas.FillRect(ColorRect);
|
|
|
|
{$IFDEF VERSION5}
|
|
|
|
Category.Canvas.Rectangle(ColorRect);
|
|
|
|
{$ELSE}
|
|
|
|
Category.Canvas.Rectangle(ColorRect.Left, ColorRect.Top, ColorRect.Right,
|
|
|
|
ColorRect.Bottom);
|
|
|
|
{$ENDIF}
|
|
|
|
ARect.Left := ColorRect.Right + 5;
|
|
|
|
Category.Canvas.Brush.Color := SaveColor;
|
|
|
|
Category.Canvas.TextOut(ARect.Left, ARect.Top, Name);
|
|
|
|
end;
|
|
|
|
|
2008-02-03 12:05:55 +00:00
|
|
|
{=====}
|
|
|
|
|
|
|
|
procedure TDlgEventEdit.CancelBtnClick(Sender: TObject);
|
|
|
|
begin
|
|
|
|
Close;
|
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
|
|
|
procedure TDlgEventEdit.PopulateDialog;
|
|
|
|
var
|
|
|
|
I: Integer;
|
|
|
|
begin
|
|
|
|
{ Resource }
|
|
|
|
ResourceNameLbl.Caption := Resource.Description;
|
|
|
|
|
|
|
|
{ Events }
|
|
|
|
StartDate.Date := Event.StartTime;
|
|
|
|
EndDate.Date := Event.EndTime;
|
|
|
|
RepeatUntil.Date := Event.RepeatRangeEnd;
|
2008-02-08 15:07:26 +00:00
|
|
|
StartTime.Text := FormatDateTime('hh:mm',Event.StartTime);
|
|
|
|
EndTime.Text := FormatDateTime('hh:mm',Event.EndTime);
|
2008-02-03 12:05:55 +00:00
|
|
|
|
|
|
|
StartTimeChange(Self);
|
|
|
|
CBAllDay.Checked := Event.AllDayEvent;
|
2016-06-12 12:53:26 +00:00
|
|
|
AlarmWavPath := Event.DingPath;
|
2008-02-03 12:05:55 +00:00
|
|
|
|
|
|
|
StartDate.Enabled := not CBAllDay.Checked;
|
2008-02-20 21:13:06 +00:00
|
|
|
EndDate.Enabled := not CBAllDay.Checked;
|
2008-02-03 12:05:55 +00:00
|
|
|
EndTime.Enabled := not CBAllDay.Checked;
|
|
|
|
StartTime.Enabled := not CBAllDay.Checked;
|
|
|
|
|
|
|
|
DescriptionEdit.Text := Event.Description;
|
2016-06-11 14:09:10 +00:00
|
|
|
LocationEdit.Text := Event.Location;
|
|
|
|
NotesMemo.Text := Event.Notes;
|
2008-02-03 12:05:55 +00:00
|
|
|
AlarmSet.Checked := Event.AlarmSet;
|
|
|
|
AlarmSetClick(Self);
|
|
|
|
if not Event.AlarmSet then
|
|
|
|
AlarmAdvance.Text := '15'
|
|
|
|
else
|
2016-06-12 12:53:26 +00:00
|
|
|
AlarmAdvance.Text := IntToStr(Event.AlarmAdvance);
|
|
|
|
AlarmAdvanceType.ItemIndex := Ord(Event.AlarmAdvanceType);
|
2008-02-03 12:05:55 +00:00
|
|
|
RecurringType.ItemIndex := Ord(Event.RepeatCode);
|
|
|
|
RecurringTypeChange(Self);
|
2016-06-12 12:53:26 +00:00
|
|
|
FCustomInterval.Text := IntToStr(Event.CustomInterval);
|
2008-02-03 12:05:55 +00:00
|
|
|
|
|
|
|
Category.Items.Clear;
|
|
|
|
|
|
|
|
for I := 0 to 9 do
|
|
|
|
if (CatColorMap.GetName(I) <> '') then
|
|
|
|
Category.Items.Add(CatColorMap.GetName(I));
|
|
|
|
|
|
|
|
Category.ItemIndex := Event.Category;
|
|
|
|
|
|
|
|
FLastEndTime := Event.EndTime;
|
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
|
|
|
procedure TDlgEventEdit.DePopulateDialog;
|
|
|
|
begin
|
|
|
|
{ Events }
|
2008-02-05 23:55:30 +00:00
|
|
|
Event.StartTime := StartDate.Date + StrToTime(StartTime.Text);
|
|
|
|
Event.EndTime := EndDate.Date + StrToTime(EndTime.Text);
|
2008-02-03 12:05:55 +00:00
|
|
|
Event.RepeatRangeEnd := RepeatUntil.Date;
|
|
|
|
Event.Description := DescriptionEdit.Text;
|
2016-06-11 14:09:10 +00:00
|
|
|
Event.Location := LocationEdit.Text;
|
|
|
|
Event.Notes := NotesMemo.Text;
|
2008-02-03 12:05:55 +00:00
|
|
|
Event.Category := Category.ItemIndex;
|
|
|
|
Event.AlarmSet := AlarmSet.Checked;
|
2016-06-12 12:53:26 +00:00
|
|
|
Event.AlarmAdvance := StrToIntDef(AlarmAdvance.Text, 0);
|
|
|
|
Event.AlarmAdvanceType := TVpAlarmAdvType(AlarmAdvanceType.ItemIndex);
|
2008-02-03 12:05:55 +00:00
|
|
|
Event.RepeatCode := TVpRepeatType(RecurringType.ItemIndex);
|
2016-06-12 12:53:26 +00:00
|
|
|
Event.CustomInterval := StrToIntDef(FCustomInterval.Text, 0);
|
2008-02-03 12:05:55 +00:00
|
|
|
Event.AllDayEvent := CBAllDay.Checked;
|
2016-06-11 14:09:10 +00:00
|
|
|
Event.DingPath := AlarmWavPath;
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
|
|
|
procedure TDlgEventEdit.StartDateChange(Sender: TObject);
|
|
|
|
begin
|
|
|
|
if StartDate.Date > EndDate.Date then
|
|
|
|
EndDate.Date := StartDate.Date;
|
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
|
|
|
procedure TDlgEventEdit.EndDateChange(Sender: TObject);
|
|
|
|
begin
|
|
|
|
if StartDate.Date > EndDate.Date then
|
|
|
|
StartDate.Date := EndDate.Date;
|
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
|
|
|
procedure TDlgEventEdit.StartTimeChange(Sender: TObject);
|
2009-12-24 22:41:52 +00:00
|
|
|
var
|
|
|
|
ST: TDateTime;
|
2008-02-03 12:05:55 +00:00
|
|
|
begin
|
|
|
|
{ Verify the value is valid }
|
|
|
|
try
|
2009-12-24 22:41:52 +00:00
|
|
|
ST := StrToTime(StartTime.Text);
|
2008-02-03 12:05:55 +00:00
|
|
|
except
|
|
|
|
StartTime.Color := clRed;
|
2008-02-05 23:55:30 +00:00
|
|
|
if Visible then
|
|
|
|
StartTime.SetFocus;
|
2008-02-03 12:05:55 +00:00
|
|
|
Exit;
|
|
|
|
end;
|
|
|
|
StartTime.Color := clWindow;
|
|
|
|
|
|
|
|
{ if the end time is less than the start time then change the end time to }
|
|
|
|
{ follow the start time by 30 minutes }
|
2009-12-24 22:41:52 +00:00
|
|
|
if ST > StrToTime(EndTime.Text) then begin
|
|
|
|
if TimeFormat = tf24Hour then
|
2016-06-12 18:11:04 +00:00
|
|
|
EndTime.Text := FormatDateTime('h:mm', ST + 30 / MinutesInDay)
|
2009-12-24 22:41:52 +00:00
|
|
|
else
|
2016-06-12 18:11:04 +00:00
|
|
|
EndTime.Text := FormatDateTime('hh:mm AM/PM', ST + 30 / MinutesInDay);
|
2009-12-24 22:41:52 +00:00
|
|
|
end;
|
2008-02-03 12:05:55 +00:00
|
|
|
|
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
|
|
|
procedure TDlgEventEdit.EndTimeChange(Sender: TObject);
|
|
|
|
|
2016-06-12 18:11:04 +00:00
|
|
|
function IsMidnight(ATime: TDateTime) : Boolean;
|
2008-02-03 12:05:55 +00:00
|
|
|
begin
|
2016-06-12 18:11:04 +00:00
|
|
|
Result := ATime = Trunc(ATime);
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
var
|
|
|
|
ET: TDateTime;
|
|
|
|
|
|
|
|
begin
|
|
|
|
{ Verify the value is valid }
|
|
|
|
try
|
2016-06-12 18:11:04 +00:00
|
|
|
ET := StrToTime(EndTime.Text);
|
|
|
|
if (IsMidnight(ET)) and (not IsMidnight(FLastEndTime)) then
|
2008-02-03 12:05:55 +00:00
|
|
|
EndDate.Date := EndDate.Date + 1
|
2016-06-12 18:11:04 +00:00
|
|
|
else if (not IsMidnight(ET)) and (IsMidnight(FLastEndTime)) then
|
2008-02-03 12:05:55 +00:00
|
|
|
EndDate.Date := EndDate.Date - 1;
|
|
|
|
FLastEndTime := ET;
|
|
|
|
except
|
|
|
|
EndTime.Color := clRed;
|
|
|
|
EndTime.SetFocus;
|
|
|
|
Exit;
|
|
|
|
end;
|
|
|
|
EndTime.Color := clWindow;
|
|
|
|
|
|
|
|
{ if the end time is less than the start time then change the start time to }
|
|
|
|
{ precede the end time by 30 minutes }
|
2009-12-24 22:41:52 +00:00
|
|
|
if ET < StrToTime(StartTime.Text) then begin
|
|
|
|
if TimeFormat = tf24Hour then
|
2016-06-12 18:11:04 +00:00
|
|
|
StartTime.Text := FormatDateTime('h:mm', ET - 30 / MinutesInDay)
|
2009-12-24 22:41:52 +00:00
|
|
|
else
|
2016-06-12 18:11:04 +00:00
|
|
|
StartTime.Text := FormatDateTime('h:mm AM/PM', ET - 30 / MinutesInDay);
|
2009-12-24 22:41:52 +00:00
|
|
|
end;
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
|
|
|
procedure TDlgEventEdit.PopLists;
|
2016-06-12 18:11:04 +00:00
|
|
|
{$IFDEF DELPHI}
|
2008-02-03 12:05:55 +00:00
|
|
|
var
|
|
|
|
StringList: TStringList;
|
|
|
|
I, Hour, Minute: Integer;
|
|
|
|
MinStr, AMPMStr: string;
|
2016-06-12 18:11:04 +00:00
|
|
|
{$ENDIF}
|
2008-02-03 12:05:55 +00:00
|
|
|
begin
|
2016-06-12 18:11:04 +00:00
|
|
|
{$IFDEF DELPHI} // No longer needed for Lazarus using a TTimeEdit now.
|
2008-02-03 12:05:55 +00:00
|
|
|
{ Time Lists }
|
|
|
|
StringList := TStringList.Create;
|
|
|
|
try
|
|
|
|
Minute := 0;
|
|
|
|
AMPMStr := ' AM';
|
|
|
|
for I := 0 to 96 do begin
|
|
|
|
if I > 0 then Inc(Minute, 15);
|
|
|
|
if Minute > 719 then
|
|
|
|
AMPMStr := ' PM';
|
|
|
|
if Minute = MinutesInDay then
|
|
|
|
AMPMStr := ' AM';
|
|
|
|
Hour := (Minute div 15) div 4;
|
|
|
|
MinStr := IntToStr(Minute mod 60);
|
|
|
|
if MinStr = '0' then MinStr := '00';
|
|
|
|
if TimeFormat = tf24Hour then
|
|
|
|
StringList.Add(IntToStr(Hour) + ':' + MinStr)
|
|
|
|
else begin
|
|
|
|
if Hour > 12 then Hour := Hour - 12;
|
|
|
|
if Hour = 0 then Hour := 12;
|
|
|
|
StringList.Add(IntToStr(Hour) + ':' + MinStr + AMPMStr);
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
StartTime.Items.Assign(StringList);
|
|
|
|
StartTime.ItemIndex := 0;
|
|
|
|
|
|
|
|
EndTime.Items.Assign(StringList);
|
|
|
|
EndTime.ItemIndex := 0;
|
|
|
|
finally
|
|
|
|
StringList.Free;
|
|
|
|
end;
|
2016-06-12 13:20:21 +00:00
|
|
|
{$ENDIF}
|
2008-02-03 12:05:55 +00:00
|
|
|
|
|
|
|
{ RecurringList }
|
|
|
|
RecurringType.Items.Add(RSNone);
|
|
|
|
RecurringType.Items.Add(RSDaily);
|
|
|
|
RecurringType.Items.Add(RSWeekly);
|
|
|
|
RecurringType.Items.Add(RSMonthlyByDay);
|
|
|
|
RecurringType.Items.Add(RSMonthlyByDate);
|
|
|
|
RecurringType.Items.Add(RSYearlyByDay);
|
|
|
|
RecurringType.Items.Add(RSYearlyByDate);
|
|
|
|
RecurringType.Items.Add(RSCustom);
|
|
|
|
RecurringType.ItemIndex := 0;
|
|
|
|
|
|
|
|
{ Alarm Advance Type }
|
2016-06-12 12:53:26 +00:00
|
|
|
AlarmAdvanceType.Items.Add(RSMinutes);
|
|
|
|
AlarmAdvanceType.Items.Add(RSHours);
|
|
|
|
AlarmAdvanceType.Items.Add(RSDays);
|
|
|
|
AlarmAdvanceType.ItemIndex := 0;
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
|
|
|
procedure TDlgEventEdit.LoadCaptions;
|
|
|
|
begin
|
|
|
|
OKBtn.Caption := RSOKBtn;
|
|
|
|
CancelBtn.Caption := RSCancelBtn;
|
|
|
|
AppointmentGroupBox.Caption := RSAppointmentGroupBox;
|
|
|
|
DescriptionLbl.Caption := RSDescriptionLbl;
|
2016-06-11 14:09:10 +00:00
|
|
|
LocationLbl.Caption := RSLocationLbl;
|
2008-02-03 12:05:55 +00:00
|
|
|
CategoryLbl.Caption := RSCategoryLbl;
|
|
|
|
StartTimeLbl.Caption := RSStartTimeLbl;
|
|
|
|
EndTimeLbl.Caption := RSEndTimeLbl;
|
|
|
|
AlarmSet.Caption := RSAlarmSet;
|
|
|
|
RecurringLbl.Caption := RSRecurringLbl;
|
|
|
|
IntervalLbl.Caption := RSIntervalLbl;
|
|
|
|
RecurrenceEndsLbl.Caption := RSRecurrenceEndsLbl;
|
|
|
|
CBAllDay.Caption := RSAllDayEvent;
|
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
|
|
|
procedure TDlgEventEdit.AlarmAdvanceChange(Sender: TObject);
|
|
|
|
var
|
|
|
|
I: Integer;
|
|
|
|
Str: string;
|
|
|
|
begin
|
|
|
|
if AAVerifying then exit;
|
|
|
|
AAVerifying := true;
|
|
|
|
{ Don't allow non numeric values. }
|
|
|
|
Str := AlarmAdvance.Text;
|
|
|
|
I := Length(Str);
|
|
|
|
if (Str[I] > #57) or (Str[I] < #48) then
|
|
|
|
Delete(Str, I, 1);
|
|
|
|
AlarmAdvance.Text := Str;
|
|
|
|
AAVerifying := false;
|
|
|
|
|
|
|
|
if Str <> '' then
|
|
|
|
AdvanceUpDown.Position := StrToInt(Str);
|
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
|
|
|
procedure TDlgEventEdit.AdvanceUpDownClick(Sender: TObject; Button: TUDBtnType);
|
|
|
|
begin
|
|
|
|
{ Inc or Dec AlarmAdvance according to which button was pressed }
|
|
|
|
{ case Button of
|
|
|
|
btNext:
|
|
|
|
AlarmAdvance.Text := IntToStr(StrToIntDef(AlarmAdvance.Text, 0) + 1);
|
|
|
|
btPrev:
|
|
|
|
AlarmAdvance.Text := IntToStr(StrToIntDef(AlarmAdvance.Text, 0) - 1);
|
|
|
|
end;}
|
|
|
|
AlarmAdvance.Text := IntToStr(AdvanceUpDown.Position);
|
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
|
|
|
procedure TDlgEventEdit.CustomIntervalChange(Sender: TObject);
|
|
|
|
var
|
|
|
|
I: Integer;
|
|
|
|
Str: string;
|
|
|
|
begin
|
|
|
|
{ Don't allow non numeric values. }
|
|
|
|
if CIVerifying then Exit;
|
|
|
|
CIVerifying := true;
|
|
|
|
Str := FCustomInterval.Text;
|
|
|
|
for I := 1 to Length(Str) do
|
|
|
|
if (Ord(Str[I]) in [48..57]) then
|
|
|
|
Continue
|
|
|
|
else
|
|
|
|
Delete(Str, I, 1);
|
|
|
|
FCustomInterval.Text := Str;
|
|
|
|
if Str <> '' then
|
|
|
|
IntervalUpDown.Position := StrToInt(Str);
|
|
|
|
CIVerifying := false;
|
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
|
|
|
procedure TDlgEventEdit.IntervalUpDownClick(Sender: TObject; Button: TUDBtnType);
|
|
|
|
begin
|
|
|
|
FCustomInterval.Text := IntToStr(IntervalUpDown.Position);
|
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
|
|
|
procedure TDlgEventEdit.RecurringTypeChange(Sender: TObject);
|
|
|
|
begin
|
2016-06-12 18:11:04 +00:00
|
|
|
if (RecurringType.ItemIndex > 0) and (RepeatUntil.Date <= StartDate.Date) then
|
2008-02-03 12:05:55 +00:00
|
|
|
RepeatUntil.Date := StartDate.Date + 365;
|
|
|
|
|
|
|
|
RecurrenceEndsLbl.Enabled := (RecurringType.ItemIndex > 0);
|
|
|
|
RepeatUntil.Enabled := RecurrenceEndsLbl.Enabled;
|
|
|
|
|
|
|
|
FCustomInterval.Enabled := RecurringType.ItemIndex = 7;
|
|
|
|
IntervalLbl.Enabled := FCustomInterval.Enabled;
|
|
|
|
IntervalUpDown.Enabled := FCustomInterval.Enabled;
|
|
|
|
if FCustomInterval.Enabled then begin
|
|
|
|
FCustomInterval.Text := IntToStr(IntervalUpDown.Position);
|
|
|
|
if Visible then
|
|
|
|
FCustomInterval.SetFocus;
|
|
|
|
end;
|
|
|
|
|
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
|
|
|
procedure TDlgEventEdit.AlarmSetClick(Sender: TObject);
|
|
|
|
begin
|
|
|
|
AlarmAdvance.Enabled := AlarmSet.Checked;
|
2016-06-12 12:53:26 +00:00
|
|
|
AlarmAdvanceType.Enabled := AlarmSet.Checked;
|
2008-02-03 12:05:55 +00:00
|
|
|
AdvanceUpDown.Enabled := AlarmSet.Checked;
|
2016-06-13 17:26:15 +00:00
|
|
|
SoundFinderBtn.Enabled := AlarmSet.Checked;
|
2008-02-03 12:05:55 +00:00
|
|
|
Event.SnoozeTime := 0.0;
|
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
|
|
|
procedure TDlgEventEdit.CBAllDayClick(Sender: TObject);
|
|
|
|
begin
|
|
|
|
StartDate.Enabled := not CBAllDay.Checked;
|
2008-02-20 21:13:06 +00:00
|
|
|
EndDate.Enabled := not CBAllDay.Checked;
|
2008-02-03 12:05:55 +00:00
|
|
|
EndTime.Enabled := not CBAllDay.Checked;
|
|
|
|
StartTime.Enabled := not CBAllDay.Checked;
|
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
2016-06-13 10:06:54 +00:00
|
|
|
procedure TDlgEventEdit.SoundFinderBtnClick(Sender: TObject);
|
2016-06-13 12:57:00 +00:00
|
|
|
var
|
|
|
|
SoundFinder: TfrmSoundDialog;
|
|
|
|
begin
|
2016-06-14 10:33:10 +00:00
|
|
|
SoundFinder := TFrmSoundDialog.Create(nil);
|
2016-06-13 12:57:00 +00:00
|
|
|
try
|
|
|
|
SoundFinder.DingPath := AlarmWavPath;
|
2016-06-14 09:08:12 +00:00
|
|
|
SoundFinder.MediaFolder := Datastore.MediaFolder;
|
2016-06-13 12:57:00 +00:00
|
|
|
SoundFinder.OnPlaySound := DoPlaySound;
|
2016-06-14 09:08:12 +00:00
|
|
|
SoundFinder.Populate;
|
2016-06-14 10:33:10 +00:00
|
|
|
if SoundFinder.ShowModal = mrOK then begin
|
2016-06-13 12:57:00 +00:00
|
|
|
if SoundFinder.CBDefault.Checked then
|
|
|
|
AlarmWavPath := ''
|
|
|
|
else
|
2016-06-13 19:42:10 +00:00
|
|
|
AlarmWavPath := SoundFinder.GetSelectedFilename;
|
2016-06-13 12:57:00 +00:00
|
|
|
end;
|
|
|
|
finally
|
2016-06-14 10:33:10 +00:00
|
|
|
SoundFinder.Free;
|
2016-06-13 12:57:00 +00:00
|
|
|
end;
|
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
|
|
|
procedure TDlgEventEdit.DoPlaySound(Sender: TObject; const AWavFile: String;
|
|
|
|
AMode: TVpPlaySoundMode);
|
2008-02-03 12:05:55 +00:00
|
|
|
begin
|
2016-06-13 12:57:00 +00:00
|
|
|
if DataStore <> nil then
|
|
|
|
Datastore.PlaySound(AWavFile, AMode);
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
|
|
|
procedure TDlgEventEdit.FormShow(Sender: TObject);
|
|
|
|
begin
|
|
|
|
DescriptionEdit.SetFocus;
|
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
|
|
|
{ TVpEventEditDialog }
|
|
|
|
|
2016-06-12 18:11:04 +00:00
|
|
|
constructor TVpEventEditDialog.Create(AOwner: TComponent);
|
2008-02-03 12:05:55 +00:00
|
|
|
begin
|
|
|
|
inherited Create(AOwner);
|
|
|
|
FPlacement.Position := mpCenterTop;
|
|
|
|
FPlacement.Height := 415;
|
|
|
|
FPlacement.Width := 710;
|
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
|
|
|
function TVpEventEditDialog.Execute(Event: TVpEvent;
|
|
|
|
TimeFormat: TVpTimeFormat = tf12Hour): Boolean;
|
|
|
|
var
|
|
|
|
DlgEventEdit: TDlgEventEdit;
|
|
|
|
begin
|
|
|
|
ceEvent := Event;
|
2008-02-05 23:55:30 +00:00
|
|
|
DlgEventEdit := TDlgEventEdit.Create(Self);
|
2008-02-03 12:05:55 +00:00
|
|
|
try
|
|
|
|
DoFormPlacement(DlgEventEdit);
|
|
|
|
SetFormCaption(DlgEventEdit, Event.Description, RSDlgEventEdit);
|
2016-06-13 12:57:00 +00:00
|
|
|
DlgEventEdit.Datastore := Datastore;
|
2008-02-03 12:05:55 +00:00
|
|
|
DlgEventEdit.Event := Event;
|
|
|
|
DlgEventEdit.TimeFormat := FTimeFormat;
|
|
|
|
DlgEventEdit.Resource := DataStore.Resource;
|
|
|
|
DlgEventEdit.CatColorMap := DataStore.CategoryColorMap;
|
|
|
|
DlgEventEdit.PopulateDialog;
|
|
|
|
DlgEventEdit.ShowModal;
|
|
|
|
result := (DlgEventEdit.ReturnCode = rtCommit);
|
|
|
|
if Result then begin
|
|
|
|
DlgEventEdit.DePopulateDialog;
|
|
|
|
DataStore.PostEvents;
|
|
|
|
end;
|
|
|
|
finally
|
|
|
|
DlgEventEdit.Release;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
|
|
|
function TVpEventEditDialog.AddNewEvent(StartTime, EndTime: TDateTime): Boolean;
|
|
|
|
begin
|
|
|
|
Result := false;
|
|
|
|
if DataStore <> nil then begin
|
|
|
|
ceEvent := DataStore.Resource.Schedule.AddEvent(
|
|
|
|
DataStore.GetNextID(EventsTableName), StartTime, EndTime);
|
|
|
|
if ceEvent <> nil then begin
|
|
|
|
Result := Execute(ceEvent);
|
|
|
|
if (not Result) or (ceEvent = nil) then
|
|
|
|
ceEvent.Free;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
|
|
|
procedure TDlgEventEdit.StartTimeExit(Sender: TObject);
|
|
|
|
var
|
|
|
|
ST : TDateTime;
|
|
|
|
begin
|
2016-06-12 18:11:04 +00:00
|
|
|
{ Verify the value is valid }
|
2008-02-03 12:05:55 +00:00
|
|
|
try
|
2016-06-12 18:11:04 +00:00
|
|
|
ST := StartDate.Date + StrToTime(StartTime.Text);
|
|
|
|
except
|
|
|
|
StartTime.Color := clRed;
|
|
|
|
StartTime.SetFocus;
|
|
|
|
Exit;
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
2016-06-12 18:11:04 +00:00
|
|
|
StartTime.Color := clWindow;
|
2008-02-03 12:05:55 +00:00
|
|
|
|
2016-06-12 18:11:04 +00:00
|
|
|
{ If the end time is less than the start time then change the end }
|
2008-02-03 12:05:55 +00:00
|
|
|
{ time to follow the start time by 30 minutes }
|
|
|
|
|
2016-06-12 18:11:04 +00:00
|
|
|
if ST > EndDate.Date + StrToTime (EndTime.Text) then
|
|
|
|
EndTime.Text := FormatDateTime('hh:mm', ST + 30 / MinutesInDay);
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TDlgEventEdit.EndTimeExit(Sender: TObject);
|
|
|
|
var
|
2016-06-12 18:11:04 +00:00
|
|
|
ET: TDateTime;
|
2008-02-03 12:05:55 +00:00
|
|
|
begin
|
2016-06-12 18:11:04 +00:00
|
|
|
{ Verify the value is valid }
|
|
|
|
try
|
|
|
|
ET := EndDate.Date + StrToTime(EndTime.Text);
|
|
|
|
except
|
|
|
|
EndTime.Color := clRed;
|
|
|
|
EndTime.SetFocus;
|
|
|
|
Exit;
|
|
|
|
end;
|
|
|
|
EndTime.Color := clWindow;
|
2008-02-03 12:05:55 +00:00
|
|
|
|
2016-06-12 18:11:04 +00:00
|
|
|
{ If the end time is less than the start time then change the }
|
2008-02-03 12:05:55 +00:00
|
|
|
{ start time to precede the end time by 30 minutes }
|
|
|
|
|
2016-06-12 18:11:04 +00:00
|
|
|
if ET < StartDate.Date + StrToTime (StartTime.Text) then
|
|
|
|
StartTime.Text := FormatDateTime('hh:mm', ET - 30 / MinutesInDay);
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
2016-06-07 16:34:18 +00:00
|
|
|
|
2008-02-03 12:05:55 +00:00
|
|
|
end.
|
|
|
|
|