OSDN Git Service

連続表示にすると予期せぬ動作を起こすようになりました
[vobslideshow/vob.git] / Unit1.pas
index e936c9d..c9f93ce 100644 (file)
--- a/Unit1.pas
+++ b/Unit1.pas
@@ -3,10 +3,11 @@ unit Unit1;
 interface
 
 uses
-  System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
+  System.SysUtils, System.Types, System.UITypes, System.Classes,
+  System.Variants,
   FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs,
-  Data.Bind.EngExt, Fmx.Bind.DBEngExt, System.Rtti, System.Bindings.Outputs,
-  Fmx.Bind.Editors, Data.Bind.Components, FMX.StdCtrls, FMX.Effects,
+  Data.Bind.EngExt, FMX.Bind.DBEngExt, System.Rtti, System.Bindings.Outputs,
+  FMX.Bind.Editors, Data.Bind.Components, FMX.StdCtrls, FMX.Effects,
   FMX.Filter.Effects, FMX.Ani, FMX.Objects, FMX.Menus, FMX.ListView.Types,
   FMX.ListView, System.TypInfo, FMX.Layouts, FMX.ListBox;
 
@@ -41,14 +42,28 @@ type
     Button1: TButton;
     OpenDialog1: TOpenDialog;
     Button2: TButton;
-    Image2: TImage;
-    ListBox1: TListBox;
+    MenuItem1: TMenuItem;
+    MenuItem2: TMenuItem;
+    MenuItem3: TMenuItem;
+    MenuItem4: TMenuItem;
+    MenuItem5: TMenuItem;
+    MenuItem6: TMenuItem;
+    ComboBox1: TComboBox;
+    MenuItem7: TMenuItem;
+    MenuItem8: TMenuItem;
+    MenuItem9: TMenuItem;
+    MenuItem10: TMenuItem;
+    SpeedButton1: TSpeedButton;
     procedure Button1Click(Sender: TObject);
     procedure Button2Click(Sender: TObject);
     procedure ListView1Change(Sender: TObject);
     procedure FormCreate(Sender: TObject);
     procedure FloatAnimation1Finish(Sender: TObject);
+    procedure MenuItem5Click(Sender: TObject);
+    procedure MenuItem8Click(Sender: TObject);
+    procedure SpeedButton1Click(Sender: TObject);
   private
+    progress: Boolean;
     { private \90é\8c¾ }
   public
     { public \90é\8c¾ }
@@ -61,15 +76,28 @@ implementation
 
 {$R *.fmx}
 
+uses Unit2;
+
 procedure TForm1.Button1Click(Sender: TObject);
 var
   i: Integer;
+  s: TListViewItem;
 begin
   if OpenDialog1.Execute = true then
   begin
     ListView1.Items.Clear;
-    for i := 0 to OpenDialog1.Files.Count-1 do
-      ListView1.Items.Add.Text:=OpenDialog1.Files[i];
+    for i := 0 to OpenDialog1.Files.Count - 1 do
+    begin
+      s := ListView1.Items.Add;
+      s.Text := ExtractFileName(OpenDialog1.Files[i]);
+      s.Detail := OpenDialog1.Files[i];
+      s.Bitmap.LoadFromFile(OpenDialog1.Files[i]);
+    end;
+    if ListView1.ItemCount > 0 then
+    begin
+      ListView1.ItemIndex := 0;
+      Image1.Bitmap.Assign(ListView1.Items[0].Bitmap);
+    end;
   end;
 end;
 
@@ -78,39 +106,78 @@ var
   s: TFmxObject;
   i: Integer;
 begin
-  if Image1.Bitmap.IsEmpty = false then
+  if Sender = Button2 then
+    Randomize;
+  if (ListView1.ItemIndex > -1) and
+    (ListView1.ItemIndex < ListView1.ItemCount - 1) then
   begin
-    FloatAnimation1.Stop;
-    for i := 0 to Image2.ChildrenCount-1 do
-      if Image2.Children[i].ClassName = ListBox1.Items[ListBox1.ItemIndex] then
-        s:=Image2.Children[i];
-    s.Parent:=Image1;
-    FloatAnimation1.Parent:=s;
-    SetObjectProp(s,'target',Image2.Bitmap);
-    FloatAnimation1.Start;
+    if FloatAnimation1.Running = true then
+    begin
+      progress := true;
+      FloatAnimation1.Stop;
+    end;
+    for i := 0 to Button1.ChildrenCount - 1 do
+      if Button1.Children[i].ClassName = ComboBox1.Items[ComboBox1.ItemIndex]
+      then
+      begin
+        s := Button1.Children[i];
+        s.Parent := Image1;
+        FloatAnimation1.Parent := s;
+        SetObjectProp(s, 'target',
+          ListView1.Items[ListView1.ItemIndex + 1].Bitmap);
+        FloatAnimation1.Start;
+        break;
+      end;
   end;
 end;
 
 procedure TForm1.FloatAnimation1Finish(Sender: TObject);
 begin
-  FloatAnimation1.Parent.Parent:=Image2;
+  FloatAnimation1.Parent.Parent := Button1;
+  if (ListView1.ItemIndex < ListView1.ItemCount - 1) and (progress = false) then
+  begin
+    ComboBox1.ItemIndex := Random(ComboBox1.Items.Count);
+    ListView1.ItemIndex := ListView1.ItemIndex + 1;
+    Image1.Bitmap.Assign(ListView1.Items[ListView1.ItemIndex].Bitmap);
+    Button2Click(Sender);
+  end
+  else
+    progress := false;
 end;
 
 procedure TForm1.FormCreate(Sender: TObject);
 var
   i: Integer;
 begin
-  for i := 0 to Image2.ChildrenCount-1 do
-    ListBox1.Items.Add(Image2.Children[i].ClassName);
-  ListBox1.ItemIndex:=0;
+  for i := 0 to Button1.ChildrenCount - 1 do
+    ComboBox1.Items.Add(Button1.Children[i].ClassName);
+  ComboBox1.ItemIndex := 0;
 end;
 
 procedure TForm1.ListView1Change(Sender: TObject);
 begin
-  FloatAnimation1.Stop;
-  Image1.Bitmap.LoadFromFile(ListView1.Items[ListView1.ItemIndex].Text);
-  if ListView1.ItemIndex < ListView1.ItemCount-1 then
-    Image2.Bitmap.LoadFromFile(ListView1.Items[ListView1.ItemIndex+1].Text);
+  if FloatAnimation1.Running = true then
+  begin
+    progress := true;
+    FloatAnimation1.Stop;
+  end;
+  Image1.Bitmap.Assign(ListView1.Items[ListView1.ItemIndex].Bitmap);
+end;
+
+procedure TForm1.MenuItem5Click(Sender: TObject);
+begin
+  Close;
+end;
+
+procedure TForm1.MenuItem8Click(Sender: TObject);
+begin
+  if Form2.ShowModal = mrOK then
+    ComboBox1.Items.Assign(Form2.ListBox2.Items);
+end;
+
+procedure TForm1.SpeedButton1Click(Sender: TObject);
+begin
+  FloatAnimation1.Pause := SpeedButton1.IsPressed;
 end;
 
 end.