diff --git a/http.aardio b/http.aardio new file mode 100644 index 0000000..548398b --- /dev/null +++ b/http.aardio @@ -0,0 +1,60 @@ +import win.ui; +/*DSG{{*/ +var winform = win.form(text="aardio form";right=759;bottom=469) +winform.add() +/*}}*/ + +import console; +import process; + +import wsock.tcp.simpleHttpServer; +var server = wsock.tcp.simpleHttpServer()//"127.0.0.1",/*8081*/); + +console.log( server.getUrl() ) +process.execute( server.getUrl() ); + +//如果不需要窗口界面,那也可以直接使用 wsock.tcp.simpleHttpServer +server.run( + function(response,request,session){ + if( io.exist( request.path,0) + && request.path!="/main.aardio" ){ + response.loadcode( request.path ) + } + else{ + loadcodex(` + + + `) + + } + } +) + + + + + + + + +import win.timer +var timer = win.timer( winform ); +timer.onTimer = function(hwnd,msg,id,tick){ + server.publish("reload",) +} + +//timer.setInterval(100) +timer.enable(100,100) + + + + + + + + +winform.show(); +win.loopMessage(); diff --git a/ocr识别.aardio b/ocr识别.aardio new file mode 100644 index 0000000..431d7b1 --- /dev/null +++ b/ocr识别.aardio @@ -0,0 +1,51 @@ +//屏幕找字完整版 +import win.ui; +/*DSG{{*/ +var winform = win.form(text="string.ocrLite简单演示";right=796;bottom=504) +winform.add( +button={cls="button";text="识别剪贴板图像";left=528;top=423;right=712;bottom=477;db=1;dr=1;z=2}; +edit={cls="edit";left=497;top=36;right=764;bottom=403;db=1;dr=1;dt=1;edge=1;hscroll=1;multiline=1;vscroll=1;z=3}; +plus={cls="plus";left=25;top=36;right=474;bottom=403;db=1;dl=1;dr=1;dt=1;repeat="scale";z=1} +) +/*}}*/ + +/*DSG{{*/ +var winform2 = win.form(text="输出窗口";right=1151;bottom=745;parent=...;scroll=1) +winform.add() +/*}}*/ + +//web.form 使用系统自带的 IE 内核,生成的EXE体积很小, +//即使 WIN10 删除IE浏览器,IE内核浏览器控件仍作为操作系统组件被保留。 +//大家通常低估了IE控件的作用:IE11已普及,一般用不到最新前端技术的话IE控件是非常强大的。 +import web.form; +var wb = web.form.ie11( winform2);//低于IE11就自动安装IE11 + +//相关 OCR 范例:"~\codes\范例程序\2) 调用其他语言\2) dotNet\ocr.aardio" +import string.ocrLite; +import string.ocrLite.defaultModels; +import win.clip; + +var ocr = string.ocrLite(,true); +winform.button.oncommand = function(id,event){ +var hBmp = win.clip.readBitmap() +if(!hBmp){ +winform.edit.print("剪贴板未读取到图像") +return; +} + +var bmp = gdip.bitmap(hBmp); +var ocrRet = ocr.detectBitmap(bmp); +if(ocrRet){ +winform.plus.background = ocrRet.resultBitmap; + +winform.edit.text = ocrRet.text; + +} +} + + +winform.show(); + + + +win.loopMessage(); \ No newline at end of file diff --git a/serial.aardio b/serial.aardio new file mode 100644 index 0000000..8a87680 --- /dev/null +++ b/serial.aardio @@ -0,0 +1,303 @@ +import fonts.fontAwesome; +import win.ui; +/*DSG{{*/ +var winform = win.form(text="aardio form";right=226;bottom=211;border="dialog frame";max=false;min=false) +winform.add( +pluslen={cls="plus";left=122;top=89;right=221;bottom=119;bgcolor=-5197169;dl=1;dt=1;font=LOGFONT(h=-13);z=6}; +plusparity={cls="plus";left=122;top=121;right=221;bottom=151;bgcolor=-5197169;dl=1;dt=1;font=LOGFONT(h=-13);z=8}; +plusport={cls="plus";left=122;top=25;right=221;bottom=55;bgcolor=12632256;dl=1;dt=1;font=LOGFONT(h=-13);z=2}; +plusrate={cls="plus";left=122;top=57;right=221;bottom=87;bgcolor=-5197169;dl=1;dt=1;font=LOGFONT(h=-13);textPadding={top=6;bottom=3};z=4}; +plusstop={cls="plus";left=122;top=153;right=221;bottom=183;bgcolor=-5197169;dl=1;dt=1;font=LOGFONT(h=-13);z=10}; +staticlen={cls="static";text="Static";left=9;top=90;right=115;bottom=120;align="right";center=1;dl=1;dt=1;transparent=1;z=5}; +staticparity={cls="static";text="Static";left=15;top=122;right=115;bottom=152;align="right";center=1;dl=1;dt=1;transparent=1;z=7}; +staticport={cls="static";text="Static";left=15;top=25;right=115;bottom=55;align="right";center=1;dl=1;dt=1;transparent=1;z=1}; +staticrate={cls="static";text="Static";left=15;top=58;right=115;bottom=88;align="right";center=1;dl=1;dt=1;transparent=1;z=3}; +staticstop={cls="static";text="Static";left=15;top=154;right=115;bottom=184;align="right";center=1;dl=1;dt=1;transparent=1;z=9}; +tab1={cls="plus";text="按钮";left=257;top=69;right=356;bottom=99;align="left";bgcolor=-5197169;font=LOGFONT(h=-13);iconStyle={align="left";font=LOGFONT(h=-13;name='FontAwesome');padding={left=20}};iconText='\uF10C';textPadding={left=39};z=11}; +tab2={cls="plus";text="按钮";left=257;top=101;right=356;bottom=131;align="left";bgcolor=-5197169;font=LOGFONT(h=-13);iconStyle={align="left";font=LOGFONT(h=-13;name='FontAwesome');padding={left=20}};iconText='\uF10C';textPadding={left=39};z=12} +) +/*}}*/ + +import console +//console.log() + +var arg = {...};//winform,is popup,active color,hover color +arg[["active"]]=arg[3] +arg[["hover"]]=arg[4] + +if(!arg[["active"]]){ + arg[["active"]] = 0xFF1E90FF +} +if(!arg[["hover"]]){ + arg[["hover"]] = 0xFF99CCFF +} + +if(0){//无边框 + win.form.border="none" + winform.add(bkplus={cls="bkplus";left=-11;top=-1;right=253;bottom=24;dl=1;dt=1;forecolor=12632256};) + import win.ui.simpleWindow2 + var wui = win.ui.simpleWindow2(winform,,24,24) + //winform.text = "配置串口" + wui.skin( + background = { + hover = arg[["hover"]]; + active = 0xffff6666; + default = 0x00000000; + } + color = { + hover = 0xff666666; + active = 0xffffffff; + default = 0xffffffff; + } + ) +} + +import fsys.config +var cfg = fsys.config("/config/"); +winform.bindConfig( cfg.serialcfg,{ + //edit = "text"; + //radiobutton = "checked"; + //checkbox = "checked"; + //combobox = "selIndex"; + plus ={ + //["^chk"] = "checked"; + ["plus*"] = "text"; + }; + +} ); + +import sio +import sys.comPort + + + +var comPorts = sys.comPort.list(); + +//console.varDump(comPorts) +var str,cfginfo = {}; +ratetmp = table.map(sio.baudRates(),function(v,k,result){ + result[k+1]=tostring(v) + }) + +table.push(ratetmp,"自定义") +//console.varDump(ratetmp) +str={ +port={ + info="端口/Port"; + index=1; + data=table.map(comPorts,function(v,k,result){ + result[k]=tostring(v) + }) + }; +rate={ + info="波特率/Baud rate"; + index=12; + data=ratetmp + /** { + "2400"; + "4800"; + "9600"; + "38400"; + "115200"; + "自定义" + }**/ + }; +len={ + info="数据位数/Data bits"; + index=4; + data={ + "5"; + "6"; + "7"; + "8" + } + }; +parity={ + info="极性/Parity"; + index=1; + data={ + "无/None"; + "奇/Odd"; + "偶/Even"; + "零/Spc"; + "一/Mrk"; + } + }; +stop={ + info="结束位/Stop bits"; + index=1; + data={ + "1"; + "1.5"; + "2"; + } + }; +} + +import win.ui.tabs +var tbs=win.ui.tabs(winform.tab1,winform.tab2) +//tbs.initPopup() +tbs.itemMargin = 2 + +tbs.skin({ + background={ + default=0xFFD3D3D3;//0xffc0c0c0; + //disabled=0xFFCCCCCC; + hover=arg[["hover"]] + }; + + + checked = { + iconText = '\uF05D'; + background={ + default=arg[["active"]]; + //disabled=0xFFCCCCCC; + hover=arg[["hover"]] + }; + } +}) + + +for(name,ctrl in winform.eachControl("static") ){ + var tmp = string.replace(name,"static",""); + ctrl.text = str[tmp][["info"]] +} + +init = function(){ + + + +for(name,ctrl in winform.eachControl("plus","plus*") ){ + + ctrl.skin({ + + background={ + default=0xffc0c0c0;//0x668FB2B0; + active = arg[["active"]]; + //disabled=0xFFCCCCCC; + hover=arg[["hover"]]//0xFF928BB3 + }; + color={ + default=0xFF000000; + disabled=0xFF6D6D6D + } + }) + + var tmp = string.replace(name,"plus",""); + //var idx = str[tmp].index + if(ctrl.text == ""){ + ctrl.text = str[tmp][["data"]][str[tmp][["index"]]] + } + if(!#str[tmp].data){ + ctrl.text = "" + } + + ctrl.oncommand = function(id,event){ + + var tmp = string.replace(name,"plus",""); + + tbs.clear()//清空原tbs + tbs.initPopup()//必须初始化 + + if(tmp == "port"){ + str[tmp].data=table.map(sys.comPort.list(),function(v,k,result){ + result[k]=tostring(v) + }) + } + //tbs.setItemTexts(str[tmp].data) + for(i=1;#str[tmp].data;1){ + //for(k,v in str[tmp].data){ + tbs.add({ + text=str[tmp].data[i]; + }) + + //折叠过长的列表 + var col = 6; + if(#str[tmp].data < col){ + continue + } + var tbrec = winform.tab1._defRect; + var x2,y2,cx2,cy2 = tbrec.left,tbrec.top,tbrec.right-tbrec.left,tbrec.bottom-tbrec.top + var rec = tbs.strips[tbs.count()]._defRect; + if( i%col == 0){ + //x2,y2 = win.getPos(ctrl.hwnd,true) + + rec.left=x2+(cx2+tbs.itemMargin)*math.floor(i/col) + rec.right = rec.left+cx2 + rec.top=y2-cy2-tbs.itemMargin// + rec.bottom=rec.top+cy2 + } + + } + + tbs.selText = ctrl.text + if(!tbs.selIndex){ + tbs.selText="自定义" + } + + tbs.popup(true,ctrl,"right") + + } + +} +} +init() +winform.getcfg = function(){//poart,baud,wordLength,stopBits,parity + var ctrl = winform; + cfginfo = {ctrl.plusport.text;tonumber(ctrl.plusrate.text);ctrl.pluslen.text;tonumber(ctrl.plusstop.text);string.lower(string.replace(ctrl.plusparity.text,".*/",""))} + //console.varDump(cfginfo); + cfg.saveAll() + if(winform.parent){ + return cfginfo; + } +} + +winform.getcfg() + +tbs.onOk = function(strip){ + //console.varDump(tbs.$popBuddy) + if(strip.text == "自定义"){ + tbs.$popBuddy.editable = 1;//"edit"; + //tbs.$popBuddy.num=1 + winform.plusrate.editBox.limit=7 + tbs.$popBuddy.setFocus() + tbs.$popBuddy.editBox.onChange = function(){ + winform.getcfg() + } + tbs.$popBuddy.editBox.onFocusLost = function(){ + var tmp = tbs.$popBuddy.text; + var rec = tbs.$popBuddy.getRect()//_defRect; + tbs.$popBuddy.close() + winform.add( + plusrate={cls="plus";left=rec.left;top=rec.top;right=rec.right;bottom=rec.bottom;bgcolor=-5197169;dl=1;dt=1;font=LOGFONT(h=-13);textPadding={top=6;bottom=4}}; + ) + init() + winform.plusrate.text = tmp + } + } + else { + tbs.$popBuddy.text = strip.text + } + + winform.getcfg() +} + + + +if(winform.parent != null){ + + //winform.doModal() +} +//console.varDump(winform.parent) + +winform.onDestroy = function(){ + //console.log("12") + //winform.getcfg(); + +} + +winform.show(); + +win.loopMessage(); +return winform,cfginfo; + diff --git a/sio.aardio b/sio.aardio new file mode 100644 index 0000000..4906ece --- /dev/null +++ b/sio.aardio @@ -0,0 +1,174 @@ +import win.dlg.message; +import win.ui; +/*DSG{{*/ +var winform = win.form(text="简单串口助手";right=846;bottom=465) +winform.add( +btnOpen={cls="button";text="打开端口";left=85;top=411;right=183;bottom=445;db=1;dl=1;z=7}; +btnR={cls="button";text="R";left=196;top=178;right=307;bottom=241;z=13}; +btnT={cls="button";text="T";left=51;top=166;right=143;bottom=225;z=12}; +btnTx={cls="button";text="发送";left=582;top=411;right=680;bottom=445;db=1;dr=1;z=6}; +button={cls="button";text="Button";left=720;top=419;right=793;bottom=446;z=9}; +button2={cls="button";text="Button";left=726;top=351;right=793;bottom=399;z=11}; +combobox={cls="combobox";left=30;top=13;right=169;bottom=39;dl=1;dt=1;edge=1;items={};mode="dropdown";z=2}; +editRx={cls="edit";left=34;top=64;right=732;bottom=111;db=1;dl=1;dr=1;dt=1;edge=1;multiline=1;z=3}; +editTx={cls="edit";left=240;top=414;right=569;bottom=446;db=1;dl=1;dr=1;edge=1;z=5}; +lbComPort={cls="static";text="没有找到任何串口,建议安装虚拟串口驱动: Virtual Serial Port Driver";left=199;top=16;right=607;bottom=40;dl=1;dr=1;dt=1;transparent=1;z=4}; +openDeviceManager={cls="plus";text="打开设备管理器";left=612;top=14;right=732;bottom=38;align="left";color=8388608;font=LOGFONT(h=-13);notify=1;textPadding={left=5};z=8}; +static={cls="static";text="Static";left=71;top=341;right=203;bottom=367;transparent=1;z=10}; +trackbar={cls="plus";left=106;top=284;right=548;bottom=299;bgcolor=14265123;border={radius=-1};foreRight=15;forecolor=1865727;paddingBottom=5;paddingTop=5;z=1} +) +/*}}*/ + +//串口列表 +import sys.comPort; +var comPorts = sys.comPort.list(); +winform.combobox.items = comPorts; +winform.combobox.selIndex = sys.comPort.find("CP210x")[["index"]] or 1; + +//获取串口信息 +winform.combobox.oncommand = function(id,event){ + var item = comPorts[winform.combobox.selIndex] + if(item){ + winform.lbComPort.text = item.friendlyName; + } +} +winform.combobox.oncommand(); + +//串口发送 +import sio; +var sioPort; +winform.btnTx.oncommand = function(id,event){ + if(!sioPort){ + winform.btnOpen.oncommand(); + } + + if( !sioPort.write( winform.editTx.text ) ){ + return winform.msgErr("发送失败"); + } +} + +//打开串口 +winform.btnOpen.oncommand = function(id,event){ + if(sioPort){ + sioPort.close(); + } + + var err; + sioPort,err = sio.port(winform.combobox.selText); + if(!sioPort){ + return winform.msgErr(err); + } + + sioPort.ioctl(1e6,8,1); + //串口接收到数据触发回调 + sioPort.termCntIrq(1,function(port){ + var r = sioPort.read(); + //winform.editRx.appendText(r); + if(r == "try"){ + //sioPort.write("hello") + } + + } ) + + winform.msgOk("已打开端口",1000) +} + +winform.onDestroy = function(){ + if(sioPort){ + sioPort.close(); + } +} + +import sys.device; +winform.openDeviceManager.oncommand = function(id,event){ + sys.device.manager(); +} + +winform.openDeviceManager.skin({ + color={ + active=0xFF00FF00; + default=0xFF000080; + disabled=0xFF6D6D6D; + hover=0xFFFF0000 + } +}) + +var pos=0 +update = function(winform,length,total,pos){ + import console + + winform.trackbar.progressPos = math.round(length/total*100,1) + winform.static.text = winform.trackbar.progressPos + //console.log(winform.trackbar.progressPos) + +} + +winform.trackbar.setTrackbarRange(1,100) + +winform.button.oncommand = function(id,event){ + //var rst = sioPort.request("try",,5) + //winform.editRx.appendText("rec---"++rst) + sioPort.transmitAscii("E:\OneDrive - Cutting-Edge\Desktop\组成.png", + function(length,bufSize,buf,total){ + if(length >pos){ + pos = length + thread.invokeAndWait(update,winform,length,total) + } + + } + ) + winform.editRx.appendText("456"); +} + +winform.button2.oncommand = function(id,event){ + sioPort.abortWrite() +} + +winform.btnT.oncommand = function(id,event){ + /* +sioPort.transmitXmodem1kCrc("E:\OneDrive - Cutting-Edge\Desktop\组成.png", + function(length,bufSize,buf,total){ + if(length >pos){ + pos = length + thread.invokeAndWait(update,winform,length,total) + } + } + ) +*/ + //pos=0 + sioPort.transmitZmodem("E:\OneDrive - Cutting-Edge\Desktop\组成.png", + function(length,bufSize,buf,total){ + if(length >pos){ + pos = length + thread.invokeAndWait(update,winform,length,total) + } + } + ) +} + +winform.btnR.oncommand = function(id,event){ + var sta =sioPort.receiveXmodem1kCrc( + function(length,bufSize,buf,total){ + if(length >pos){ + pos = length + thread.invokeAndWait(update,winform,length,total) + } + } + ) + //pos=0 + + /** +sioPort.receiveAscii(5/*秒*/, + function(length,bufSize,buf,total){ + if(length >pos){ + pos = length + thread.invokeAndWait(update,winform,length,total) + } + } + ) +**/ +console.log("sta---",sta) +} + +winform.show(); +win.loopMessage(); \ No newline at end of file diff --git a/test.aardio b/test.aardio new file mode 100644 index 0000000..c2e0443 --- /dev/null +++ b/test.aardio @@ -0,0 +1,37 @@ +import win.ui; +/*DSG{{*/ +var winform = win.form(text="aardio form";right=759;bottom=469) +winform.add( +button={cls="button";text="Button";left=373;top=87;right=452;bottom=121;z=2}; +button2={cls="button";text="Button";left=586;top=65;right=668;bottom=100;z=3}; +custom={cls="\serial.aardio";text="自定义控件";left=49;top=45;right=396;bottom=363;z=1} +) +/*}}*/ + +import sio +import win.dlg.message; + +import console +var cfg, comport; +winform.button.oncommand = function(id,event){ + var ctrl = winform.custom; + cfg = winform.custom.getcfg() + console.dump(cfg) + comport,err = sio.port(cfg[1]) + if(!comport){ + return winform.msgErr(err); + } + sta,err = comport.ioctl(table.unpack(cfg,2)) + if(!sta){ + return winform.msgErr(err); + } + owner.text = "close" +} + +winform.button2.oncommand = function(id,event){ + var cfg = winform.custom.getcfg() + console.dump(cfg) +} + +winform.show(); +win.loopMessage(); \ No newline at end of file diff --git a/txt2table.aardio b/txt2table.aardio new file mode 100644 index 0000000..8017193 --- /dev/null +++ b/txt2table.aardio @@ -0,0 +1,467 @@ +import fonts.fontAwesome; +import win.ui; +/*DSG{{*/ +var winform = win.form(text="aardio form";right=815;bottom=567) +winform.add( +btnWbPrint={cls="button";text="Print";left=752;top=448;right=792;bottom=472;z=9}; +button={cls="button";text="Button";left=744;top=520;right=800;bottom=552;z=3}; +button2={cls="button";text="Copy";left=736;top=104;right=784;bottom=128;z=4}; +combobox={cls="combobox";left=736;top=168;right=808;bottom=192;edge=1;items={};mode="dropdownlist";z=8}; +edit={cls="edit";left=16;top=16;right=728;bottom=280;db=0.51;dl=1;dr=0.11;dt=1;edge=1;font=LOGFONT(name='Consolas');hscroll=1;multiline=1;vscroll=1;z=1}; +editOri={cls="edit";text="Edit";left=16;top=288;right=728;bottom=552;db=1;dl=1;dr=0.11;dt=0.51;edge=1;font=LOGFONT(name='Consolas');hscroll=1;multiline=1;vscroll=1;z=2}; +plusCenter={cls="plus";left=760;top=64;right=780;bottom=84;bgcolor=-5197169;font=LOGFONT(h=-13);iconStyle={font=LOGFONT(h=-13;name='FontAwesome')};iconText='\uF037';textPadding={left=20};z=7}; +plusLeft={cls="plus";left=736;top=64;right=756;bottom=84;bgcolor=-5197169;font=LOGFONT(h=-13);iconStyle={font=LOGFONT(h=-13;name='FontAwesome')};iconText='\uF036';notify=1;textPadding={left=20};z=5}; +plusRight={cls="plus";left=784;top=64;right=804;bottom=84;bgcolor=-5197169;font=LOGFONT(h=-13);iconStyle={font=LOGFONT(h=-13;name='FontAwesome')};iconText='\uF038';textPadding={left=20};z=6} +) +/*}}*/ + +/*** ++完成每列等宽设计 ++完成行内换行设计 +++完成换行后行内垂直居中设计 ++完成对齐功能L、C、R ++完成列合并功能 +++完成列合并后居中功能 ++完成行合并功能 +--待完成行合并后垂直居中功能 +*修复列宽bug +***/ + +import console +winform.editOri.text = /*** +阶段 逻辑信道 子帧类型 子帧简写 使用时隙类型 时隙简写 +初始\r建网阶段 搜索逻辑信道 \- \- 初始搜索子帧 SearchSFrm 长搜索时隙 SRSlot +\| 同\r步\r逻\r辑\r信\r道 自举子帧 BootSFrm 同步时隙 CS +\| 自举应答子帧 RBootSFrm 同步时隙 CR + 参数分发子帧 PSFrm 同步时隙 CP +入网周期帧阶段 同步逻辑信道 勤务同步子帧 SyncSFrm 同步时隙 S +\| 业务逻辑信道 数据子帧 DataSFrm 基本数据时隙 D + 信令逻辑信道 信令子帧 CSFrm 基本数据时隙 C +***/ + +/*** +"\r"代表单元格内换行 +"\-"代表与前列合并单元格,其后值忽略 +"\|"代表与前行合并单元格 +***/ + +winform.combobox.items = {"空白字符";"制表符";"空格"} +winform.combobox.selIndex =1 + +align = "" + + + + +str2xls = function(str,ss,s,c){ + if(!s){ + s= "-" + } + if(!c){ + c="+" + } + if(!ss){ + ss=s + } + + + + var strXls = ""; + string.appendText = function(str){ + strXls = strXls ++ str + } + var delta = 1; //默认两侧各多1个空格 + var Rowstr = string.splitEx(str,'\r\n')//分行 + + var pattern = {"\s+";"\t+";" +"}; //截断规则 + var Rowarr = table.map(Rowstr,lambda(v,k) string.splitEx(string.trimright(v),pattern[winform.combobox.selIndex]) )//分列 + + var Cmax = table.map(Rowarr,lambda(v,k) #v ); + table.sort(Cmax)//获取最大列数Cmax[#Cmax] + + var Rmax={}//最大子行数 + + RowarrRN = table.map(Rowarr,function(v,k,result){//分子行 + var a = {}; + var rr = 1; + //console.dump(v) + for(i=1;Cmax[#Cmax];1){//#tmp[1]获取最大列而非#v是避免遗漏空列 + var x = string.splitEx(v[i]==null?" ":v[i],"\\r"); //||代表元素换行 + table.push(a,x) + + if(rr<#x){//当前行内排序,找出最大的子行数 + rr=#x + } + } + table.push(Rmax,rr) + + return a; + }); + //console.dump(RowarrRN) + + + vc = function(arg,max){//数组元素居中 + var arr = arg; + var num = math.floor((max-#arr)/2); + while(num){ + table.insert(arr,"") + num = num-1 + } + arr = table.slice(table.mix(arr,table.array(max,"")),1,max) + return arr; + } + + vc1line = function(arg){//行内(换行)垂直居中 + var tmp = arg; + for(i=1;#tmp;1){ + for(j=1;#tmp[1];1){ + tmp[i][j] = vc(tmp[i][j],Rmax[i]) + } + } + return tmp; + } + + var tmp = vc1line(RowarrRN) + + vc2line = function(i,j){//连续行(合并行)垂直居中 + arr = vc(RowarrRN[i-1][j],Rmax[i-1]+2) + return arr; + } + //console.dump(vc2line(3,3)) + + glA = function(str){//获取字符中ASCII字符个数 + var llA = {}; + string.search(llA,str,"\i" ) + return #llA; + } + + gw = function(){ //获取每列最大列宽 + var wmax = {}; //每列最大列宽 + + for(j=1;#tmp[1];1){//col + var llA = glA(tmp[1][j][1]) + var w = string.len(tmp[1][j][1])-math.floor(llA/2)//;#tmp[1][j][1];#l1A}; //字符宽,字节宽,ASCII个数 + + for(i=1;#tmp;1){//row + for(ii=1;Rmax[i];1){ + if(tmp[i][j][ii]==null){ + tmp[i][j][ii]= "" + } + + + var llA = glA(tmp[i][j][ii]) + var l = string.len(tmp[i][j][ii])-math.floor(llA/2) + if(w <= l){//字符最长 + w = l//字符宽 + } + } + } + table.push(wmax,w) + } + return wmax; + + } + + var UserWmax = table.clone(gw()) + //console.dump(UserWmax) + + + + txt2arrOri = function(){ + var newstr = {}; + for(i=1;#tmp;1){//row + for(ii=1;Rmax[i];1){//元素换行 + var rowsep={} + var rowtxt={} + for(j=1;#tmp[1];1){ + + // + //新数组,[行号]={连接符; 单元格字符; sta;对应原txt所在行} + var con = c; + var dstr = string.repeat((UserWmax[j]+delta)*2,s) + //var l = (UserWmax[j]-string.len(tmp[i][j][ii]))*2+math.round(glA(tmp[i][j][ii]))+2*delta; //需添加空格数 + + + if(i == 2){//表头,last + //dstr = string.repeat((UserWmax[j]+delta)*2,ss); + } + + if(ii == 1){//子行不添加分割行 + table.push(rowsep,{con;dstr;0}) + } + + table.push(rowtxt,{"|";tmp[i][j][ii];0;i}) + }//end j + + if(rowsep[1]!=null){ + table.push(newstr,rowsep)//new row in cell; + } + table.push(newstr,rowtxt) + //console.dump(newstr[i][2]) + }//end ii + }//end i + return newstr; + } + + //var txtArr = txt2arrOri() + +//console.dump(txt2arrOri()) + formatarr = function(a){ + + var arg = a; + + gs = function(){ + var a = table.array(#arg,#arg[1],0); + for(i=1;#arg;1){//row + for(j=1;#arg[1];1){ + select(arg[i][j][2]) { + case "\-" {//优先处理行内合并 + a[i][j]=-1 + if(j>1){ + a[i][j-1]=-1 + } + } + case "\|" { + a[i][j]=1 + } + else { + a[i][j]=0 + } + } + } + } + return a; + } + var sta = gs() + //console.dump(sta) + + //align + aCell = function(str,w){//align current cell + if(w==null){ + //w=UserWmax[j] + } + var ll = (w-string.len(str))*2+math.round(glA(str))+2*delta; //需添加空格数 + + select(align) { + case "Center" {//center + return string.repeat(math.floor(ll/2)," ") ++ str ++ string.repeat(ll-math.floor(ll/2)," ")) + } + case "Right" {//right + return string.repeat(ll-delta," ") ++ str ++ string.repeat(delta," ")) + } + else {//left + return string.repeat(delta," ") ++ str ++ string.repeat(ll-delta," ")) + } + } + } + + + + + var tmpalign = align + for(i=1;#arg;1){//row + for(j=1;#arg[1];1){ + if(arg[i][j][1] != c){//only txt + if(i == 2){//表头强制居中 + align = "Center" + } + else { + align = tmpalign + } + arg[i][j][2] = aCell(arg[i][j][2],UserWmax[j]) + } + } + } + + + + + + var Rc = Rowarr; + var xd = txt2arrOri(); + for(i=1;#arg;1){//row + for(j=1;#arg[1];1){ + if(arg[i][j][1] != c){//only txt + + //行合并 + if(xd[i][j][2] == "\|" and i != 1 and sta[i-1] != -1){ + //xd[i][j][2] = "" + var k = 1; + var r2c = Rmax[arg[i][j][4]] + Rmax[arg[i][j][4]-1]+1; + var ori = {}; + var r1 = i-math.floor((Rmax[arg[i][j][4]]-1)/2)-Rmax[arg[i][j][4]-1]-1 + for(r=r1;r1+Rmax[arg[i][j][4]-1]-1;1){ + table.push(ori,xd[r][j][2]) + } + + //while(xd[i+2*(k)][j][2] == "\|"){ + while(Rc[arg[i][j][4]+k][j] == "\|"){//txt下一行同列 + //console.dump(k,Rmax[arg[i][j][4]+k]) + Rc[arg[i][j][4]+k][j] = "" + math.floor((Rmax[arg[i][j][4]]-1)/2) + r2c += Rmax[arg[i][j][4]+k]+1 + if(k!=#arg){ + k += 1 + } + //console.dump(Rc) + } + ori = vc(ori,r2c) + //console.dump(ori) + for(r=1;#ori;1){ + xd[r1+r-1][j][2]="" + arg[r1+r-1][j][2]=aCell(ori[r],UserWmax[j]) + } + } + + //行内合并 + if(xd[i][j][2] == "\-" and j != 1){//第一列无效 + xd[i][j][2] = "" + //check how many cells to compose + var k = 1; + var w = UserWmax[j]+UserWmax[j-1]; + while(xd[i][j+k][2] == "\-"){ + //console.log(k) + xd[i][j+k][2] = "" + w += UserWmax[j+k] + if(k!=#arg[1]){ + k += 1 + } + } + + //force align to center + var r2c = Rmax[arg[i][j-1][4]]; + for(r=i-math.floor((r2c-1)/2);i+r2c-math.floor((r2c-1)/2)-1;1){ + var str = txt2arrOri()[r][j-1][2]; + var ll = (w-string.len(str))*2+math.round(glA(str))+2*delta+(2*delta+1)*k; //需添加空格数 + arg[r][j-1][2] = string.repeat(math.floor(ll/2)," ") ++ str ++ string.repeat(ll-math.floor(ll/2)," ") + //arg[r][j][2] = "" + for(n=0;k-1;1){ + arg[r][j+n][2] = "" + } + } + }//end + + + } + } + } + + + + return arg; + + } + + arr2str = function(arr){ + var strs = table.map(arr,function(v,k,result){ + var c = v[1][1]; + //var str = table.map(v,lambda(vv,kk) vv[2]) + var str = {} + for(i=1;#v;1){//去掉空cell,数组大小会减小,map不改变数组大小 + if(v[i][2]!=""){ + table.push(str,v[i][2]) + } + } + return c++string.join(str,c)++c + }) + //console.dump(strs) + strXls = string.join(strs,'\r\n') ++ '\r\n' ++ strs[1] + } + + arr2str(formatarr(txt2arrOri())) + + return "
" ++ strXls ++"
"; +}//end str2xls + + + + +//write-space:pre|pre-line; + +import web.form +var wb = web.form(winform.edit); +wb.html = /** + + + + + + + + + + + + + + +**/ + +winform.button2.oncommand = function(id,event){ + wb.execWb( 0x11/*_OLECMDID_SELECTALL*/,0 ) + wb.execWb( 0xC/*_OLECMDID_COPY*/,0 ) +} + +winform.button.oncommand = function(id,event){ + wb.body.innerHTML = str2xls(winform.editOri.text,"="); +} + + +for(name,ctrl in winform.eachControl("plus","plus*") ){ + ctrl.skin({ + background={ + default=0x668FB2B0; + disabled=0xFFCCCCCC; + hover=0xFF928BB3 + }; + color={ + default=0xFF000000; + disabled=0xFF6D6D6D + } + }) + + ctrl.oncommand = function(id,event){ + align = string.trimleft(name,"plus"); + winform.button.oncommand() + } +} + +winform.button.oncommand() + +winform.editOri.onChange = function(){ + winform.button.oncommand() +} + + +winform.combobox.oncommand= function(id,event){ + var text = owner.selText; + if(event == 9/*_CBN_SELENDOK*/){ + winform.button.oncommand() + } +} + + + //HTML格式打印 +winform.btnWbPrint.oncommand = function(id,event){ + wb.getDoc().execCommand("print") +} + +winform.show(); +win.loopMessage(); \ No newline at end of file diff --git a/保存ADI器件手册地址.aardio b/保存ADI器件手册地址.aardio new file mode 100644 index 0000000..35ac7e9 --- /dev/null +++ b/保存ADI器件手册地址.aardio @@ -0,0 +1,59 @@ + +//修改网站页面 +import win.ui; +import web.form; +/*DSG{{*/ +var winform = win.form(text="aardio form";right=713;bottom=477;parent=...;scroll=1) +winform.add( +Go={cls="button";text="Go";left=569;top=38;right=608;bottom=71;z=4}; +button={cls="button";text="Download";left=638;top=37;right=693;bottom=71;z=1}; +edit={cls="edit";text="https://www.analog.com/en/parametricsearch/11010";left=52;top=41;right=555;bottom=65;edge=1;multiline=1;z=3}; +static={cls="static";text="Static";left=32;top=128;right=677;bottom=443;db=1;dl=1;dr=1;dt=1;transparent=1;z=2} +) +/*}}*/ + +import web.form; + +//创建web窗体 +var wb = web.form( winform.static,,,,true ); +wb.noScriptErr=true; + + + + +winform.show() + + + +winform.button.oncommand = function(id,event){ +var ele = wb.waitQueryEles( +//innerHTML="ADR1399"; +//tagName="^A$"; +href="//www.analog.com/en/.*"; +//className="product" +target="_blank" +//rel="noopener noreferrer" + ),10000; +//win.msgbox(ele.href++ "/datasheet") + +var list = {} +for(k,v in ele){ + var tmp = v.href ++ "/datasheet"++ '\r\n' + list[tmp] = list[tmp]==null?1:list[tmp] + 1 +} +import console +console.dumpTable(list) +for(k,v in list){ + string.save("d:\adi.txt",k ,true) + +} + +} + + + +winform.Go.oncommand = function(id,event){ +wb.go(winform.edit.text) +} + +win.loopMessage(); \ No newline at end of file diff --git a/悬浮窗口.aardio b/悬浮窗口.aardio new file mode 100644 index 0000000..b5effb4 --- /dev/null +++ b/悬浮窗口.aardio @@ -0,0 +1,72 @@ +//透明 3D +import win.ui; +/*DSG{{*/ +var winform = win.form(text="WebView2 - 透明3D";right=1112;bottom=771;border="none") +winform.add( +static={cls="static";text="Static";left=523;top=334;right=1054;bottom=699;transparent=1;z=1} +) +/*}}*/ + +import console +import web.form; +var wb = web.form(winform); + + +//窗口透明 +winform.transparent(128,0xFFFFFFFF) +//winform.transparent(true) + +//webView2 控件透明 +//wb.defaultBackgroundColor = 0x00000000; + +wb.go("/index.aardio",{str="IMG_1199.jpg"}) + +//var ele = wb.document.getElementsByClassName('sp-wrap'); + +//console.log(ele.innerHTML) + +//wb.waitEle("body") +winform.show() +wb.wait() + + +var js = /** + document.body.style.backgroundColor = 'transparent'; +**/ +wb.doScript(js, ) + + +wb.showMenu = function(x,y,id,ele){ + /*定义此事件函数则禁用默认的右键弹出菜单*/ + select(id) { + case 0/*_CONTEXT_MENU_DEFAULT */ { + + } + case 1/*_CONTEXT_MENU_IMAGE*/ { + + } + case 2/*_CONTEXT_MENU_CONTROL*/ { + + } + case 4/*_CONTEXT_MENU_TEXTSELECT */ { + + } + case 5/*_CONTEXT_MENU_ANCHOR*/ { + + } + } + return false; +} + + +wb.attach( + function(event){ + if(event.button = 2){ + wb._form.hitClose() + } + } + ,"onmouseup",/*也可输入getEle()所需参数,省略表示doc*/ +) + + +win.loopMessage(); \ No newline at end of file