unit uFileProperties;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.ExtCtrls, Vcl.Buttons,
  uFileType;

type
  TFileProperties = class(TForm)
    lName: TLabel;
    lType: TLabel;
    lFileSize: TLabel;
    lCreated: TLabel;
    lChanged: TLabel;
    lLastAccess: TLabel;
    eLink: TEdit;
    bInsertFile: TBitBtn;
    Bevel1: TBevel;
    Image: TImage;
    procedure FormShow(Sender: TObject);
    procedure bInsertFileClick(Sender: TObject);
  private
    { Private declarations }



  public
    { Public declarations }

    constructor Create(AOwner: TComponent); override;



  end;

var
  FileProperties: TFileProperties;

implementation

{$R *.dfm}

uses uVisualFrame;

var VisualFrame_HTTP_UnitVar:TVisualFrame_HTTP;


{ TFileProperties }

procedure TFileProperties.bInsertFileClick(Sender: TObject);
begin
ModalResult:=mrOk;
end;

constructor TFileProperties.Create(AOwner: TComponent);
begin
  inherited;


  if (Aowner is TVisualFrame_HTTP) then
  VisualFrame_HTTP_UnitVar:=(Aowner as TVisualFrame_HTTP);



end;

procedure TFileProperties.FormShow(Sender: TObject);

var idCurrent:integer;
    Link:String;
    HumanFileSize: String;
    FileTypeLocal:TFileType;

begin

FileTypeLocal:=TFileType.Create(Self);

try

with VisualFrame_HTTP_UnitVar do begin

//idCurrent:=DBGrid.DataSource.DataSet.FieldByName('id').AsInteger;
Link:=DBGrid.DataSource.DataSet.FieldByName('Link').AsString;

     //Name
lName.Caption:=DBGrid.DataSource.DataSet.FieldByName('Name').AsString;

     //Type

lType.Caption:='';


     if FileTypeLocal.IsFilePicture(Link) then
      lType.Caption:='Изображение' else

     if FileTypeLocal.IsFileVideo(Link) then
      lType.Caption:='Видео' else

    if FileTypeLocal.IsFileAudio(Link) then
      lType.Caption:='Аудио' else

      lType.Caption:='Неизвестный файл';



// FileSize
GiveHumanFileSize(

DBGrid.DataSource.DataSet.FieldByName('fileSize').AsInteger,
HumanFileSize
); //DBGrid.DataSource.DataSet.FieldByName('fileSize').AsInteger.ToString;

lFileSize.Caption:=HumanFileSize;

lCreated.Caption:='Создан '+DBGrid.DataSource.DataSet.FieldByName('creationDateTime').AsString;
lChanged.Caption:='Изменен '+DBGrid.DataSource.DataSet.FieldByName('changesDateTime').AsString;
lLastAccess.Caption:='Последний доступ '+DBGrid.DataSource.DataSet.FieldByName('lastAccessDateTime').AsString;

eLink.Text:=DBGrid.DataSource.DataSet.FieldByName('Link').AsString;

end;

finally
FreeAndNil(FileTypeLocal);
end;



end;

end.
