public static object[] destruct(object control) { List <object> list = new List <object>(); if (control != null) { // ToolMobile.log("control destruct [" + control.GetType().FullName + "]"); list.Add(control); if ((control as IIndestructable) == null) { ISelfDestructable s = control as ISelfDestructable; if (s != null) { foreach (object o in s.selfDestruct()) { list.AddRange(destruct(o)); } } else { // ToolMobile.log("control destruct try as group view [" + control.GetType().FullName + "]"); foreach (object o in ToolMobile.getChilds(control as View)) { list.AddRange(destruct(o)); } } } } return(list.ToArray()); }
public static void SAVE() { LOAD(); StringBuilder sb = new StringBuilder(); foreach (ENVITM itm in envKeys_.Values) { sb.AppendLine(itm.ToString()); } ToolMobile.writeFileText(fileName, sb.ToString()); }
public void print(string pData, Encoding pEnc) { IPrinter handler = null; string printer_ = CurrentVersion.ENV.getPrinter(); if (printer_.Contains(":")) { handler = new PrintHandlerTcp(pEnc); } else { handler = new PrintHandlerBT(pEnc); } try { handler.open(); handler.writeLine(" ", true); handler.write(pData); // handler.writeLine(" ", true); // // if (CurrentVersion.ENV.getEnvBool("AUTOCUT", false)) { string GS = Convert.ToString((char)29); string ESC = Convert.ToString((char)27); string COMMAND = ""; COMMAND = ESC + "@"; COMMAND += GS + "V" + (char)1; handler.write(COMMAND); } } catch (Exception exc) { ToolMobile.setException(exc); } finally { handler.close(); } }
public ImplUserImage(string folder) { if (ToolMobile.existsDir(folder)) { string[] files = ToolMobile.getFiles(folder); foreach (string file in files) { if (System.IO.Path.GetExtension(file).ToLowerInvariant() == ".png") { byte[] arr_ = ToolMobile.readFileData(file); setImage(System.IO.Path.GetFileName(file), BitmapFactory.DecodeByteArray(arr_, 0, arr_.Length)); } } } }
public SqliteCommand getNewSqlCommand(string sqlText, SqliteParameter[] par) { ToolMobile.log(sqlText); SqliteCommand cmd = new SqliteCommand(); cmd.CommandText = this.prepareSqlText(sqlText); cmd.Connection = this.getConnection(); cmd.Transaction = this.getTransaction(); //cmd.CommandTimeout = this.getSqlTimeOut(); if (par != null) { cmd.Parameters.AddRange(par); } return(cmd); }
public static void startFormForResult(Type type) { try { ActivityExt x = getContextLast(); Intent intent = new Intent(x, type); x.StartActivityForResult(intent, 0); } catch (Exception exc) { ToolMobile.setException(exc); throw new MyExceptionInner(MessageCollection.T_MSG_ERROR_INNER, exc); } }
public static void LOAD() { if (envKeys_ == null) { envKeys_ = new Dictionary <string, ENV.ENVITM>(); if (ToolMobile.existsFile(fileName)) { StringReader sr = new StringReader(ToolMobile.readFileText(fileName)); string line_ = null; while ((line_ = sr.ReadLine()) != null) { ENV.ENVITM.PARSE(line_); } } } }
public static void start() { try { string tmp = getTmpDir(); if (Directory.Exists(tmp)) { Directory.Delete(tmp, true); } ToolMobile.createDir(tmp); } catch (Exception exc) { ToolMobile.setExceptionInner(exc); } }
public static void restartEnvironment() { try { ToolMobile.setEnvironment(null); } catch (Exception exc) { ToolMobile.setExceptionInner(exc); } try { getEnvironment(); } catch (Exception exc) { ToolMobile.setExceptionInner(exc); } }
public static void setEnvironment(IEnvironment pEnv) { if (_environment != null) { var x = _environment; _environment = null; x.Dispose(); } _environment = pEnv; if (_environment == null) { ToolMobile.log("environment stoped"); } else { ToolMobile.log("environment starting"); } }
public static void startForm(Type type, string[] args, Java.IO.ISerializable[] vals) { try { ActivityExt x = getContextLast(); Intent intent = new Intent(x, type); if (args != null && vals != null) { for (int i = 0; i < Math.Min(args.Length, vals.Length); ++i) { intent.PutExtra(args[i], vals[i]); } } x.StartActivity(intent); } catch (Exception exc) { ToolMobile.setException(exc); throw new MyExceptionInner(MessageCollection.T_MSG_ERROR_INNER, exc); } }
public static Stream findChain(String pFileName) { try { for (int i = 0; i < FileConst.keyDirLocations.Length; ++i) { string dir = FileConst.keyDirLocations[i]; string fullPath = Path.Combine(dir, pFileName); if (Directory.Exists(dir)) { if (ToolMobile.existsFile(fullPath)) { return(new FileStream(fullPath, FileMode.Open)); } } } return(null); } catch { return(null); } }
async static void startScan(Action <string> barcode) { try { var opt = new ZXing.Mobile.MobileBarcodeScanningOptions(); opt.PossibleFormats.Clear(); opt.PossibleFormats.Add(ZXing.BarcodeFormat.EAN_13); opt.PossibleFormats.Add(ZXing.BarcodeFormat.EAN_8); opt.PossibleFormats.Add(ZXing.BarcodeFormat.CODE_128); var scanner = new ZXing.Mobile.MobileBarcodeScanner(); var result = await scanner.Scan(opt); if (result != null && barcode != null) { barcode.Invoke(result.Text); } } catch (Exception exc) { ToolMobile.setException(exc); } }
static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) { ToolMobile.setExceptionInner(e.ExceptionObject as Exception); }
internal bool openBT() { BluetoothAdapter mBluetoothAdapter = getAdapter(); BluetoothDevice mmDevice = null; if (mBluetoothAdapter == null) { ToolMobile.log("no bt adapter"); ToolMsg.show(null, MessageCollection.T_MSG_ERROR_CONNECTION + " [BLUETOOTH]", null); return(false); } if (!mBluetoothAdapter.IsEnabled) { ToolMobile.log("enable bt adapter"); mBluetoothAdapter.Enable(); for (int i = 0; i < 15; ++i) { if (mBluetoothAdapter.IsEnabled) { break; } Thread.Sleep(100); } if (!mBluetoothAdapter.IsEnabled) { ToolMsg.show(null, MessageCollection.T_MSG_ERROR_CONNECTION + " [BLUETOOTH]", null); return(false); } } List <string> list = new List <string>(); foreach (BluetoothDevice dev_ in mBluetoothAdapter.BondedDevices) { list.Add(dev_.Name); if (dev_.Name == CurrentVersion.ENV.getPrinter()) { mmDevice = dev_; break; } } if (mmDevice == null) { string[] arr_ = list.ToArray(); ToolMsg.askList(null, arr_, (o, e) => { if (e.Which >= 0 && e.Which < arr_.Length) { CurrentVersion.ENV.setPrinter(arr_[e.Which]); } }); // ToolMsg.show(null, MessageCollection.T_MSG_ERROR_NO_DATA + " BLUETOOTH = [" + CurrentVersion.ENV.getPrinter() + "]", null); return(false); } try { //mBluetoothAdapter.StartDiscovery(); //for (int i = 0; i < 10; ++i) //{ // if (mBluetoothAdapter.IsDiscovering) // break; // Thread.Sleep(100); //} // UUID uuid = UUID.FromString("00001101-0000-1000-8000-00805f9b34fb"); IntPtr createRfcommSocket = JNIEnv.GetMethodID(mmDevice.Class.Handle, "createRfcommSocket", "(I)Landroid/bluetooth/BluetoothSocket;"); IntPtr _socket = JNIEnv.CallObjectMethod(mmDevice.Handle, createRfcommSocket, new Android.Runtime.JValue(1)); mmSocket = Java.Lang.Object.GetObject <BluetoothSocket>(_socket, JniHandleOwnership.TransferLocalRef); mBluetoothAdapter.CancelDiscovery(); mmSocket.Connect(); // Method m = mmDevice.GetType().GetMethod("CreateRfcommSocket", new Type[] {int.class}); //tmp = (BluetoothSocket) m.invoke(device, 1); // mmSocket = mmDevice.CreateRfcommSocketToServiceRecord(uuid); // mmSocket.Connect(); //time out not supported // mmInputStream.ReadTimeout = mmInputStream.WriteTimeout = mmOutputStream.ReadTimeout = mmOutputStream.WriteTimeout = 5000; return(true); } catch (Exception exc) { ToolMobile.log(exc.ToString()); ToolMobile.setExceptionInner(exc); } finally { } return(false); }