Index » Empathy Jukebox : Blob 73e807 / aboutform.pas
unit aboutform;

//   Copyright (C) 2012 Matthew Smith

//    This program is free software: you can redistribute it and/or modify
//    it under the terms of the GNU General Public License as published by
//    the Free Software Foundation, either version 3 of the License, or
//    (at your option) any later version.

//    This program is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//    GNU General Public License for more details.

//    You should have received a copy of the GNU General Public License
//    along with this program.  If not, see <http://www.gnu.org/licenses/>.

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  ExtCtrls, StdCtrls,shellapi,global, bitmapactionbutton,mydialog,isconnected,VersionInfo;

type
  Tabout = class(TForm)
    logo: TImage;
    outline: TShape;
    reguser: TLabel;
    regserial: TLabel;
    hyperlink: TLabel;
    album: TLabel;
    artist: TLabel;
    mes: TLabel;
    Timer: TTimer;
    back: TImage;
    version: TLabel;
    albslabel: TLabel;
    albs: TLabel;
    netset: TLabel;
    copyright: TLabel;
    OK: TBitmapActionButton;
    procedure FormCreate(Sender: TObject);
    procedure hyperlinkClick(Sender: TObject);
    procedure FormActivate(Sender: TObject);
    procedure TimerTimer(Sender: TObject);
    procedure netsetClick(Sender: TObject);
    procedure copyrightClick(Sender: TObject);
    procedure OKClick(Sender: TObject);
  private
    { Private declarations }
  public

    { Public declarations }
  end;

var
  about: Tabout;
  aboutmode : boolean;

procedure showabout(mode : integer);
procedure initmessage(mes,artist,album : string);
function byteformat(i : int64) : string;
implementation

uses Main, jukeboxform;
var
cancel : boolean = false;

{$R *.DFM}

procedure showabout(mode : integer);
begin
cancel:=false;
if mode=1 then begin
aboutmode:=true;
about := Tabout.Create(Application);
  try
    about.Showmodal;
    finally
    about.free;
    end;
end;
if mode=0 then begin
aboutmode:=false;
about := Tabout.Create(Application);
  try
   about.show;
  finally
  end;
end;
end;







procedure initmessage(mes,artist,album : string);
begin
     if (firstrun=true) and (about.visible=true) then begin
     if assigned(about)=false then exit;

     about.mes.caption:=mes;
     about.artist.caption:=artist;
     about.album.caption:=album;
     end;
     application.processmessages;
end;

procedure Tabout.FormCreate(Sender: TObject);
begin

doublebuffered:=true;
cancel:=false;


loadbitmap(logo,'LOGO');
outline.top:=0;
outline.left:=0;
outline.width:=width;
outline.height:=height;



if aboutmode=true then begin
   ok.visible:=true;
   mes.caption:='MP3 Filesystem information:-';
   album.caption:=inttostr(albumrefonloadcount)+' total albums.';
   if config.networksettings<>'' then netset.visible:=true;
end else begin
    screen.cursor:=crAppstart;
   ok.visible:=false;
end;

version.caption:='v'+GetVersionInfo(application.exename);

   copyright.font.style:=[];
   copyright.font.color:=clgreen;

   hyperlink.caption:=WEBSITEURL;
if kiosk=true then begin
   hyperlink.font.style:=[];
   hyperlink.font.color:=clgreen;


end;
end;


procedure Tabout.hyperlinkClick(Sender: TObject);
begin
if kiosk=true then exit;
ShellExecute (0, nil, pchar(WEBSITEURL), nil, nil, SW_SHOWNORMAL);
end;

procedure Tabout.OKClick(Sender: TObject);
begin
cancel:=true;
end;


function byteformat(i : int64) : string;
var
a,res : string;
x,n : integer;
begin
a:=inttostr(i);
res:='';
for n:=1 to length(a) do begin
x:=length(a)-n;
res:=res+a[n];
if (x mod 3)=0 then res:=res+',';
end;
if res[length(res)]=',' then res:=copy(res,1,length(res)-1);
result:=res;
end;

procedure Tabout.FormActivate(Sender: TObject);
var
n : integer;
sizer : int64;
filecount : longint;
freespace,scrap : TLargeInteger;
mp3count : integer;

procedure doadditions;
begin
     sizer:=sizer+getalbumsize(config.path+'\'+albumrefonload[n].artist+'__'+albumrefonload[n].album,filecount,mp3count,cancel);
     artist.caption:=byteformat(sizer)+ ' total bytes in '+inttostr(filecount)+ ' file(s).';
     artist.caption:=artist.caption+chr(13)+chr(10)+inttostr(mp3count)+' total MP3 files.';
     getdiskfreespaceex(pchar(config.path),freespace,scrap,nil);
     artist.caption:=artist.caption+chr(13)+chr(10)+byteformat(freespace)+' bytes free on volume.';
end;


begin
moveformtomonitor(self);
mp3count:=0;
filecount:=0;
sizer:=0;
if aboutmode=true then begin
   timer.enabled:=true;
   for n:=1 to albumrefonloadcount do begin
   application.processmessages;
   if cancel=true then  break;
    doadditions;
   end;
end;

end;



procedure Tabout.TimerTimer(Sender: TObject);
begin
if cancel=true then about.modalresult:=mrOK;
end;

procedure Tabout.netsetClick(Sender: TObject);
begin
netset.visible:=false;
application.processmessages;
osk(false,false);
runprogram(config.networksettings+' '+cachepath+'\',0,true);
end;

procedure Tabout.copyrightClick(Sender: TObject);
begin
//if aboutmode=true then showlicence;
end;

end.