unit cxSchedulerTaskDependencyEditor; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, cxSchedulerStorage, cxGraphics, cxTextEdit, cxMaskEdit, cxDropDownEdit, cxControls, cxContainer, cxEdit, cxLabel, Menus, cxLookAndFeelPainters, StdCtrls, cxButtons, cxGroupBox; type TfmSchedulerTaskDependencyEditor = class(TForm) lbFrom: TcxLabel; lbTo: TcxLabel; lbType: TcxLabel; cbTypeRelation: TcxComboBox; btnCancel: TcxButton; btnOk: TcxButton; btnDelete: TcxButton; lbFromName: TcxLabel; lbToName: TcxLabel; cxGroupBox1: TcxGroupBox; procedure cbTypeRelationPropertiesChange(Sender: TObject); procedure btnDeleteClick(Sender: TObject); procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); private FIsDelete: Boolean; FEventFrom: TcxSchedulerEvent; FEventTo: TcxSchedulerEvent; FIsModified: Boolean; FLinkRelation: TcxSchedulerEventRelation; procedure CheckButtonState; procedure SetLinkRelation(AValue: TcxSchedulerEventRelation); protected function GetEventStr(const AEvent: TcxSchedulerEvent): string; virtual; procedure InitControls; virtual; procedure SetCaptions; public function ShowModal: Integer; override; property IsDelete: Boolean read FIsDelete; property EventFrom: TcxSchedulerEvent read FEventFrom write FEventFrom; property EventTo: TcxSchedulerEvent read FEventTo write FEventTo; property IsModified: Boolean read FIsModified; property LinkRelation: TcxSchedulerEventRelation read FLinkRelation write SetLinkRelation; end; TcxSchedulerTaskDependencyEditor = TfmSchedulerTaskDependencyEditor; TcxSchedulerTaskDependencyEditorClass = class of TcxSchedulerTaskDependencyEditor; implementation uses cxSchedulerStrs; {$R *.dfm} function TfmSchedulerTaskDependencyEditor.ShowModal: Integer; begin FIsModified := False; InitControls; FIsDelete := False; Result := inherited ShowModal; end; function TfmSchedulerTaskDependencyEditor.GetEventStr(const AEvent: TcxSchedulerEvent): string; begin Result := AEvent.Caption; end; procedure TfmSchedulerTaskDependencyEditor.InitControls; begin with cbTypeRelation.ActiveProperties.Items do begin Clear; Add(scxFinishToStartLong); Add(scxStartToStartLong); Add(scxFinishToFinishLong); Add(scxStartToFinishLong); end; cbTypeRelation.ItemIndex := Integer(LinkRelation); SetCaptions; FIsModified := False; CheckButtonState; end; procedure TfmSchedulerTaskDependencyEditor.SetCaptions; begin Self.Caption := scxTaskDependencyEditorCaption; btnOk.Caption := scxOk; btnCancel.Caption := scxCancel; btnDelete.Caption := scxDelete; lbFrom.Caption := scxFrom; lbTo.Caption := scxTo; lbType.Caption := scxType; lbFromName.Caption := cxGetStringAdjustedToWidth(lbFromName.Style.Font, GetEventStr(FEventFrom), lbFromName.ClientWidth); lbToName.Caption := cxGetStringAdjustedToWidth(lbToName.Style.Font, GetEventStr(FEventTo), lbToName.ClientWidth); end; procedure TfmSchedulerTaskDependencyEditor.CheckButtonState; begin btnOk.Enabled := IsModified; end; procedure TfmSchedulerTaskDependencyEditor.SetLinkRelation(AValue: TcxSchedulerEventRelation); begin if AValue <> FLinkRelation then begin FLinkRelation := AValue; FIsModified := True; CheckButtonState; end; end; procedure TfmSchedulerTaskDependencyEditor.cbTypeRelationPropertiesChange(Sender: TObject); begin LinkRelation := TcxSchedulerEventRelation(cbTypeRelation.ItemIndex); CheckButtonState; end; procedure TfmSchedulerTaskDependencyEditor.btnDeleteClick(Sender: TObject); begin FIsDelete := True; end; procedure TfmSchedulerTaskDependencyEditor.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); begin if Key = VK_ESCAPE then begin ModalResult := mrCancel; Key := 0; end; end; end.