⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 teeediseri.pas

📁 第三方控件:PaintGrid.pas 网格型仪表控件源文件 Mymeter.pas 圆型仪表控件源文件 Project1是这两个控件的使用范例。 该
💻 PAS
📖 第 1 页 / 共 3 页
字号:
        loNone       : CBSort.ItemIndex:= 2;
        loAscending  : CBSort.ItemIndex:= 0;
        loDescending : CBSort.ItemIndex:= 1;
      end;

      ShowControls(ValuesList.Count<=2,[CBSort,LSort,LDepth,EDepth,UDDepth,CBDepth]);

      tmpCursor:=Cursor;
    end
    else tmpCursor:=crDefault;

    TeeFillCursors(CBCursor,tmpCursor);
  end;

begin
  With PageSeries do
  if ActivePage=TabGeneral then SetTabSeriesGeneral else
  if ActivePage=TabMarks then SetTabSeriesMarks     else
  if ActivePage=TabDataSource then SetTabDataSource;

  ChangingPage:=False;
end;

Procedure TFormTeeSeries.FillAxes;
begin
  FillAxis(CBHorizAxis.Items,True);
  FillAxis(CBVertAxis.Items,False);
end;

type
   TChartSeriesAccess=class(TChartSeries);

procedure TFormTeeSeries.SetTabDataSource;
var tmp : Integer;
    t   : Integer;
    tmpSource : TTeeSeriesSourceClass;
begin
  {$IFDEF CLX}
  if not Assigned(TheSeries) then exit;
  {$ENDIF}

  tmp:=CBDataSourceStyle.ItemIndex;

  if Assigned(TheSeries.FunctionType) then
     CBDataSourceStyle.ItemIndex:=2
  else
  if not Assigned(TheSeries.DataSource) then
  begin
    if (TheSeries.Count>0) and (not TChartSeriesAccess(TheSeries).ManualData) then
       CBDataSourceStyle.ItemIndex:=1
    else
       CBDataSourceStyle.ItemIndex:=0;
  end
  else
  if TheSeries.DataSource is TChartSeries then
     CBDataSourceStyle.ItemIndex:=2
  else

  begin
    tmpSource:=nil;
    for t:=0 to TeeSources.Count-1 do
    if TTeeSeriesSourceClass(TeeSources[t]).HasSeries(TheSeries) then
    begin
      tmpSource:=TTeeSeriesSourceClass(TeeSources[t]);
      break;
    end;

    With CBDataSourceStyle do
    if Assigned(tmpSource) then
       ItemIndex:=Items.IndexOfObject(TObject(tmpSource))
    else
       ItemIndex:=0;
  end;

  if CBDataSourceStyle.ItemIndex<>tmp then CreateDataSourceForm;
end;

Function TFormTeeSeries.AddToTab(AForm:TForm; ATab:TTabSheet; AObject:TPersistent):TForm;
begin
  result:=AForm;
  result.Align:=alClient;
  Inc(NumSeriesForms);
  TheSeriesForms[NumSeriesForms]:=result;
  result.Align:=alClient;
  TeeTranslateControl(result);
  AddFormTo(result,ATab,AObject);
end;

Function TFormTeeSeries.InsertSeriesForm( EditorClass:TFormClass;
                                          Position:Integer;
                                          Const EditorTabName:String;
                                          AnObject:TPersistent):TCustomForm;
var tmpPage  : TTabSheet;
begin
  tmpPage:=TTabSheet.Create(Self);
  With tmpPage do
  begin
    PageControl:=PageSeries;
    PageIndex:=Position;
    Caption:=EditorTabName;
  end;

  result:=AddToTab(EditorClass.Create(Self),tmpPage,AnObject);
end;

{$IFNDEF CLR}
type
  TTeePanelAccess=class(TCustomTeePanel);
{$ENDIF}

procedure TFormTeeSeries.DestroySeriesForms;
var t       : Integer;
    tmpPage : TTabSheet;
begin
  for t:=1 to NumSeriesForms do
  if Assigned(TheSeriesForms[t]) then
  begin
    tmpPage:=(TheSeriesForms[t].Parent as TTabSheet);
    FreeAndNil(TheSeriesForms[t]);

    if tmpPage.PageIndex>0 then
       if not (csDestroying in tmpPage.PageControl.ComponentState) then
          if not (csDestroying in tmpPage.ComponentState) then
             tmpPage.Free;
  end;

  NumSeriesForms:=0;

  DestroyDataSourceForm;
end;

Function SeriesEditorForm(Series:TChartSeries):TFormClass;
begin
  result:=TFormClass(GetClass(Series.EditorClass));
end;

procedure TFormTeeSeries.CBSeriesChange(Sender: TObject);

  Procedure CreateTheSeriesForm;
  var tmpClass : TFormClass;
  begin
    tmpClass:=SeriesEditorForm(TheSeries);
    if Assigned(tmpClass) then
       AddToTab(tmpClass.Create(Self),TheTabSheet,TheSeries)
    else
    begin
      DestroySeriesForms;
      TheTabSheet.TabVisible:=False;
    end;
  end;

  Procedure HideSeriesPage;
  begin
    ImageSeries.Visible:=False;
    LabelSeriesClass.Caption:='';
    PageSeries.Visible:=False;
  end;

  Function FindTab(Const ATab:String):TTabSheet;
  var t : Integer;
  begin
    with PageSeries do
    begin
      result:=nil;
      for t:=0 to PageCount-1 do
      if Pages[t].Caption=ATab then
      begin
        result:=Pages[t];
        break;
      end;
    end;
  end;

  Procedure AddTeeSources;
  var t: Integer;
      tmpSource : TTeeSeriesSourceClass;
  begin
    { remove source styles from combobox }
    with CBDataSourceStyle.Items do
         while Count>3 do Delete(Count-1);

    { add sources that are available for this chart type }
    for t:=0 to TeeSources.Count-1 do { 5.02 }
    begin
      tmpSource:=TTeeSeriesSourceClass(TeeSources[t]);
      if CBDataSourceStyle.Items.IndexOfObject(TObject(tmpSource))=-1 then
         if tmpSource.Available(TheSeries.ParentChart) then
            CBDataSourceStyle.Items.AddObject(tmpSource.Description,TObject(tmpSource));
    end;
  end;

  procedure ChangeSeriesForms(OldTab:String);
  var tmpBitmap : TBitmap;
      tmpString : string;
      Index: Integer;
  begin
    TheChart:=TheSeries.ParentChart;
    if Assigned(TheChart) then
       {$IFNDEF CLR}TTeePanelAccess{$ENDIF}(TheChart).Listeners.Add(Self);

    AddTeeSources;

    tmpBitmap:=TBitmap.Create;
    try
      TeeGetBitmapEditor(TheSeries,tmpBitmap);
      ImageSeries.Picture.Assign(tmpBitmap);
    finally
      tmpBitmap.Free;
    end;

    PaintBox1.Visible:=TChartSeriesAccess(TheSeries).IUseSeriesColor;

    tmpString := GetGallerySeriesName(TheSeries);
    Index := Pos('&', tmpString);
    if Index > 0 then
       Insert('&', tmpString, Index + 1); // Point & Figure --> Point && Figure
    LabelSeriesClass.Caption:=tmpString+': '+SeriesTitleOrName(TheSeries);

    ImageSeries.Visible:=True;
    PageSeries.Visible:=True;
    TabGeneral.TabVisible:=ShowTabGeneral;
    TabMarks.TabVisible:=ShowTabMarks;
    TabDataSource.TabVisible:=ShowTabDataSource and
                              ( (not (tssIsTemplate in TheSeries.Style)) and
                                (not (tssHideDataSource in TheSeries.Style)) );

    if (OldTab='') or
       ((OldTab=TabDataSource.Caption) and (not TabDataSource.TabVisible)) then
         OldTab:=TheTabSheet.Caption;

    ShowControls(TheSeries.UseAxis,[ GBHorizAxis,GBVertAxis ]);
    CBPersistent.Visible:=IsDssGraph and (not (tssIsTemplate in TheSeries.Style));
    if CBPersistent.Visible then
       CBPersistent.Checked:=(tssIsPersistent in TheSeries.Style);

    DestroySeriesForms;
    CreateTheSeriesForm;

    PageSeries.ActivePage:=FindTab(OldTab);
    if (OldTab='') or (PageSeries.ActivePage=nil) then
       PageSeries.ActivePage:=TheTabSheet;

    if not PageSeries.ActivePage.TabVisible then
       PageSeries.ActivePage:=TabGeneral;

    CBDataSourceStyle.ItemIndex:=-1;
    PageSeriesChange(Self);

    PaintBox1.Repaint; { 5.02 }
  end;

var OldTab : String;
begin
  CreatingForm:=True;

  if Assigned(PageSeries.ActivePage) then OldTab:=PageSeries.ActivePage.Caption
                                     else OldTab:='';

  With CBSeries do
  if ItemIndex<>-1 then
  begin
    TheSeries:=TChartSeries(Items.Objects[ItemIndex]);

    if Assigned(TheSeries) then
    begin
      TheListBox.ClearSelection;
      TheListBox.SelectedSeries:=TheSeries; // 6.0 Synchronize main ChartListBox

      if TheSeries<>LastSeries then
      begin
        ChangeSeriesForms(OldTab);
        LastSeries:=TheSeries;
      end;
    end
    else HideSeriesPage;
  end
  else HideSeriesPage;

  CreatingForm:=False;
end;

procedure TFormTeeSeries.FormCreate(Sender: TObject);
begin
  ChangingPage:=False;
  CreatingForm:=True;
  NumSeriesForms:=0;
  ShowTabDataSource:=True;
  ShowTabGeneral:=True;
  ShowTabMarks:=True;
  IsDssGraph:=False;

  CBDataSourceStyle.DropDownCount:=12; { 5.02 }
  CBDataSourceStyle.Items.Objects[2]:=TObject(TTeeFuncEditor); { 5.02 }
  PageSeries.ActivePage:=TheTabSheet;
  PageControlMarks.ActivePage:=TabSheet1;
end;

procedure TFormTeeSeries.RGMarkStyleClick(Sender: TObject);
begin
  TheSeries.Marks.Style:=TSeriesMarksStyle(RGMarkStyle.ItemIndex);
  EnableMultiLine;
end;

procedure TFormTeeSeries.CBPersistentClick(Sender: TObject);
begin
  With TheSeries do
  if CBPersistent.Checked then Style:=Style+[tssIsPersistent]
                          else Style:=Style-[tssIsPersistent];
end;

procedure TFormTeeSeries.CBYDateTimeClick(Sender: TObject);
begin
  TheSeries.YValues.DateTime:=CBYDateTime.Checked;
end;

procedure TFormTeeSeries.CBXDateTimeClick(Sender: TObject);
begin
  TheSeries.XValues.DateTime:=CBXDateTime.Checked;
end;

procedure TFormTeeSeries.CBDataSourcestyleChange(Sender: TObject);

  Procedure CheckOldSource;
  var tmpSource : TTeeSeriesSource;
  begin
    { if the datasource is an internal "Series Source",
      remove and free it ! }
    if Assigned(TheSeries.DataSource) and
       (TheSeries.DataSource is TTeeSeriesSource) and
       (TheSeries.DataSource.Owner=TheSeries) then
    begin
      tmpSource:=TTeeSeriesSource(TheSeries.DataSource);
      tmpSource.Series:=nil;
      tmpSource.Free;
      TheSeries.DataSource:=nil;
      TheSeries.Clear;
    end;

    TheSeries.SetFunction(nil);
  end;

begin
  if Assigned(DataSourceStyle) then
     DataSourceStyle.BApply.Enabled:=False;

  { change datasource form }
  Case CBDataSourceStyle.ItemIndex of
     0: begin  // Manual data. No source.
          CheckOldSource;
          TChartSeriesAccess(TheSeries).ManualData:=True;
        end;
     1: CheckOldSource; // Random values.
  end;

  CreateDataSourceForm;
end;

procedure TFormTeeSeries.DestroyDataSourceForm;
begin
  if Assigned(DataSourceStyle) and DataSourceStyle.CloseQuery then
     FreeAndNil(DataSourceStyle);
end;

procedure TFormTeeSeries.CreateDataSourceForm;

  Procedure EnableButton(AButton:TButton);
  begin
    AButton.Visible:=Assigned(AButton.OnClick);
  end;

var tmpForm   : TCustomForm;
    tmpSource : TTeeSeriesSourceClass;
    tmpNum    : Integer;
begin
  DestroyDataSourceForm;

  if not Assigned(DataSourceStyle) then
  begin
    NewDataButton.Visible:=False;
    EditDataButton.Visible:=False;
    DeleteDataButton.Visible:=False;

    ChartGrid1.Visible:=False;
    ChartGridNavigator1.Visible:=False;

    if CBDataSourceStyle.ItemIndex=0 then

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -