-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmain.aardio
385 lines (348 loc) · 11 KB
/
main.aardio
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
import fonts.fontAwesome;
import win.ui;
//import win.ui.simpleWindow;
import win.ui.atom;
import win.ui.tabs;
import win.ui.tooltip;
import win.util.tray;
import key;
import sqlite;
import process;
import config;
import domisoft;
import SAP;
import solidedge.application;
import godking.listboxEx;
import fsys.table;
/*DSG{{*/
mainForm = win.form(text="TBM";right=750;bottom=550;bgcolor=15793151)
mainForm.add(
closeAll={cls="plus";left=715;top=10;right=747;bottom=35;align="left";color=3947580;dr=1;dt=1;font=LOGFONT(h=-16);iconStyle={font=LOGFONT(h=-16;name='FontAwesome')};iconText='\uF05C';notify=1;z=8};
custom={cls="custom";left=140;top=40;right=750;bottom=520;ah=1;aw=1;bgcolor=16777215;db=1;dl=1;dr=1;dt=1;z=2};
foldchk={cls="plus";left=8;top=8;right=32;bottom=32;align="left";color=8388608;dl=1;dt=1;font=LOGFONT(h=-27);iconStyle={align="left";font=LOGFONT(h=-27;name='FontAwesome')};iconText='\uF03B';notify=1;textPadding={left=15};z=3};
listbox={cls="listbox";left=0;top=40;right=140;bottom=520;ah=1;bgcolor=11224832;color=16777215;db=1;dl=1;dt=1;font=LOGFONT(h=-13;name='FontAwesome');items={};ownerDraw=1;vscroll=1;z=4};
splitter={cls="splitter";left=139;top=40;right=144;bottom=550;db=1;dt=1;z=5};
stripTab1={cls="plus";text="tab1";left=145;top=16;right=245;bottom=40;dl=1;dt=1;font=LOGFONT(name='FontAwesome');iconStyle={align="left";font=LOGFONT(name='FontAwesome')};iconText='\uF0AD';z=6};
stripTab2={cls="plus";text="tab2";left=245;top=16;right=345;bottom=40;dl=1;dt=1;iconStyle={align="left";font=LOGFONT(name='FontAwesome')};iconText='\uF0AD';z=7};
titleBar={cls="bkplus";left=0;top=0;right=750;bottom=40;bgcolor=11224832;dl=1;dr=1;dt=1;forecolor=16777215;linearGradient=180;z=1}
)
/*}}*/
mainForm.closeAll.skin({
color={
active=0xFF00FF00;
default=0xFF3C3C3C;
disabled=0xFF6D6D6D;
hover=0xFFFF0000
}
})
/*只允许一个实例{{*/
var atom,hwnd = mainForm.atom("domisoft.aardio.tbm");
if(!atom and !_STUDIO_INVOKED){
win.showForeground(hwnd);
win.setActive(hwnd);
win.quitMessage();
return;
}
/*}}*/
/*closeOnEscPress{{*/
mainForm.isDialogMessage = function(hwnd,msg){
if( msg.message == 0x100/*_WM_KEYDOWN*/){
if( msg.wParam == 0x1B/*_VK_ESC*/ ){ //按Esc退出窗口
mainForm.close();
return true;//告诉消息处理函数这是一个快捷键,阻止按键消息继续分发
}
}
//检测并响应默认快捷键
return win.isDialogMessage(hwnd,msg);
}
/*}}*/
//win.ui.simpleWindow( mainForm );
mainForm.bindConfig( config.mainForm,{
splitter = "left";
listbox = "width";
} );
mainForm.foldchk.skin(
color = {
hover = 0xFFFF0000;
active = 0xFF00FF00;
}
checked = {
//text = '';//' 勾选了'/*_FA_CHECK_SQUARE*/;;
iconText = '\uF03C';
}
)
/*托盘图标{{*/
mainForm.tray = win.util.tray(mainForm);
mainForm.onMinimize = function(lParam){
mainForm.show(false);
return true;
}
mainForm.onClose = function(hwnd,message,wParam,lParam){
if io.exist(io.joinpath(io._exedir,"update\se_tbm.exe")){
win.quitMessage();
return 0;
}
if _STUDIO_INVOKED win.quitMessage();
mainForm.onMinimize();
return true;
}
mainForm.onDestroy = function(){
if(mainForm.tray){
mainForm.tray.delete()
}
}
import com.interface.ITaskbarList3;
mainForm.wndproc = function(hwnd,message,wParam,lParam){
select(message) {
case 0xACCF/*_WM_TRAYMESSAGE*/ {
select(lParam) {
case 0x205/*_WM_RBUTTONUP*/ {
win.setForeground(mainForm.hwnd) //弹出托盘菜单以前,一定要前置主窗口中,不然不点击菜单不会消失
var pt = ::POINT();
::User32.GetCursorPos(pt);
mainForm.popmenu2.popup(pt.x,pt.y, true);
}
case 0x202/*_WM_LBUTTONUP*/ {
win.setForeground(mainForm.hwnd); //弹出托盘菜单以前,一定要前置主窗口中,不然不点击菜单不会消失
mainForm.show(!win.isVisible(mainForm.hwnd));
}
}
}
case _WM_TASKBARBUTTONCREATED {
mainForm.taskbar = com.interface.ITaskbarList3.Create() ;
}
}
}
/*}}*/
/*托盘右键菜单{{*/
mainForm.popmenu2 = win.ui.popmenu(mainForm);//创建弹出菜单
mainForm.popmenu2.add('&Open TBM', function(){
//在下面输入菜单响应代码
win.setForeground(mainForm.hwnd)
mainForm.show();
});
mainForm.popmenu2.add();//分隔线
mainForm.popmenu2.add('Teamcenter插件更新...', λ() thread.invoke(λ() loadcodex("\forms\Teamcenter\更新插件.aardio")));
mainForm.popmenu2.add('收集Teamcenter打开的图纸...', λ() thread.invoke(λ() loadcodex("\forms\Teamcenter\收集temp内的PDF文件放入PDF库.aardio")));
mainForm.popmenu2.add();//分隔线
mainForm.popmenu2.add('SE导出当前截图...', λ() thread.invoke(
function(){
import solidedge.application;
var seApp = solidedge.application();
seApp.exportViewAsPng();
}
)
);
mainForm.popmenu2.add('SAP一键登入1', function(){
thread.invoke(SAP.sapQuickOpen)
mainForm.tray.message = 0xACCF/*_WM_TRAYMESSAGE*/
mainForm.tray.pop("Starting SAP GUI ...","TBM");
});
mainForm.popmenu2.add('SAP一键登入2', function(){
thread.invoke(SAP.sapQuickOpen,2)
mainForm.tray.message = 0xACCF/*_WM_TRAYMESSAGE*/
mainForm.tray.pop("Starting SAP GUI ...","TBM");
});
mainForm.popmenu2.add();//分隔线
mainForm.popmenu2.add('&Exit', λ() win.quitMessage());
/*}}*/
mainForm.splitter.split(mainForm.listbox, mainForm.custom);
{
var tWidth = mainForm.stripTab1.width;
mainForm.stripTab1.left = mainForm.listbox.width;
mainForm.stripTab1.width = tWidth;
mainForm.stripTab2.left = mainForm.listbox.width + mainForm.stripTab1.width;
}
mainForm.mTabs = win.ui.tabs(mainForm.stripTab1, mainForm.stripTab2);
/*tabStle{{*/
mainForm.mTabs.margin = 40;
mainForm.mTabs.clear();
mainForm.mTabs.skin({
background={
active=0xFFFFFFFF;
default=0x00FFFFFF;
hover=0xFF98FB98;
};
color={
default=0xFF0F0000;
};
checked={
background={default=0xFFFFFFFF;};
color={default=0xFF42A875;};
border = {
default = {left=1;right=1;top=1;color=0xFF008000}
disabled = {left=1;right=1;top=1;color=0xFF008000}
};
}
})
/*}}*/
mainForm.mTabs.onSelchange = function(idx,tab,form){
mainForm.text = string.join({tab.text, "TBM工具箱"}," - ");
mainForm.listbox.selected = null;
for (i=1; mainForm.listbox.count) {
var txt = table.pop(string.split(mainForm.listbox.items[i],","))
if txt == tab.text {
mainForm.listbox.selIndex = i;
break;
}
}
}
/*左侧导航按钮{{*/
var loadfrmName, menuList, menuTheme = loadcodex("\menulist.aardio");
var navlb = godking.listboxEx(
mainForm.listbox/*列表框组件*/,
menuList/*菜单列表*/,
menuTheme/*主题*/
)
var getExistTabIdx = function(tabname){
for(tab,form,idx in mainForm.mTabs.each() ){
if tab.text == tabname
return idx;
}
return null;
}
mainForm.listbox.getSelMenuInfo = function(selText){
selText := mainForm.listbox.selText
var navArr = string.split(selText,",");
return {
index: tonumber(navArr[1]);
subindex: tonumber(navArr[2]);
iconText: string.unescape(navArr[3]);
ActiveIconText: string.unescape(navArr[4]);
text: navArr[5] ;
};
}
var rSelTab = null;
mainForm.mTabPopMenu = win.ui.popmenu(mainForm);
mainForm.mTabPopMenu.add("重复打开此窗口",function(){
for (i=1; mainForm.listbox.count) {
var txt = table.pop(string.split(mainForm.listbox.items[i],","))
if txt == rSelTab.text {
var navItem = mainForm.listbox.getSelMenuInfo(mainForm.listbox.items[i]);
mainForm.listbox.addThisTab(navItem);
break;
}
}
})
mainForm.mTabPopMenu.add("关闭此窗口",λ() mainForm.mTabs.deleteByTab(rSelTab))
mainForm.listbox.addThisTab = function(navItem){
win.setTimeout(function(){
navItem := mainForm.listbox.getSelMenuInfo();
mainForm.mTabs.selIndex = mainForm.mTabs.add(
{
text = navItem.text;
iconText = navItem.ActiveIconText;
hasCloseButton = true
}, loadfrmName[navItem.index][navItem.subindex]
);
mainForm.mTabs.selTab.onRightMouseUp = function(wParam,lParam){
var x,y = win.getMessagePos();
rSelTab = mainForm.mTabs.hitTest(x,y)
mainForm.mTabPopMenu.popup(x,y,true);
}
})
}
navlb.onClick = function(index,subindex,text){
if !subindex return ;
var checkIdx = getExistTabIdx(text);
if !checkIdx
mainForm.listbox.addThisTab();
else
mainForm.mTabs.selIndex = checkIdx;
}
/*}}*/
/*折叠导航按钮{{*/
var foldNave = function(){
if mainForm.foldchk.checked {
mainForm.listbox.show(false);
mainForm.splitter.show(false);
mainForm.custom.left = 0;
} else {
mainForm.custom.left = mainForm.listbox.width + 3 ;
mainForm.splitter.width = 3;
mainForm.listbox.show(true);
mainForm.splitter.show(true);
}
}
mainForm.foldchk.oncommand = foldNave
/*}}*/
win.setTimeout(
function(){
mainForm.custom.loadForm(loadfrmName[4][1])
}
)
if !config.settings.startupMinimized or !config.settings.closeToTray
mainForm.show();
if _STUDIO_INVOKED
mainForm.show();
/*格式化BOM{{*/
subscribe("dok", function(...){
import win;
win.delay(3*1000);
var ftab = ...;
if !ftab return ;
thread.invoke(
function(ftab){
import domisoft;
import config;
import QHC;
var sht = domisoft.getRunningWorkSheet(ftab);
QHC.formatBOM(sht);
import fsys;
var destPath = io.joinpath(config.dbServer.path,"\xl_lib\");
if sht.ParentPath !== destPath
fsys.copy(sht.Parent.FullName, destPath, 0x10/*_FOF_NOCONFIRMATION*/)
}, ftab
)
} )
/*}}*/
//mainForm.closeAll.oncommand = mainForm.mTabs.clear;
mainForm.closeAll.onMouseClick = function(wParam,lParam){
//var x,y = win.getMessagePos(lParam);
var ctrl = ::GetKeyState(0x11/*_VK_CTRL*/) & 0x8000;
if !ctrl
mainForm.mTabs.delete(mainForm.mTabs.selIndex);
else
mainForm.mTabs.clear();
}
var tooltipCtrl = win.ui.tooltip( mainForm );
mainForm.closeAll.tooltip = tooltipCtrl.addTool(mainForm.closeAll,"点击: 关闭当前子窗口" ++ '\r\n' ++ "CTRL+点击: 关闭所有子窗口");
mainForm.foldchk.tooltip = tooltipCtrl.addTool(mainForm.foldchk,"折叠左侧导航栏");
mainForm.popmenu = win.ui.popmenu(mainForm);
mainForm.popmenu.add('在新窗口中打开', λ() mainForm.listbox.addThisTab());
/*右键新建菜单{{*/
mainForm.listbox.wndproc = function(hwnd,message,wParam,lParam){
select( message ) {
case 0x205/*_WM_RBUTTONUP*/{
var x,y = win.getMessagePos();
var item = mainForm.listbox.hitTest(x,y,true);
if( item ){
mainForm.listbox.selIndex = item;
mainForm.popmenu.popup(x,y,true)
}
}
}
}
/*}}*/
import mouse.hook;
var hook = mouse.hook();
import win.ui.statusbar;
var statusbar = win.ui.statusbar( mainForm );
statusbar.addItem("", 100/*宽度*/);
statusbar.addItem("", 400/*宽度*/);
statusbar.setMinHeight(30);//设置最小高度(含上下边框宽度)
//录制回调函数
hook.proc = function(msg,x,y,mouseData,injected,flags,timeStamp,extraInfo){
if( injected ) return; //模拟鼠标不处理
select(msg) {
case 0x20C/*_WM_XBUTTONUP*/{
var backButtonUp = (::HIWORD(mouseData) == 1);
if backButtonUp
statusbar.setText("back", 2/*第几个分块*/);
else
statusbar.setText("forward", 2/*第几个分块*/);
}
}
}
win.loopMessage();
return mainForm;