TAChart: Fix streaming of TChartImageList after changes to TImageList bitmap format

git-svn-id: trunk@39945 -
This commit is contained in:
ask 2013-01-24 04:44:35 +00:00
parent 6709c70681
commit 07276efd34

View File

@ -47,13 +47,15 @@ type
protected protected
procedure ClearAllSeries; procedure ClearAllSeries;
procedure Populate; procedure Populate;
public
procedure ReadData(AStream: TStream); override;
procedure WriteData(AStream: TStream); override;
public public
constructor Create(AOwner: TComponent); override; constructor Create(AOwner: TComponent); override;
destructor Destroy; override; destructor Destroy; override;
function GetSeries(AImgIndex: Integer): TCustomChartSeries; function GetSeries(AImgIndex: Integer): TCustomChartSeries;
function ImageIndexOfSeries(ASeries: TCustomChartSeries): Integer; function ImageIndexOfSeries(ASeries: TCustomChartSeries): Integer;
procedure SeriesChanged(ASender: TObject); procedure SeriesChanged(ASender: TObject);
procedure WriteData(AStream: TStream); override;
property FirstSeriesIndex: Integer read FFirstSeriesIndex; property FirstSeriesIndex: Integer read FFirstSeriesIndex;
property SeriesCount: Integer read FSeriesCount; property SeriesCount: Integer read FSeriesCount;
published published
@ -78,6 +80,17 @@ end;
{ TChartImageList } { TChartImageList }
procedure TChartImageList.ClearAllSeries;
var
i: Integer;
begin
if FFirstSeriesIndex < 0 then exit;
for i := FFirstSeriesIndex + FSeriesCount - 1 downto FFirstSeriesIndex do
Delete(i);
FFirstSeriesIndex := -1;
FSeriesCount := 0;
end;
constructor TChartImageList.Create(AOwner: TComponent); constructor TChartImageList.Create(AOwner: TComponent);
begin begin
inherited Create(AOwner); inherited Create(AOwner);
@ -92,17 +105,6 @@ begin
inherited Destroy; inherited Destroy;
end; end;
procedure TChartImageList.ClearAllSeries;
var
i: Integer;
begin
if FFirstSeriesIndex < 0 then exit;
for i := FFirstSeriesIndex + FSeriesCount - 1 downto FFirstSeriesIndex do
Delete(i);
FFirstSeriesIndex := -1;
FSeriesCount := 0;
end;
function TChartImageList.GetSeries(AImgIndex: Integer): TCustomChartSeries; function TChartImageList.GetSeries(AImgIndex: Integer): TCustomChartSeries;
begin begin
Result := nil; Result := nil;
@ -166,6 +168,12 @@ begin
end; end;
end; end;
procedure TChartImageList.ReadData(AStream: TStream);
begin
Unused(AStream);
Clear;
end;
// Notification procedure of the listener. Responds to chart broadcasts // Notification procedure of the listener. Responds to chart broadcasts
// by populating the imagelist with the chart's series icons. // by populating the imagelist with the chart's series icons.
procedure TChartImageList.SeriesChanged(ASender:TObject); procedure TChartImageList.SeriesChanged(ASender:TObject);
@ -188,18 +196,10 @@ begin
end; end;
procedure TChartImageList.WriteData(AStream: TStream); procedure TChartImageList.WriteData(AStream: TStream);
var
ch: TChart;
begin begin
ch := Chart; // Don't write the series images to stream.
try // They will be recreated automatically when the chart is assigned on loading.
// Don't write the series images to stream. Unused(AStream);
// They will be recreated automatically when the chart is assigned on loading.
Chart := nil;
inherited WriteData(AStream);
finally
Chart := ch;
end;
end; end;
end. end.