unit cde_MainForm;
{$mode delphi}
{$codepage UTF8}
interface
uses Classes, SysUtils, FileUtil, Forms, Controls, Dialogs, Buttons, ExtCtrls, ComCtrls, Menus, kernel, cde_dir,
     SimplyJSON, LazUTF8Classes, ShellApi, cde_lang, cde_types;
type
  { Tcde_Main }
  Tcde_Main = class(TForm)
    DiscPages: TPageControl;
    Images: TImageList;
    MainMenu: TMainMenu;
    DiscM: TMenuItem;
    ActionsM: TMenuItem;
    HelpM: TMenuItem;
    BrowseM: TMenuItem;
    CreateLinkM: TMenuItem;
    EjectM: TMenuItem;
    AboutM: TMenuItem;
    DCloseM: TMenuItem;
    ProgramWebM: TMenuItem;
    Sep3: TMenuItem;
    Sep2: TMenuItem;
    Sep1: TMenuItem;
    RefrashM: TMenuItem;
    SettingsM: TMenuItem;
    NoDiscFound: TPanel;
    procedure AboutMClick(Sender: TObject);
    procedure BrowseMClick(Sender: TObject);
    procedure CreateLinkMClick(Sender: TObject);
    procedure DCloseMClick (Sender: TObject );
    procedure EjectMClick(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
    procedure DiscsMenuClick(Sender: TObject);
    procedure ProgramWebMClick(Sender: TObject);
    procedure RefrashMClick(Sender: TObject);
    procedure SettingsMClick(Sender: TObject);
  private
  public
  DiscList: TStringListUTF8;
  end;
var
  cde_Main: Tcde_Main;
implementation
uses cde_disc_frame;
{$R *.lfm}
procedure Tcde_Main.FormCreate(Sender: TObject);
var Ind: Byte;
begin
UpdateLanguage;
DiscList:= TStringListUTF8.Create;
UpdateDL(DiscList);
if DiscList.Count > 0 then
 begin
 NoDiscFound.Hide;
 DiscPages.Show;
 for Ind:= 0 to DiscList.Count - 1 do
  CreateDriveRec(Ind);
 end
 else
 begin
 DiscPages.Hide;
 NoDiscFound.Show;
 end;
DiscM.Visible:= JSReadBoolean('/interface/discmshow', True, GetCDEPath + 'configs\configs.json');
end;
procedure Tcde_Main.EjectMClick(Sender: TObject);
begin
GetFrame.do_EjectDisc;
end;
procedure Tcde_Main.CreateLinkMClick(Sender: TObject);
begin
GetFrame.do_CreateLink;
end;
procedure Tcde_Main.DCloseMClick (Sender: TObject );
begin
GetFrame.do_CloseDisc;
end;
procedure Tcde_Main.BrowseMClick(Sender: TObject);
begin
GetFrame.do_BrowseDisc;
end;
procedure Tcde_Main.AboutMClick(Sender: TObject);
begin
ShowAboutInfo;
end;
procedure Tcde_Main.FormDestroy(Sender: TObject);
begin
FreeAndNil(DiscList);
end;
procedure Tcde_Main.DiscsMenuClick(Sender: TObject);
var Indx: Integer;
begin
Indx:= (Sender as TMenuItem).Tag;
DiscPages.ActivePageIndex:= Indx;
end;
procedure Tcde_Main.ProgramWebMClick(Sender: TObject);
begin
ShellExecute(Self.Handle, 'open', PChar(WebHomePage), Nil, PChar(GetCDEPath + 'help\'), 1);
end;
procedure Tcde_Main.RefrashMClick(Sender: TObject);
begin
GetFrame.do_Refrash;
end;
procedure Tcde_Main.SettingsMClick(Sender: TObject);
begin
ShowSettings();
end;
end.
