unit FMXTee.Editor.Tools.SeriesBand;
{$I TeeDefs.inc}

interface

uses
  System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
  {$IFDEF D17}
  System.UIConsts,
  {$ENDIF}
  FMX.Types, FMX.Controls, FMX.Forms, FMX.Dialogs, FMXTee.Editor.Tools.Series,
  FMXTee.Procs, FMX.ListBox, FMXTee.Tools.SeriesBand, FMX.Edit;

type
  TSeriesBandToolEdit = class(TSeriesToolEditor)
    Label5: TLabel;
    UDTransparency: TSpinBox;
    CBDrawBehindSeries: TCheckBox;
    Label2: TLabel;
    CBSeries2: TComboBox;
    BPen: TButton;
    BBrush: TButton;
    BGradient: TButton;
    procedure FormActivate(Sender: TObject);
    procedure UDTransparencyChange(Sender: TObject);
    procedure CBDrawBehindSeriesChange(Sender: TObject);
    procedure CBSeries2Change(Sender: TObject);
    procedure BPenClick(Sender: TObject);
    procedure BBrushClick(Sender: TObject);
    procedure BGradientClick(Sender: TObject);
  private
    { Private declarations }
    SeriesBand : TSeriesBandTool;
  public
    { Public declarations }
  end;

implementation

{$R *.fmx}

uses
  FMXTee.Engine, FMXTee.Editor.Stroke, FMXTee.Editor.Brush, FMXTee.Editor.Series,
  FMXTee.Editor.Gradient;

procedure TSeriesBandToolEdit.BBrushClick(Sender: TObject);
begin
  if Assigned(SeriesBand) then
     TBrushEditor.Edit(Self, SeriesBand.Brush);
end;

procedure TSeriesBandToolEdit.BGradientClick(Sender: TObject);
begin
  if Assigned(SeriesBand) then
    TGradientEditor.Edit(Self, SeriesBand.Gradient)
end;

procedure TSeriesBandToolEdit.BPenClick(Sender: TObject);
begin
  if Assigned(SeriesBand) then
     TStrokeEditor.Edit(Self, SeriesBand.Pen);
end;

procedure TSeriesBandToolEdit.CBDrawBehindSeriesChange(Sender: TObject);
begin
  if Assigned(SeriesBand) then
    SeriesBand.DrawBehindSeries:=CBDrawBehindSeries.IsChecked;
end;

procedure TSeriesBandToolEdit.CBSeries2Change(Sender: TObject);
begin
  if Assigned(SeriesBand) then
    SeriesBand.Series2:=TChartSeries(CBSeries2.Selected.Data);
end;

procedure TSeriesBandToolEdit.FormActivate(Sender: TObject);
begin
  inherited;

  if not Assigned(SeriesBand) then
  begin
    SeriesBand:=TSeriesBandTool(TagObject);

    if Assigned(SeriesBand) then
    With SeriesBand do
    begin
      FillSeriesCombo(CBSeries2,Series2,ParentChart);

      UDTransparency.Value:=Transparency;
      CBDrawBehindSeries.IsChecked:=DrawBehindSeries;
    end;
  end;
end;

procedure TSeriesBandToolEdit.UDTransparencyChange(Sender: TObject);
begin
  if Assigned(SeriesBand) then
    SeriesBand.Transparency:=Round(UDTransparency.Value);
end;

initialization
  RegisterSeriesEditor(TSeriesBandToolEdit);
end.
