import win.ui;
/*DSG{{*/
var winform = win.form(text="aardio做界面调用node.js解压asar文件";right=714;bottom=229)
winform.add(
btnExtractAll={cls="button";text="解压";left=451;top=115;right=618;bottom=179;z=3};
btnOpen={cls="button";text="选择要解压的文件";left=499;top=42;right=657;bottom=85;z=2};
editAsarFile={cls="edit";left=55;top=45;right=494;bottom=83;edge=1;multiline=1;z=1}
)
/*}}*/

import fsys.dlg;
winform.btnOpen.oncommand = function(id,event){
	winform.editAsarFile.text = fsys.dlg.open("*.asar|*.asar|","选择asar文件",,winform.hwnd)
}

winform.btnExtractAll.oncommand = function(id,event){
    winform.btnExtractAll.disabled = true;
    
    win.invoke(
    	function(winform){
    		import nodeJs;	
    		
    		nodeJs.startEnviron(
				src = winform.editAsarFile.text;
				dest = fsys.getParentDir(winform.editAsarFile.text) ++ fsys.getFileName(winform.editAsarFile.text) + "_ExtractAll"; 
			)
			
			nodeJs.require('asar');
			
			var testjs = /***
			var startEnviron = require('startEnviron')
			var asar = require('asar');
			 
			asar.extractAll(startEnviron.src, startEnviron.dest )
			***/
			var node = nodeJs.exec(testjs);
    	},winform
    ) 
    
    winform.btnExtractAll.disabled = false;
}
 
winform.show(true);
win.loopMessage();