Index » Empathy Jukebox : Blob 201cf8 / infoform.pas
unit infoform;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, ExtCtrls,loadjpegorbmp,shellapi,global;

type
  Tinfodialog = class(TForm)
    fsimage: TImage;
    mainpanel: TPanel;
    additionalpanel: TPanel;
    additional: TImage;
    insidepanel: TPanel;
    inside: TImage;
    rearpanel: TPanel;
    rear: TImage;
    frontpanel: TPanel;
    front: TImage;
    Label12: TLabel;
    Label11: TLabel;
    Label13: TLabel;
    Label14: TLabel;
    Bevel1: TBevel;
    Label15: TLabel;
    Label6: TLabel;
    record_label: TLabel;
    Label2: TLabel;
    notes: TMemo;
    description: TMemo;
    Label7: TLabel;
    Label8: TLabel;
    compilation: TLabel;
    decade: TLabel;
    Label5: TLabel;
    Year: TLabel;
    label4: TLabel;
    artist_type: TLabel;
    Label10: TLabel;
    label3: TLabel;
    genre: TLabel;
    albumname: TLabel;
    Label9: TLabel;
    Label1: TLabel;
    artistname: TLabel;
    closeform: TButton;
    edit: TButton;
    Label16: TLabel;
    catno: TLabel;
    Label17: TLabel;
    Label18: TLabel;
    Label19: TLabel;
    urlalbum: TLabel;
    urlartist: TLabel;
    urladditional: TLabel;
    procedure FormCreate(Sender: TObject);
    procedure frontClick(Sender: TObject);
    procedure rearClick(Sender: TObject);
    procedure insideClick(Sender: TObject);
    procedure additionalClick(Sender: TObject);
    procedure fsimageClick(Sender: TObject);
    procedure FormActivate(Sender: TObject);
    procedure closeformClick(Sender: TObject);
    procedure editClick(Sender: TObject);
    procedure descriptionKeyPress(Sender: TObject; var Key: Char);
    procedure notesKeyPress(Sender: TObject; var Key: Char);
    procedure urlalbumClick(Sender: TObject);
    procedure mainpanelClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;


procedure showinfo; export;

implementation
uses main,albuminfo;

var
  infodialog: Tinfodialog;
  info : tinfo;
  wtop,wleft,wwidth,wheight : integer;
  fn : string;


{$R *.DFM}
function settext(inp : string) : string;
begin
if inp='0' then result:='Not Defined' else result:=inp;
end;

procedure showinfo; export;
begin

if mainform.cdplayerbut.checked=true then fn:=config.path+album[mainform.albumlist.itemindex+1].artist+'__'+album[mainform.albumlist.itemindex+1].album
   else begin
   if mainform.dplaylist.itemindex>-1 then fn:=dPlayListMatrixAlb[mainform.dplaylist.itemindex] else exit;
   end;

infodialog := tinfodialog.Create(Application);

  try
    infodialog.showmodal;
    finally
    infodialog.Free;
  end;
end;


procedure Tinfodialog.FormCreate(Sender: TObject);
var
albm,arst : string;
o : tbitmap;
begin
frontpanel.doublebuffered:=true;
info.rear:=tbitmap.create;
info.inside:=tbitmap.create;
info.additional:=tbitmap.create;


info_openrecord(fn,info,true);

if mainform.cdplayerbut.checked=true then begin
  artistname.caption:=album[mainform.albumlist.itemindex+1].artist;
  albumname.caption:=album[mainform.albumlist.itemindex+1].album;
  edit.enabled:=true;
end
else begin
  extractalbumandaristfrompath( dPlayListMatrixAlb[mainform.dplaylist.itemindex],albm,arst);
  artistname.caption:=albm;
  albumname.caption:=arst;
  edit.enabled:=false;
end;


genre.caption:=settext(info.genre);
artist_type.caption:=settext(info.artist_type);
year.caption:=settext(inttostr(info.year));
decade.caption:=settext(inttostr(info.decade));
description.text:=info.description;
notes.text:=info.notes;
catno.caption:=info.catno;
urlalbum.caption:=info.urlalbum;
urlartist.caption:=info.urlartist;
urladditional.caption:=info.urladditional;

record_label.caption:=info.recordlabel;
if info.compilation=false then compilation.caption:='No' else compilation.caption:='Yes';
loadjpegbmp(fn,o);
front.picture.bitmap.assign(o);
o.free;
if info.rear.empty then info.rear:=errorwithbitmap('','','');
if info.inside.empty then info.inside:=errorwithbitmap('','','');
if info.additional.empty then info.additional:=errorwithbitmap('','','');

rear.Picture.bitmap.assign(info.rear);
inside.Picture.bitmap.assign(info.inside);
additional.Picture.bitmap.assign(info.additional);
notes.text:=info.notes;



end;

procedure showfull(img : timage);
var
o : tbitmap;
begin
if img=infodialog.front then begin
loadjpegbmp(fn,o);
infodialog.fsimage.picture.bitmap.assign(o);
o.free;
end
else infodialog.fsimage.picture.bitmap.assign(img.picture.bitmap);
infodialog.mainpanel.visible:=false;
infodialog.fsimage.visible:=true;
infodialog.windowstate:=wsmaximized;
infodialog.fsimage.left:=0;
infodialog.fsimage.top:=0;
infodialog.fsimage.width:=infodialog.width;
infodialog.fsimage.height:=infodialog.height;
infodialog.borderstyle:=bsNone;
end;

procedure Tinfodialog.frontClick(Sender: TObject);
var
o : tbitmap;
begin
loadjpegbmp(fn,o);
fsimage.picture.bitmap.Assign(o);
o.free;
showfull(front);
end;

procedure Tinfodialog.rearClick(Sender: TObject);
begin
showfull(rear);
end;

procedure Tinfodialog.insideClick(Sender: TObject);
begin
showfull(inside);
end;

procedure Tinfodialog.additionalClick(Sender: TObject);
begin
showfull(additional);
end;

procedure Tinfodialog.fsimageClick(Sender: TObject);
begin
infodialog.borderstyle:=bsDialog;
infodialog.top:=wtop;
infodialog.left:=wleft;
infodialog.width:=wwidth;
infodialog.height:=wheight;
infodialog.mainpanel.visible:=true;
fsimage.visible:=false;
mainpanel.visible:=true;

end;

procedure Tinfodialog.FormActivate(Sender: TObject);
begin
wtop:=infodialog.top;
wleft:=infodialog.left;
wwidth:=infodialog.width;
wheight:=infodialog.height;
end;

procedure Tinfodialog.closeformClick(Sender: TObject);
begin
infodialog.close;
end;

procedure Tinfodialog.editClick(Sender: TObject);
begin
mainform.trackeditclick(nil);
formcreate(nil);
end;

procedure Tinfodialog.descriptionKeyPress(Sender: TObject; var Key: Char);
begin
key:=#0;
end;

procedure Tinfodialog.notesKeyPress(Sender: TObject; var Key: Char);
begin
key:=#0;
end;

procedure Tinfodialog.urlalbumClick(Sender: TObject);
begin
ShellExecute (0, nil, pchar(tlabel(sender).caption), nil, nil, SW_SHOWNORMAL);
end;

procedure Tinfodialog.mainpanelClick(Sender: TObject);
begin
ShellExecute (0, nil, pchar(fn), nil, nil, SW_SHOWNORMAL);
end;

end.