{**************************
Dashboard Weather OnSetting script Ver1.0 by snowfox
**************************}
var
  ts1:TTabSheet;
  //Tab1
  chkNetWeather:TCheckBox;
  lblNetWeatherSetting:TLabel;
  
  isNeedRefreshNetWeather:boolean;

  
//Init Skin form setting
procedure InitSetting;
var
	s:string;
	inifn:TIniFile;
	bColor,bTrans:Boolean;
begin
  inifn:=TIniFile.create(SkinFileName);
  with inifn do
  try
    //Tab1
		chkNetWeather.checked:=ReadBool('system','isCustomNetWeather',false);
    if not chkNetWeather.checked then
      lblNetWeatherSetting.Enabled:=false;
  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
    //
		WriteBool('system','isCustomNetWeather',chkNetWeather.checked);

    InitSkin; 
  finally
    inifn.free;
  end;
  if isNeedRefreshNetWeather then RefreshNetWeather;
end;

//---界面设置---
procedure CreateTab1;
begin
  ts1:=TTabSheet.Create(pgc);
  ts1.PageControl:=pgc;
  ts1.Caption:='天气服务器设置';
  
	chkNetWeather:=TCheckBox.create(self);
	with chkNetWeather do
	begin
	  parent:=ts1;
	  caption:='自定义网络天气预报';
	  left:=16; top:=16; width:=161;
	  OnClick:=@chkNetWeatherClick;
	end;
	lblNetWeatherSetting:=TLabel.create(self);
	with lblNetWeatherSetting do
	begin
	  parent:=ts1; 
	  Caption:='网络天气预报设置...';
	  left:=16; top:=40; width:=114;
	  font.color:=$008C6D52;
	  cursor:=crHandPoint;
	  OnClick:=@lblNetWeatherSettingOnClick;
	end;
end;

procedure chkNetWeatherClick(Sender: TObject);
begin
  lblNetWeatherSetting.Enabled:=chkNetWeather.checked;
end;

procedure lblNetWeatherSettingOnClick(Sender: TObject);
begin
  isNeedRefreshNetWeather:=ShowWeatherConfigDlg(SkinFileName);
end;

begin
  CreateTab1;
  InitSetting;
  
end.