unit Main;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ComCtrls, Vcl.ToolWin,
  System.ImageList, Vcl.ImgList, Vcl.Edge, ZylVscEditor, System.IOUtils;

type
  TFormMain = class(TForm)
    dfsToolBar: TToolBar;
    btnNew: TToolButton;
    btnOpen: TToolButton;
    btnSave: TToolButton;
    btnSaveAll: TToolButton;
    ImageList: TImageList;
    openDialog: TOpenDialog;
    buttonClose: TToolButton;
    buttonDark: TToolButton;
    buttonWhite: TToolButton;
    zylVscEditor: TZylVscEditor;
    buttonCompare: TToolButton;
    buttonInline: TToolButton;
    ToolButton1: TToolButton;
    ToolButton2: TToolButton;
    saveDialog: TSaveDialog;
    procedure btnOpenClick(Sender: TObject);
    procedure btnNewClick(Sender: TObject);
    procedure buttonCloseClick(Sender: TObject);
    procedure buttonDarkClick(Sender: TObject);
    procedure buttonWhiteClick(Sender: TObject);
    procedure buttonCompareClick(Sender: TObject);
    procedure buttonInlineClick(Sender: TObject);
    procedure btnSaveClick(Sender: TObject);
    procedure btnSaveAllClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  FormMain: TFormMain;

implementation

{$R *.dfm}

procedure TFormMain.btnNewClick(Sender: TObject);
begin
  zylVscEditor.NewFile();
end;

procedure TFormMain.btnOpenClick(Sender: TObject);
begin
  if openDialog.Execute then
  begin
      zylVscEditor.OpenFile(OpenDialog.FileName);
  end;
end;

procedure TFormMain.btnSaveAllClick(Sender: TObject);
begin
  saveDialog.DefaultExt := TPath.GetExtension(zylVscEditor.FileName);
  if saveDialog.Execute() then
  begin
    zylVscEditor.SaveFile(saveDialog.FileName);
  end;
end;

procedure TFormMain.btnSaveClick(Sender: TObject);
begin
  zylVscEditor.SaveFile();
end;

procedure TFormMain.buttonCloseClick(Sender: TObject);
begin
  zylVscEditor.CloseFile();
end;

procedure TFormMain.buttonCompareClick(Sender: TObject);
begin
  //if zylVscEditor.FileName <> '' then
  begin
    if openDialog.Execute then
    begin
      zylVscEditor.CompareFile(OpenDialog.FileName);
    end;
  end;
end;

procedure TFormMain.buttonInlineClick(Sender: TObject);
begin
  zylVscEditor.InlineCompare := not zylVscEditor.InlineCompare;
end;

procedure TFormMain.buttonDarkClick(Sender: TObject);
begin
  zylVscEditor.Theme := 'vs-dark';
end;

procedure TFormMain.buttonWhiteClick(Sender: TObject);
begin
  zylVscEditor.Theme := 'vs';
end;

end.
