{*********************************************}
{  TeeChart Charting Library for FireMonkey   }
{  Copyright (c) 2012-2020 by Steema Software }
{  All Rights Reserved                        }
{*********************************************}
unit FMXTee.Editor.Strings;
{$I TeeDefs.inc}

interface

uses
  SysUtils, Types, System.UITypes, Classes, Variants,
  FMX.Types, FMX.Controls, FMX.Forms,
  {$IFNDEF UPTOXE3}
  FMX.StdCtrls,
  {$ENDIF}
  FMX.Memo, FMX.Dialogs, FMX.Layouts;

type
  TStringsEditor = class(TForm)
    Panel1: TPanel;
    Panel2: TPanel;
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    Button4: TButton;
    Button5: TButton;
    Memo1: TMemo;
    OpenDialog1: TOpenDialog;
    SaveDialog1: TSaveDialog;
    procedure Button3Click(Sender: TObject);
    procedure Button4Click(Sender: TObject);
    procedure Button5Click(Sender: TObject);
    procedure Button1Click(Sender: TObject);
  private
   { Private declarations }
    Strings : TStrings;
  public
   { Public declarations }
    class function Edit(AOwner:TComponent; AStrings:TStrings):Boolean;
  end;

implementation

{$R *.fmx}

procedure TStringsEditor.Button1Click(Sender: TObject);
begin
  Strings.Text:=Memo1.Text;
end;

procedure TStringsEditor.Button3Click(Sender: TObject);
begin
  Memo1.CopyToClipboard;
end;

procedure TStringsEditor.Button4Click(Sender: TObject);
begin
  if OpenDialog1.Execute then
     Memo1.Lines.LoadFromFile(OpenDialog1.FileName);
end;

procedure TStringsEditor.Button5Click(Sender: TObject);
begin
  if SaveDialog1.Execute then
     Memo1.Lines.SaveToFile(SaveDialog1.FileName);
end;

class function TStringsEditor.Edit(AOwner: TComponent;
  AStrings: TStrings): Boolean;
begin
  with TStringsEditor.Create(AOwner) do
  try
    Strings:=AStrings;
    Memo1.Text:=Strings.Text;

    result:=ShowModal=mrOk;
  finally
    Free;
  end;
end;

end.
