unit FMXTee.Editor.Series.Volume;

interface

uses
  System.SysUtils, System.Types, System.UITypes, System.Rtti, System.Classes,
  System.Variants, FMX.Types, FMX.Controls, FMX.Forms, FMX.Dialogs,
  FMXTee.Series.Candle, FMXTee.Editor.Stroke, FMX.Edit,
  FMX.Layouts, FMXTee.Chart.GalleryPanel, FMX.ListBox, FMX.Colors,
  FMX.TabControl;

type
  TVolumeSeriesEditor = class(TStrokeEditor)
    CBColorEach: TCheckBox;
    CBUseOrigin: TCheckBox;
    EOrigin: TEdit;
    procedure CBColorEachChange(Sender: TObject);
    procedure FormActivate(Sender: TObject);
    procedure ComboColorBox1Change(Sender: TObject);
    procedure CBUseOriginChange(Sender: TObject);
    procedure EOriginChangeTracking(Sender: TObject);
  private
    { Private declarations }
    TheSeries   : TVolumeSeries;
  public
    { Public declarations }
  end;

implementation

{$R *.fmx}

procedure TVolumeSeriesEditor.CBColorEachChange(Sender: TObject);
begin
  TheSeries.ColorEachPoint:=CBColorEach.IsChecked;
//  BColor.Enabled:=not TheSeries.ColorEachPoint;
end;

procedure TVolumeSeriesEditor.CBUseOriginChange(Sender: TObject);
begin
  TheSeries.UseYOrigin:=CBUseOrigin.IsChecked;
  EOrigin.Enabled:=TheSeries.UseYOrigin;
end;

procedure TVolumeSeriesEditor.ComboColorBox1Change(Sender: TObject);
begin
  inherited;
  TheSeries.SeriesColor:=Pen.Color;
end;

procedure TVolumeSeriesEditor.EOriginChangeTracking(Sender: TObject);
begin
  //if Showing then
     with TheSeries do YOrigin:=StrToFloatDef(EOrigin.Text,YOrigin);
end;

procedure TVolumeSeriesEditor.FormActivate(Sender: TObject);
begin
  TheSeries:=TVolumeSeries(TagObject);

  if Assigned(TheSeries) then
  begin
    Pen:=TheSeries.Pen;

    inherited;

    //BColor.Enabled:=not TheSeries.ColorEachPoint;

    CBColorEach.IsChecked:=TheSeries.ColorEachPoint;
    CBUseOrigin.IsChecked:=TheSeries.UseYOrigin;
    EOrigin.Text:=FloatToStr(TheSeries.YOrigin);
    EOrigin.Enabled:=TheSeries.UseYOrigin;
  end;
end;

initialization
  RegisterClass(TVolumeSeriesEditor);
end.
