////示例脚本  object pascal 语言编写
////作者:  醉拥孤衾&cfish828
////创建时间: 2006-7-25

var
  Label0,ListBox0,ComboBox0,ComboBox1,ComboBox2,XDSEdit0,XDSEdit1,XDSEdit2,XDSEdit3;
  XDSSpinEdit0,XDSSpinEdit1,XDSSpinEdit2,XDSSpinEdit3,XDSSpinEdit4,XDSSpinEdit5,XDSSpinEdit6;


Function InputForm(cap,title,def);
begin
  fm := TForm.CreateForm;
  fm.Caption := cap;
  fm.Width := 240;
  fm.Height := 130;
  fm.BorderStyle := bsToolWindow;
  fm.Position := poDesktopCenter;
  fm.font.name := '宋体';
  fm.font.size := 9;
  //------文本 Label0
  Label0 :=  TLabel.Create( fm ); 
  Label0.Parent := fm; 
  Label0.Left := 16; 
  Label0.top := 22;
  Label0.width := 108; 
  Label0.height := 12;
  Label0.AutoSize := -1; 
  Label0.WordWrap := 0; 
  Label0.Caption := title;

  //------编辑框 XDSEdit0
  XDSEdit0 :=  TXDSEdit.Create( fm ); 
  XDSEdit0.Parent := fm; 
  XDSEdit0.Left := 16; 
  XDSEdit0.top := 40; 
  XDSEdit0.width := 209; 
  XDSEdit0.height := 20; 
  XDSEdit0.Text := def;
  XDSEdit0.LinkStyle := lsNormal; 

  //------按钮 BitBtn0
  BitBtn0 :=  TBitBtn.Create( fm ); 
  BitBtn0.Parent := fm; 
  BitBtn0.Left := 77; 
  BitBtn0.top := 72; 
  BitBtn0.width := 75; 
  BitBtn0.height := 25; 
  BitBtn0.Caption := '确定';
  BitBtn0.ModalResult := 1;
  BitBtn0.onclick := 'BitBtn10Click';

  //------按钮 BitBtn1
  BitBtn1 :=  TBitBtn.Create( fm ); 
  BitBtn1.Parent := fm; 
  BitBtn1.Left := 152; 
  BitBtn1.top := 72; 
  BitBtn1.width := 75; 
  BitBtn1.height := 25; 
  BitBtn1.Caption := '取消'; 
  BitBtn1.ModalResult := 2;


  //----显示配置窗口----
  if fm.ShowModal = mrOk then
  begin
    Result := XDSEdit0.Text;
  end
  else
    Result := '';
  fm.free;
end;


//当widget保存配置信息的时候触发此事件,并执行此函数内代码.
procedure OnSaveIni;
var
  index;
begin
  //如果自定义了某些变量,请在这里将自定义的配置信息保存
  //SaveIni(name,value);
    SaveIni('iconSize',xInt[100]);
    SaveIni('iconHotSize',xInt[101]);
    SaveIni('iconTopOffset',xInt[102]);
    SaveIni('bgTop',xInt[103]);
    SaveIni('IconSpace',xInt[104]);
    SaveIni('IconLeft',xInt[106]);
    SaveIni('IconCount',xInt[105]);
    SaveIni('IconDir',xStr[500]);
    SaveIni('labelFontname',xStr[501]);
    SaveIni('labelFontSize',xStr[502]); 
    SaveIni('BgDir',xStr[503]);
    SaveIni('IconHotDirection',xInt[107]);
    SaveIni('BgMidWidthOffset',xInt[108]);
    saveIni('EnableMouseActive',xBool[100]);


    for index:=0 to xInt[105]-1 do
    begin
      SaveIni('Label'+inttostr(index),xStr[index]);
      SaveIni('File'+inttostr(index),xStr[50+index]);
      SaveIni('Argu'+inttostr(index),xStr[100+index]);
    end;

end;

//当widget保存默认配置信息的时候触发此事件,并执行此函数内代码.
procedure OnSaveDefIni;
var
  index;
begin
  //如果自定义了某些变量,可以在这里将自定义的配置信息写入默认ini文件,以便克隆新建的插件沿用此配置
  //SaveDefIni(name,value);
    SaveDefIni('iconSize',xInt[100]);
    SaveDefIni('iconHotSize',xInt[101]);
    SaveDefIni('iconTopOffset',xInt[102]);
    SaveDefIni('bgTop',xInt[103]);
    SaveDefIni('IconSpace',xInt[104]);
    SaveDefIni('IconCount',xInt[105]);
    SaveDefIni('IconLeft',xInt[106]);
    SaveDefIni('IconDir',xStr[500]);
    SaveDefIni('labelFontname',xStr[501]);
    SaveDefIni('labelFontSize',xStr[502]);
    SaveDefIni('BgDir',xStr[503]);
    SaveDefIni('IconHotDirection',xInt[107]);
    SaveDefIni('BgMidWidthOffset',xInt[108]);
    saveDefIni('EnableMouseActive',xBool[100]);

    for index:=0 to xInt[105]-1 do
    begin
      SaveDefIni('Label'+inttostr(index),xStr[index]);
      SaveDefIni('File'+inttostr(index),xStr[50+index]);
      SaveDefIni('Argu'+inttostr(index),xStr[100+index]);
    end;
end;


//插件初始化函数   用于资源和图片的载入等初始化
procedure Init;
var
  i : integer;
  count,size:integer;
  EnableMouseActive : boolean;
begin
  //位置大小配置
  iconSize := strtointDef(LoadIni('iconSize','90'),90);
  iconHotSize := strtointDef(LoadIni('iconHotSize','100'),100);
  IconDir := LoadIni('IconDir','Icon1');
  BgDir := LoadIni('BgDir','Default');
  bgTop := strtointDef(LoadIni('bgTop','100'),100);  //背景图片的y坐标
  iconTopOffset :=  strtointDef(LoadIni('iconTopOffset','55'),55);   //图标y坐标
  IconSpace := strtointDef(LoadIni('IconSpace','10'),10);  //图标之间的间隔
  IconCount := strtointDef(LoadIni('IconCount','5'),5);//图标的个数
  IconLeft :=  strtointDef(LoadIni('IconLeft','20'),20);//图标的左边距、横坐标
  EnableMouseActive := StrToBool(LoadIni('EnableMouseActive','1'));  //是否鼠标激活
  IconHotDirection := strtointDef(LoadIni('IconHotDirection','1'),1);//图标放大的方向
  BgMidWidthOffset :=  strtointDef(LoadIni('BgMidWidthOffset','0'),0);//背景中间图片宽度偏移值

  labelFontname := LoadIni('labelFontname','黑体');
  labelFontSize := LoadIni('labelFontSize','12');

  //将变量存入全局数组变量中
  xInt[100] := iconSize;
  xInt[101] := iconHotSize;
  xInt[102] := iconTopOffset;
  xInt[103] := bgTop;
  xInt[104] := IconSpace;
  xInt[105] := IconCount;
  xInt[106] := IconLeft;
  xInt[107] := IconHotDirection;
  xInt[108] := BgMidWidthOffset;


  xStr[500] := IconDir;
  xStr[501] := labelFontname;
  xStr[502] := labelFontSize;
  xStr[503] := BgDir;  //背景目录名称

  xBool[100] := EnableMouseActive;//是否启用鼠标激活

  //全局控制变量
  xInt[150] := 0 ;  //当前编辑属性的图标序号


  GetRecyclInfo(count,size);
  xInt[1000] := count;  //xint[1000]用于专门存放上次回收站内文件数量
  xStr[1000] := formatfloat('0.0',size); //专门用于存放上次回收站的

  for i:=0 to IconCount-1 do
  begin
    //从配置中载入标签
    xStr[i] := LoadIni('Label'+inttostr(i),'快捷方式'+inttostr(i));

    //从配置中载入 指向的文件路径
    xStr[50+i] := LoadIni('File'+inttostr(i),'');

    //从配置中载入 指向的文件路径
    xStr[100+i] := LoadIni('Argu'+inttostr(i),'');
  end;


  //设置背景图片的坐标
  BackgroundLeft := 0;
  BackgroundTop := bgTop - 47;

  //载入背景图片
  AddImage(0,widgetpath + 'bg\' + BgDir + '\bg_left.png');
  AddImage(1,widgetpath + 'bg\' + BgDir + '\bg_mid.png');
  AddImage(2,widgetpath + 'bg\' + BgDir + '\bg_right.png');

  SetImagePro(1,'stretch', 'true' );

  SetImagePro(0,'top',bgTop);
  SetImagePro(1,'top',bgTop);
  SetImagePro(2,'top',bgTop);

  SetImagePro(0,'left',0);
  SetImagePro(1,'left', GetImagePro(0,'width') );
  SetImagePro(1,'width', iconCount*(iconSize + IconSpace) - IconSpace + BgMidWidthOffset );
  SetImagePro(2,'left', GetImagePro(0,'width') + GetImagePro(1,'width')   );

  //设置整个widget插件的宽度和高度
  widgetWidth := 100 + GetImagePro(0,'width') + GetImagePro(1,'width')  + GetImagePro(2,'width') ;
  widgetHeight := 200+getimageintegerpro(0,'height') + bgTop ;

  //添加文字
  AddLabel(0,'');
  SetLabelPro(0,'fontStr','clwhite/-12/' + labelFontname + '/' + labelFontSize + '/1000');
  SetLabelPro(0,'text','');
//  SetLabelPro(0,'alpha','255');
  SetLabelPro(0,'width','200');  //
  SetLabelPro(0,'AutoSize','false');  //
  SetLabelPro(0,'top','10');
  SetLabelPro(0,'Align','1');  // 0为左对齐  1为居中  2为右对齐

  SetLabelPro(0,'EnableShadow','true');
  SetLabelPro(0,'shadowalpha','255');
  SetLabelPro(0,'shadowcolor','clBlack');
  SetLabelPro(0,'shadowleft','0');
  SetLabelPro(0,'shadowtop','0');
  SetLabelPro(0,'shadowBlur','3');


 //添加文字
  AddLabel(1,'XDeskDock');
  SetLabelPro(1,'fontStr','clBlack/-12/黑体/12/1000');
  SetLabelPro(1,'visible','false');
  SetLabelPro(1,'width','300');//
  SetLabelPro(1,'top','30');//
  SetLabelPro(1,'AutoSize','false');  //
  SetLabelPro(1,'Align','1');  // 0为左对齐  1为居中  2为右对齐

  //添加按钮
  for i:=0 to IconCount-1 do
  begin
    AddButton(i,false,widgetpath + 'Icons\' + IconDir + '\' + inttostr(i)+'.png');
    SetButtonPro(i,'alpha','255');
    SetButtonPro(i,'left',IconLeft + i*iconSize + i*IconSpace);
    SetButtonPro(i,'top',iconTopOffset);
    SetButtonPro(i,'width',iconSize);
    SetButtonPro(i,'height',iconSize);
    SetButtonPro(i,'stretch','true');
    SetButtonPro(i,'EnableHotSize','true');
    SetButtonPro(i,'HotSizeOffset', iconHotSize - iconSize );
    SetButtonPro(i,'hotdirection',IconHotDirection);
    SetButtonPro(i,'quality','2');
//    SetButtonPro(i,'hint',xStr[50+i]   );
    SetButtonPro(i,'filepath',xStr[50+i]   );
    SetButtonPro(i,'EnableSystemPopMenu','true');
    SetButtonPro(i,'AcceptDropFile','true');
  end;


  if xInt[1000]>0 then
  begin
    for i:=0 to IconCount-1 do
    begin
      if xStr[50+i] = '回收站' then
        SetButtonPro(i,'normalpicture',widgetpath + 'Icons\' + IconDir + '\' + inttostr(i) + '_full.png');
    end;
  end;

  nCustMenu0.Visible := true;
  nCustMenu1.Visible := true;
  nCustMenu2.Visible := true;
  nCustMenu3.Visible := true;
  nCustMenu4.Visible := true;
  nCustMenu5.Visible := true;
  nCustMenu6.Visible := true;
  nCustMenu7.Visible := true;
  nCustMenu8.Visible := true;
  nCustMenu9.Visible := true;

  nCustMenu0.caption := '添加新图标...';
  nCustMenu1.caption := '删除最后一个图标';
  nCustMenu2.caption := '-';
  nCustMenu3.caption := '管理图标和快捷方式...';
  nCustMenu4.caption := '大小位置和背景设置...';
  if xBool[100] then
    nCustMenu5.caption := '禁用鼠标激活'
  else
    nCustMenu5.caption := '启用鼠标激活';
  nCustMenu6.caption := '更换标签字体...';
  nCustMenu7.caption := '-';
  nCustMenu8.caption := '主题管理';
  nCustMenu9.caption := '-';
end;


procedure OnDrawWidget;
begin

  InheritDrawWidget;

end;

//启动插件事件
procedure StartWidget;
begin
  //启动定时器0 每1000毫秒执行一次
  SetTimer(0,1000,true);

  //设置一个定时器用于鼠标激活
  SetTimer(1,500,xBool[100]);

end;

//双击插件事件
procedure OnDBClickWidget;
begin
//  RefreshWidget;
end;


//定时器定时执行此函数代码
procedure OnTimer(index);
var
  count,size;
  x,y;
  top,left,right,bottom;
begin
  Case index of
    0:
    begin
      GetRecyclInfo(count,size);
      if xInt[1000]=count then
        exit;

      for i:=0 to xInt[105]-1 do
      begin
        if xStr[50+i] = '回收站'  then
        begin
          if count>0 then
            SetButtonPro(i,'normalpicture',widgetpath + 'Icons\' + xStr[500] + '\' + inttostr(i) + '_full.png')
          else
            SetButtonPro(i,'normalpicture',widgetpath + 'Icons\' + xStr[500] + '\' + inttostr(i) + '.png');
          SetButtonPro(i,'quality','2');
        end;
      end;

      xInt[1000] := count;  //xint[1000]用于专门存放上次回收站内文件数量
      xStr[1000] := formatfloat('0.0',size); //专门用于存放上次回收站的

      RefreshWidget;


    end;
    1:
      begin
        if not xBool[100] then exit;

        GetMousePos (x,y);
        top := GetWidgetTop + xInt[103];
        left := GetWidgetLeft ;
        right := GetWidgetLeft + GetImagePro(0,'width') + GetImagePro(1,'width') + GetImagePro(2,'width') ;
        bottom := GetWidgetTop + xInt[103] + GetImagePro(0,'height');

        if (x>=left) and (x<=right) and (y>=top) and  (y<=bottom) then
        begin
       //   xBool[100] := true;
          BringWidgetToFront;
        end;

      end;
    2:
      begin

      end;
    3:
      begin

      end;
    end;

end;



//当某个按钮被点击后,执行此函数代码. 传入的index为被点击的按钮的序号
procedure OnButtonClick(index);
begin
  if xStr[50 + index]='关机' then
  begin
    shellapp := CreateOleObject('Shell.Application');
    shellapp.shutdownwindows;
    shellapp := Unassigned;
  end
  else if uppercase(xStr[50 + index])='QQ' then
  begin
    Run( GetQQInstallPath + 'qq.exe' ,xStr[100 + index],1);
  end
  else
    Run(xStr[50 + index],xStr[100 + index],1);
  //如果希望打开的文件夹使用资源管理器方式，也就是说左侧有文件夹树型列表的
  //请启用一下语句
  //RunEx(xStr[50 + index],xStr[100 + index],1);
end;

procedure OnButtonHot(index);
begin
//  RefreshWidget;

  SetLabelPro(0,'text',xStr[index]);
  SetLabelPro(0,'visible','true');
  SetLabelPro(0,'AutoSize','false');  //
  SetLabelPro(0,'left', GetButtonPro(index,'left') - xInt[104] - 100 );  //
  SetLabelPro(0,'width', xInt[100] + 2*xInt[104] + 206 );  // 图标的大小 加上 2倍的 图标间距

  IconHotDirection := xInt[107];
  case IconHotDirection of
    0:
      begin
        SetLabelPro(0,'top', GetButtonPro(index,'top') - (xInt[101]-xInt[100]) - 30   );
      end;
    1:
      begin
        SetLabelPro(0,'top', GetButtonPro(index,'top') - 2*(xInt[101]-xInt[100]) - 30   );
      end;
    2:
      begin
        SetLabelPro(0,'top', GetButtonPro(index,'top') + xInt[100] + 2*(xInt[101]-xInt[100]) + 10   );
      end;
   end;

  SetLabelPro(0,'Align','1');  // 0为左对齐  1为居中  2为右对齐
  Refreshwidget;


end;

procedure OnMoveOnWidget;
begin
  SetLabelPro(0,'visible','false');
end;


//当鼠标进入widget上方时,触发此事件,将执行此函数代码.
procedure OnMouseEnterWidget;
begin

end;

procedure OnButtonDown(index);
begin
  RefreshWidget;
  Case index of
    0:
      begin
      //在这里写序号为0的按钮的down事件响应代码

      end;
    1:
      begin

      end;
    2:
      begin

      end;
    3:
      begin

      end;
    end;
end;


procedure OnMouseLeaveWidget;
begin
//  SetButtonPro(0,'visible',false);
  SetLabelPro(0,'visible','false');
  RefreshWidget;

 // xBool[100] := false;
end;

Procedure ListBox0OnClick(Sender);
var
  index;
begin
  index :=  GetListBoxItemIndex( ListBox0 );
  XDSEdit0.text := xStr[index];
  XDSEdit1.text := WidgetPath + 'Icons\' + xStr[500] + '\' + inttostr(index) + '.png';
  XDSEdit2.text := xStr[100+ Index];
  ComboBox0.Text := xStr[50+index];
  Label0.caption := '设置图标 ' + inttostr(index) + ' 的属性'
end;

Procedure MySetIconsConfigForm(flag);
var
  i,index,iconCount ;
begin
  index := 0 ;//xInt[150];
  iconCount := xInt[105];

  fm := TForm.CreateForm;
  fm.Caption := '设置图标属性';
  fm.Width := 440;
  fm.Height := 295;
  fm.BorderStyle := bsToolWindow;
  fm.Position := poDesktopCenter;
  fm.font.name := '宋体';
  fm.font.size := 9;

  //------列表框 ListBox0
  ListBox0 :=  TListBox.Create( fm );
  ListBox0.Parent := fm;
  ListBox0.Left := 8;
  ListBox0.top := 8;
  ListBox0.width := 89;
  ListBox0.height := 217;
  for i:=0 to iconCount-1 do
    ListBox0.items.add( xStr[i]  );//'设置图标' + inttostr(i));
  ListBox0.ItemHeight := 22;
  ListBox0.style := 1;
  ListBox0.OnClick := 'ListBox0OnClick';
  if flag='addnew' then
    SetListBoxItemIndex( ListBox0,ListBox0.items.count-1)
  else
    SetListBoxItemIndex( ListBox0,0);

  //------线条 Bevel0
  Bevel0 :=  TBevel.Create( fm );
  Bevel0.Parent := fm;
  Bevel0.Left := 104;
  Bevel0.top := 10;
  Bevel0.width := 321;
  Bevel0.height := 215;
  Bevel0.Style := 0;
  Bevel0.Shape := 0;

  //------文本 Label0
  Label0 :=  TLabel.Create( fm );
  Label0.Parent := fm;
  Label0.Left := 113;
  Label0.top := 6;
  Label0.width := 48;
  Label0.height := 12;
  Label0.AutoSize := -1;
  Label0.WordWrap := 0;
  Label0.Caption := '设置图标 0 的属性' ;

  //------文本 Label1
  Label1 :=  TLabel.Create( fm );
  Label1.Parent := fm; 
  Label1.Left := 112; 
  Label1.top := 31; 
  Label1.width := 48; 
  Label1.height := 12; 
  Label1.AutoSize := -1; 
  Label1.WordWrap := 0; 
  Label1.Caption := '标签名称';

  //------编辑框 XDSEdit0
  XDSEdit0 :=  TXDSEdit.Create( fm );
  XDSEdit0.Parent := fm;
  XDSEdit0.Left := 168;
  XDSEdit0.top := 27;
  XDSEdit0.width := 241;
  XDSEdit0.height := 20;
  XDSEdit0.Text :=  xStr[index];
  XDSEdit0.LinkStyle := lsNormal;

  //------文本 Label2
  Label2 :=  TLabel.Create( fm ); 
  Label2.Parent := fm; 
  Label2.Left := 112; 
  Label2.top := 59; 
  Label2.width := 48; 
  Label2.height := 12;
  Label2.AutoSize := -1; 
  Label2.WordWrap := 0; 
  Label2.Caption := '图标路径';


  //------编辑框 XDSEdit1
  XDSEdit1 :=  TXDSEdit.Create( fm ); 
  XDSEdit1.Parent := fm; 
  XDSEdit1.Left := 168; 
  XDSEdit1.top := 56; 
  XDSEdit1.width := 241; 
  XDSEdit1.height := 20; 
  XDSEdit1.Text :=  WidgetPath + 'Icons\' + xStr[500]  + '\'+ inttostr(index) + '.png';
  XDSEdit1.LinkStyle := lsEllipsis;
  XDSEdit1.OnButtonClick := 'XDSEdit1ButtonClick';

  //------文本 Label3
  Label3 :=  TLabel.Create( fm );
  Label3.Parent := fm;
  Label3.Left := 112; 
  Label3.top := 90; 
  Label3.width := 48;
  Label3.height := 12;
  Label3.AutoSize := -1; 
  Label3.WordWrap := 0; 
  Label3.Caption := '执行程序';



  //------下拉框 ComboBox0
  ComboBox0 :=  TComboBox.Create( fm );
  ComboBox0.Parent := fm;
  ComboBox0.Left := 168;
  ComboBox0.top := 86; 
  ComboBox0.width := 239; 
  ComboBox0.height := 20;
  ComboBox0.Style := 0;
  ComboBox0.DropDownCount := 20;
  ComboBox0.ItemIndex := -1;
  ComboBox0.items.add('我的电脑');
  ComboBox0.items.add('我的文档');
  ComboBox0.items.add('网上邻居');
  ComboBox0.items.add('控制面板');
  ComboBox0.items.add('回收站');
  ComboBox0.items.add('QQ');
  ComboBox0.items.add('桌面');
  ComboBox0.items.add('字体');
  ComboBox0.items.add('收藏夹');
  ComboBox0.items.add('程序');
  ComboBox0.items.add('启动');
  ComboBox0.items.add('Internet设置');
  ComboBox0.items.add('打印机设置');
  ComboBox0.items.add('最近文档');
  ComboBox0.items.add('发送到');
  ComboBox0.items.add('开始');
  ComboBox0.items.add('用户桌面');
  ComboBox0.items.add('当前用户的网络连接');
  ComboBox0.items.add('模块');
  ComboBox0.items.add('所有用户开始菜单');
  ComboBox0.items.add('所有用户程序');
  ComboBox0.items.add('所有用户开始目录');
  ComboBox0.items.add('所有用户桌面');
  ComboBox0.items.add('当前用户特定的应用程序数据存储文件夹');
  ComboBox0.items.add('网络打印机');
  ComboBox0.items.add('所有用户的“启动”文件夹');
  ComboBox0.items.add('所有用户的“收藏夹”文件夹');
  ComboBox0.items.add('Internet的缓存目录');
  ComboBox0.items.add('Cookies目录');
  ComboBox0.items.add('历史记录');
  ComboBox0.items.add('关机');
  ComboBox0.Text := xStr[50 + index];


  //------按钮 BitBtn0
  BitBtn0 :=  TBitBtn.Create( fm );
  BitBtn0.Parent := fm;
  BitBtn0.Left := 367;
  BitBtn0.top := 88;
  BitBtn0.width := 22;
  BitBtn0.height := 16;
  BitBtn0.Caption := '...';
  BitBtn0.ModalResult := 0;
  BitBtn0.OnClick := 'BitBtn1110Click';

  //------文本 Label4
  Label4 :=  TLabel.Create( fm );
  Label4.Parent := fm;
  Label4.Left := 112;
  Label4.top := 120;
  Label4.width := 24;
  Label4.height := 12;
  Label4.AutoSize := -1;
  Label4.WordWrap := 0;
  Label4.Caption := '参数';

  //------编辑框 XDSEdit2
  XDSEdit2 :=  TXDSEdit.Create( fm ); 
  XDSEdit2.Parent := fm; 
  XDSEdit2.Left := 168; 
  XDSEdit2.top := 116; 
  XDSEdit2.width := 241; 
  XDSEdit2.height := 20; 
  XDSEdit2.Text :=  xStr[100 + index];
  XDSEdit2.LinkStyle := lsNormal;

  //------线条 Bevel1
  Bevel1 :=  TBevel.Create( fm );
  Bevel1.Parent := fm; 
  Bevel1.Left := 112; 
  Bevel1.top := 152; 
  Bevel1.width := 305; 
  Bevel1.height := 10; 
  Bevel1.Style := 0; 
  Bevel1.Shape := 2;

  //------文本 Label5
  Label5 :=  TLabel.Create( fm ); 
  Label5.Parent := fm; 
  Label5.Left := 112;
  Label5.top := 168; 
  Label5.width := 264; 
  Label5.height := 12; 
  Label5.AutoSize := -1;
  Label5.WordWrap := 0; 
  Label5.Caption := '回收站满状态时的图标(执行程序为回收站时有效)';

  //------编辑框 XDSEdit3
  XDSEdit3 :=  TXDSEdit.Create( fm );
  XDSEdit3.Parent := fm; 
  XDSEdit3.Left := 168; 
  XDSEdit3.top := 184;
  XDSEdit3.width := 241; 
  XDSEdit3.height := 20; 
  XDSEdit3.Text := ''; 
  XDSEdit3.LinkStyle := lsEllipsis; 
  XDSEdit3.OnButtonClick := 'XDSEdit1ButtonClick';

  //------按钮 BitBtn1
  BitBtn1 :=  TBitBtn.Create( fm ); 
  BitBtn1.Parent := fm; 
  BitBtn1.Left := 314; 
  BitBtn1.top := 240; 
  BitBtn1.width := 56; 
  BitBtn1.height := 25; 
  BitBtn1.Caption := '确定'; 
  BitBtn1.ModalResult := 1; 
  BitBtn1.onclick := 'BitBtn0Click';

  //------按钮 BitBtn2
  BitBtn2 :=  TBitBtn.Create( fm );
  BitBtn2.Parent := fm;
  BitBtn2.Left := 248;
  BitBtn2.top := 240;
  BitBtn2.width := 56;
  BitBtn2.height := 25;
  BitBtn2.Caption := '应用';
  BitBtn2.ModalResult := 0;
  BitBtn2.onclick := 'BitBtn111112Click';

  //------按钮 BitBtn3
  BitBtn3 :=  TBitBtn.Create( fm );
  BitBtn3.Parent := fm;
  BitBtn3.Left := 370;
  BitBtn3.top := 240;
  BitBtn3.width := 56;
  BitBtn3.height := 25;
  BitBtn3.Caption := '取消';
  BitBtn3.ModalResult := 2;

  //------按钮 BitBtn4
  BitBtn4 :=  TBitBtn.Create( fm );
  BitBtn4.Parent := fm;
  BitBtn4.Left := 15;
  BitBtn4.top := 240;
  BitBtn4.width := 33;
  BitBtn4.height := 25;
  BitBtn4.Caption := '添加';
  BitBtn4.ModalResult := 0;
  BitBtn4.onclick := 'BitBtn111114Click';

  //------按钮 BitBtn5
  BitBtn5 :=  TBitBtn.Create( fm );
  BitBtn5.Parent := fm;
  BitBtn5.Left := 48;
  BitBtn5.top := 240;
  BitBtn5.width := 33;
  BitBtn5.height := 25;
  BitBtn5.Caption := '删除';
  BitBtn5.ModalResult := 0;
  BitBtn5.onclick := 'BitBtnDelIconClick';

  //------线条 Bevel2
  Bevel2 :=  TBevel.Create( fm ); 
  Bevel2.Parent := fm; 
  Bevel2.Left := -8;
  Bevel2.top := 232; 
  Bevel2.width := 489; 
  Bevel2.height := 10; 
  Bevel2.Style := 0; 
  Bevel2.Shape := 2;

  ListBox0OnClick(ListBox0);

  //----显示配置窗口----
  if fm.ShowModal = mrOk then
  begin
    Index := GetListBoxItemIndex( ListBox0 ) ;

    if Index < 0 then exit;
    xInt[150] := index;

    xStr[index] := XDSEdit0.Text;
    xStr[50+index] := ComboBox0.Text;
    xStr[100+index] := XDSEdit2.Text;

    SaveIni('Label'+inttostr(index),xStr[index]);
    SaveIni('File'+inttostr(index),xStr[50+index]);
    SaveIni('Argu'+ inttostr(index),xStr[100+index]);

    SaveDefIni('Label'+ inttostr(index),xStr[index]);
    SaveDefIni('File'+ inttostr(index),xStr[50+index]);
    SaveDefIni('Argu'+ inttostr(index),xStr[100+index]);

    if uppercase(XDSEdit1.Text) <> uppercase(WidgetPath + 'Icons\' + xStr[500]  + '\'+  inttostr(index) + '.png') then
    begin
      CopyFile( XDSEdit1.Text , WidgetPath + 'Icons\' + xStr[500]  + '\' +  inttostr(index) + '.png',false);
      SetButtonPro(index,'normalpicture',widgetpath + 'Icons\' + xStr[500]  + '\' + inttostr(index)+'.png');
    end;

    if (xStr[50+index] = '回收站') and (trim(XDSEdit3.Text) <> '') then
    begin
      CopyFile( XDSEdit3.Text , WidgetPath + 'Icons\' + xStr[500]  + '\' +  inttostr(index) + '_full.png',false);
      if xInt[1000]>0 then
        SetButtonPro(index,'normalpicture',widgetpath + 'Icons\' + xStr[500] + '\' +inttostr(index)+'_full.png');
    end;

//    SetButtonPro(index,'hint',xStr[50+index]   );
    SetButtonPro(index,'filepath',xStr[50+index]   );

    RefreshWidget;
  end;
  fm.free;
end;



Procedure BitBtn111112Click(sender);
var
  index;
begin
  //应用 按钮
    Index := GetListBoxItemIndex( ListBox0 ) ;
    if Index < 0 then exit;
    xInt[150] := index;

    xStr[index] := XDSEdit0.Text;
    xStr[50+index] := ComboBox0.Text;
    xStr[100+index] := XDSEdit2.Text;

    ListBox0.items.Strings[index] := xStr[index];
                                  
    if uppercase(XDSEdit1.Text) <> uppercase(WidgetPath + 'Icons\' + xStr[500] + '\' +  inttostr(index) + '.png') then
    begin
      CopyFile( XDSEdit1.Text , WidgetPath + 'Icons\' + xStr[500] + '\' +  inttostr(index) + '.png',false);
      SetButtonPro(index,'normalpicture',widgetpath + 'Icons\' + xStr[500] + '\' +inttostr(index)+'.png');
    end;

    if (xStr[50+index] = '回收站') and (trim(XDSEdit3.Text) <> '') then
    begin
      CopyFile( XDSEdit3.Text , WidgetPath + 'Icons\' + xStr[500] + '\' +  inttostr(index) + '_full.png',false);
      if xInt[1000]>0 then
        SetButtonPro(index,'normalpicture',widgetpath + 'Icons\' + xStr[500] + '\' +inttostr(index)+'_full.png');
    end;

  //  SetButtonPro(index,'hint',xStr[50+index]   );
    SetButtonPro(index,'filepath',xStr[50+index]   );

    RefreshWidget;

end;


procedure myAddIcon;
var
  index,iconSize,iconHotSize,iconTopOffset,bgTop,IconSpace,IconCount,IconLeft,IconDir,IconHotDirection;
begin
  iconSize := xInt[100];
  iconHotSize := xInt[101];
  iconTopOffset := xInt[102];
  bgTop := xInt[103];
  IconSpace := xInt[104];
  IconCount := xInt[105];
  IconLeft := xInt[106];
  IconDir := xStr[500];
  IconHotDirection := xInt[107];
  BgMidWidthOffset := xInt[108] ;
  //添加图标
  xInt[105] := xInt[105] + 1 ;
  IconCount := xInt[105];
  index := IconCount - 1;

  if not fileexists(  WidgetPath + 'Icons\' + IconDir + '\' +  inttostr(index) + '.png' ) then
    CopyFile( XDeskShowPath + 'Res\Icon.png' , WidgetPath + 'Icons\' + IconDir + '\' +  inttostr(index) + '.png',false);
  if trim(xStr[index])='' then
    xStr[index] := '新快捷方式';

  AddButton(index,false,widgetpath + 'Icons\' + IconDir  + '\'+ inttostr(index)+'.png');
  SetButtonPro(index,'alpha','255');
  SetButtonPro(index,'left',IconLeft + index*iconSize + index*IconSpace);
  SetButtonPro(index,'top',iconTopOffset);
  SetButtonPro(index,'width',iconSize);
  SetButtonPro(index,'height',iconSize);
  SetButtonPro(index,'stretch','true');
  SetButtonPro(index,'EnableHotSize','true');
  SetButtonPro(index,'HotSizeOffset', iconHotSize - iconSize );
  SetButtonPro(index,'hotdirection',IconHotDirection);
  SetButtonPro(index,'quality','2');
 // SetButtonPro(index,'hint',xStr[50+index]   );
  SetButtonPro(index,'filepath',xStr[50+index]   );
  SetButtonPro(index,'EnableSystemPopMenu','true');
  SetButtonPro(index,'AcceptDropFile','true');

  SetImagePro(1,'width', iconCount*(iconSize + IconSpace)  - IconSpace + BgMidWidthOffset );
  SetImagePro(2,'left', GetImagePro(0,'width') + GetImagePro(1,'width')   );

  //设置整个widget插件的宽度和高度
  widgetWidth := 100 + GetImagePro(0,'width') + GetImagePro(1,'width')  + GetImagePro(2,'width') ;
  widgetHeight := 200+getimageintegerpro(0,'height') + bgTop ;

  SaveIni('Label'+inttostr(index),xStr[index]);
  SaveDefIni('Label'+inttostr(index),xStr[index]);

  SaveIni('IconCount',xInt[105]);
  SaveDefIni('IconCount',xInt[105]);

  RefreshWidget;
end;


procedure OnDropFile(filename);
begin
  iconCount := xInt[105];
  IconDir := xStr[500];

 {
  if (lowercase( copy(filename,length(filename)-2,3) )='png')  or
     (lowercase( copy(filename,length(filename)-2,3) )='ico')   then
  begin
    CopyFile( filename , WidgetPath + 'Icons\' + IconDir + '\' +  inttostr(iconCount) + '.png',false);
    myAddIcon;
  end;
  }

  SaveFileIconToPngFile(filename,WidgetPath + 'Icons\' + IconDir + '\' +  inttostr(iconCount) + '.png');
  xStr[IconCount] := ExtractFilename(filename);// '111';
  xStr[50 + IconCount] := filename;

//  CopyFile( filename , WidgetPath + 'Icons\' + IconDir + '\' +  inttostr(iconCount) + '.png',false);
  myAddIcon;
end;

procedure myDeleteIcon(index);
var
  iconSize,iconHotSize,iconTopOffset,bgTop,IconSpace,IconCount,IconLeft,IconDir;
begin
  iconSize := xInt[100];
  iconHotSize := xInt[101];
  iconTopOffset := xInt[102];
  bgTop := xInt[103];
  IconSpace := xInt[104];
  IconCount := xInt[105];
  IconLeft := xInt[106];
  IconDir := xStr[500];
  BgMidWidthOffset := xInt[108];

  //删除图标
  if (index=-1) or (index=IconCount-1) then
  begin

  end
  else
  begin
    for i:= index to IconCount-1 do
    begin
      xStr[i] := xStr[i + 1];
      xStr[50 + i] := xStr[50 + i + 1];
      xStr[100 + i] := xStr[100 + i + 1];
      Copyfile(  WidgetPath + 'Icons\' + IconDir + '\' +  inttostr(i + 1) + '.png' , WidgetPath + 'Icons\' + IconDir + '\' +  inttostr(i) + '.png'  ,false);

      if xStr[50+i] = '回收站' then
      begin
        Copyfile(  WidgetPath + 'Icons\' + IconDir + '\' +  inttostr(i + 1) + '_full.png' , WidgetPath + 'Icons\' + IconDir + '\' +  inttostr(i) + '_full.png'  ,false);
        SetButtonPro(i,'normalpicture',widgetpath + 'Icons\' + IconDir + '\' + inttostr(i) + '_full.png')
      end
      else
        SetButtonPro(i,'normalpicture',widgetpath + 'Icons\' + IconDir + '\' + inttostr(i) + '.png');

    end;
  end;

  xInt[105] := xInt[105] - 1 ;
  IconCount := xInt[105];
  index := IconCount - 1;



  SaveIni('IconCount',xInt[105]);
  SaveDefIni('IconCount',xInt[105]);


  SetImagePro(1,'width', iconCount*(iconSize + IconSpace) - IconSpace + BgMidWidthOffset  );
  SetImagePro(2,'left', GetImagePro(0,'width') + GetImagePro(1,'width')   );

  //设置整个widget插件的宽度和高度
  widgetWidth := 100 + GetImagePro(0,'width') + GetImagePro(1,'width')  + GetImagePro(2,'width') ;
  widgetHeight := 200 + getimageintegerpro(0,'height') + bgTop ;

  DeleteButton(IconCount);

  RefreshWidget;
end;


procedure BitBtn111114Click(Sender);
begin
  myAddIcon;
  ListBox0.Items.Add('设置图标'+ IntTostr(xInt[105]-1));

end;


procedure BitBtnDelIconClick(Sender);
var
  index;
begin
  index :=  GetListBoxItemIndex( ListBox0 );

  ListBox0.Items.Delete(index);

  myDeleteIcon(index);
end;

Procedure XDSEdit1ButtonClick(sender);
var
  op;
begin
 op := TOpenPictureDialog.create(nil);
 op.Execute;
 if (op.filename)<>'' then
    Sender.text := op.filename;
 op.free;
end;


Procedure BitBtn1110Click(sender);
var
  op;
begin
 op := TOpenDialog.create(nil);
 op.Execute;
 if (op.filename)<>'' then
    ComboBox0.text := op.filename;
 op.free;
end;

Procedure MyConfigForm2;
var
  index,iconSize,iconHotSize,iconTopOffset,bgTop,IconSpace,IconCount,IconLeft,IconDir,BgDir,sl,IconHotDirection;
begin
  iconSize := xInt[100];
  iconHotSize := xInt[101];
  iconTopOffset := xInt[102];
  bgTop := xInt[103];
  IconSpace := xInt[104];
  IconCount := xInt[105];
  IconLeft := xInt[106];
  IconDir := xStr[500];
  BgDir := xStr[503];
  IconHotDirection := xInt[107] ;
  BgMidWidthOffset := xInt[108] ;

  fm := TForm.CreateForm;
  fm.Caption := '大小位置和背景设置';
  fm.Width := 330;
  fm.Height := 320;
  fm.BorderStyle := bsToolWindow;
  fm.Position := poDesktopCenter;
  fm.font.name := '宋体';
  fm.font.size := 9;

  //------文本 Label0
  Label0 :=  TLabel.Create( fm ); 
  Label0.Parent := fm;
  Label0.Left := 16; 
  Label0.top := 16; 
  Label0.width := 72; 
  Label0.height := 12; 
  Label0.AutoSize := -1; 
  Label0.WordWrap := 0; 
  Label0.Caption := '图标默认大小'; 

  //------数字框 XDSSpinEdit0
  XDSSpinEdit0 :=  TXDSSpinEdit.Create( fm ); 
  XDSSpinEdit0.Parent := fm; 
  XDSSpinEdit0.Left := 96; 
  XDSSpinEdit0.top := 10; 
  XDSSpinEdit0.width := 49; 
  XDSSpinEdit0.height := 21; 
  XDSSpinEdit0.Value := iconSize;

  //------文本 Label1
  Label1 :=  TLabel.Create( fm ); 
  Label1.Parent := fm; 
  Label1.Left := 162; 
  Label1.top := 16; 
  Label1.width := 84; 
  Label1.height := 12; 
  Label1.AutoSize := -1; 
  Label1.WordWrap := 0; 
  Label1.Caption := '图标放大后大小'; 

  //------数字框 XDSSpinEdit1
  XDSSpinEdit1 :=  TXDSSpinEdit.Create( fm ); 
  XDSSpinEdit1.Parent := fm; 
  XDSSpinEdit1.Left := 266; 
  XDSSpinEdit1.top := 10; 
  XDSSpinEdit1.width := 49; 
  XDSSpinEdit1.height := 21;
  XDSSpinEdit1.Value := iconHotSize;

  //------线条 Bevel0
  Bevel0 :=  TBevel.Create( fm ); 
  Bevel0.Parent := fm; 
  Bevel0.Left := -24; 
  Bevel0.top := 40; 
  Bevel0.width := 425; 
  Bevel0.height := 10; 
  Bevel0.Style := 0; 
  Bevel0.Shape := 2; 

  //------文本 Label2
  Label2 :=  TLabel.Create( fm ); 
  Label2.Parent := fm; 
  Label2.Left := 16; 
  Label2.top := 56; 
  Label2.width := 72; 
  Label2.height := 12; 
  Label2.AutoSize := -1;
  Label2.WordWrap := 0; 
  Label2.Caption := '图标垂直坐标'; 

  //------数字框 XDSSpinEdit2
  XDSSpinEdit2 :=  TXDSSpinEdit.Create( fm );
  XDSSpinEdit2.Parent := fm; 
  XDSSpinEdit2.Left := 96; 
  XDSSpinEdit2.top := 50; 
  XDSSpinEdit2.width := 49; 
  XDSSpinEdit2.height := 21; 
  XDSSpinEdit2.Value := iconTopOffset;

  //------文本 Label3
  Label3 :=  TLabel.Create( fm ); 
  Label3.Parent := fm; 
  Label3.Left := 160; 
  Label3.top := 56; 
  Label3.width := 72; 
  Label3.height := 12; 
  Label3.AutoSize := -1; 
  Label3.WordWrap := 0; 
  Label3.Caption := '图标水平坐标'; 

  //------数字框 XDSSpinEdit3
  XDSSpinEdit3 :=  TXDSSpinEdit.Create( fm ); 
  XDSSpinEdit3.Parent := fm; 
  XDSSpinEdit3.Left := 266; 
  XDSSpinEdit3.top := 50; 
  XDSSpinEdit3.width := 49; 
  XDSSpinEdit3.height := 21; 
  XDSSpinEdit3.Value := IconLeft;

  //------文本 Label4
  Label4 :=  TLabel.Create( fm ); 
  Label4.Parent := fm; 
  Label4.Left := 16; 
  Label4.top := 88; 
  Label4.width := 48; 
  Label4.height := 12; 
  Label4.AutoSize := -1; 
  Label4.WordWrap := 0; 
  Label4.Caption := '图标间距'; 

  //------数字框 XDSSpinEdit4
  XDSSpinEdit4 :=  TXDSSpinEdit.Create( fm ); 
  XDSSpinEdit4.Parent := fm; 
  XDSSpinEdit4.Left := 96; 
  XDSSpinEdit4.top := 83; 
  XDSSpinEdit4.width := 49; 
  XDSSpinEdit4.height := 21; 
  XDSSpinEdit4.Value := IconSpace;

  //------文本 Label5
  Label5 :=  TLabel.Create( fm );
  Label5.Parent := fm;
  Label5.Left := 160;
  Label5.top := 88;
  Label5.width := 96;
  Label5.height := 12;
  Label5.AutoSize := -1;
  Label5.WordWrap := 0; 
  Label5.Caption := '背景图片垂直坐标';

  //------数字框 XDSSpinEdit5
  XDSSpinEdit5 :=  TXDSSpinEdit.Create( fm );
  XDSSpinEdit5.Parent := fm;
  XDSSpinEdit5.Left := 266;
  XDSSpinEdit5.top := 83;
  XDSSpinEdit5.width := 49;
  XDSSpinEdit5.height := 21;
  XDSSpinEdit5.Value := bgTop;


///////////////////////////////
  //------文本 Label111115
  Label111115 :=  TLabel.Create( fm );
  Label111115.Parent := fm;
  Label111115.Left := 16;
  Label111115.top := 215;
  Label111115.width := 96;
  Label111115.height := 12;
  Label111115.AutoSize := -1;
  Label111115.WordWrap := 0;
  Label111115.Caption := '背景图片中间宽度偏移值';

  //------数字框 XDSSpinEdit6
  XDSSpinEdit6 :=  TXDSSpinEdit.Create( fm );
  XDSSpinEdit6.Parent := fm;
  XDSSpinEdit6.Left := 160;
  XDSSpinEdit6.top := 210;
  XDSSpinEdit6.width := 109;
  XDSSpinEdit6.height := 21;
  XDSSpinEdit6.Value := BgMidWidthOffset;

  ///////////////////////////////////////
  //------文本 Label6
  Label6 :=  TLabel.Create( fm );
  Label6.Parent := fm;
  Label6.Left := 16;
  Label6.top := 154;
  Label6.width := 72;
  Label6.height := 12;
  Label6.AutoSize := -1;
  Label6.WordWrap := 0;
  Label6.Caption := '更换图标目录';

  //------下拉框 ComboBox0
  ComboBox0 :=  TComboBox.Create( fm );
  ComboBox0.Parent := fm;
  ComboBox0.Left := 96;
  ComboBox0.top := 150;
  ComboBox0.width := 219;
  ComboBox0.height := 20;
  ComboBox0.Style := 0;
  ComboBox0.DropDownCount := 8;
  ComboBox0.ItemIndex := -1;

  sl := TStringlist.create;
  sl.text := GetFoldNameList(WidgetPath + 'Icons\');
  for i:=0 to sl.count-1 do
  begin
    ComboBox0.items.add( sl.strings[i] );
  end;
  ComboBox0.Text := IconDir;
  sl.free;

/////////////////////
  //------文本 Label7
  Label7 :=  TLabel.Create( fm );
  Label7.Parent := fm;
  Label7.Left := 16;
  Label7.top := 127;
  Label7.width := 72;
  Label7.height := 12;
  Label7.AutoSize := -1;
  Label7.WordWrap := 0;
  Label7.Caption := '更换背景';

  //------下拉框 ComboBox1
  ComboBox1 :=  TComboBox.Create( fm );
  ComboBox1.Parent := fm;
  ComboBox1.Left := 96;
  ComboBox1.top := 123;
  ComboBox1.width := 219;
  ComboBox1.height := 20;
  ComboBox1.Style := 0;
  ComboBox1.DropDownCount := 8;
  ComboBox1.ItemIndex := -1;

  sl := TStringlist.create;
  sl.text := GetFoldNameList(WidgetPath + 'bg\');
  for i:=0 to sl.count-1 do
  begin
    ComboBox1.items.add( sl.strings[i] );
  end;
  ComboBox1.Text := BgDir;
  sl.free;


//////////////////////////////
//
/////////////////////
  //------文本 Label8
  Label8 :=  TLabel.Create( fm );
  Label8.Parent := fm;
  Label8.Left := 16;
  Label8.top := 181;
  Label8.width := 72;
  Label8.height := 12;
  Label8.AutoSize := -1;
  Label8.WordWrap := 0;
  Label8.Caption := '图标放大方向';

  //------下拉框 ComboBox2
  ComboBox2 :=  TComboBox.Create( fm );
  ComboBox2.Parent := fm;
  ComboBox2.Left := 96;
  ComboBox2.top := 177;
  ComboBox2.width := 219;
  ComboBox2.height := 20;
  ComboBox2.Style := 2;
  ComboBox2.DropDownCount := 8;
  ComboBox2.items.add('原地放大');
  ComboBox2.items.add('向上放大');
  ComboBox2.items.add('向下放大');
  ComboBox2.ItemIndex := IconHotDirection;

////////////////////


  //------线条 Bevel1
  Bevel1 :=  TBevel.Create( fm );
  Bevel1.Parent := fm; 
  Bevel1.Left := -8; 
  Bevel1.top := 112; 
  Bevel1.width := 409; 
  Bevel1.height := 10; 
  Bevel1.Style := 0; 
  Bevel1.Shape := 2; 

  //------线条 Bevel2
  Bevel2 :=  TBevel.Create( fm ); 
  Bevel2.Parent := fm; 
  Bevel2.Left := -8; 
  Bevel2.top := 248; 
  Bevel2.width := 417; 
  Bevel2.height := 10; 
  Bevel2.Style := 0; 
  Bevel2.Shape := 2; 

  //------按钮 BitBtn0
  BitBtn0 :=  TBitBtn.Create( fm ); 
  BitBtn0.Parent := fm; 
  BitBtn0.Left := 15; 
  BitBtn0.top := 264; 
  BitBtn0.width := 75; 
  BitBtn0.height := 25; 
  BitBtn0.Caption := '应用'; 
  BitBtn0.ModalResult := 0;
  BitBtn0.onclick := 'BitBtn_yinyongOnClick';

  //------按钮 BitBtn1
  BitBtn1 :=  TBitBtn.Create( fm );
  BitBtn1.Parent := fm;
  BitBtn1.Left := 160;
  BitBtn1.top := 264;
  BitBtn1.width := 75;
  BitBtn1.height := 25;
  BitBtn1.Caption := '确定';
  BitBtn1.ModalResult := 1;
  BitBtn1.onclick := 'BitBtn0Click';

  //------按钮 BitBtn2
  BitBtn2 :=  TBitBtn.Create( fm );
  BitBtn2.Parent := fm;
  BitBtn2.Left := 235;
  BitBtn2.top := 264;
  BitBtn2.width := 75;
  BitBtn2.height := 25;
  BitBtn2.Caption := '取消';
  BitBtn2.ModalResult := 2;


  //----显示配置窗口----
  if fm.ShowModal = mrOk then
  begin
    xInt[100] := XDSSpinEdit0.Value;
    xInt[101] := XDSSpinEdit1.Value;
    xInt[102] := XDSSpinEdit2.Value;
    xInt[106] := XDSSpinEdit3.Value;
    xInt[104] := XDSSpinEdit4.Value;
    xInt[103] := XDSSpinEdit5.Value;
    xInt[107] :=   ComboBox2.ItemIndex;
    xInt[108] := XDSSpinEdit6.Value;
    BgMidWidthOffset := xInt[108];

    IconHotDirection := xInt[107];

    xStr[500] := comboBox0.Text;

    if xStr[503] <> comboBox1.Text then
    begin
      xStr[503] := comboBox1.Text;
      BgDir := xStr[503];
      SetImagePro(1,'height',GetImageFileHeight( widgetPath + 'bg\' + BgDir + '\bg_mid.png' ));
      SetImagePro(1,'stretch', 'false' );

      SetImagePro(0,'filename',widgetPath + 'bg\' + BgDir + '\bg_left.png');
      SetImagePro(1,'filename',widgetPath + 'bg\' + BgDir + '\bg_mid.png');
      SetImagePro(2,'filename',widgetPath + 'bg\' + BgDir + '\bg_right.png');

      SetImagePro(1,'stretch', 'true' );
      SetImagePro(1,'left',GetImageFileWidth( widgetPath + 'bg\' + BgDir + '\bg_left.png' ));
    end;


    for i:=0 to IconCount-1 do
    begin
      if uppercase(IconDir)<>uppercase(xStr[500]) then
      begin
        if xStr[50+i] = '回收站' then
          SetButtonPro(i,'normalpicture',widgetpath + 'Icons\' + xStr[500] + '\' + inttostr(i) + '_full.png')
        else
          SetButtonPro(i,'normalpicture',widgetpath + 'Icons\' + xStr[500] + '\' + inttostr(i) + '.png');
      end;

      SetButtonPro(i,'left', xInt[106] + i*xInt[100] + i*xInt[104] );
      SetButtonPro(i,'width',xInt[100]);
      SetButtonPro(i,'height',xInt[100]);
      SetButtonPro(i,'HotSizeOffset', xInt[101] - xInt[100] );
      SetButtonPro(i,'hotdirection', IconHotDirection );
      SetButtonPro(i,'top', xInt[102]);
      SetButtonPro(i,'EnableSystemPopMenu','true');
      SetButtonPro(i,'AcceptDropFile','true');
    end;


    SetImagePro(0,'top',xInt[103]);
    SetImagePro(1,'top',xInt[103]);
    SetImagePro(2,'top',xInt[103]);

    SetImagePro(1,'width', iconCount*(xInt[100] + xInt[104])  - xInt[104] + xInt[108] );
    SetImagePro(2,'left', GetImagePro(0,'width') + GetImagePro(1,'width')   );

    //设置整个widget插件的宽度和高度
    widgetWidth := 100 + GetImagePro(0,'width') + GetImagePro(1,'width')  + GetImagePro(2,'width') ;
    widgetHeight := 200 + getimageintegerpro(0,'height') + bgTop ;

    SaveIni('iconSize',xInt[100]);
    SaveIni('iconHotSize',xInt[101]);
    SaveIni('iconTopOffset',xInt[102]);
    SaveIni('bgTop',xInt[103]);
    SaveIni('IconSpace',xInt[104]);
    SaveIni('IconLeft',xInt[106]);
    SaveIni('IconDir',xStr[500]);
    SaveIni('BgDir',xStr[503]);
    SaveIni('IconHotDirection',xInt[107]);
    SaveIni('BgMidWidthOffset',xInt[108]);

    SaveDefIni('iconSize',xInt[100]);
    SaveDefIni('iconHotSize',xInt[101]);
    SaveDefIni('iconTopOffset',xInt[102]);
    SaveDefIni('bgTop',xInt[103]);
    SaveDefIni('IconSpace',xInt[104]);
    SaveDefIni('IconLeft',xInt[106]);
    SaveDefIni('IconDir',xStr[500]);
    SaveDefIni('BgDir',xStr[503]);
    SaveDefIni('IconHotDirection',xInt[107]);
    SaveDefIni('BgMidWidthOffset',xInt[108]);
                        

    Refreshwidget;
  end;
  fm.free;
end;

Procedure BitBtn_yinyongOnClick(sender);
var
  index,iconSize,iconHotSize,iconTopOffset,bgTop,IconSpace,IconCount,IconLeft,IconDir;
begin                     //应用
  iconSize := xInt[100];
  iconHotSize := xInt[101];
  iconTopOffset := xInt[102];
  bgTop := xInt[103];
  IconSpace := xInt[104];
  IconCount := xInt[105];
  IconLeft := xInt[106];
  IconDir := xStr[500];
  BgDir := xStr[503];

    xInt[100] := XDSSpinEdit0.Value;
    xInt[101] := XDSSpinEdit1.Value;
    xInt[102] := XDSSpinEdit2.Value;
    xInt[106] := XDSSpinEdit3.Value;
    xInt[104] := XDSSpinEdit4.Value;
    xInt[103] := XDSSpinEdit5.Value;
    xInt[107] :=   ComboBox2.ItemIndex;
    xInt[108] := XDSSpinEdit6.Value;
    BgMidWidthOffset := xInt[108];

    IconHotDirection := xInt[107];

    xStr[500] := comboBox0.Text;

    if xStr[503] <> comboBox1.Text then
    begin
      xStr[503] := comboBox1.Text;
      BgDir := xStr[503];
      SetImagePro(1,'height',GetImageFileHeight( widgetPath + 'bg\' + BgDir + '\bg_mid.png' ));
      SetImagePro(1,'stretch', 'false' );

      SetImagePro(0,'filename',widgetPath + 'bg\' + BgDir + '\bg_left.png');
      SetImagePro(1,'filename',widgetPath + 'bg\' + BgDir + '\bg_mid.png');
      SetImagePro(2,'filename',widgetPath + 'bg\' + BgDir + '\bg_right.png');

      SetImagePro(1,'stretch', 'true' );
      SetImagePro(1,'left',GetImageFileWidth( widgetPath + 'bg\' + BgDir + '\bg_left.png' ));
    end;


    for i:=0 to IconCount-1 do
    begin
      if uppercase(IconDir)<>uppercase(xStr[500]) then
      begin
        if xStr[50+i] = '回收站' then
          SetButtonPro(i,'normalpicture',widgetpath + 'Icons\' + xStr[500] + '\' + inttostr(i) + '_full.png')
        else
          SetButtonPro(i,'normalpicture',widgetpath + 'Icons\' + xStr[500] + '\' + inttostr(i) + '.png');
      end;

      SetButtonPro(i,'left', xInt[106] + i*xInt[100] + i*xInt[104] );
      SetButtonPro(i,'width',xInt[100]);
      SetButtonPro(i,'height',xInt[100]);
      SetButtonPro(i,'HotSizeOffset', xInt[101] - xInt[100] );
      SetButtonPro(i,'hotdirection', IconHotDirection );
      SetButtonPro(i,'top', xInt[102]);
      SetButtonPro(i,'EnableSystemPopMenu','true');
      SetButtonPro(i,'AcceptDropFile','true');
    end;

    SetImagePro(0,'top',xInt[103]);
    SetImagePro(1,'top',xInt[103]);
    SetImagePro(2,'top',xInt[103]);

    SetImagePro(1,'width', iconCount*(xInt[100] + xInt[104]) - xInt[104] + xInt[108]  );
    SetImagePro(2,'left', GetImagePro(0,'width') + GetImagePro(1,'width')   );

    //设置整个widget插件的宽度和高度
    widgetWidth := 100 + GetImagePro(0,'width') + GetImagePro(1,'width')  + GetImagePro(2,'width') ;
    widgetHeight := 200 + getimageintegerpro(0,'height') + bgTop ;

    Refreshwidget;
end;

Procedure BitBtn0Click(sender);
begin
  Sender.ModalResult := mrOk;
end;


Procedure BitBtn10Click(sender);
begin
  Sender.ModalResult := mrOk;
end;


Procedure BitBtnSaveThemeClick(sender);
var
  ss ;
begin
  ss := InputForm('保存当前主题为','请输入主题文件名','newXDeskDockTheme');
  if trim(ss)='' then exit;

   CopyFile(widgetPath + 'xwidget.ini',widgetPath + 'Themes\' + ss + '.XDockTheme',false);

  //XDockTheme
end;


Procedure MyThemesConfigForm;
var
  ss;
begin
  fm := TForm.CreateForm;
  fm.Caption := '管理主题';
  fm.Width := 270;
  fm.Height := 135;
  fm.BorderStyle := bsToolWindow;
  fm.Position := poDesktopCenter;
  fm.font.name := '宋体';
  fm.font.size := 9;
  //------文本 Label0
  Label0 :=  TLabel.Create( fm ); 
  Label0.Parent := fm; 
  Label0.Left := 16;
  Label0.top := 20;
  Label0.width := 48;
  Label0.height := 12;
  Label0.AutoSize := -1;
  Label0.WordWrap := 0;
  Label0.Caption := '选择要更换的主题';

  //------下拉框 ComboBox0
  ComboBox0 :=  TComboBox.Create( fm ); 
  ComboBox0.Parent := fm; 
  ComboBox0.Left := 16;
  ComboBox0.top := 40;
  ComboBox0.width := 229;
  ComboBox0.height := 20; 
  ComboBox0.Style := 0;
  ComboBox0.DropDownCount := 28;

  sl := TStringlist.create;
  sl.text := GetExtFileNameList(WidgetPath + 'Themes\' ,'XDockTheme');
  for i:=0 to sl.count-1 do
  begin
    ComboBox0.items.add( sl.strings[i] );
  end;
  if sl.count>0 then
    ComboBox0.ItemIndex := 0;
  sl.free;

//  ComboBox0.Text := '下拉框0';

  //------线条 Bevel0
  Bevel0 :=  TBevel.Create( fm );
  Bevel0.Parent := fm; 
  Bevel0.Left := 0; 
  Bevel0.top := 72;
  Bevel0.width := 361; 
  Bevel0.height := 10;
  Bevel0.Style := 0; 
  Bevel0.Shape := 2; 

  //------按钮 BitBtn0
  BitBtn15 :=  TBitBtn.Create( fm );
  BitBtn15.Parent := fm;
  BitBtn15.Left := 16;
  BitBtn15.top := 83;
  BitBtn15.width := 89;
  BitBtn15.height := 25;
  BitBtn15.Caption := '保存当前主题';
  BitBtn15.ModalResult := 0;
  BitBtn15.onclick := 'BitBtnSaveThemeClick';

  //------按钮 BitBtn1
  BitBtn0 :=  TBitBtn.Create( fm );
  BitBtn0.Parent := fm;
  BitBtn0.Left := 130;
  BitBtn0.top := 83;
  BitBtn0.width := 57;
  BitBtn0.height := 25;
  BitBtn0.Caption := '确定';
  BitBtn0.ModalResult := 1;
  BitBtn0.onclick := 'BitBtn10Click';

  //------按钮 BitBtn2
  BitBtn2 :=  TBitBtn.Create( fm ); 
  BitBtn2.Parent := fm;
  BitBtn2.Left := 187;
  BitBtn2.top := 83;
  BitBtn2.width := 57; 
  BitBtn2.height := 25; 
  BitBtn2.Caption := '取消';
  BitBtn2.ModalResult := 2; 


  //----显示配置窗口----
  if fm.ShowModal = mrOk then
  begin
    ss := widgetPath + 'Themes\' + ComboBox0.text;
    if not fileExists(ss) then exit;
    CopyFile( ss,widgetPath + 'xwidget.ini',false);

    ////////////////////////////////////////////
    iconSize := strtointDef(LoadDefIni('iconSize','35'),35);
    iconHotSize := strtointDef(LoadDefIni('iconHotSize','50'),50);
    IconDir := LoadDefIni('IconDir','Icon1');
    BgDir := LoadDefIni('BgDir','Default');
    bgTop := strtointDef(LoadDefIni('bgTop','100'),100);  //背景图片的y坐标
    iconTopOffset :=  strtointDef(LoadDefIni('iconTopOffset','55'),55);   //图标y坐标
    IconSpace := strtointDef(LoadDefIni('IconSpace','10'),10);  //图标之间的间隔
    IconCount := strtointDef(LoadDefIni('IconCount','5'),5);//图标的个数
    IconLeft :=  strtointDef(LoadDefIni('IconLeft','20'),20);//图标的左边距、横坐标
    EnableMouseActive := StrToBool(LoadDefIni('EnableMouseActive','1'));  //是否鼠标激活
    IconHotDirection := strtointDef(LoadDefIni('IconHotDirection','1'),1);//图标放大的方向
    BgMidWidthOffset :=  strtointDef(LoadDefIni('BgMidWidthOffset','0'),0);//背景中间图片宽度偏移值

    labelFontname := LoadDefIni('labelFontname','黑体');
    labelFontSize := LoadDefIni('labelFontSize','12');

    //将变量存入全局数组变量中
    xInt[100] := iconSize;
    xInt[101] := iconHotSize;
    xInt[102] := iconTopOffset;
    xInt[103] := bgTop;
    xInt[104] := IconSpace;

    xInt[106] := IconLeft;
    xInt[107] := IconHotDirection;
    xInt[108] := BgMidWidthOffset;

    xStr[500] := IconDir;
    xStr[501] := labelFontname;
    xStr[502] := labelFontSize;
 //   xStr[503] := BgDir;  //背景目录名称

    xBool[100] := EnableMouseActive;//是否启用鼠标激活

    ////////////

    for i:=0 to max(IconCount, xInt[105]) do
    begin
        SetButtonPro(i,'left',-1000);
        SetButtonPro(i,'visible',false);
       // DeleteButton(i);
    end;
    xInt[105] := IconCount;

    for i:=0 to IconCount-1 do
    begin
      //从配置中载入标签
      xStr[i] := LoadDefIni('Label'+inttostr(i),'快捷方式'+inttostr(i));

      //从配置中载入 指向的文件路径
      xStr[50+i] := LoadDefIni('File'+inttostr(i),'');

      //从配置中载入 指向的文件路径
      xStr[100+i] := LoadDefIni('Argu'+inttostr(i),'');
    end;



    if xStr[503] <> BgDir then
    begin
      xStr[503] := BgDir;
      SetImagePro(1,'height',GetImageFileHeight( widgetPath + 'bg\' + BgDir + '\bg_mid.png' ));
      SetImagePro(1,'stretch', 'false' );

      SetImagePro(0,'filename',widgetPath + 'bg\' + BgDir + '\bg_left.png');
      SetImagePro(1,'filename',widgetPath + 'bg\' + BgDir + '\bg_mid.png');
      SetImagePro(2,'filename',widgetPath + 'bg\' + BgDir + '\bg_right.png');

      SetImagePro(1,'stretch', 'true' );
      SetImagePro(1,'left',GetImageFileWidth( widgetPath + 'bg\' + BgDir + '\bg_left.png' ));
    end;

    for i:=0 to IconCount-1 do
    begin
      AddButton(i,false,widgetpath + 'Icons\' + xStr[500] + '\' + inttostr(i) + '.png');

      if uppercase(IconDir)<>uppercase(xStr[500]) then
      begin
        if xStr[50+i] = '回收站' then
          SetButtonPro(i,'normalpicture',widgetpath + 'Icons\' + xStr[500] + '\' + inttostr(i) + '_full.png')
        else
          SetButtonPro(i,'normalpicture',widgetpath + 'Icons\' + xStr[500] + '\' + inttostr(i) + '.png');
      end;

      SetButtonPro(i,'left', xInt[106] + i*xInt[100] + i*xInt[104] );
      SetButtonPro(i,'stretch','true');
      SetButtonPro(i,'width',xInt[100]);
      SetButtonPro(i,'height',xInt[100]);
      SetButtonPro(i,'EnableHotSize','true');
      SetButtonPro(i,'HotSizeOffset', xInt[101] - xInt[100] );                                                               
      SetButtonPro(i,'hotdirection', IconHotDirection );
      SetButtonPro(i,'top', xInt[102]);
      SetButtonPro(i,'visible', true);
      SetButtonPro(i,'EnableSystemPopMenu','true');
      SetButtonPro(i,'AcceptDropFile','true');
    end;

                                         
    SetImagePro(0,'top',xInt[103]);
    SetImagePro(1,'top',xInt[103]);
    SetImagePro(2,'top',xInt[103]);

    SetImagePro(1,'width', iconCount*(xInt[100] + xInt[104]) - xInt[104] + xInt[108]  );
    SetImagePro(2,'left', GetImagePro(0,'width') + GetImagePro(1,'width')   );

    //设置整个widget插件的宽度和高度
    widgetWidth := 100 + GetImagePro(0,'width') + GetImagePro(1,'width')  + GetImagePro(2,'width') ;
    widgetHeight := 200 + getimageintegerpro(0,'height') + bgTop ;

    Refreshwidget;


  end;
  fm.free;
end;


//当自定义菜单被点击时,这里添加的代码将被执行
//index为自定义菜单的序号（0－8）
procedure OnCustomMenuClick(index);
var
  fd : TFontDialog;
begin
  Case index of
    0:
      begin
        myAddIcon;
        MySetIconsConfigForm('addnew');
      end;
    1:
      begin
        myDeleteIcon(-1);
      end;
    3:
      begin
        MySetIconsConfigForm('');
      end;
    4:
      begin
        MyConfigForm2;
      end;
    5:
      begin
        xBool[100] := not xBool[100];//是否启用鼠标激活
        saveIni('EnableMouseActive',xBool[100]);
        saveDefIni('EnableMouseActive',xBool[100]);
        if xBool[100] then
          nCustMenu5.caption := '禁用鼠标激活'
        else
          nCustMenu5.caption := '启用鼠标激活';

        //设置一个定时器用于鼠标激活
        SetTimer(1,500,xBool[100]);
      end;
    6:
      begin
        fd := TFontDialog.create(nil);
        fd.font.name := xStr[501];
        fd.font.size := xStr[502];
        fd.execute;

        xStr[501] := fd.font.name;
        xStr[502] := fd.font.size;

        SaveIni('labelFontname',xStr[501]);
        SaveIni('labelFontSize',xStr[502]);

        SaveDefIni('labelFontname',xStr[501]);
        SaveDefIni('labelFontSize',xStr[502]);


//        SetLabelPro(0,'fontname',xStr[501]);
//        SetLabelPro(0,'fontsize',xStr[502]);
        SetLabelPro(0,'fontStr','clwhite/-12/' + xStr[501] + '/' + xStr[502] + '/1000');
        fd.free;
      end;
    8:
      begin
      //主题管理
        MyThemesConfigForm;
      end;
    end;
end;

//当widget的右键菜单弹出的时候触发此事件
procedure OnPopupMenu;
begin

end;

//当xdeskshow的widget获得焦点时,触发此事件,并执行此函数内代码.
procedure OnActiveWidget;
begin

end;


//当xdeskshow的widget失去焦点时,触发此事件,并执行此函数内代码.
procedure OnDeActiveWidget;
begin
  SetLabelPro(0,'visible','false');
 // xBool[100] := false;

end;



//当鼠标单击widget时触发此事件,执行此函数内代码
procedure OnClickWidget;
begin
  //当widget被鼠标单击时,这里添加的代码将被执行
  {......}
end;


procedure OnWidgetMouseDown(x,y,ctl,alt,shf);
begin


end;


//当文件拖放到按纽上时,如果按纽的AcceptDropFile属性为true,则触发此事件
procedure OnButtonDropFile(index,filename);
begin
  iconCount := xInt[105];
  IconDir := xStr[500];

  if (lowercase( copy(filename,length(filename)-2,3) )='png')  or
     (lowercase( copy(filename,length(filename)-2,3) )='ico')   then
  begin
    CopyFile( filename , WidgetPath + 'Icons\' + IconDir + '\' +  inttostr(index) + '.png',false);
    SetButtonPro(index,'normalpicture',widgetpath + 'Icons\' + IconDir  + '\' + inttostr(index)+'.png');
    RefreshWidget;
  end
  else
  begin
    OnDropFile(filename);
  end;

end;


