-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFormMirrorSHP.pas
161 lines (145 loc) · 3.92 KB
/
FormMirrorSHP.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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
unit FormMirrorSHP;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, Spin, math, SHP_Image_Effects, Undo_Redo, XPMan;
const
C_SHPFX_MIRROR = 0;
C_SHPFX_FLIP = 1;
type
TFrmMirrorSHP = class(TForm)
GbEscope: TGroupBox;
RbAll: TRadioButton;
RbRange: TRadioButton;
LbFrom: TLabel;
SpeFrom: TSpinEdit;
SpeTo: TSpinEdit;
LbTo: TLabel;
Bevel: TBevel;
BtOK: TButton;
BtCancel: TButton;
RbCurrent: TRadioButton;
XPManifest: TXPManifest;
procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
procedure SpeToChange(Sender: TObject);
procedure SpeFromChange(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure BtOKClick(Sender: TObject);
procedure BtCancelClick(Sender: TObject);
private
{ Private declarations }
procedure ApplyChanges;
public
{ Public declarations }
OpType : byte;
end;
implementation
{$R *.dfm}
uses FormMain;
procedure TFrmMirrorSHP.BtCancelClick(Sender: TObject);
begin
close;
end;
procedure TFrmMirrorSHP.BtOKClick(Sender: TObject);
begin
ApplyChanges;
close;
end;
procedure TFrmMirrorSHP.FormCreate(Sender: TObject);
begin
OpType := C_SHPFX_MIRROR;
end;
procedure TFrmMirrorSHP.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
begin
if Key = VK_RETURN then
begin
BtOkClick(Sender);
end
else if Key = VK_ESCAPE then
begin
BtCancelClick(Sender);
end;
end;
procedure TFrmMirrorSHP.FormShow(Sender: TObject);
begin
if OpType = C_SHPFX_MIRROR then
begin
Caption := 'Mirror SHP';
GbEscope.Caption := 'Mirror The Following Frames...';
end
else
begin
Caption := 'Flip SHP';
GbEscope.Caption := 'Flip The Following Frames...';
end;
SpeTo.MaxValue := FrmMain.ActiveData^.SHP.Header.NumImages;
SpeFrom.MaxValue := FrmMain.ActiveData^.SHP.Header.NumImages;
end;
procedure TFrmMirrorSHP.SpeFromChange(Sender: TObject);
begin
RbRange.Checked := true;
if SpeFrom.Value < 1 then
SpeFrom.Value := 1;
if SpeFrom.Value > FrmMain.ActiveData^.SHP.Header.NumImages then
SpeFrom.Value := FrmMain.ActiveData^.SHP.Header.NumImages;
end;
procedure TFrmMirrorSHP.SpeToChange(Sender: TObject);
begin
RbRange.Checked := true;
if SpeTo.Value < 1 then
SpeTo.Value := 1;
if SpeTo.Value > FrmMain.ActiveData^.SHP.Header.NumImages then
SpeTo.Value := FrmMain.ActiveData^.SHP.Header.NumImages;
end;
procedure TFrmMirrorSHP.ApplyChanges;
var
i : integer;
first,last : integer;
begin
if rbAll.Checked then
begin
first := 1;
last := FrmMain.ActiveData^.SHP.Header.NumImages;
end
else if RbRange.Checked then
begin
if (SpeFrom.Value >= 1) and (SpeFrom.Value <= FrmMain.ActiveData^.SHP.Header.NumImages) then
begin
if (SpeTo.Value >= 1) and (SpeTo.Value <= FrmMain.ActiveData^.SHP.Header.NumImages) then
begin
// Let's get the range.
first := Min(SpeFrom.Value,SpeTo.Value);
last := Max(SpeFrom.Value,SpeTo.Value);
end
else
exit;
end
else
exit;
end
else
begin
first := FrmMain.ActiveForm^.Frame;
last := FrmMain.ActiveForm^.Frame;
end;
if OpType = C_SHPFX_MIRROR then
begin
AddToUndo(FrmMain.ActiveData^.UndoList,FrmMain.ActiveData^.SHP,first,last);
for i := first to last do
begin
MirrorFrame(FrmMain.ActiveData^.SHP.Data[i].FrameImage);
end;
end
else
begin
AddToUndo(FrmMain.ActiveData^.UndoList,FrmMain.ActiveData^.SHP,first,last);
for i := first to last do
begin
FlipFrame(FrmMain.ActiveData^.SHP.Data[i].FrameImage);
end;
end;
FrmMain.UndoUpdate(FrmMain.ActiveData^.UndoList);
FrmMain.RefreshAll;
end;
end.