-
Notifications
You must be signed in to change notification settings - Fork 1
/
CutlistRate_dialog.pas
99 lines (80 loc) · 2.42 KB
/
CutlistRate_dialog.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
unit CutlistRate_dialog;
{$I Information.inc}
// basic review and reformatting: done
interface
uses
// Delphi
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls,
Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.ExtCtrls;
type
TFCutlistRate = class(TForm)
lblSendRating: TLabel;
RGRatingByAuthor: TRadioGroup;
cmdCancel: TButton;
cmdOk: TButton;
procedure RGRatingByAuthorClick(Sender: TObject);
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
private
{ private declarations }
FRatingSelectedByUser: Boolean;
function GetSelectedRating: Integer;
procedure SetSelectedRating(rating: Integer);
function GetSelectedRatingText: string;
public
{ public declarations }
property SelectedRating: Integer read GetSelectedRating write SetSelectedRating;
property SelectedRatingText: string read GetSelectedRatingText;
end;
var
FCutlistRate: TFCutlistRate;
implementation
uses
// CA
CAResources, Utils, Main;
{$R *.dfm}
procedure TFCutlistRate.RGRatingByAuthorClick(Sender: TObject);
begin
if RGRatingByAuthor.ItemIndex >= 0 then
begin
cmdOk.Enabled := True;
FRatingSelectedByUser := (Sender = RGRatingByAuthor);
end;
end;
function TFCutlistRate.GetSelectedRatingText: string;
begin
if SelectedRating < 0 then
Result := ''
else
Result := RGRatingByAuthor.Items.Strings[SelectedRating];
end;
function TFCutlistRate.GetSelectedRating: Integer;
begin
Result := RGRatingByAuthor.ItemIndex;
end;
procedure TFCutlistRate.SetSelectedRating(rating: Integer);
begin
if rating >= RGRatingByAuthor.Items.Count then
rating := -1;
RGRatingByAuthor.ItemIndex := rating;
FRatingSelectedByUser := False;
end;
procedure TFCutlistRate.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
var
msg: string;
begin
if ModalResult = mrOk then
begin
if SelectedRating < 0 then
CanClose := False
else
if not FRatingSelectedByUser then
begin
msg := StringReplace(Format(RsMsgConfirmRating, [SelectedRatingText]), '&', '', [rfReplaceAll]);
FRatingSelectedByUser := NoYesMsg(RsTitleConfirmRating + #13#13 + msg, Settings.NoWarnUseRate);
CanClose := FRatingSelectedByUser;
end;
if not CanClose then
RGRatingByAuthor.SetFocus;
end;
end;
end.