function WeatherTypeToIndex(aType:string):string;
var
  s:string;
  i:Integer;
begin
  Result:='';
  case aType of
    'Sunny': i:=32;
	  'CloudyLightPartly': i:=34;
    'CloudyPartly': i:=28;
    'CloudyMostly': i:=26;
    'SunnyHot': i:=36;
    'Cloudy': i:=26;
    'RainLight': i:=11;
    'Rain': i:=11;
    'RainHeavy': i:=11;
    'ShowerLight': i:=9;
    'Shower': i:=9;
    'ShowerHeavy': i:=9;
    'LighteningLight': i:=3;
    'Lightening': i:=3;
    'Thunderstorms': i:=3;
    'RainIcyLight': i:=7;
    'RainnIcy': i:=7;
    'RainIcyHeavy': i:=7;
    'SnowRainMix': i:=7;
    'SnowLight': i:=41;
    'Snow': i:=41;
    'Snowflakes': i:=15;
    'SnowHeavy': i:=16;
    'SnowWindy': i:=16;
    'Hail': i:=16;
    'Dust': i:=19;
    'Fog': i:=22;
    'Haze': i:=23;
    'Smoke': i:=22;
    'Windy': i:=23;
    'Frigid': i:=41;
    'Night_CloudyMostly': i:=26;
    'Night_CloudyPartly': i:=27;
    'Night_LightPartlyCloudy': i:=28;
    'Night_Clear': i:=32;
    'Night_Rain': i:=11;
    'Night_Snow': i:=41;
    'Night_Thunderstorms': i:=3;
    'NA': i:=45;
  else
    i:=-1;
  end;
  try
    Result:=inttostr(i);
  except

  end;
end;

//更新皮肤中的天气显示信息
procedure WeatherChange;
var
  s,sIcon:string;
  h,m:integer;
begin
  Beginupdate;  
  DecodeTime(now,h,m,m,m);
  if (h>=6) and (h<19) then
    imgbg.FileName:=WidgetPath+'images\bgBlue.png'
  else
    imgbg.FileName:=WidgetPath+'images\bgBlack.png';
  lblcity.caption:=GetWeatherInfo(0,'City');
  lblw0Desc.caption:=GetWeatherInfo(0,'desc');
  lblw0h.caption:=GetWeatherInfo(0,'tmphigh')+'°C';
  lblw0l.caption:=GetWeatherInfo(0,'tmplow')+'°C';
  imgw0.Hint:=GetWeatherDayDesc(0);
  imgw0.FileName:=WidgetPath+'images\small\'+WeatherTypeToIndex(GetWeatherInfo(0,'Type'))+'.png';
  lblw1Desc.caption:=GetWeatherInfo(1,'desc');
  lblw1h.caption:=GetWeatherInfo(1,'tmphigh')+'°C';
  lblw1l.caption:=GetWeatherInfo(1,'tmplow')+'°C';
  imgw1.Hint:=GetWeatherDayDesc(1);
  imgw1.FileName:=WidgetPath+'images\small\'+WeatherTypeToIndex(GetWeatherInfo(1,'Type'))+'.png';
  lblw2Desc.caption:=GetWeatherInfo(2,'desc');
  lblw2h.caption:=GetWeatherInfo(2,'tmphigh')+'°C';
  lblw2l.caption:=GetWeatherInfo(2,'tmplow')+'°C';
  imgw2.Hint:=GetWeatherDayDesc(2);
  imgw2.FileName:=WidgetPath+'images\small\'+WeatherTypeToIndex(GetWeatherInfo(2,'Type'))+'.png';
  EndUpdate;
end;

//--- Widget移入边栏事件，当Widget被移到边栏上时会触发此事件 ---
procedure OnWidgetDock;
begin
  BeginUpdate;
  Widget.Width:=134;
  EndUpdate;
end;

//--- Widget移出边栏事件，当Widget被移出边栏时会触发此事件 ---
procedure OnWidgetUnDock;
begin
  BeginUpdate;
  Widget.Width:=145;
  EndUpdate;
end;

//读取当前Widget的INI设置
procedure InitIni;
begin
  if Docking then OnWidgetDock;
end;

//--- Widget初始化事件，当打开Widget时会触发此事件 ---
procedure OnWidgetInit;
begin
  BeginUpdate;
  InitIni;
  WeatherChange;
  if Docking then 
  	OnWidgetDock
  else
    OnWidgetUnDock;
  EndUpdate;
end;

//--- Widget关闭事件，当关闭Widget时会触发此事件 ---
procedure OnWidgetClose;
begin
  
end;

//--- 天气刷新事件，当天气成功刷新后会触发此事件 ---
procedure OnRefreshWidgetWeatherInfo;
begin
  WeatherChange;
end;

