unit editmenuform; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, bitmapactionbutton,empripmain, ExtCtrls, StdCtrls,albumartist,mydialog,artworkform,jpeg, TransparentPanel,main,cdartworkform,id3; type Teditmenu = class(TForm) title: TLabel; pnl: TTransparentPanel; gotitle: TBitmapActionButton; gotracks: TBitmapActionButton; goartworkweb: TBitmapActionButton; goartworkcd: TBitmapActionButton; godelete: TBitmapActionButton; OK: TBitmapActionButton; thumb: TImage; gotracksauto: TBitmapActionButton; procedure FormCreate(Sender: TObject); procedure cancelClick(Sender: TObject); procedure OKClick(Sender: TObject); procedure gotitleClick(Sender: TObject); procedure gotracksClick(Sender: TObject); procedure goartworkwebClick(Sender: TObject); procedure goartworkcdClick(Sender: TObject); procedure godeleteClick(Sender: TObject); procedure FormPaint(Sender: TObject); procedure FormResize(Sender: TObject); procedure FormActivate(Sender: TObject); procedure gotracksautoClick(Sender: TObject); private { Private declarations } public { Public declarations } end; function goeditmenu(al : integer) : Word; var editmenu: Teditmenu; res : word; // albu : string; // arti : string; pth : string; editing : integer; implementation uses global,verifyform,isconnected,loadjpegorbmp, jukeboxform; function goeditmenu(al : integer) : Word; begin res:=0; editing:=al; global.artist:=album[editing].artist; global.title:=album[editing].album; editmenu:=teditmenu.create(nil); editmenu.pnl.sourcebitmap:=ripmain.bg.picture.bitmap; apic:=tbitmap.create; editmenu.showmodal; apic.free; editmenu.free; result:=res; end; {$R *.DFM} procedure Teditmenu.FormCreate(Sender: TObject); begin doublebuffered:=true; title.width:=Width; title.left:=0; sizeform(self,'Edit Album',false); canvas.Brush.style:=bsClear; gotitle.font.size:=aspy(10); gotitle.font.name:=JUKEBOXFONT; gotitle.font.color:=FONTCOL; gotracks.font.size:=gotitle.font.size; gotracks.font.name:=gotitle.font.name; gotracks.font.color:=gotitle.font.color; gotracksauto.font.size:=gotitle.font.size; gotracksauto.font.name:=gotitle.font.name; gotracksauto.font.color:=gotitle.font.color; goartworkweb.font.size:=gotitle.font.size; goartworkweb.font.name:=gotitle.font.name; goartworkweb.font.color:=gotitle.font.color; goartworkcd.font.size:=gotitle.font.size; goartworkcd.font.name:=gotitle.font.name; goartworkcd.font.color:=gotitle.font.color; godelete.font.size:=gotitle.font.size; godelete.font.name:=gotitle.font.name; godelete.font.color:=gotitle.font.color; title.font.size:=gotitle.font.size; title.font.name:=gotitle.font.name; title.font.color:=cllime; ok.font.size:=gotitle.font.size; ok.font.name:=JUKEBOXFONT; ok.font.color:=FONTCOL; pnl.left:=(width div 2) - (pnl.width div 2); color:=clblack; title.caption:=global.artist+' - '+global.title; title.left:=20; title.width:=width-20; end; procedure Teditmenu.cancelClick(Sender: TObject); begin close; die; end; procedure Teditmenu.OKClick(Sender: TObject); begin close; die; end; procedure Teditmenu.gotitleClick(Sender: TObject); var res : integer; frm,too : string; begin visible:=false; spinglobe.stop; res:=getuseralbumtitle(global.title,global.artist); pnl.repaint; if res=mrOk then begin frm:=config.path+'\'+main.album[editing].path; main.album[editing].album:=global.title; main.album[editing].artist:=global.artist; jalbum[editing].album:=global.title; jalbum[editing].artist:=global.artist; mainform.Dalbumlist.Items[editing-1]:=global.artist+' - '+global.title; mainform.albumlist.Items[editing-1]:=global.artist+' - '+global.title; too:=config.path+'\'+main.album[editing].path; if (windows.movefile(pchar(frm),pchar(too))=false) then begin mainform.stopclick(nil); try mainform.MP.close; except end; windows.movefile(pchar(frm),pchar(too)); end; end; title.caption:=global.artist+' - '+global.title; visible:=true; end; procedure Teditmenu.gotracksClick(Sender: TObject); var fl : textfile; pth : string; n : integer; sr : TSearchRec; foundfile : boolean; otc : integer; begin visible:=false; pth:=config.path+'\'+main.album[editing].path; trackscount:=0; otc:=0; try if findfirst(pth+'\track*.mp3',faAnyfile,sr)=0 then begin foundfile:=true; while(foundfile=true) do begin inc(otc); if findnext(sr)<>0 then foundfile:=false; end; end; except; end; findclose(sr); loadtitles(pth); if otc>trackscount then begin setlength(tracks,otc+1); for n:=trackscount to otc do begin tracks[n]:=format('Track %2d',[n+1]); end; end; if trackscount=0 then begin visible:=true; gotracksauto.caption:='No Tracks to Edit'; gotracks.caption:='No Tracks to Edit'; exit; end; spinglobe.stop; doverify(1); assignfile(fl,pth+'\title.dat'); try rewrite(fl); for n:=0 to trackscount-1 do begin writeln(fl,tracks[n]); end; closefile(fl); except end; visible:=true; end; procedure Teditmenu.goartworkwebClick(Sender: TObject); var pth : string; i : tjpegimage; begin if mshand<>0 then begin if closehandle(mshand)<>false then mshand:=0; initmailslot; end; pth:=config.path+'\'+main.album[editing].path; visible:=false; retry:=true; if Checkhost('myjukebox.co.uk')=false then begin while (retry=true) do begin mres:=md('A connection to the internet is needed to find artwork.','Connect to Internet','Go Back','Information Aquision',false); if mres=mrCancel then begin visible:=true; exit; end else begin retry:=true; if mshand<>0 then begin if closehandle(mshand)<>false then mshand:=0; initmailslot; end; if runprogram('rasdialr.exe',0,false)= true then begin ms:=''; while ((ms<>'connected') and (ms<>'exit')) do begin ms:=readmailslot; application.processmessages; end; end; retry:=true; if ms='connected' then retry:=false; end; end; end; if doartwork(1)=mrcancel then begin visible:=true; exit; end; thumb.picture.Assign(apic); jukebox.thumbs.replace(editing-1,apic,editing-1); i:=TJpegImage.Create; i.pixelformat:=jf24bit; i.assign(apic); try i.savetofile(pth+'\title.jpg'); except; md('Error creating image file: '+config.path+albumpath+'\title.jpg','','Cancel','Filing Error',true); end; i.free; visible:=true; end; procedure Teditmenu.goartworkcdClick(Sender: TObject); var jpeg : tjpegimage; pth : string; begin if getcdartwork=mrOk then begin thumb.picture.Assign(apic); jukebox.thumbs.replace(editing-1,apic,editing-1); try pth:=config.path+'\'+main.album[editing].path; jpeg:=tjpegimage.create; jpeg.assign(thumb.picture.bitmap); jpeg.SaveToFile(pth+'\title.jpg'); except end; end; end; procedure Teditmenu.godeleteClick(Sender: TObject); var sr : TSearchRec; foundfile : boolean; pt : string; begin res:=0; pt:=config.path+main.album[editing].path; if md('Delete Entire CD? Are you really sure?','Yes','No','Delete CD',false)=mrOK then begin pnl.repaint; if findfirst(pt+'\*.*',faAnyfile,sr)=0 then begin foundfile:=true; while(foundfile=true) do begin filesetattr(pt+'\'+sr.name,faArchive); if uppercase(mainform.mp.filename)=uppercase(pt+'\'+sr.name) then begin jukebox.panelshapeMouseDown(jukebox.rejectshape2,mbleft,[], 0, 0); application.processmessages; end; if (windows.deletefile(pchar(pt+'\'+sr.name))=false) then begin if (sr.name<>'.') and (sr.name<>'..') then begin jukebox.panelshapeMouseDown(jukebox.rejectshape2,mbleft,[], 0, 0); deletefile(pt+'\'+sr.name) end; end; if findnext(sr)<>0 then foundfile:=false; end; findclose(sr); try chdir('\'); rmdir(pt); except; end; close; deletealbum(editing); die; end; end; end; {procedure Teditmenu.savechanges; var jpeg : TJPEGImage; fl : textfile; n : integer; pt : string; begin jpeg:=tjpegimage.create; jpeg.assign(thumb.picture.bitmap); jpeg.SaveToFile(paramstr(1)+'\title.jpg'); pt:=paramstr(1); windows.movefile(pchar(pt),pchar(config.path+arti+'__'+albu)); end;} procedure Teditmenu.FormPaint(Sender: TObject); begin dobg(self); end; procedure Teditmenu.FormResize(Sender: TObject); begin title.top:=0; pnl.top:=title.top+title.height; pnl.left:=(width div 2) - pnl.width div 2; end; procedure Teditmenu.FormActivate(Sender: TObject); var pth : string; begin pth:=config.path+'\'+main.album[editing].path; loadjpegbmp(pth,apic); thumb.picture.assign(apic); end; procedure Teditmenu.gotracksautoClick(Sender: TObject); var fl : textfile; pth : string; n : integer; sr : TSearchRec; foundfile : boolean; id3 : tid3tag; begin visible:=false; pth:=config.path+'\'+main.album[editing].path; trackscount:=0; try if findfirst(pth+'\track*.mp3',faAnyfile,sr)=0 then begin foundfile:=true; while(foundfile=true) do begin inc(trackscount); setlength(tracks,trackscount); id3:=readtag(pth+'\'+sr.name); if id3.track<>'' then tracks[trackscount-1]:=id3.track else tracks[trackscount-1]:='Unknown Track'; if findnext(sr)<>0 then foundfile:=false; end; end; except; end; findclose(sr); if trackscount=0 then begin visible:=true; gotracksauto.caption:='No Tracks to Edit'; gotracks.caption:='No Tracks to Edit'; exit; end; spinglobe.stop; doverify(1); assignfile(fl,pth+'\title.dat'); try rewrite(fl); for n:=0 to trackscount-1 do begin writeln(fl,tracks[n]); end; closefile(fl); except end; visible:=true; end; end.