{----------------------------------------------------------------------------- Unit Name: vlthumbsForm Author: vesal Purpose: Create thumbs from current directory History: Usage: Variables in HTML-template: #FIRST# - first picture in directory #LAST# - first picture in directory #TITLE# - title of album #NEXT# - next picture in dircetory #PREV# - previous picture in directory #NAME# - name of current picture #EXT# - extension of current pictutr #SIZE# - size of current picture #EXPLANATION# - explanation to current picture #FOLDER# - folder name (directory) for current folder Command-line parameters: /title="Title" - gives the title from command line and starts Run Html /dir=dir - change to directory and clears showmode /show=dir - changes to directory and sets showmode /start - starts slideshow /nohelp - do not start with help screen /smallermode - show first smaller picture (faster) /html - show make html-mode ToDo: - JOS SELITYS, MUISTA SIIRTÄÄ MYÖS SELITYS (del)!!! -----------------------------------------------------------------------------} unit vlthumbsForm; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, OptionButton, ExtCtrls, kEditPnl, kMacroString, VlThumbsOptionsForm, ActnList, Menus, savepos, ZoomPicture, ksplitter, Parameters, Folder, ExifForm, ComCtrls, kinicomp, ThumbsPanel, ExtDlgs; type TStatusBarIndex = (ixInfo,ixFast,ixZoom,ixScale,ixSmall,ixTime); TFormVlThumbs = class(TForm) SavePos1: TSavePos; MainMenu1: TMainMenu; ActionListMain: TActionList; ActionZoomPlus: TAction; ActionZoom100: TAction; ActionZoomMiinus: TAction; ActionNextPicture: TAction; TimerShow: TTimer; ActionShow: TAction; ActionZoomWidth: TAction; File1: TMenuItem; Edit1: TMenuItem; Exit1: TMenuItem; MakeHTML1: TMenuItem; View1: TMenuItem; Help1: TMenuItem; About1: TMenuItem; Showshow1: TMenuItem; Next1: TMenuItem; N1: TMenuItem; N1001: TMenuItem; Zoom1: TMenuItem; Zoom2: TMenuItem; Zoomwidth1: TMenuItem; ActionExit: TAction; ActionProperties: TAction; Properties1: TMenuItem; PanelLeft: TPanel; PanelRight: TPanel; ListBoxFiles: TListBox; kSplitterFiles: TkSplitter; ListBoxFolders: TListBox; ActionMakeHtml: TAction; ActionStopShow: TAction; StopShow1: TMenuItem; ActionFullScreen: TAction; FullScreen1: TMenuItem; PopupMenu1: TPopupMenu; FullScreen2: TMenuItem; Next2: TMenuItem; Startshow1: TMenuItem; StopShow2: TMenuItem; N1002: TMenuItem; Zoom3: TMenuItem; Zoom4: TMenuItem; Zoomwidth2: TMenuItem; ActionPreviousPicture: TAction; Previouspicture1: TMenuItem; Previouspicture2: TMenuItem; ActionEditPrint: TAction; EditPrint1: TMenuItem; ActionShowMakeHTML: TAction; N2: TMenuItem; ShowMakeHTML1: TMenuItem; PanelHeading: TPanel; PanelHelp: TPanel; PanelHelpButtons: TPanel; ButtonStartShow: TOptionButton; MemoHelp: TMemo; ActionHelp: TAction; Help2: TMenuItem; ButtonFullScreen: TOptionButton; ActionSaveTitle: TAction; Help3: TMenuItem; N3: TMenuItem; N4: TMenuItem; PanelHTMLInner: TPanel; EditTitle: TEditPanel; EditTitleEdit: TEdit; ButtonSaveTitle: TOptionButton; ButtonMakeHtml: TOptionButton; kSplitter1: TkSplitter; ActionSmallerMode: TAction; Smallermode1: TMenuItem; ButtonShowHtml: TOptionButton; ActionShowHtml: TAction; ActionShowInfo: TAction; Showinfo1: TMenuItem; MemoInfo: TMemo; StatusBar: TStatusBar; ActionViewStatusbar: TAction; ActionViewEXIF: TAction; N5: TMenuItem; ViewEXIFinfo1: TMenuItem; Viewstatusbar1: TMenuItem; PanelOptions: TPanel; CBViewExifInfo: TCheckBoxIni; CBViewStatusBar: TCheckBoxIni; ButtonMakeSmallerPictures: TOptionButton; ButtonMakeThumbs: TOptionButton; ActionMakeThumbs: TAction; ActionMakeSmallerPictures: TAction; kSplitter2: TkSplitter; ActionFasterLoad: TAction; Fasterload1: TMenuItem; ActionScale: TAction; cbFasterMode: TCheckBoxIni; PageControl: TPageControl; TabHelp: TTabSheet; TabThumbs: TTabSheet; TabSheet3: TTabSheet; ActionViewThumbs: TAction; ButtonShowThumbs: TOptionButton; ViewThumbs1: TMenuItem; ViewThumbs2: TMenuItem; ActionLongerHelp: TAction; Longerhelp1: TMenuItem; ButtonLongerHelp: TOptionButton; ActionChangeDirectory: TAction; Changedirectory1: TMenuItem; OpenPictureDialog1: TOpenPictureDialog; ActionShowMode: TAction; ShowMode1: TMenuItem; ActionEditCopy: TAction; Copy1: TMenuItem; N6: TMenuItem; Copy2: TMenuItem; ActionDelete: TAction; ActionDeletePermanent: TAction; procedure ButtonRunClick(Sender: TObject); procedure FormCreate(Sender: TObject); procedure ListBoxFilesClick(Sender: TObject); procedure FormDestroy(Sender: TObject); procedure FormShow(Sender: TObject); procedure ActionZoomPlusExecute(Sender: TObject); procedure ActionZoom100Execute(Sender: TObject); procedure ActionZoomMiinusExecute(Sender: TObject); procedure ActionNextPictureExecute(Sender: TObject); procedure TimerShowTimer(Sender: TObject); procedure ActionShowExecute(Sender: TObject); procedure ActionZoomWidthExecute(Sender: TObject); procedure About1Click(Sender: TObject); procedure ActionExitExecute(Sender: TObject); procedure ActionPropertiesExecute(Sender: TObject); procedure ListBoxFoldersClick(Sender: TObject); procedure ActionMakeHtmlExecute(Sender: TObject); procedure ActionStopShowExecute(Sender: TObject); procedure ActionFullScreenExecute(Sender: TObject); procedure ActionPreviousPictureExecute(Sender: TObject); procedure ActionEditPrintExecute(Sender: TObject); procedure ActionShowMakeHTMLExecute(Sender: TObject); procedure ActionHelpExecute(Sender: TObject); procedure ActionSaveTitleExecute(Sender: TObject); procedure ActionSmallerModeExecute(Sender: TObject); procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean); procedure ActionShowHtmlExecute(Sender: TObject); procedure ActionShowInfoExecute(Sender: TObject); procedure ActionViewEXIFExecute(Sender: TObject); procedure ActionViewStatusbarExecute(Sender: TObject); procedure ActionMakeThumbsExecute(Sender: TObject); procedure ActionMakeSmallerPicturesExecute(Sender: TObject); procedure ActionFasterLoadExecute(Sender: TObject); procedure ActionScaleExecute(Sender: TObject); procedure ActionViewThumbsExecute(Sender: TObject); procedure ActionLongerHelpExecute(Sender: TObject); procedure ActionChangeDirectoryExecute(Sender: TObject); procedure ActionShowModeExecute(Sender: TObject); procedure ActionEditCopyExecute(Sender: TObject); procedure ActionDeleteExecute(Sender: TObject); procedure ActionDeletePermanentExecute(Sender: TObject); private SplitterThumbs : TkSplitter; picturedir : string; originaldir : string; macros : TkMacroVarList; options : TFormOptions; ZoomPicture : TZoomPicture; PanelThumbs : TThumbsPanel; parameters : TParameters; FShowMode: boolean; FCurrentCaption: string; FShowSmall: boolean; FormExif : TFormExif; procedure ScanFolders(dir:string); overload; procedure ScanFolders; overload; procedure ScanDir(dir:string); overload; procedure ScanDir; overload; function GetCount: integer; function GetItems(i: integer): string; function GetNames(i: integer): string; function GetSizes(i: integer): string; function GetExts(i: integer): string; procedure SetCurrent(i: integer); procedure CopyFile(nf, nt: string; app: boolean); procedure RunHtml; function Next: boolean; function Previous: boolean; procedure ShowPicture(fullscale:boolean=false); procedure SetZoomFactor(const Value: double); function GetZoomFactor: double; function GetItemIndex: integer; procedure SetItemIndex(const Value: integer); function GetCurrentFolder: string; procedure SetShowMode(const Value: boolean); function GetFolderIndex: integer; procedure SetFolderIndex(const Value: integer); procedure ChangeFolder(newdir:string); overload; procedure ChangeFolder; overload; function GetFolderCount: integer; function GetFolders(i: integer): string; function NextFolder: boolean; function PreviousFolder: boolean; procedure StartShow; procedure StopShow; procedure SetCurrentCaption(const Value: string); procedure SetFullScreenMode(const Value:boolean); function GetFullScreenMode: boolean; procedure EditPrint; procedure SetShowHtml(const Value: boolean); function GetShowHtml: boolean; function GetHelpMode: boolean; procedure SetHelpMode(const Value: boolean); function GetCurrentTitle: string; procedure SaveTitle; procedure SetCurrentTitle(const Value: string); function GetSmallerMode: boolean; procedure SetSmallerMode(const Value: boolean); procedure SetShowSmall(const Value: boolean); function GetSmallerDir: string; function GetCurrentFolderObj: TFolder; procedure ShowInfo(FileName: string); procedure ShowCurrentInfo; procedure MakeSmallerPictures; procedure MakeThumbs; function GetPanels(i: TStatusBarIndex): string; procedure SetPanels(i: TStatusBarIndex; const Value: string); procedure UpdateZoomFactor(Sender: TObject); procedure UpdateSCale(Sender: TObject); procedure SetSmallerDir(Value: string); procedure SetFasterLoad; procedure SetShowHtmlPermanent(const Value: boolean); procedure ShowThumbs; procedure ThumbClicked(Sender: TObject); procedure RefreshThumbs(ReShow:boolean = false); procedure PauseShow; function GetShowGoing: boolean; function GetZoomPictureVisible: boolean; procedure SetZoomPictureVisible(const Value: boolean); function GetThumbsVisible: boolean; procedure ClearShortCuts; procedure SetShortCuts; procedure PreparePanelThumbs(changeParent: boolean); procedure FileNameToClipboard; function GetCurrentFileName: string; function DeleteItem(i: integer): boolean; procedure DeleteFile(trash:string); public property Count : integer read GetCount; property ItemIndex : integer read GetItemIndex write SetItemIndex; property Items[i:integer]:string read GetItems; property Names[i:integer]:string read GetNames; property CurrentFileName : string read GetCurrentFileName; property Sizes[i:integer]:string read GetSizes; property Exts[i:integer]:string read GetExts; property ZoomFactor : double read GetZoomFactor write SetZoomFactor; property CurrentFolder : string read GetCurrentFolder; property CurrentTitle : string read GetCurrentTitle write SetCurrentTitle; property FolderIndex : integer read GetFolderIndex write SetFolderIndex; property FolderCount : integer read GetFolderCount; property Folders[i:integer]:string read GetFolders; property ShowMode : boolean read FShowMode write SetShowMode; property CurrentCaption : string read FCurrentCaption write SetCurrentCaption; property FullScreenMode : boolean read GetFullScreenMode write SetFullScreenMode; property ShowMakeHtml : boolean read GetShowHtml write SetShowHtml; property ShowMakeHtmlPermanent : boolean write SetShowHtmlPermanent; property HelpMode : boolean read GetHelpMode write SetHelpMode; property SmallerMode : boolean read GetSmallerMode write SetSmallerMode; property ShowSmall : boolean read FShowSmall write SetShowSmall; property SmallerDir : string read GetSmallerDir write SetSmallerDir; property CurrentFolderObj : TFolder read GetCurrentFolderObj; property Panels[i:TStatusBarIndex]:string read GetPanels write SetPanels; property ShowGoing : boolean read GetShowGoing; property ZoomPictureVisible : boolean read GetZoomPictureVisible write SetZoomPictureVisible; property ThumbsVisible : boolean read GetThumbsVisible; end; var FormVlThumbs: TFormVlThumbs; implementation uses RecurseDir,jpeg, AboutVlThumbsForm, ShellApi, Clipbrd; {$R *.dfm} const THUMBSINI = 'vlthumbs.ini'; procedure TFormVlThumbs.CopyFile(nf,nt:string;app:boolean); var ff,ft : TextFile; s: string; begin AssignFile(ff,nf); AssignFile(ft,nt); try Reset(ff); except ShowMessage('Can not open file: ' + nf); exit; end; try if ( app ) then Append(ft) else Rewrite(ft); except CloseFile(ff); exit; end; try while ( not eof(ff) ) do begin Readln(ff,s); writeln(ft,macros.Change(s)); end; finally CloseFile(ff); CloseFile(ft); end; end; procedure TFormVlThumbs.SetCurrent(i:integer); var n,p : integer; begin n := i+1; if ( n >= Count ) then n := 0; p := i-1; if ( p < 0 ) then p := Count - 1; macros.Add('#NAME#',Names[i]); macros.Add('#EXT#',Exts[i]); macros.Add('#SIZE#',Sizes[i]); macros.Add('#PREV#',Names[p]); macros.Add('#NEXT#',Names[n]); macros.Add('#EXPLANATION#',''); macros.Add('#FOLDER#',ListBoxFolders.Hint); end; procedure TFormVlThumbs.RunHtml; var htmlpath,expath,thumbspath:string; i:integer; begin htmlpath := SmallerDir + '\' + options.EditHTMLPath.AsString; thumbspath := options.EditThumbsPath.AsString; expath := options.TemplateDir + '\' + options.EditSkin.AsString; try MkDir(htmlpath); except end; // try MkDir(thumbspath); except end; if ( Count = 0 ) then exit; macros.Add('#TITLE#',EditTitle.AsString); macros.Add('#FIRST#',Names[0]); macros.Add('#LAST#',Names[Count-1]); SetCurrent(0); CopyFile(expath+'\eindex.html',SmallerDir + '\index.html',false); CopyFile(expath+'\thumbsbeg.html',htmlpath+'\thumbs.html',false); for i:=0 to Count-1 do begin SetCurrent(i); CopyFile(expath+'\thumbsmid.html',htmlpath+'\thumbs.html',true); CopyFile(expath+'\pic.html',htmlpath+'\'+names[i]+'.html',false); end; CopyFile(expath+'\thumbsend.html',htmlpath+'\thumbs.html',true); end; procedure TFormVlThumbs.ButtonRunClick(Sender: TObject); begin RunHtml; end; procedure FillStrings(name:string;var cont:boolean;obj:TObject); var st : TStrings; ext : string; oldname : string; begin st := TStrings(obj); ext := ExtractFileExt(name); if ( ext = '.JPG' ) then begin oldname := name; name := ChangeFileExt(name,'.jpg'); RenameFile(oldname,name); end; st.Add(ExtractFileName(name)); end; procedure FillFolderStrings(name:string;var cont:boolean;obj:TObject); var st : TStrings; s : string; fol : TFolder; begin s := ExtractFileName(name); // if ( s = '.' ) then exit; st := TStrings(obj); fol := TFolder.Create(name,THUMBSINI); st.AddObject(fol.Title,fol); end; function FolderCompare(List: TStringList; Index1, Index2: Integer): Integer; var fol1,fol2 : TFolder; begin fol1 := TFolder(List.Objects[Index1]); fol2 := TFolder(List.Objects[Index2]); Result := AnsiCompareFileName(fol1.Name,fol2.Name); end; function FileCompare(List: TStringList; Index1, Index2: Integer): Integer; begin Result := AnsiCompareFileName(List[Index1],List[Index2]); end; procedure TFormVlThumbs.ScanFolders(dir:string); var i:integer; st : TStringList; begin st := TStringList.Create; for i:=0 to ListBoxFolders.Count-1 do ListBoxFolders.Items.Objects[i].Free; ListBoxFolders.Clear; ScanFiles(dir,'*.',FillFolderStrings,st); st.CustomSort(FolderCompare); ListBoxFolders.Items := st; st.Free; ListBoxFolders.ItemIndex := 0; end; procedure TFormVlThumbs.ScanFolders; begin ScanFolders(picturedir); end; procedure TFormVlThumbs.ScanDir(dir:string); var st : TStringList; begin st := TStringList.Create; ListBoxFiles.Clear; ScanFiles(dir,'*.jpg',FillStrings,st); st.CustomSort(FileCompare); ListBoxFiles.Items := st; st.Free; end; procedure TFormVlThumbs.ScanDir; begin ScanDir(picturedir); end; procedure TFormVlThumbs.SetFasterLoad; begin if ( Assigned(ZoomPicture) ) then begin ZoomPicture.FasterLoad := ActionFasterLoad.Checked; ShowPicture; end; if ( ActionFasterLoad.Checked ) then Panels[ixFast] := 'Faster' else Panels[ixFast] := 'Quality'; end; procedure TFormVlThumbs.FormCreate(Sender: TObject); procedure HideFolder(i:integer); begin ListBoxFolders.Items.Objects[i].Free; ListBoxFolders.Items.Delete(i); end; var s : string; i:integer; begin parameters := TParameters.Create(self); options := TFormOptions.Create(self); s := options.LastDir.AsString; if ( parameters['/show'] = '' ) and ( parameters['/dir'] = '' ) then begin try ChDir(s); except end; GetDir(0,originaldir); end; ZoomPicture := TZoomPicture.Create(self); ZoomPicture.ZoomFactorChange := UpdateZoomFactor; ZoomPicture.ScaleChange := UpdateScale; ZoomPicture.Parent := PanelLeft; ZoomPicture.Align := alClient; ZoomPicture.Color := 0; ZoomPicture.CanGetFocus := true; PanelThumbs := TThumbsPanel.Create(self); PanelThumbs.Parent := TabThumbs; PanelThumbs.Align := alClient; PanelThumbs.OnClick := ThumbClicked; RefreshThumbs(true); SplitterThumbs := TkSplitter.Create(self); SplitterThumbs.Name := 'SplitterThumbs'; SplitterThumbs.Parent := PanelLeft; SplitterThumbs.Width := 2; SplitterThumbs.Top := 250; SplitterThumbs.Left := 250; SplitterThumbs.Ini.AutoSave := false; PreparePanelThumbs(false); SetFasterLoad; UpdateScale(ZoomPicture); macros := TkMacroVarList.Create; try MemoHelp.Lines.LoadFromFile(options.ProgramPath+'\help.txt'); except end; if ( not parameters.Bool['/nohelp'] ) then HelpMode := true; s := parameters['/dir']; if ( s <> '' ) then begin ChDir(s); originaldir := s; ShowMode := false; end; s := parameters['/show']; if ( s <> '' ) then begin ChDir(s); originaldir := s; end; ShowMode := parameters.Bool['/show']; SmallerMode := parameters.Bool['/smallmode']; ShowMakeHtmlPermanent := parameters.Bool['/html']; picturedir := GetCurrentDir; ScanFolders; ScanDir; if ( ShowMode ) then begin while ( FolderCount > 0 ) and ( Pos('.',Folders[0]) > 0 ) do HideFolder(0); i := 0; while ( i < FolderCount ) do begin if ( Pos('.',Folders[i]) > 0 ) then begin HideFolder(i); continue; end; if ( Folders[i] = options.SmallerDir ) then begin HideFolder(i); continue; end; if ( Folders[i] = options.EditThumbsPath.AsString ) then begin HideFolder(i); continue; end; Inc(i); end; FolderIndex := 0; end; if ( parameters.Bool['/start'] ) then StartShow; end; function TFormVlThumbs.GetPanels(i: TStatusBarIndex): string; begin Result := StatusBar.Panels[Ord(i)].Text; end; procedure TFormVlThumbs.SetPanels(i: TStatusBarIndex; const Value: string); begin StatusBar.Panels[Ord(i)].Text := Value; end; procedure TFormVlThumbs.ShowCurrentInfo; begin if ( not Assigned(FormExif) ) then exit; MemoInfo.Clear; FormExif.FillInfo(MemoInfo.Lines); Panels[ixInfo] := FormExif.Values[$9003] + ', ' + FormExif.Values[$920A] + ' mm, ' + FormExif.Values[$829A] + ', f' + FormExif.Values[$9202]; end; procedure TFormVlThumbs.ShowInfo(FileName:string); begin if ( Assigned(FormExif) ) then FormExif.Free; FormExif := TFormExif.Create2(self,FileName); ShowCurrentInfo; end; procedure TFormVlThumbs.ShowPicture(fullscale:boolean); var t1,t2 : TDateTime; begin ActionFullScreen.Enabled := (ItemIndex >= 0); if ( ItemIndex < 0 ) then exit; HelpMode := false; ShowInfo(Items[ItemIndex]); PanelThumbs.ItemIndex := ItemIndex; if ( FullScreenMode ) then SetShortCuts; t1 := Time; if ( ShowSmall ) and ( not fullscale ) then begin try ZoomPicture.Scale := jsFullSize; ZoomPicture.FileName := SmallerDir + '\' + Items[ItemIndex] except ShowSmall := false; // follows recursive call to ShowPicture exit; end; end else begin if ( fullscale ) then ZoomPicture.Scale := jsFullSize else ZoomPicture.Scale := TJpegScale(options.EditScaleComboBoxIni.ItemIndex); FShowSmall := false; ZoomPicture.FileName := Items[ItemIndex]; end; if ( ShowSmall ) then Panels[ixSmall] := SmallerDir else Panels[ixSmall] := 'Normal'; t2 := time; Panels[ixTime] := Format('%3.2f s',[(t2-t1)*3600*24]); CurrentCaption := CurrentCaption; SetCurrent(ItemIndex); end; procedure TFormVlThumbs.ListBoxFilesClick(Sender: TObject); begin ShowSmall := SmallerMode; end; procedure TFormVlThumbs.FormDestroy(Sender: TObject); begin macros.Free; end; function TFormVlThumbs.GetCount: integer; begin Result := ListBoxFiles.Count; end; function TFormVlThumbs.GetItems(i: integer): string; begin Result := ''; if ( i < 0 ) or ( i >= Count ) then exit; Result := ListBoxFiles.Items[i]; end; function TFormVlThumbs.DeleteItem(i: integer): boolean; begin Result := false; if ( i < 0 ) or ( i >= Count ) then exit; Result := true; ListBoxFiles.Items.Delete(i); end; function TFormVlThumbs.GetNames(i: integer): string; var p:integer; begin Result := ExtractFileName(Items[i]); p := LastDelimiter('.',Result); Delete(Result,p,100); end; function TFormVlThumbs.GetSizes(i: integer): string; var f:file of byte; size : integer; begin size := 0; Result := ''; AssignFile(f,SmallerDir+'\'+Items[i]); try Reset(f); try size := FileSize(f); finally CloseFile(f); end; except end; if ( size >= 1024 ) then begin size := size div 1024; Result := 'kB'; end; if ( size >= 1024 ) then begin size := size div 1024; Result := 'MB'; end; Result := IntToStr(size) + ' ' + Result; end; function TFormVlThumbs.GetExts(i: integer): string; var p:integer; begin Result := ExtractFileExt(Items[i]); p := Pos('.',Result); if ( p > 0 ) then Delete(Result,p,1); end; procedure TFormVlThumbs.FormShow(Sender: TObject); var title : string; fol : TFolder; begin title := parameters.Item['/title']; if ( title = '' ) then exit; fol := TFolder.Create('.',THUMBSINI); if ( title <> '.' ) then fol.Title := Title; EditTitle.AsString := fol.Title; RunHtml; fol.Free; Close; end; function TFormVlThumbs.Next : boolean; var i:integer; begin Result := false; i := ItemIndex; // if ( i >= 2 ) then begin if ( i >= Count - 1 ) then begin if ( not ShowMode ) then exit; i := -1; if ( not NextFolder ) then exit; end; ItemIndex := i + 1; Result := true; end; function TFormVlThumbs.Previous : boolean; var i:integer; begin Result := false; i := ItemIndex; // if ( i >= 2 ) then begin if ( i <= 0 ) then begin if ( not ShowMode ) then exit; if ( not PreviousFolder ) then exit; i := Count; end; ItemIndex := i - 1; Result := true; end; procedure TFormVlThumbs.TimerShowTimer(Sender: TObject); begin TimerShow.Interval := Round(options.EditIntervallEditDouble.Value * 1000+1); if ( not Next ) then StopShow; end; function TFormVlThumbs.GetFullScreenMode: boolean; begin Result := ActionFullScreen.Checked; end; procedure TFormVlThumbs.ClearShortCuts; begin ActionNextPicture.SecondaryShortCuts.Clear; ActionPreviousPicture.SecondaryShortCuts.Clear; end; procedure TFormVlThumbs.SetShortCuts; begin if ( ZoomPicture.Parent <> PanelThumbs.Parent ) then begin ActionNextPicture.SecondaryShortCuts.Add('Down'); ActionPreviousPicture.SecondaryShortCuts.Add('Up'); ActionNextPicture.SecondaryShortCuts.Add('Right'); ActionPreviousPicture.SecondaryShortCuts.Add('Left'); ActionNextPicture.SecondaryShortCuts.Add('Space'); end else PanelThumbs.SetActive; end; procedure TFormVlThumbs.SetFullScreenMode(const Value : boolean); begin if ( Value ) then begin HelpMode := false; Menu := nil; PanelRight.Visible := false; kSplitterFiles.Visible := false; WindowState := wsMaximized; PanelLeft.BevelOuter := bvNone; PanelLeft.BevelInner := bvNone; BorderStyle := bsNone; ZoomPicture.BevelInner := bvNone; ZoomPicture.BevelOuter := bvNone; ZoomPicture.ImageBorder := bsNone; StatusBar.Visible := false; ShowMakeHtml := false; SetShortCuts; // PanelHeading.Visible := false; end else begin ZoomPicture.ImageBorder := bsSingle; BorderStyle := bsSizeable; kSplitterFiles.Visible := true; PanelRight.Visible := true; PanelRight.Left := 10000; Menu := MainMenu1; // PanelHeading.Visible := ActionShowMakeHTML.Checked; StatusBar.Visible := ActionViewStatusbar.Checked; ClearShortCuts; ShowMakeHtml := ActionShowMakeHTML.Checked; end; ActionFullScreen.Checked := Value; end; procedure TFormVlThumbs.StartShow; begin FullScreenMode := true; CurrentCaption := 'vlthumbs - Slide Show (Press ESC to stop)'; if ( ItemIndex < 0 ) then ItemIndex := 0; TimerShow.Interval := Round(options.EditIntervallEditDouble.Value * 1000+1); TimerShow.Enabled := true; PanelThumbs.Visible := false; end; procedure TFormVlThumbs.StopShow; begin FullScreenMode := false; CurrentCaption := 'vlthumbs'; PauseShow; end; procedure TFormVlThumbs.PauseShow; begin TimerShow.Enabled := false; PanelThumbs.Visible := true; end; function TFormVlThumbs.GetShowGoing: boolean; begin Result := TimerShow.Enabled; end; procedure TFormVlThumbs.UpdateScale(Sender:TObject); begin Panels[ixScale] := ZoomPicture.RealScaleSt; end; procedure TFormVlThumbs.UpdateZoomFactor(Sender:TObject); begin Panels[ixZoom] := Format('%1.0f %%',[ZoomFactor*100]); end; procedure TFormVlThumbs.SetZoomFactor(const Value: double); var old,newzoom : double; begin HelpMode := false; newzoom := Value; if ( ShowSmall ) and ( value >= 1 ) then begin old := ZoomFactor; ShowPicture(true); newzoom := ZoomFactor/old; end; ZoomPicture.RealZoomFactor := newzoom; end; function TFormVlThumbs.GetZoomFactor: double; begin Result := ZoomPicture.RealZoomFactor; end; function TFormVlThumbs.GetItemIndex: integer; begin Result := ListBoxFiles.ItemIndex; end; procedure TFormVlThumbs.SetItemIndex(const Value: integer); begin ListBoxFiles.ItemIndex := Value; ShowSmall := SmallerMode; end; function TFormVlThumbs.GetCurrentFolder: string; var fol : TFolder; begin Result := '.'; if ( ListBoxFolders.ItemIndex < 0 ) then exit; fol := TFolder(ListBoxFolders.Items.Objects[ListBoxFolders.ItemIndex]); Result := fol.Name; end; function TFormVlThumbs.GetCurrentTitle: string; var fol : TFolder; begin Result := ''; if ( ListBoxFolders.ItemIndex < 0 ) then exit; fol := TFolder(ListBoxFolders.Items.Objects[ListBoxFolders.ItemIndex]); Result := fol.Title; end; procedure TFormVlThumbs.SetCurrentTitle(const Value: string); var fol : TFolder; begin if ( ListBoxFolders.ItemIndex < 0 ) then exit; fol := TFolder(ListBoxFolders.Items.Objects[ListBoxFolders.ItemIndex]); fol.Title := Value; ListBoxFolders.Items[ListBoxFolders.ItemIndex] := value; end; procedure TFormVlThumbs.SaveTitle; begin CurrentTitle := EditTitle.AsString; end; procedure TFormVlThumbs.ChangeFolder(newdir:string); begin ChDir(newdir); options.LastDir.AsString := newdir; EditTitle.AsString := CurrentTitle; ListBoxFolders.Hint := CurrentFolder; if ( not ShowMode ) then begin picturedir := GetCurrentDir; ScanFolders(picturedir); end; ScanDir(GetCurrentDir); ListBoxFiles.ItemIndex := -1; CurrentCaption := CurrentCaption; RefreshThumbs(true); // if ( ShowMode ) then Next; end; procedure TFormVlThumbs.ChangeFolder; begin ChangeFolder(picturedir+'\'+CurrentFolder); end; procedure TFormVlThumbs.ListBoxFoldersClick(Sender: TObject); begin ChangeFolder; end; procedure TFormVlThumbs.SetShowMode(const Value: boolean); begin FShowMode := Value; ShowMakeHtml := false; ActionShowMode.Checked := value; end; function TFormVlThumbs.GetFolderIndex: integer; begin Result := ListBoxFolders.ItemIndex; end; procedure TFormVlThumbs.SetFolderIndex(const Value: integer); begin ListBoxFolders.ItemIndex := Value; ChangeFolder; end; function TFormVlThumbs.NextFolder:boolean; begin Result := false; if ( FolderIndex >= FolderCount-1 ) then exit; Result := true; FolderIndex := FolderIndex + 1; end; function TFormVlThumbs.PreviousFolder:boolean; begin Result := false; if ( FolderIndex <= 0 ) then exit; Result := true; FolderIndex := FolderIndex - 1; end; function TFormVlThumbs.GetFolderCount: integer; begin Result := ListBoxFolders.Items.Count; end; function TFormVlThumbs.GetFolders(i: integer): string; begin Result := ''; if ( i < 0 ) or ( i > FolderCount ) then exit; Result := ListBoxFolders.Items[i]; end; procedure TFormVlThumbs.SetCurrentCaption(const Value: string); begin FCurrentCaption := Value; if ( ItemIndex < 0 ) then Caption := CurrentCaption + Format('- [%s :] (%d/%d)',[CurrentTitle,0,Count]) else if ShowMode then Caption := CurrentCaption + Format(' - [%s : %s] (Folder: %d/%d Picture: %d/%d)',[ CurrentTitle, Names[ItemIndex], FolderIndex+1,FolderCount, ItemIndex+1,Count]) else Caption := CurrentCaption + Format('- [%s : %s] (%d/%d)',[ CurrentTitle,Names[ItemIndex],ItemIndex+1,Count]) end; procedure TFormVlThumbs.EditPrint; var s:string; begin s := options.EditProgram.AsString; s := macros.Change(s); if ( WinExec(PChar(s),SW_SHOW) > 31 ) then exit; options.ShowModal; end; procedure TFormVlThumbs.SetShowHtml(const Value: boolean); begin ActionMakeHtml.Visible := Value; PanelHeading.Visible := Value; ButtonMakeHtml.Left := 10000; ButtonShowHtml.Left := 11000; // ActionShowMakeHTML.Checked := Value; if ( Value ) then ActionNextPicture.SecondaryShortCuts.Clear else ActionNextPicture.SecondaryShortCuts.Add('Space'); end; procedure TFormVlThumbs.SetShowHtmlPermanent(const Value: boolean); begin ActionShowMakeHTML.Checked := Value; ShowMakeHtml := Value; end; function TFormVlThumbs.GetShowHtml: boolean; begin Result := ActionMakeHtml.Visible; end; function TFormVlThumbs.GetHelpMode: boolean; begin Result := PageControl.Visible and (PageControl.ActivePage = TabHelp); end; function TFormVlThumbs.GetZoomPictureVisible: boolean; begin Result := ZoomPicture.Visible; end; procedure TFormVlThumbs.PreparePanelThumbs(changeParent : boolean); var ps : integer; begin ps := options.EditThumbsPosComboBoxIni.ItemIndex; if ( ps = 0 ) then begin //if ( PanelThumbs.Parent = ZoomPicture.Parent ) then PanelThumbs.Parent := TabThumbs; SplitterThumbs.Visible := false; exit; end; //if ( PanelThumbs.Parent = ZoomPicture.Parent ) then exit; if ( ChangeParent ) then begin SplitterThumbs.Visible := true; PanelThumbs.Parent := ZoomPicture.Parent; end; case ps of 1: begin PanelThumbs.Align := alTop; PanelThumbs.Rows := 1; PanelThumbs.Height := 150; SplitterThumbs.Align := alTop; end; 2: begin PanelThumbs.Align := alBottom; PanelThumbs.Rows := 1; PanelThumbs.Height := 150; SplitterThumbs.Align := alBottom; end; 3: begin PanelThumbs.Align := alLeft; PanelThumbs.Rows := 1000; PanelThumbs.Width := 150; SplitterThumbs.Align := alLeft; end; 4: begin PanelThumbs.Align := alRight; PanelThumbs.Rows := 1000; PanelThumbs.Width := 150; SplitterThumbs.Align := alRight; end; end; SplitterThumbs.Top := 250; SplitterThumbs.Left := 250; // if ( changeParent ) then SplitterThumbs.Ini.Restore else SplitterThumbs.Ini.Load; end; procedure TFormVlThumbs.SetZoomPictureVisible(const Value: boolean); begin ZoomPicture.Visible := Value; if ( Value ) then begin PreparePanelThumbs(true); end else begin PanelThumbs.Parent := TabThumbs; PanelThumbs.Align := alClient; PanelThumbs.Rows := 0; end; end; procedure TFormVlThumbs.SetHelpMode(const Value: boolean); begin PageControl.Visible := value; ZoomPictureVisible := not Value; if ( Value ) then begin StopShow; PageControl.ActivePage := TabHelp; end; end; procedure TFormVlThumbs.ThumbClicked(Sender:TObject); begin if ( not ( Sender is TZoomPicture ) ) then exit; ItemIndex := TZoomPicture(Sender).Tag; end; procedure TFormVlThumbs.RefreshThumbs(ReShow:boolean); begin PanelThumbs.BasicThumbsDir := options.EditThumbsPath.AsString; PanelThumbs.ThumbSize := Round(options.EditThumbSizeEditDouble.Value); // PanelThumbs.Rows := Round(options.EditThumbRowsEditDouble.Value); if ( ReShow ) then PanelThumbs.Names := ListBoxFiles.Items; end; function TFormVlThumbs.GetThumbsVisible: boolean; begin Result := ( PageControl.ActivePage = TabThumbs ) and ( not ZoomPictureVisible ); end; procedure TFormVlThumbs.ShowThumbs; begin ZoomPictureVisible := false; PageControl.Visible := true; PageControl.ActivePage := TabThumbs; PanelThumbs.SetActive; ClearShortCuts; end; (* procedure TFormVlThumbs.SetThumbsMode(const Value: boolean); begin PanelHelp.Visible := Value; ZoomPictureVisible := not Value; end; *) function TFormVlThumbs.GetSmallerMode: boolean; begin Result := ActionSmallerMode.Checked; end; procedure TFormVlThumbs.SetSmallerMode(const Value: boolean); begin ActionSmallerMode.Checked := Value; ShowSmall := SmallerMode; end; procedure TFormVlThumbs.SetShowSmall(const Value: boolean); begin FShowSmall := Value; ShowPicture; end; procedure TFormVlThumbs.FormCloseQuery(Sender: TObject; var CanClose: Boolean); begin FullScreenMode := false; end; function TFormVlThumbs.GetSmallerDir: string; var fol : TFolder; begin Result := macros.Change(options.EditSmallerDir.AsString); fol := CurrentFolderObj; if ( fol = nil ) or ( fol.SmallerDir = '' ) then exit; Result := fol.SmallerDir; end; procedure TFormVlThumbs.SetSmallerDir(Value:string); var fol : TFolder; begin fol := CurrentFolderObj; if ( fol = nil ) then exit; fol.SmallerDir := Value; end; function TFormVlThumbs.GetCurrentFolderObj: TFolder; begin Result := nil; if ( FolderIndex < 0 ) then exit; Result := TFolder(ListBoxFolders.Items.Objects[FolderIndex]); end; procedure TFormVlThumbs.MakeThumbs; var s : string; begin ForceDirectories('.\'+options.EditThumbsPath.AsString); s := options.EditRunThumbs.AsString; s := macros.Change(s); if ( WinExec(PChar(s),SW_SHOW) > 31 ) then exit; options.ShowModal; end; procedure TFormVlThumbs.MakeSmallerPictures; var s,smaller : string; begin smaller := SmallerDir; ForceDirectories('.\'+smaller); s := options.EditRunSmallerPictures.AsString; s := macros.Change(s); if ( WinExec(PChar(s),SW_SHOW) > 31 ) then begin SmallerDir := smaller; exit; end; options.ShowModal; end; procedure TFormVlThumbs.FileNameToClipboard; begin Clipboard.AsText := GetCurrentDir + '\' + Items[ItemIndex]; end; //============================================================================== // ACTIONS //============================================================================== procedure TFormVlThumbs.ActionNextPictureExecute(Sender: TObject); begin if ( ShowGoing ) then begin PauseShow; Previous; end else Next; end; procedure TFormVlThumbs.ActionShowExecute(Sender: TObject); begin StartShow; end; procedure TFormVlThumbs.ActionShowInfoExecute(Sender: TObject); begin if ( Assigned(FormExif) ) then FormExif.ShowModal; ShowCurrentInfo; end; procedure TFormVlThumbs.ActionZoomWidthExecute(Sender: TObject); begin PauseShow; if ( ShowSmall ) then begin ShowPicture(true); exit; end; if ZoomPicture.RealScale <> jsFullSize then ZoomPicture.RealScale := jsFullSize; ZoomPicture.ReSizePicture; end; procedure TFormVlThumbs.ActionViewEXIFExecute(Sender: TObject); begin MemoInfo.Visible := ActionViewEXIF.Checked; MemoInfo.Top := 1000; end; procedure TFormVlThumbs.ActionViewStatusbarExecute(Sender: TObject); begin StatusBar.Visible := ActionViewStatusbar.Checked; end; procedure TFormVlThumbs.ActionMakeThumbsExecute(Sender: TObject); begin MakeThumbs; RefreshThumbs(true); ShowThumbs; end; procedure TFormVlThumbs.ActionMakeSmallerPicturesExecute(Sender: TObject); begin MakeSmallerPictures; end; procedure TFormVlThumbs.ActionZoomPlusExecute(Sender: TObject); begin PauseShow; ZoomFactor := ZoomFactor*1.4; end; procedure TFormVlThumbs.ActionZoomMiinusExecute(Sender: TObject); begin PauseShow; ZoomFactor := ZoomFactor/1.4; end; procedure TFormVlThumbs.ActionZoom100Execute(Sender: TObject); begin PauseShow; if ( ShowSmall ) then ShowPicture(true); ZoomFactor := 1; end; procedure TFormVlThumbs.About1Click(Sender: TObject); begin FormAboutVlThumbs.ShowModal; end; procedure TFormVlThumbs.ActionExitExecute(Sender: TObject); begin Close; end; procedure TFormVlThumbs.ActionPropertiesExecute(Sender: TObject); begin PauseShow; options.ShowModal; RefreshThumbs; ZoomPictureVisible := ZoomPictureVisible; end; procedure TFormVlThumbs.ActionShowHtmlExecute(Sender: TObject); var s : string; begin // s := 'start.exe "" s := '"' + GetCurrentDir + '\' + SmallerDir+'\index.html"'; ShellExecute(0,'open',PChar(s),nil,nil,0); end; procedure TFormVlThumbs.ActionSaveTitleExecute(Sender: TObject); begin SaveTitle; end; procedure TFormVlThumbs.ActionSmallerModeExecute(Sender: TObject); begin SmallerMode := not SmallerMode; end; procedure TFormVlThumbs.ActionShowMakeHTMLExecute(Sender: TObject); begin ShowMakeHtml := ActionShowMakeHTML.Checked; end; procedure TFormVlThumbs.ActionHelpExecute(Sender: TObject); begin PauseShow; HelpMode := not HelpMode; end; procedure TFormVlThumbs.ActionFullScreenExecute(Sender: TObject); begin FullScreenMode := not FullScreenMode; end; procedure TFormVlThumbs.ActionPreviousPictureExecute(Sender: TObject); begin PauseShow; Previous; end; procedure TFormVlThumbs.ActionEditPrintExecute(Sender: TObject); begin PauseShow; EditPrint; end; procedure TFormVlThumbs.ActionMakeHtmlExecute(Sender: TObject); begin RunHtml; end; procedure TFormVlThumbs.ActionStopShowExecute(Sender: TObject); begin StopShow; end; procedure TFormVlThumbs.ActionFasterLoadExecute(Sender: TObject); begin SetFasterLoad; end; procedure TFormVlThumbs.ActionScaleExecute(Sender: TObject); var i:integer; begin i := options.EditScaleComboBoxIni.ItemIndex; Inc(i); if ( i >= options.EditScaleComboBoxIni.Items.Count ) then i := 0; options.EditScaleComboBoxIni.ItemIndex := i; ShowPicture; end; procedure TFormVlThumbs.ActionViewThumbsExecute(Sender: TObject); begin PauseShow; if ( ThumbsVisible ) then ItemIndex := PanelThumbs.ItemIndex else ShowThumbs; end; procedure TFormVlThumbs.ActionLongerHelpExecute(Sender: TObject); var s : string; begin s := '"' + options.ProgramPath + '\doc\vlthumbs.htm"'; ShellExecute(0,'open',PChar(s),nil,nil,0); end; procedure TFormVlThumbs.ActionChangeDirectoryExecute(Sender: TObject); var newname : string; begin OpenPictureDialog1.InitialDir := GetCurrentDir; OpenPictureDialog1.FileName := 'a.a'; if ( not OpenPictureDialog1.Execute ) then exit; newname := OpenPictureDialog1.FileName; ShowMode := false; ChangeFolder(ExtractFilePath(newname)); end; procedure TFormVlThumbs.ActionShowModeExecute(Sender: TObject); begin ShowMode := not ShowMode; end; procedure TFormVlThumbs.ActionEditCopyExecute(Sender: TObject); begin FileNameToClipboard; end; procedure TFormVlThumbs.DeleteFile(trash:string); var mask,dir,tofolder,name,fromname,toname,text : string; folder : TFolder; i :integer; begin name := CurrentFileName; if ( name = '' ) then exit; if ( options.CBAskDelete.Checked or ( trash='' ) ) then begin text := 'Move file to trash: '; if ( trash='' ) then text := 'Delete file permanent: '; if ( MessageDlg(text + name, mtConfirmation, [mbYes,mbNo],0) = mrNo ) then exit; end; tofolder := macros.ChangeAll(trash); ForceDirectories(tofolder); toname := tofolder + name; folder := CurrentFolderObj; dir := folder.Path; fromname := dir + '\' + name; i := ItemIndex; mask := Names[i]; // JOS SELITYS, MUISTA SIIRTÄÄ MYÖS SELITYS!!! if ( trash='' ) then begin SysUtils.DeleteFile(fromname); end else if ( not MoveFile(PChar(fromname),PChar(toname)) ) then begin ShowMessage(Format('File %s already exists! Delete first.',[toname])); exit; end; DeleteItem(i); ItemIndex := i; DeleteFilesRecurse(dir,mask+'.*'); end; procedure TFormVlThumbs.ActionDeleteExecute(Sender: TObject); begin DeleteFile(options.EditTrashDir.AsString); end; function TFormVlThumbs.GetCurrentFileName: string; var i:integer; begin i := ItemIndex; Result := ''; if ( i < 0 ) then exit; Result := Names[i]+'.'+Exts[i]; end; procedure TFormVlThumbs.ActionDeletePermanentExecute(Sender: TObject); begin DeleteFile(options.EditTrashDir2.AsString); end; end.