OSDN Git Service

実行ファイル初公開時
[vobslideshow/vob.git] / Unit1.pas
1 unit Unit1;
2
3 interface
4
5 uses
6   System.SysUtils, System.Types, System.UITypes, System.Classes,
7   System.Variants,
8   FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs,
9   Data.Bind.EngExt, FMX.Bind.DBEngExt, System.Rtti, System.Bindings.Outputs,
10   FMX.Bind.Editors, Data.Bind.Components, FMX.StdCtrls, FMX.Effects,
11   FMX.Filter.Effects, FMX.Ani, FMX.Objects, FMX.Menus, FMX.ListView.Types,
12   FMX.ListView, System.TypInfo, FMX.Layouts, FMX.ListBox,
13   FMX.Controls.Presentation, FMX.Edit, FMX.EditBox, FMX.SpinBox, FMX.Media,
14   Math;
15
16 type
17   TForm1 = class(TForm)
18     BlurTransitionEffect1: TBlurTransitionEffect;
19     Image1: TImage;
20     Timer1: TTimer;
21     BandedSwirlTransitionEffect1: TBandedSwirlTransitionEffect;
22     MainMenu1: TMainMenu;
23     BlindTransitionEffect1: TBlindTransitionEffect;
24     CircleTransitionEffect1: TCircleTransitionEffect;
25     MagnifyTransitionEffect1: TMagnifyTransitionEffect;
26     CrumpleTransitionEffect1: TCrumpleTransitionEffect;
27     DissolveTransitionEffect1: TDissolveTransitionEffect;
28     DropTransitionEffect1: TDropTransitionEffect;
29     FadeTransitionEffect1: TFadeTransitionEffect;
30     BrightTransitionEffect1: TBrightTransitionEffect;
31     PixelateTransitionEffect1: TPixelateTransitionEffect;
32     WiggleTransitionEffect1: TWiggleTransitionEffect;
33     ShapeTransitionEffect1: TShapeTransitionEffect;
34     RippleTransitionEffect1: TRippleTransitionEffect;
35     RotateCrumpleTransitionEffect1: TRotateCrumpleTransitionEffect;
36     SaturateTransitionEffect1: TSaturateTransitionEffect;
37     SlideTransitionEffect1: TSlideTransitionEffect;
38     SwirlTransitionEffect1: TSwirlTransitionEffect;
39     WaterTransitionEffect1: TWaterTransitionEffect;
40     WaveTransitionEffect1: TWaveTransitionEffect;
41     LineTransitionEffect1: TLineTransitionEffect;
42     FloatAnimation1: TFloatAnimation;
43     ListView1: TListView;
44     Button1: TButton;
45     OpenDialog1: TOpenDialog;
46     Button2: TButton;
47     MenuItem1: TMenuItem;
48     MenuItem2: TMenuItem;
49     MenuItem3: TMenuItem;
50     MenuItem4: TMenuItem;
51     MenuItem5: TMenuItem;
52     MenuItem6: TMenuItem;
53     ComboBox1: TComboBox;
54     MenuItem7: TMenuItem;
55     MenuItem8: TMenuItem;
56     MenuItem9: TMenuItem;
57     MenuItem10: TMenuItem;
58     Button3: TButton;
59     MenuItem11: TMenuItem;
60     SpinBox1: TSpinBox;
61     Label1: TLabel;
62     Label2: TLabel;
63     MediaPlayer1: TMediaPlayer;
64     Label3: TLabel;
65     MenuItem12: TMenuItem;
66     procedure Button1Click(Sender: TObject);
67     procedure Button2Click(Sender: TObject);
68     procedure ListView1Change(Sender: TObject);
69     procedure FormCreate(Sender: TObject);
70     procedure FloatAnimation1Finish(Sender: TObject);
71     procedure MenuItem5Click(Sender: TObject);
72     procedure MenuItem8Click(Sender: TObject);
73     procedure Button3Click(Sender: TObject);
74     procedure SpinBox1Change(Sender: TObject);
75     procedure MenuItem12Click(Sender: TObject);
76   private
77     progress: Boolean;
78     { private \90é\8c¾ }
79   public
80     { public \90é\8c¾ }
81   end;
82
83 var
84   Form1: TForm1;
85
86 implementation
87
88 {$R *.fmx}
89
90 uses Unit2, Unit3;
91
92 procedure TForm1.Button1Click(Sender: TObject);
93 var
94   i: Integer;
95   s: TListViewItem;
96 begin
97   if OpenDialog1.Execute = true then
98   begin
99     for i := 0 to OpenDialog1.Files.Count - 1 do
100     begin
101       s := ListView1.Items.Add;
102       s.Text := ExtractFileName(OpenDialog1.Files[i]);
103       s.Detail := OpenDialog1.Files[i];
104       s.Bitmap.LoadFromFile(OpenDialog1.Files[i]);
105     end;
106     if ListView1.ItemCount > 0 then
107     begin
108       ListView1.ItemIndex := 0;
109       Image1.Bitmap.Assign(ListView1.Items[0].Bitmap);
110       Randomize;
111     end;
112   end;
113 end;
114
115 procedure TForm1.Button2Click(Sender: TObject);
116 var
117   s: TFmxObject;
118   i: Integer;
119 begin
120   if (ListView1.ItemIndex > -1) and (ComboBox1.Items.Count > 0) and
121     (ListView1.ItemIndex < ListView1.ItemCount - 1) then
122   begin
123     if FloatAnimation1.Running = true then
124     begin
125       progress := true;
126       FloatAnimation1.Stop;
127     end;
128     for i := 0 to Image1.ChildrenCount - 1 do
129       if Image1.Children[i].ClassName = ComboBox1.Items[ComboBox1.ItemIndex]
130       then
131       begin
132         s := Image1.Children[i];
133         (s as TEffect).Enabled := true;
134         FloatAnimation1.Parent := s;
135         SetObjectProp(s, 'target',
136           ListView1.Items[ListView1.ItemIndex + 1].Bitmap);
137         FloatAnimation1.Start;
138         if Sender = Button2 then
139           MediaPlayer1.Play;
140         break;
141       end;
142   end;
143 end;
144
145 procedure TForm1.Button3Click(Sender: TObject);
146 var
147   i: Integer;
148 begin
149   for i := ListView1.Items.Count - 1 downto 0 do
150     if ListView1.Items[i].Checked = true then
151       ListView1.Items.Delete(i);
152 end;
153
154 procedure TForm1.FloatAnimation1Finish(Sender: TObject);
155 begin
156   (FloatAnimation1.Parent as TEffect).Enabled := false;
157   if (ListView1.ItemIndex < ListView1.ItemCount - 1) and (progress = false) then
158   begin
159     ListView1.ItemIndex := ListView1.ItemIndex + 1;
160     Image1.Bitmap.Assign(ListView1.Items[ListView1.ItemIndex].Bitmap);
161     if ListView1.ItemIndex < ListView1.ItemCount - 1 then
162     begin
163       ComboBox1.ItemIndex := Random(ComboBox1.Items.Count);
164       Button2Click(Sender);
165     end;
166   end
167   else
168   begin
169     progress := false;
170     MediaPlayer1.Stop;
171   end;
172 end;
173
174 procedure TForm1.FormCreate(Sender: TObject);
175 var
176   i: Integer;
177 begin
178   for i := 0 to Image1.ChildrenCount - 1 do
179     ComboBox1.Items.Add(Image1.Children[i].ClassName);
180   ComboBox1.ItemIndex := 0;
181 end;
182
183 procedure TForm1.ListView1Change(Sender: TObject);
184 begin
185   if FloatAnimation1.Running = true then
186   begin
187     progress := true;
188     FloatAnimation1.Stop;
189   end;
190   SpinBox1Change(Sender);
191   if (Form3.CheckBox1.IsChecked = true) and
192     (MediaPlayer1.CurrentTime > MediaPlayer1.Duration) then
193     MediaPlayer1.CurrentTime :=
194       MediaPlayer1.CurrentTime mod MediaPlayer1.Duration;
195   Image1.Bitmap.Assign(ListView1.Items[ListView1.ItemIndex].Bitmap);
196 end;
197
198 procedure TForm1.MenuItem12Click(Sender: TObject);
199 begin
200   if Form3.ShowModal = mrOK then
201     if Form3.FIleName = '' then
202     begin
203       MediaPlayer1.Clear;
204       Label3.Text := '\89¹\90º\83t\83@\83C\83\8b\81F' + '\82È\82µ';
205     end
206     else
207     begin
208       MediaPlayer1.FIleName := Form3.FIleName;
209       if Form3.Switch1.IsChecked = true then
210         MediaPlayer1.Volume := 0
211       else
212         MediaPlayer1.Volume := Form3.MediaPlayer1.Volume;
213       Label3.Text := '\89¹\90º\83t\83@\83C\83\8b\81F' + ExtractFileName(Form3.FIleName);
214     end;
215 end;
216
217 procedure TForm1.MenuItem5Click(Sender: TObject);
218 begin
219   Close;
220 end;
221
222 procedure TForm1.MenuItem8Click(Sender: TObject);
223 var
224   s: string;
225   i: Integer;
226 begin
227   if ComboBox1.Items.Count > 0 then
228     s := ComboBox1.Items[ComboBox1.ItemIndex];
229   if Form2.ShowModal = mrOK then
230   begin
231     ComboBox1.Items.Assign(Form2.ListBox2.Items);
232     i := ComboBox1.Items.IndexOf(s);
233     if i > -1 then
234       ComboBox1.ItemIndex := i
235     else if ComboBox1.Items.Count > 0 then
236       ComboBox1.ItemIndex := 0;
237   end;
238 end;
239
240 procedure TForm1.SpinBox1Change(Sender: TObject);
241 begin
242   with FloatAnimation1 do
243   begin
244     if Running = true then
245     begin
246       progress := true;
247       Stop;
248     end;
249     Delay := SpinBox1.Value - Duration;
250   end;
251   if ListView1.Items.Count > 0 then
252     MediaPlayer1.CurrentTime := Floor(SpinBox1.Value * MediaPlayer1.Duration *
253       MediaTimeScale * ListView1.ItemIndex / ListView1.Items.Count);
254   Label2.Visible := SpinBox1.Value = 2.50;
255 end;
256
257 end.