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

interface

uses
  System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
  FMX.Types, FMX.Controls, FMX.Forms, FMX.Dialogs,
  FMXTee.Canvas, FMXTee.Engine, FMXTee.Editor.Stroke, FMXTee.Series.Kagi,
  FMXTee.Editor.Series.Pointer, FMX.TabControl;

type
  TKagiSeriesEditor = class(TForm)
    TabControl1: TTabControl;
    TabUp: TTabItem;
    TabDown: TTabItem;
    TabBuy: TTabItem;
    TabSell: TTabItem;
    procedure FormActivate(Sender: TObject);
    procedure TabControl1Change(Sender: TObject);
  private
    { Private declarations }
    Kagi : TKagiSeries;
    FUpSwing : TStrokeEditor;
    FDownSwing : TStrokeEditor;
  public
    { Public declarations }
  end;

var
  KagiSeriesEditor: TKagiSeriesEditor;

implementation

{$R *.fmx}

uses
  Math, FMXTee.ProConstants, FMXTee.Chart, FMXTee.Procs;

procedure TKagiSeriesEditor.FormActivate(Sender: TObject);
begin
  Kagi:=TKagiSeries(TagObject);

  if Assigned(Kagi) then
  with Kagi do
  begin
    EmbeddForm(TSeriesPointerEditor.CreateEditor(Self, BuySymbol),TabBuy);
    EmbeddForm(TSeriesPointerEditor.CreateEditor(Self, SellSymbol),TabSell);

    TabControl1Change(Self);
  end;
end;

procedure TKagiSeriesEditor.TabControl1Change(Sender: TObject);
begin
  if (TabControl1.ActiveTab=TabUp) and (not assigned(FUpSwing)) then
     FUpSwing:=TStrokeEditor.InsertForm(Kagi.UpSwing,TabUp)
  else
  if (TabControl1.ActiveTab=TabDown) and (not assigned(FDownSwing)) then
     FDownSwing:=TStrokeEditor.InsertForm(Kagi.DownSwing,TabDown);
end;

initialization
  RegisterClass(TKagiSeriesEditor);
end.
