-
Notifications
You must be signed in to change notification settings - Fork 4
/
fileprops.pas
132 lines (106 loc) · 2.96 KB
/
fileprops.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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
unit fileprops;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, ExtCtrls,
ComCtrls, rwpng,rmconfig;
type
{ TFileProperties }
TFileProperties = class(TForm)
A: TLabel;
AV: TEdit;
B: TLabel;
BV: TEdit;
TextToClipboardCheckBox: TCheckBox;
ColorIndexCheckBox: TCheckBox;
ColorIndexValue: TEdit;
CustomCheckBox: TCheckBox;
FuschiaCheckBox: TCheckBox;
G: TLabel;
GV: TEdit;
Label2: TLabel;
OKButton: TButton;
Label1: TLabel;
R: TLabel;
RV: TEdit;
procedure OKButtonClick(Sender: TObject);
procedure TextToClipboardCheckBoxChange(Sender: TObject);
procedure ValueChange(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
PngRGBA : PngRGBASettingsRec;
public
procedure UpdateValues;
procedure SetProps(var props : PngRGBASettingsRec);
procedure GetProps(var props : PngRGBASettingsRec);
end;
var
FilePropertiesDialog: TFileProperties;
implementation
{$R *.lfm}
{ TFileProperties }
function StrToIntHelper(IStr : String) : integer;
var
SValue : integer;
begin
Try
SValue:=StrToInt(IStr);
except
SValue:=0;
end;
if SValue > 255 then SValue:=255;
if SValue < 0 then SValue:=0;
StrToIntHelper:=SValue;
end;
procedure TFileProperties.FormCreate(Sender: TObject);
begin
// GetProps(PngRGBA); //copy the values we set in the form
rmconfigbase.GetProps(PngRGBA);
UpdateValues;
TextToClipboardCheckBox.Checked:=rmconfigbase.GetExportTextFileToClipStatus;
end;
procedure TFileProperties.ValueChange(Sender: TObject);
begin
GetProps(PngRGBA);
UpdateValues;
end;
procedure TFileProperties.OKButtonClick(Sender: TObject);
begin
modalresult:= mrOk;
end;
procedure TFileProperties.TextToClipboardCheckBoxChange(Sender: TObject);
begin
rmconfigbase.SetExportTextFileToClipStatus(TextToClipboardCheckBox.Checked);
end;
// to be called after setprops
// takes values from PngRGBA record and transfer to form
procedure TFileProperties.UpdateValues;
begin
// ColorIndexCheckBox.Checked:=false;
// FuschiaCheckBox.Checked:=false;
// CustomCheckBox.Checked:=false;
ColorIndexCheckBox.Checked:=PngRGBA.UseColorIndex;
FuschiaCheckBox.Checked:=PngRGBA.UseFuschia;
CustomCheckBox.Checked:=PngRGBA.UseCustom;
RV.Text:=IntToStr(PngRGBA.R);
GV.Text:=IntToStr(PngRGBA.G);
BV.Text:=IntToStr(PngRGBA.B);
AV.Text:=IntToStr(PngRGBA.A);
ColorIndexValue.Text:=IntToStr(PngRGBA.ColorIndex);
end;
procedure TFileProperties.SetProps(var props : PngRGBASettingsRec);
begin
PngRGBA:=props;
end;
procedure TFileProperties.GetProps(var props : PngRGBASettingsRec);
begin
props.UseColorIndex:=ColorIndexCheckBox.Checked;
props.UseFuschia:=FuschiaCheckBox.Checked;
props.UseCustom:=CustomCheckBox.Checked;
props.R:=StrToIntHelper(RV.Text);
props.G:=StrToIntHelper(GV.Text);
props.B:=StrToIntHelper(BV.Text);
props.A:=StrToIntHelper(AV.Text);
props.ColorIndex:=StrToIntHelper(ColorIndexValue.Text);
end;
end.