{**************************
桌面相框 script Ver1.0 by snowfox
History:
  2006-03-21: + create this file
**************************}
const
  RowHeight=30;
  RowSep=15;

var
  i: Integer;
  fIconBitmapName:string;
  
  ts1:TTabSheet;
  lblPath,lblInterval,lblMaxSize, lblPicFrameType:TLabel;
  edtPath:TEdit;
  btnSelPath:TButton;
	seInterval,seMaxSize:TSpinEdit;
  cbbPicFrameType:TComboBox;
  
//Init Skin form setting
procedure InitSetting;
var
	s:string;
	inifn:TIniFile;
	//lst:TStrings;
	//i:integer;
begin
  inifn:=TIniFile.create(SkinFileName);
	//lst:=TStringList.create;
  with inifn do
  try
    //Tab1
    edtPath.text:=ReadString('Item0','BitmapPath','<#PATH_SYS_MyPictures>');
		seInterval.value:=ReadInteger('Item0','Interval',60);
		seMaxSize.value:=ReadInteger('Item0','MaxSize',200);  	
		s:=ReadString('Item0','FramePath','Black Lacquer');
		cbbPicFrameType.ItemIndex:=cbbPicFrameType.Items.IndexOf(s);
  finally
    inifn.free;
    //lst.free;
  end;
end;

//save Skin form setting
function SaveSetting:boolean;
var
	s:string;
	inifn:TIniFile;
	i:integer;
begin
  result:=false;
  inifn:=TIniFile.create(SkinFileName);
  with inifn do
  try
    //Tab1
    i:=length(SkinPath);
    edtPath.text:=LowerCase(edtPath.text);
    if pos(SkinPath,edtPath.text)=1 then
      s:=copy(fIconBitmapName,i+1,length(edtPath.text)-i)
    else
      s:=edtPath.text;
    if LowerCase(ReadString('Item0','BitmapPath','<#PATH_SYS_MyPictures>'))<>s then
    	WriteString('Item0','BitmapPath',s);
		//if DirectoryExists(s) then 
		  begin
		  WriteString('system','BackgroundBitmapName',''); 
		  WriteString('Item0','BackgroundBitmap',''); 
		  end;
		WriteInteger('Item0','Interval',seInterval.value);
		WriteInteger('Item0','MaxSize',seMaxSize.value); 
		WriteInteger('system','Width',seMaxSize.value);  	
		WriteInteger('system','Height',seMaxSize.value);  
		WriteString('Item0','FramePath',cbbPicFrameType.text);
			
   	result:=true;
    InitSkin; 

  finally
    inifn.free;
  end;
end;

procedure CreateTab1;
begin
  //--- Tab 1 ---
  ts1:=TTabSheet.Create(pgc);
  ts1.PageControl:=pgc;
  ts1.Caption:='相框设置';
  
	lblPath:=TLabel.create(self);
	with lblPath do
	begin
    parent:=ts1;
    left:=16; top:=16; width:=100;
    caption:='图片文件夹路径：';
	end;
  edtPath:=TEdit.create(self);
  with edtPath do
  begin
    parent:=ts1;
    left:=16; top:=32; width:=250;
    text:='';
  end;
  btnSelPath:=TButton.create(self);
  with btnSelPath do
  begin
    parent:=ts1;
    left:=276; top:=32; width:=90; height:=23;
    caption:='选择文件夹...';
    OnClick:=@btnSelPathClick;
  end;
	lblInterval:=TLabel.create(self);
	with lblInterval do
	begin
    parent:=ts1;
    left:=16; top:=75; width:=145;
    caption:='更换图片的间隔时间(秒)：';
	end;
	seInterval:=TSpinEdit.create(self);
	with seInterval do
	begin
	  parent:=ts1;
	  left:=152; top:=72; width:=65;
	end;
	lblMaxSize:=TLabel.create(self);
	with lblMaxSize do
	begin
    parent:=ts1;
    left:=16; top:=99; width:=145;
    caption:='图片相框的最大宽/高：';
	end;
	seMaxSize:=TSpinEdit.create(self);
	with seMaxSize do
	begin
	  parent:=ts1;
	  left:=152; top:=96; width:=65;
	  MinValue:=50; MaxValue:=1024;
	end;
  
  lblPicFrameType:=TLabel.create(self);
  with lblPicFrameType do
  begin
    parent:=ts1;
    left:=8; top:=123; width:=60;
    caption:='相框类型：';
  end;
	cbbPicFrameType:=TComboBox.create(self);
	with cbbPicFrameType do
	begin
	  parent:=ts1;
	  left:=72; top:=120; width:=145;
	  DropDownCount:=15;
    //Style:=csDropDownList;
    items.text:=GetPathList(g_ResPath+'PictureFrame\');
	end;
end;

procedure btnSelPathClick(Sender:TObject);
var
  Dir: string;
begin
  Dir := edtPath.text;
  if SelectDir('请选择相框图片的目录：','',Dir) then
    edtPath.text := Dir;
end;



begin
  CreateTab1;
  InitSetting;
  
end.