{*********************************************}
{  TeeChart Charting Library for FireMonkey   }
{  Copyright (c) 2012-2020 by Steema Software }
{  All Rights Reserved                        }
{*********************************************}
unit FMXTee.Editor.Series.PointFigure;

interface

uses
  System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
  FMX.Types, FMX.Controls, FMX.Forms, FMX.Dialogs, FMX.StdCtrls,
  FMXTee.Procs, FMXTee.Series.OHLC, FMXTee.Engine, FMXTee.Series, FMX.Edit,
  FMX.TabControl,FMXTee.Editor.Series.Pointer;

type
  TPointFigureSeriesEditor = class(TForm)
    LHeight: TLabel;
    Label1: TLabel;
    EBoxSize: TEdit;
    EReversal: TEdit;
    TabControl1: TTabControl;
    TabFormat: TTabItem;
    TabUp: TTabItem;
    TabDown: TTabItem;
    procedure FormActivate(Sender: TObject);
    procedure EBoxSizeChange(Sender: TObject);
    procedure EReversalChange(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
  private
    { Private declarations }
    UpForm      : TCustomForm;
    DownForm    : TCustomForm;
    PointFigure : TPointFigureSeries;
  public
    { Public declarations }
  end;

var
  PointFigureSeriesEditor: TPointFigureSeriesEditor;

implementation

{$R *.fmx}

uses
  FMXTee.Chart, FMXTee.ProConstants, FMXTee.Canvas;


procedure TPointFigureSeriesEditor.EBoxSizeChange(Sender: TObject);
begin
  if assigned(PointFigure) then
     PointFigure.BoxSize:=StrToFloatDef(EBoxSize.Text,PointFigure.BoxSize);
end;

procedure TPointFigureSeriesEditor.EReversalChange(Sender: TObject);
begin
  if assigned(PointFigure) then
     PointFigure.ReversalAmount:=StrToFloatDef(EReversal.Text,PointFigure.ReversalAmount);
end;

procedure TPointFigureSeriesEditor.FormActivate(Sender: TObject);
begin
  PointFigure:=TPointFigureSeries(TagObject);

  if Assigned(PointFigure) then
  begin
    with PointFigure do
    begin
      EReversal.Text:=FloatToStr(ReversalAmount);
      EBoxSize.Text:=FloatToStr(BoxSize);
    end;

    if Assigned(Parent) then
    begin
      if not Assigned(UpForm) then
         TSeriesPointerEditor.InsertForm(PointFigure.UpSymbol,TabUp);
      if not Assigned(DownForm) then
         TSeriesPointerEditor.InsertForm(PointFigure.DownSymbol,TabDown);
    end;
  end;

end;

procedure TPointFigureSeriesEditor.FormDestroy(Sender: TObject);
begin
  FreeAndNil(DownForm);
  FreeAndNil(UpForm);
end;

initialization
  RegisterClass(TPointFigureSeriesEditor);
end.
