{**************************
Dashboard Clock OnSetting script Ver1.0 by snowfox
**************************}
var
  ts1:TTabSheet;
  lblbgColor,lblTime,lblRun,lblHHMMSS:TLabel;
  cbbbgType:TComboBox;
  edtHH,edtMM,edtSS:TSpinEdit;
  edtRun:TEdit; 
  btnRun:TButton;
  
  
//Init Skin form setting
procedure InitSetting;
var
	s:string;
	inifn:TIniFile; 
begin
  inifn:=TIniFile.create(SkinFileName);
  with inifn do
  try
    s:=ReadString('Item0','Type','TimerOrder-'); 
    if s='TimerOrder-' then 
      cbbbgType.itemindex:=1
      else
      cbbbgType.itemindex:=0;
    edtHH.Value:=ReadInteger('Item0','ItemHH',0); 
    edtMM.Value:=ReadInteger('Item0','ItemMM',0); 
    edtSS.Value:=ReadInteger('Item0','ItemSS',0); 
    edtRun.text:=ReadString('Item0','RunFile','');  
    
  finally
    inifn.free;
  end;
end;

//save Skin form setting
function SaveSetting:boolean;
var
	s:string;
	inifn:TIniFile;
	i:integer;
	bColor,bTrans:Boolean;
begin
  result:=true;
  inifn:=TIniFile.create(SkinFileName);
  with inifn do
  try 
    if cbbbgType.itemindex=1 then 
      WriteString('Item0','Type','TimerOrder-')
      else
      WriteString('Item0','Type','TimerOrder+');
    WriteString('Item0','ItemHH',IntToStr(edtHH.Value));
    WriteString('Item0','ItemMM',IntToStr(edtMM.Value));
    WriteString('Item0','ItemSS',IntToStr(edtSS.Value));
    WriteString('Item0','RunFile',edtRun.text); 
          
    InitSkin; 
  finally
    inifn.free;
  end;
  
end;

//---界面设置---
procedure CreateTab1;
begin
  ts1:=TTabSheet.Create(pgc);
  ts1.PageControl:=pgc;
  ts1.Caption:='计时器设置';
  
  lblbgColor:=TLabel.create(self);
  with lblbgColor do
  begin
    parent:=ts1;
    left:=16; top:=12; width:=84;
    caption:='计时方式：';
  end;
  cbbbgType:=TComboBox.create(self);
  with cbbbgType do
  begin
    parent:=ts1;
    left:=16; top:=28; width:=137;
    DropDownCount:=15; 
    Items.Add('正序');
    Items.Add('倒序');
    //OnChange:=@cbbbgTypeChange;
    Style:=csDropDownList;
  end;
  lblTime:=TLabel.create(self);
  with lblTime do
  begin
    parent:=ts1;
    left:=16; top:=33+20; width:=84;
    caption:='计时时间：';
  end;
  lblHHMMSS:=TLabel.create(self);
  with lblHHMMSS do
  begin
    parent:=ts1;
    left:=16+40+5; top:=33+20+20; width:=184;
    caption:='时        分        秒';
  end;
  
  
  edtHH:=TSpinEdit.create(self);
  with edtHH do 
    begin
    parent:=ts1;
    MaxLength:=2; MaxValue:=24; MinValue:=0;
    left:=16; top:=33+20+15; width:=40;
    end;
  edtMM:=TSpinEdit.create(self);
  with edtMM do 
    begin
    parent:=ts1;
    MaxLength:=2; MaxValue:=59; MinValue:=0;
    left:=16+30+30; top:=33+20+15; width:=40;
    end;
  edtSS:=TSpinEdit.create(self);
  with edtSS do 
    begin
    parent:=ts1;
    MaxLength:=2; MaxValue:=59; MinValue:=0;
    left:=16+30+30+30+30; top:=33+20+15; width:=40;
    end;
  lblRun:=TLabel.create(self);
  with lblRun do
  begin
    parent:=ts1;
    left:=16; top:=33+20+20+22; width:=84;
    caption:='计时到时运行文件：';
  end;
  edtRun:=TEdit.create(self);
  with edtRun do 
  begin
    parent:=ts1;
    left:=16; top:=33+20+20+20+17; width:=204;
  end;
  btnRun:=TButton.create(self);
  with btnRun do 
    begin
    parent:=ts1;
    left:=16+204+10;top:=33+20+20+20+15; width:=100; height:=23;
    Caption:='选择运行文件...';
    OnClick:=@BtnRunClick;
    end;
end;


procedure  BtnRunClick(Sender: TObject);
var
  dlgOpen:TOpenDialog;
begin
  dlgOpen:=TOpenDialog.create(self); 
  if dlgOpen.Execute then
  try 
    edtRun.text:=dlgOpen.filename;
  finally
    dlgOpen.free;  
  end;
end;
  
  

begin
  CreateTab1;
  InitSetting;
  
end.