unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ImgList, CnAOTreeView, CnAutoOption, Spin, ComCtrls,
  Menus, Buttons, ExtCtrls;

type
  TForm1 = class(TForm)
    Panel2: TPanel;
    pnlTreeView: TPanel;
    Label1: TLabel;
    Edit1: TEdit;
    CheckBox1: TCheckBox;
    Button1: TButton;
    BitBtn1: TBitBtn;
    BitBtn2: TBitBtn;
    BitBtn3: TBitBtn;
    HotKey1: THotKey;
    Memo1: TMemo;
    procedure FormCreate(Sender: TObject);
    procedure BitBtn1Click(Sender: TObject);
    procedure BitBtn2Click(Sender: TObject);
    procedure BitBtn3Click(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
  private
    { Private declarations }
    Option: TCnOptionGroup;
    TreeView: TCnAOTreeView;
    FDate: TDate;
    FDateTime: TDateTime;
    FTime: TTime;
    FIntValue: Integer;
    procedure SetDate(const Value: TDate);
    procedure SetDateTime(const Value: TDateTime);
    procedure SetTime(const Value: TTime);
  public
    { Public declarations }
  published
    property DateTime: TDateTime read FDateTime write SetDateTime;
    property Date: TDate read FDate write SetDate;
    property Time: TTime read FTime write SetTime;
    property IntValue: Integer read FIntValue write FIntValue;
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
  FDateTime := Now;
  FDate := Now;
  FTime := Now;
  FIntValue := 2;
  Option := TCnOptionGroup.Create(nil);
  Option.Text := '自动参数设置演示程序';
  with Option.AddGroup('应用程序主窗体') do
  begin
    AddItem(Self, 'Caption', '标题');
    AddItem(Self, 'Height', '高度');
    AddItem(Self, 'Width', '宽度');
    AddItem(Self, 'Align', '对齐方式');
    AddItem(Self, 'Anchors', '位置锚定方式', '左'#13#10'上'#13#10'右'#13#10'下');
    AddItem(Self, 'DateTime', '日期时间');
    AddItem(Self, 'Date', '日期');
    AddItem(Self, 'Time', '时间');
    AddItem(Self, 'IntValue', '整数索引下拉列表', '编号一'#13#10'编号二'#13#10'编号三');
    AddItem(Memo1, 'Lines', '字符串列表');
  end;
  
  with Option.AddGroup('Label1 控件') do
  begin
    AddItem(Label1, 'Caption', '标题', '可选项目一'#13#10'可选下拉二'#13#10'文本三');
    AddItem(Label1, 'Hint', '提示信息');
    AddItem(Label1, 'ShowHint', '是否显示提示信息');
    AddItem(Label1, 'Color', '颜色');
    AddItem(Label1, 'Font', '字体');
    AddItem(Label1.Font, 'Style', '字体风格');
  end;
  
  with Option.AddGroup('Checkbox1 检查框控件') do
  begin
    AddItem(CheckBox1, 'Checked', '是否选择');
    AddItem(CheckBox1, 'Caption', '标题');
    AddItem(CheckBox1, 'Enabled', '是否可用');
    AddItem(CheckBox1, 'Visible', '是否可见');
    AddItem(CheckBox1.Font, 'Style', '字体风格');
  end;

  with Option.AddGroup('Button1 按钮控件') do
  begin
    AddItem(Button1, 'Caption', '标题');
    AddItem(Button1, 'Height', '按钮高度');
    AddItem(Button1, 'Width', '按钮宽度');
  end;

  with Option.AddGroup('HotKey1 控件') do
  begin
    AddItem(HotKey1, 'Hotkey', '快捷键');
    AddItem(HotKey1, 'modifiers', 'Modifiers');
    AddItem(HotKey1, 'InvalidKeys', 'InvalidKeys');
  end;

  TreeView := TCnAOTreeView.Create(Self);
  TreeView.Parent := pnlTreeView;
  TreeView.Align := alClient;
  TreeView.Options := Option;
end;

procedure TForm1.SetDate(const Value: TDate);
begin
  FDate := Value;
end;

procedure TForm1.SetDateTime(const Value: TDateTime);
begin
  FDateTime := Value;
end;

procedure TForm1.SetTime(const Value: TTime);
begin
  FTime := Value;
end;

procedure TForm1.BitBtn1Click(Sender: TObject);
begin
  TreeView.ApplyOption;
end;

procedure TForm1.BitBtn2Click(Sender: TObject);
begin
  TreeView.ResetOption;
end;

procedure TForm1.BitBtn3Click(Sender: TObject);
begin
  TreeView.DefaultOption;
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
  Option.Free;
end;

end.
