import fonts.fontAwesome;
import win.ui;
import fsys.fileInfo;
import fsys.dlg.dir;
import process;
/*DSG{{*/
mainForm = win.form(text="缩略图批量处理";right=757;bottom=467;bgcolor=15780518)
mainForm.add(
editFile={cls="edit";left=14;top=114;right=326;bottom=402;ah=1;aw=1;dt=1;edge=1;hscroll=1;multiline=1;vscroll=1;z=3};
editThumb={cls="edit";left=339;top=114;right=742;bottom=402;ah=1;aw=1;dt=1;edge=1;hscroll=1;multiline=1;vscroll=1;z=4};
plus={cls="plus";text="目录";left=213;top=417;right=312;bottom=447;align="left";bgcolor=-5197169;font=LOGFONT(h=-16);iconStyle={align="left";font=LOGFONT(h=-13;name='FontAwesome');padding={left=20}};iconText='\uF07B';notify=1;textPadding={left=39};z=8};
plusClose={cls="plus";text="退出";left=494;top=417;right=593;bottom=447;align="left";bgcolor=-5197169;font=LOGFONT(h=-16);iconStyle={align="left";font=LOGFONT(h=-13;name='FontAwesome');padding={left=20}};iconText='\uF011';notify=1;textPadding={left=39};z=9};
plusDir={cls="plus";left=302;top=40;right=551;bottom=66;align="left";aw=1;border={bottom=1;color=-6908266};dt=1;editable=1;font=LOGFONT(h=-13);textPadding={top=6;bottom=2};z=1};
plusOpenDir={cls="plus";text="目录";left=573;top=39;right=672;bottom=69;align="left";bgcolor=-5197169;dt=1;font=LOGFONT(h=-16);iconStyle={align="left";font=LOGFONT(h=-13;name='FontAwesome');padding={left=20}};iconText='\uF07C';notify=1;textPadding={left=39};z=2};
static={cls="static";text="文件列表";left=14;top=85;right=134;bottom=108;dt=1;transparent=1;z=5};
staticThumb={cls="static";text="处理列表(大于100K,保存thumb子目录)";left=339;top=85;right=576;bottom=108;dt=1;transparent=1;z=6};
staticTitle={cls="static";text="缩略图批量处理";left=14;top=17;right=246;bottom=65;color=32768;dt=1;font=LOGFONT(h=-32;name='微软雅黑';weight=700);transparent=1;z=7}
)
/*}}*/
//缩略图批量处理实例
path = null;
//缩略图: thumb子目录
mainForm.getThumbFile = function(jpgFile){
var pathTab = io.splitpath(jpgFile);
var thumbDir = pathTab.drive++pathTab.path++"thumb";
var thumbFile = thumbDir++"\"++pathTab.name++pathTab.ext;
if (tonumber(fsys.fileInfo(jpgFile).size)>100*1024){ //ico
mainForm.editThumb.print("正在处理 "++thumbFile++" ... (大于100K) ");
if !io.exist(thumbDir) io.createDir(thumbDir)
if !io.exist(thumbFile) gdip.image(jpgFile).getThumbnail(120,115).save(thumbFile,100)
} else {
mainForm.editThumb.print("未生成 "++thumbFile++" ... "++fsys.fileInfo(jpgFile).size);
}
}
//打开目录
mainForm.plusOpenDir.oncommand = function(id,event){
path = fsys.dlg.dir(,mainForm,'请选择目录')
if(path){
mainForm.plusDir.text = path;
var files,paths,others = fsys.list(path,,{"*.jpg","*.png","*.gif","*.ico","*.bmp","*.jpeg"});
for k,v in table.eachName(files){
mainForm.editFile.print(v);
mainForm.getThumbFile(v);
}
mainForm.editFile.print("完成");
}
}
mainForm.plus.oncommand = function(id,event){
if path process.explore(path)
}
mainForm.plusClose.oncommand = function(id,event){
win.quitMessage()
}
mainForm.show();
return win.loopMessage();