public void printStoredFormatWithHash(string formatPathOnPrinter, IReadOnlyDictionary <string, string> vars, IMethodResult oResult) { Logger.Write("printStoredFormatWithHash call"); Logger.Write("formatPathOnPrinter: " + formatPathOnPrinter); Logger.Write("vars: ", vars); if (m_printer != null) { Dictionary <int, string> _params = new Dictionary <int, string>(); foreach (KeyValuePair <string, string> pair in vars) { try { _params.Add(Int32.Parse(pair.Key), pair.Value); } catch (Exception e) { } } m_printer.GetFormatUtil().PrintStoredFormat(formatPathOnPrinter, _params); oResult.set(ZebraConstants.PRINTER_STATUS_SUCCESS); return; } oResult.set(ZebraConstants.PRINTER_STATUS_ERROR); }
public void enumerateSupportedControlLanguages(IMethodResult oResult) { Logger.Write("enumerateSupportedControlLanguages call"); if (m_printer != null) { IReadOnlyDictionary <string, string> controlLanguage = new IReadOnlyDictionary <string, string>(); switch (m_printer.GetPrinterControlLanguage()) { case PrinterLanguage.CPCL: controlLanguage.Add(ZebraConstants.PRINTER_LANGUAGE_CPCL, ""); break; case PrinterLanguage.ZPL: controlLanguage.Add(ZebraConstants.PRINTER_LANGUAGE_ZPL, ""); controlLanguage.Add(ZebraConstants.PRINTER_LANGUAGE_CPCL, ""); break; } oResult.set(controlLanguage); return; } oResult.set(ZebraConstants.PRINTER_STATUS_ERR_NOT_CONNECTED); }
public override void getStatus(IMethodResult oResult) { if (status) { oResult.set(SENSOR_STATUS_STARTED); } else { oResult.set(SENSOR_STATUS_READY); } }
public void getIsConnected(IMethodResult oResult) { Logger.Write("getIsConnected call"); if (m_connection != null) { oResult.set(m_connection.IsConnected()); } else { oResult.set(false); } }
public void printStoredFormatWithArray(string formatPathOnPrinter, IReadOnlyList <string> vars, IMethodResult oResult) { Logger.Write("printStoredFormatWithArray call"); Logger.Write("formatPathOnPrinter: " + formatPathOnPrinter); Logger.Write("vars: ", vars); if (m_printer != null) { m_printer.GetFormatUtil().PrintStoredFormat(formatPathOnPrinter, vars.ToArray()); oResult.set(ZebraConstants.PRINTER_STATUS_SUCCESS); return; } oResult.set(ZebraConstants.PRINTER_STATUS_ERROR); }
public void sendConnectResult(string deviceName, string deviceAdress, Int32 devicePort, PrinterZebra.EPrinterConnectionType connType, IMethodResult oResult) { IReadOnlyDictionary <string, string> printerResult = new IReadOnlyDictionary <string, string>(); printerResult[ZebraConstants.HK_STATUS] = ZebraConstants.PRINTER_STATUS_SUCCESS; printerResult[ZebraConstants.HK_PRINTER_ID] = deviceAdress; printerResult[ZebraConstants.PROPERTY_DEVICE_ADDRESS] = deviceAdress; printerResult[ZebraConstants.PROPERTY_DEVICE_PORT] = devicePort.ToString(); printerResult[ZebraConstants.PROPERTY_PRINTER_TYPE] = ZebraConstants.PRINTER_TYPE_ZEBRA; printerResult[ZebraConstants.PROPERTY_DEVICE_NAME] = deviceName; if (connType == PrinterZebra.EPrinterConnectionType.eBluetooth) { printerResult[ZebraConstants.PROPERTY_CONNECTION_TYPE] = ZebraConstants.CONNECTION_TYPE_BLUETOOTH; } else if (connType == PrinterZebra.EPrinterConnectionType.eTCP) { printerResult[ZebraConstants.PROPERTY_CONNECTION_TYPE] = ZebraConstants.CONNECTION_TYPE_TCP; } else if (connType == PrinterZebra.EPrinterConnectionType.eOnBoard) { printerResult[ZebraConstants.PROPERTY_CONNECTION_TYPE] = ZebraConstants.CONNECTION_TYPE_ON_BOARD; } else if (connType == PrinterZebra.EPrinterConnectionType.eUSB) { printerResult[ZebraConstants.PROPERTY_CONNECTION_TYPE] = ZebraConstants.CONNECTION_TYPE_USB; } oResult.set(printerResult); }
public void sendConnectFinish(string status, IMethodResult oResult) { IReadOnlyDictionary <string, string> printerResult = new IReadOnlyDictionary <string, string>(); printerResult[ZebraConstants.HK_STATUS] = status; oResult.set(printerResult); }
protected void cameraTask_Completed(object sender, PhotoResult e) { rho.common.Hashtable <String, String> mapRes = new rho.common.Hashtable <String, String>(); switch (e.TaskResult) { case TaskResult.OK: mapRes["imageUri"] = e.OriginalFileName; mapRes["image_uri"] = e.OriginalFileName; mapRes["status"] = "ok"; break; case TaskResult.None: mapRes["message"] = "Error"; mapRes["status"] = "error"; break; case TaskResult.Cancel: mapRes["message"] = "User cancelled operation"; mapRes["status"] = "cancel"; break; default: break; } _oResult.set(mapRes); //Code to display the photo on the page in an image control named myImage. //System.Windows.Media.Imaging.BitmapImage bmp = new System.Windows.Media.Imaging.BitmapImage(); //bmp.SetSource(e.ChosenPhoto); //myImage.Source = bmp; }
public void getViewportWidth(IMethodResult oResult) { // implement this method in C# here MainPage mp = getMainPage(); oResult.set(mp != null ? mp.getScreenWidth() : 0); }
public void sendFileContents(string filePath, IMethodResult oResult) { Logger.Write("sendFileContents call"); Logger.Write("fileParh: " + filePath); if (m_connection != null && m_connection.IsConnected() && m_printer != null) { m_printer.GetFileUtil().SendFileContents(filePath); oResult.set(ZebraConstants.PRINTER_STATUS_SUCCESS); } else { oResult.set(ZebraConstants.PRINTER_STATUS_ERR_NOT_CONNECTED); } }
public void getFramework(IMethodResult oResult) { string DeviceManufacturer = (string)Microsoft.Phone.Info.DeviceExtendedProperties.GetValue("DeviceManufacturer"); string DeviceName = (string)Microsoft.Phone.Info.DeviceExtendedProperties.GetValue("DeviceName"); oResult.set(System.Environment.OSVersion.ToString() + " / " + DeviceName + ", " + DeviceManufacturer); }
public void enumerate(IMethodResult oResult) { rho.common.Vector <String> arIDs = new rho.common.Vector <String>(); arIDs.addElement("back"); oResult.set(arIDs); }
/// <summary> /// Get the kind of Camera (front or Back) facing. /// </summary> /// <param name="oResult"></param> public override void getCameraType(IMethodResult oResult) { CRhoRuntime.getInstance().logEvent("Camera class-> getCameraType"); try{ oResult.set(cameraType); }catch (Exception ex) { CRhoRuntime.getInstance().logEvent("Camera class-> getMaxWidth" + ex.Message); } }
protected void cameraTask_Completed(object sender, PhotoResult e) { rho.common.Hashtable <String, String> mapRes = new rho.common.Hashtable <String, String>(); switch (e.TaskResult) { case TaskResult.OK: WriteableBitmap writeableBitmap = new WriteableBitmap(1600, 1200); writeableBitmap.LoadJpeg(e.ChosenPhoto); string imageFolder = "rho/apps"; //CFilePath.join( rho_native_rhopath(), RHO_APPS_DIR);//"rho"; string datetime = DateTime.Now.ToString().Replace("/", ""); datetime = datetime.Replace(":", ""); string imageFileName = "Foto_" + datetime.Replace(" ", String.Empty) + ".jpg"; string filePath = ""; using (var isoFile = IsolatedStorageFile.GetUserStoreForApplication()) { if (!isoFile.DirectoryExists(imageFolder)) { isoFile.CreateDirectory(imageFolder); } filePath = System.IO.Path.Combine(imageFolder, imageFileName); using (var stream = isoFile.CreateFile(filePath)) { writeableBitmap.SaveJpeg(stream, writeableBitmap.PixelWidth, writeableBitmap.PixelHeight, 0, 100); } } mapRes["imageUri"] = "/" + imageFileName; //e.OriginalFileName; mapRes["image_uri"] = "/" + imageFileName; //e.OriginalFileName; mapRes["status"] = "ok"; break; case TaskResult.None: mapRes["message"] = "Error"; mapRes["status"] = "error"; break; case TaskResult.Cancel: mapRes["message"] = "User cancelled operation"; mapRes["status"] = "cancel"; break; default: break; } _oResult.set(mapRes); //Code to display the photo on the page in an image control named myImage. //System.Windows.Media.Imaging.BitmapImage bmp = new System.Windows.Media.Imaging.BitmapImage(); //bmp.SetSource(e.ChosenPhoto); //myImage.Source = bmp; }
/// <summary> /// Get Maximum Height of the Resolution /// </summary> /// <param name="oResult"></param> public override void getMaxHeight(IMethodResult oResult) { CRhoRuntime.getInstance().logEvent("Camera class--> getMaxHeight"); try{ oResult.set(maxResolution.Height); } catch (Exception ex) { CRhoRuntime.getInstance().logEvent("Camera class->getMaxHeight" + ex.Message); } }
public override void readData(IMethodResult oResult) { Dictionary <string, string> result = new Dictionary <string, string>(); result.Add("status", SENSOR_STATUS_ERROR); result.Add("type", type); result.Add("message", "No available sensor of this type"); oResult.set(result); }
public void getDeviceName(IMethodResult oResult) { Logger.Write("getDeviceName call"); if (m_connection != null && m_connection is BluetoothPrinterConnection) { BluetoothPrinterConnection conn = (BluetoothPrinterConnection)m_connection; oResult.set(conn.GetFriendlyName()); } }
public override void create(IMethodResult oResult) { System.Diagnostics.Debug.WriteLine("Creating timer from singleton"); // implement this method in C# here currentId++; String newId = (currentId).ToString(); getTimerByID(newId); oResult.set(newId); }
/*public Sensor getModuleByID(string id) * { * * }*/ public override void enumerate(IMethodResult oResult) { List <string> list = new List <string>(); list.Add(SensorBase.SENSOR_TYPE_ORIENTATION); list.Add(SensorBase.SENSOR_TYPE_DEVICE_ORIENTATION); list.Add(SensorBase.SENSOR_TYPE_ACCELEROMETER); list.Add(SensorBase.SENSOR_TYPE_LINEAR_ACCELERATION); list.Add(SensorBase.SENSOR_TYPE_ECOMPASS); oResult.set(list.AsReadOnly()); }
public void printRawString(string command, IReadOnlyDictionary <string, string> options, IMethodResult oResult) { Logger.Write("printRawString call: " + command); Logger.Write("command: " + command); Logger.Write("options:", options); if (m_connection != null && m_printer != null) { try { byte[] commandStr = Encoding.UTF8.GetBytes(command); m_connection.Write(commandStr); Thread.Sleep(500); byte[] printerResponse = m_connection.Read(); string printerResponseStr = Encoding.UTF8.GetString(printerResponse, 0, printerResponse.Length); IReadOnlyDictionary <string, string> response = new IReadOnlyDictionary <string, string>(); response.Add(ZebraConstants.HK_STATUS, ZebraConstants.PRINTER_STATUS_SUCCESS); response.Add(ZebraConstants.HK_STRING_RESPONCE, printerResponseStr); oResult.set(response); } catch (Exception ex) { IReadOnlyDictionary <string, string> errResponse = new IReadOnlyDictionary <string, string>(); errResponse.Add(ZebraConstants.HK_STATUS, ZebraConstants.PRINTER_STATUS_ERROR); errResponse.Add(ZebraConstants.HK_MESSAGE, ex.Message.ToString()); oResult.set(errResponse); } } else { oResult.set(ZebraConstants.PRINTER_STATUS_ERR_NOT_CONNECTED); } }
private void raiseTabEvent(string eventName, int nOldTab, int nNewTab) { if (_oTabResult != null) { Dictionary <string, string> mapRes = new Dictionary <string, string>(); mapRes["tab_index"] = Convert.ToString(nNewTab); mapRes["newTabIndex"] = Convert.ToString(nNewTab); mapRes["oldTabIndex"] = Convert.ToString(nOldTab); mapRes["tabEvent"] = eventName; _isCallbackFired = true; _oTabResult.set(mapRes); } }
public void retrieveFileNames(IMethodResult oResult) { Logger.Write("call retrieveFileNames "); IReadOnlyDictionary <string, object> resultHash = new IReadOnlyDictionary <string, object>(); if (m_connection != null && m_connection.IsConnected()) { RetriveParser parser = new RetriveParser(m_connection); List <string> resultNames = parser.getAllFileNames(); resultHash.Add(ZebraConstants.HK_STATUS, ZebraConstants.PRINTER_STATUS_SUCCESS); resultHash.Add(ZebraConstants.HK_FILE_NAMES, resultNames); oResult.set(resultHash); return; } resultHash.Add(ZebraConstants.HK_STATUS, ZebraConstants.PRINTER_STATUS_ERROR); resultHash.Add(ZebraConstants.HK_FILE_NAMES, new List <string>()); oResult.set(resultHash); }
public override void copyImageToDeviceGallery(string pathToImage, IMethodResult oResult) { Dictionary <string, string> copyPictureOutput = new Dictionary <string, string>(); try { Task <string> task = copyImageToDeviceGalleryAsync(pathToImage, oResult); try { task.Start(); } catch (Exception ex) { } try { if (task.Status == TaskStatus.Running) { task.Wait(); } } catch (Exception ex) {} string result = task.Result; if (result != null) { copyPictureOutput["status"] = CameraBase.STATUS_OK; copyPictureOutput["pathToImage"] = result; } else { throw new Exception("Can't copy picture for some reasons"); } } catch (Exception ex) { CRhoRuntime.getInstance().logEvent("Camera class-->copyImageToDeviceGallery-->Exception" + ex.ToString()); copyPictureOutput = new Dictionary <string, string>(); copyPictureOutput["status"] = "error"; copyPictureOutput["message"] = ex.Message; oResult.set(copyPictureOutput); } finally { Task.Run(() => oResult.set(copyPictureOutput)); } }
public void printFile(string fileURI, IReadOnlyDictionary <string, string> options, IMethodResult oResult) { Logger.Write("printFile call"); Logger.Write("fileURI: " + fileURI); Logger.Write("options:", options); if (m_connection != null && m_printer != null) { try { if (Path.GetExtension(fileURI) == ".jpg" || Path.GetExtension(fileURI) == ".png") { m_printer.GetGraphicsUtil().PrintImage(fileURI, 0, 0); oResult.set(ZebraConstants.PRINTER_STATUS_SUCCESS); return; } } catch (Exception ex) { } } oResult.set(ZebraConstants.PRINTER_STATUS_ERR_NOT_CONNECTED); }
/// <summary> /// Get all the Supported Resolution of the specified Camera type. /// </summary> /// <param name="oResult"></param> public override void getSupportedSizeList(IMethodResult oResult) { CRhoRuntime.getInstance().logEvent("Camera class--> Entered getSupportedSizeList"); List <Dictionary <string, string> > RTypes = new List <Dictionary <string, string> >(); foreach (Size size in imageResolutions) { Dictionary <string, string> Store_Resolution = new Dictionary <string, string>(); Store_Resolution.Add("width", size.Width.ToString()); Store_Resolution.Add("height", size.Height.ToString()); RTypes.Add(Store_Resolution); } oResult.set(RTypes); CRhoRuntime.getInstance().logEvent("Camera class--> End getSupportedSizeList"); }
public void retrieveFileNamesWithExtensions(IReadOnlyList <string> extensions, IMethodResult oResult) { Logger.Write("retrieveFileNamesWithExtensions call"); Logger.Write("extensions:", extensions); IReadOnlyDictionary <string, object> resultHash = new IReadOnlyDictionary <string, object>(); if (m_printer != null) { RetriveParser parser = new RetriveParser(m_connection); List <string> resultNames = parser.getAllFileNames(extensions); resultHash.Add(ZebraConstants.HK_STATUS, ZebraConstants.PRINTER_STATUS_SUCCESS); resultHash.Add(ZebraConstants.HK_FILE_NAMES, resultNames); oResult.set(resultHash); return; } resultHash.Add(ZebraConstants.HK_STATUS, ZebraConstants.PRINTER_STATUS_ERROR); resultHash.Add(ZebraConstants.HK_FILE_NAMES, new List <string>()); oResult.set(resultHash); }
public void disconnect(IMethodResult oResult) { Logger.Write("disconnect call"); if (m_connection != null && m_connection.IsConnected()) { Thread.Sleep(1000); m_connection.Close(); Thread.Sleep(1000); } m_connection = null; m_printer = null; oResult.set(ZebraConstants.PRINTER_STATUS_SUCCESS); }
/// <summary> /// Get the list of supported Camera /// </summary> /// <param name="oResult"></param> public override void enumerate(IMethodResult oResult) { Camera.deb("Singleton enumeration"); CRhoRuntime.getInstance().logEvent("Camera class-->enumerate"); List <string> availabeCameras = null; try { availabeCameras = Camera.initCameraIDs().Keys.ToList(); }catch (Exception e) { availabeCameras = new List <string>(); } oResult.set(availabeCameras); Camera.deb("Singleton enumeration end"); }
public override void readData(IMethodResult oResult) { Dictionary <string, string> result = new Dictionary <string, string>(); try { _screenOrientation = SimpleOrientationSensor.GetDefault().GetCurrentOrientation(); result.Add("status", SENSOR_STATUS_OK); switch (_screenOrientation) { case SimpleOrientation.Faceup: result.Add("deviceorientation_value", NORMAL); break; case SimpleOrientation.Rotated180DegreesCounterclockwise: result.Add("deviceorientation_value", UPSIDE_DOWN); break; case SimpleOrientation.Rotated90DegreesCounterclockwise: result.Add("deviceorientation_value", LANDSCAPE_RIGHT); break; case SimpleOrientation.Rotated270DegreesCounterclockwise: result.Add("deviceorientation_value", LANDSCAPE_LEFT); break; default: result.Add("deviceorientation_value", NORMAL); break; } result.Add("type", type); } catch (Exception e) { _screenOrientation = SimpleOrientation.Faceup; result.Add("status", SENSOR_STATUS_ERROR); result.Add("message", e.Message); } oResult.set(result); }
public override void readData(IMethodResult oResult) { Dictionary <string, string> result = new Dictionary <string, string>(); if (_compass != null) { result.Add("type", type); result.Add("status", SENSOR_STATUS_OK); result.Add("ecompass_value", txtNorth); } else { result.Add("status", SENSOR_STATUS_ERROR); result.Add("type", type); result.Add("message", "No available sensor of this type"); } oResult.set(result); }
public void storeImage(string printerDriveAndFileName, string imageFilePathOnDevice, int width, int height, IMethodResult oResult) { Logger.Write("storeImage call"); Logger.Write("printerDriveAndFileName: " + printerDriveAndFileName); Logger.Write("imageFilePathOnDevice: " + imageFilePathOnDevice); Logger.Write("width: " + width.ToString()); Logger.Write("height: " + height.ToString()); try { if (m_printer != null && width != 0 && height != 0 && Path.GetExtension(imageFilePathOnDevice) != ".bmp" && Path.GetExtension(imageFilePathOnDevice) != ".gif") { m_printer.GetGraphicsUtil().StoreImage(printerDriveAndFileName, imageFilePathOnDevice, width, height); oResult.set(ZebraConstants.PRINTER_STATUS_SUCCESS); return; } } catch(ZebraPrinterConnectionException) { oResult.set(ZebraConstants.PRINTER_STATUS_ERR_NETWORK); return; } catch(ZebraIllegalArgumentException) { oResult.set(ZebraConstants.PRINTER_STATUS_ERR_IO); return; } catch(ArgumentException) { oResult.set(ZebraConstants.PRINTER_STATUS_ERR_PARAM); return; } catch (Exception) { oResult.set(ZebraConstants.PRINTER_STATUS_ERROR); return; } oResult.set(ZebraConstants.PRINTER_STATUS_ERROR); }
public void getFullScreen(IMethodResult oResult) { MainPage mp = getMainPage(); oResult.set(mp != null ? mp.isFullscreen() : false); }
public void getEnableWebPlugins(IMethodResult oResult) { // implement this method in C# here oResult.set(true); }
public void printStoredFormatWithHash(string formatPathOnPrinter, IReadOnlyDictionary<string, string> vars, IMethodResult oResult) { Logger.Write("printStoredFormatWithHash call"); Logger.Write("formatPathOnPrinter: " + formatPathOnPrinter); Logger.Write("vars: ", vars); if (m_printer != null) { Dictionary<int, string> _params = new Dictionary<int, string>(); foreach (KeyValuePair<string, string> pair in vars) { try { _params.Add(Int32.Parse(pair.Key), pair.Value); } catch(Exception e) { } } m_printer.GetFormatUtil().PrintStoredFormat(formatPathOnPrinter, _params); oResult.set(ZebraConstants.PRINTER_STATUS_SUCCESS); return; } oResult.set(ZebraConstants.PRINTER_STATUS_ERROR); }
public void currentURL(int tabIndex, IMethodResult oResult) { MainPage mp = getMainPage(); oResult.set(mp != null ? mp.getCurrentURL(tabIndex) : ""); }
public void sendFileContents(string filePath, IMethodResult oResult) { Logger.Write("sendFileContents call"); Logger.Write("fileParh: " + filePath); if (m_connection != null && m_connection.IsConnected() && m_printer != null) { m_printer.GetFileUtil().SendFileContents(filePath); oResult.set(ZebraConstants.PRINTER_STATUS_SUCCESS); } else { oResult.set(ZebraConstants.PRINTER_STATUS_ERR_NOT_CONNECTED); } }
public void getCacheSize(IMethodResult oResult) { // implement this method in C# here oResult.set(0); }
public void retrieveFileNamesWithExtensions(IReadOnlyList<string> extensions, IMethodResult oResult) { Logger.Write("retrieveFileNamesWithExtensions call"); Logger.Write("extensions:", extensions); IReadOnlyDictionary<string, object> resultHash = new IReadOnlyDictionary<string, object>(); if (m_printer != null) { RetriveParser parser = new RetriveParser(m_connection); List<string> resultNames = parser.getAllFileNames(extensions); resultHash.Add(ZebraConstants.HK_STATUS, ZebraConstants.PRINTER_STATUS_SUCCESS); resultHash.Add(ZebraConstants.HK_FILE_NAMES, resultNames); oResult.set(resultHash); return; } resultHash.Add(ZebraConstants.HK_STATUS, ZebraConstants.PRINTER_STATUS_ERROR); resultHash.Add(ZebraConstants.HK_FILE_NAMES, new List<string>()); oResult.set(resultHash); }
public void retrieveFileNames(IMethodResult oResult) { Logger.Write("call retrieveFileNames "); IReadOnlyDictionary<string, object> resultHash = new IReadOnlyDictionary<string, object>(); if (m_connection != null && m_connection.IsConnected()) { RetriveParser parser = new RetriveParser(m_connection); List<string> resultNames = parser.getAllFileNames(); resultHash.Add(ZebraConstants.HK_STATUS, ZebraConstants.PRINTER_STATUS_SUCCESS); resultHash.Add(ZebraConstants.HK_FILE_NAMES, resultNames); oResult.set(resultHash); return; } resultHash.Add(ZebraConstants.HK_STATUS, ZebraConstants.PRINTER_STATUS_ERROR); resultHash.Add(ZebraConstants.HK_FILE_NAMES, new List<string>()); oResult.set(resultHash); }
public void stopSearch(IMethodResult oResult) { oResult.set(ZebraConstants.PRINTER_STATUS_SUCCESS); }
public void sendConnectResult(string deviceName, string deviceAdress, Int32 devicePort, PrinterZebra.EPrinterConnectionType connType, IMethodResult oResult) { IReadOnlyDictionary<string, string> printerResult = new IReadOnlyDictionary<string, string>(); printerResult[ZebraConstants.HK_STATUS] = ZebraConstants.PRINTER_STATUS_SUCCESS; printerResult[ZebraConstants.HK_PRINTER_ID] = deviceAdress; printerResult[ZebraConstants.PROPERTY_DEVICE_ADDRESS] = deviceAdress; printerResult[ZebraConstants.PROPERTY_DEVICE_PORT] = devicePort.ToString(); printerResult[ZebraConstants.PROPERTY_PRINTER_TYPE] = ZebraConstants.PRINTER_TYPE_ZEBRA; printerResult[ZebraConstants.PROPERTY_DEVICE_NAME] = deviceName; if (connType == PrinterZebra.EPrinterConnectionType.eBluetooth) { printerResult[ZebraConstants.PROPERTY_CONNECTION_TYPE] = ZebraConstants.CONNECTION_TYPE_BLUETOOTH; } else if (connType == PrinterZebra.EPrinterConnectionType.eTCP) { printerResult[ZebraConstants.PROPERTY_CONNECTION_TYPE] = ZebraConstants.CONNECTION_TYPE_TCP; } else if (connType == PrinterZebra.EPrinterConnectionType.eOnBoard) { printerResult[ZebraConstants.PROPERTY_CONNECTION_TYPE] = ZebraConstants.CONNECTION_TYPE_ON_BOARD; } else if (connType == PrinterZebra.EPrinterConnectionType.eUSB) { printerResult[ZebraConstants.PROPERTY_CONNECTION_TYPE] = ZebraConstants.CONNECTION_TYPE_USB; } oResult.set(printerResult); }
public void sendConnectFinish(string status, IMethodResult oResult) { IReadOnlyDictionary<string, string> printerResult = new IReadOnlyDictionary<string, string>(); printerResult[ZebraConstants.HK_STATUS] = status; oResult.set(printerResult); }
public void getViewportEnabled(IMethodResult oResult) { // implement this method in C# here oResult.set(true); }
public void getAcceptLanguage(IMethodResult oResult) { // implement this method in C# here oResult.set("en"); }
public void getViewportWidth(IMethodResult oResult) { // implement this method in C# here MainPage mp = getMainPage(); oResult.set(mp != null ? mp.getScreenWidth() : 0); }
public void getTextZoomLevel(IMethodResult oResult) { // implement this method in C# here oResult.set(1.0); }
public void getEnableCache(IMethodResult oResult) { // implement this method in C# here oResult.set(false); }
public void requestState(IReadOnlyList<string> listOfParameters, IMethodResult oResult) { Logger.Write("requestState call"); Logger.Write("listOfParameters:", listOfParameters); IReadOnlyDictionary<string, object> resultHash = new IReadOnlyDictionary<string, object>(); if (m_connection != null && m_connection.IsConnected() && m_printer != null) { PrinterStatus currStatus = getStatus(); if (currStatus != null) { resultHash.Add(ZebraConstants.HK_STATUS, ZebraConstants.PRINTER_STATUS_SUCCESS); resultHash.Add(ZebraConstants.HK_MESSAGE, ""); foreach (string parameter in listOfParameters) { switch(parameter) { case ZebraConstants.PRINTER_STATE_IS_HEAD_COLD: resultHash.Add(ZebraConstants.PRINTER_STATE_IS_HEAD_COLD, currStatus.IsHeadCold); break; case ZebraConstants.PRINTER_STATE_IS_HEAD_OPEN: resultHash.Add(ZebraConstants.PRINTER_STATE_IS_HEAD_OPEN, currStatus.IsHeadOpen); break; case ZebraConstants.PRINTER_STATE_IS_HEAD_TOO_HOT: resultHash.Add(ZebraConstants.PRINTER_STATE_IS_HEAD_TOO_HOT, currStatus.IsHeadTooHot); break; case ZebraConstants.PRINTER_STATE_IS_PAPER_OUT: resultHash.Add(ZebraConstants.PRINTER_STATE_IS_PAPER_OUT, currStatus.IsPaperOut); break; case ZebraConstants.PRINTER_STATE_IS_PARTIAL_FORMAT_IN_PROGRESS: resultHash.Add(ZebraConstants.PRINTER_STATE_IS_PARTIAL_FORMAT_IN_PROGRESS, currStatus.IsPartialFormatInProgress); break; case ZebraConstants.PRINTER_STATE_IS_PAUSED: resultHash.Add(ZebraConstants.PRINTER_STATE_IS_BATTERY_LOW, currStatus.IsPaused); break; case ZebraConstants.PRINTER_STATE_IS_READY_TO_PRINT: resultHash.Add(ZebraConstants.PRINTER_STATE_IS_READY_TO_PRINT, currStatus.IsReadyToPrint); break; case ZebraConstants.PRINTER_STATE_IS_RECEIVE_BUFFER_FULL: resultHash.Add(ZebraConstants.PRINTER_STATE_IS_RECEIVE_BUFFER_FULL, currStatus.IsReceiveBufferFull); break; case ZebraConstants.PRINTER_STATE_IS_RIBBON_OUT: resultHash.Add(ZebraConstants.PRINTER_STATE_IS_RIBBON_OUT, currStatus.IsRibbonOut); break; case ZebraConstants.PRINTER_STATE_LABELS_REMAINING_IN_BATCH: resultHash.Add(ZebraConstants.PRINTER_STATE_LABELS_REMAINING_IN_BATCH, currStatus.LabelsRemainingInBatch); break; case ZebraConstants.PRINTER_STATE_LABEL_LENGTH_IN_DOTS: resultHash.Add(ZebraConstants.PRINTER_STATE_LABEL_LENGTH_IN_DOTS, currStatus.LabelLengthInDots); break; case ZebraConstants.PRINTER_STATE_NUMBER_OF_FORMATS_IN_RECEIVE_BUFFER: resultHash.Add(ZebraConstants.PRINTER_STATE_NUMBER_OF_FORMATS_IN_RECEIVE_BUFFER, currStatus.NumberOfFormatsInReceiveBuffer); break; case ZebraConstants.PRINTER_STATE_PRINT_MODE: switch (currStatus.PrintMode) { case ZplPrintMode.REWIND: resultHash.Add(ZebraConstants.PRINTER_STATE_PRINT_MODE, ZebraConstants.PRINT_MODE_REWIND); break; case ZplPrintMode.PEEL_OFF: resultHash.Add(ZebraConstants.PRINTER_STATE_PRINT_MODE, ZebraConstants.PRINT_MODE_PEEL_OFF); break; case ZplPrintMode.TEAR_OFF: resultHash.Add(ZebraConstants.PRINTER_STATE_PRINT_MODE, ZebraConstants.PRINT_MODE_TEAR_OFF); break; case ZplPrintMode.CUTTER: resultHash.Add(ZebraConstants.PRINTER_STATE_PRINT_MODE, ZebraConstants.PRINT_MODE_CUTTER); break; case ZplPrintMode.APPLICATOR: resultHash.Add(ZebraConstants.PRINTER_STATE_PRINT_MODE, ZebraConstants.PRINT_MODE_APPLICATOR); break; case ZplPrintMode.DELAYED_CUT: resultHash.Add(ZebraConstants.PRINTER_STATE_PRINT_MODE, ZebraConstants.PRINT_MODE_DELAYED_CUT); break; case ZplPrintMode.LINERLESS_PEEL: resultHash.Add(ZebraConstants.PRINTER_STATE_PRINT_MODE, ZebraConstants.PRINT_MODE_LINERLESS_PEEL); break; case ZplPrintMode.LINERLESS_REWIND: resultHash.Add(ZebraConstants.PRINTER_STATE_PRINT_MODE, ZebraConstants.PRINT_MODE_REWIND); break; case ZplPrintMode.PARTIAL_CUTTER: resultHash.Add(ZebraConstants.PRINTER_STATE_PRINT_MODE, ZebraConstants.PRINT_MODE_PARTIAL_CUTTER); break; case ZplPrintMode.RFID: resultHash.Add(ZebraConstants.PRINTER_STATE_PRINT_MODE, ZebraConstants.PRINT_MODE_RFID); break; case ZplPrintMode.KIOSK: resultHash.Add(ZebraConstants.PRINTER_STATE_PRINT_MODE, ZebraConstants.PRINT_MODE_KIOSK); break; case ZplPrintMode.UNKNOWN: resultHash.Add(ZebraConstants.PRINTER_STATE_PRINT_MODE, ZebraConstants.PRINT_MODE_UNKNOWN); break; } break; } } } else { resultHash.Add(ZebraConstants.HK_STATUS, ZebraConstants.PRINTER_STATUS_ERROR); resultHash.Add(ZebraConstants.HK_MESSAGE, ""); } } else { resultHash.Add(ZebraConstants.HK_STATUS, ZebraConstants.PRINTER_STATUS_ERR_NOT_CONNECTED); resultHash.Add(ZebraConstants.HK_MESSAGE, ""); } oResult.set(resultHash); }
public void getZoomPage(IMethodResult oResult) { // implement this method in C# here oResult.set(1.0); }
public void currentTabIndex(IMethodResult oResult) { MainPage mp = getMainPage(); oResult.set(mp != null ? mp.tabbarGetCurrent() : 0); }
public void getActiveTab(IMethodResult oResult) { MainPage mp = getMainPage(); oResult.set(mp != null ? mp.tabbarGetCurrent() : 0); }
public void isCreated(IMethodResult oResult) { MainPage mp = getMainPage(); oResult.set(mp != null ? (mp.tabbarIsStarted() != 0) : false); }
public void getFramework(IMethodResult oResult) { string DeviceManufacturer = (string)Microsoft.Phone.Info.DeviceExtendedProperties.GetValue("DeviceManufacturer"); string DeviceName = (string)Microsoft.Phone.Info.DeviceExtendedProperties.GetValue("DeviceName"); oResult.set(System.Environment.OSVersion.ToString() + " / " + DeviceName + ", " + DeviceManufacturer); }
public void getScrollTechnique(IMethodResult oResult) { // implement this method in C# here oResult.set("natural"); }
public void getEnablePageLoadingIndication(IMethodResult oResult) { // implement this method in C# here oResult.set(false); }
public void getFontFamily(IMethodResult oResult) { // implement this method in C# here oResult.set("Arial"); }
public void getNavigationTimeout(IMethodResult oResult) { // implement this method in C# here oResult.set(0); }
public void getUserAgent(IMethodResult oResult) { // implement this method in C# here oResult.set("IE/" + System.Environment.OSVersion.ToString()); }
public void connectWithOptions(IReadOnlyDictionary<string, string> options, IMethodResult oResult) { Logger.Write("connectWithOptions call"); Logger.Write("options:", options); string valueObj = null; Int32 connectionTimeout = 0; if (m_connection != null && m_connection.IsConnected() && m_printer != null) { m_connection.Close(); Thread.Sleep(1000); m_connection = null; m_printer = null; } if (options.ContainsKey(ZebraConstants.HK_TIMEOUT)) { valueObj = options[ZebraConstants.HK_TIMEOUT]; if ((valueObj != null) && (valueObj is String)) { try { connectionTimeout = Int32.Parse(valueObj.ToString()); } catch (System.FormatException) { m_maxTimeoutForRead = 0; } } } if (options.ContainsKey(ZebraConstants.PROPERTY_MAX_TIMEOUT_FOR_READ)) { valueObj = options[ZebraConstants.PROPERTY_MAX_TIMEOUT_FOR_READ]; if ((valueObj != null) && (valueObj is String)) { try { m_maxTimeoutForRead = Int32.Parse(valueObj.ToString()); } catch (System.FormatException) { m_maxTimeoutForRead = 0; } } } if (options.ContainsKey(ZebraConstants.PROPERTY_TIME_TO_WAIT_FOR_MORE_DATA)) { valueObj = options[ZebraConstants.PROPERTY_TIME_TO_WAIT_FOR_MORE_DATA]; if ((valueObj != null) && (valueObj is String)) { try { m_timeToWaitForMoreData = Int32.Parse(valueObj.ToString()); } catch (System.FormatException) { m_maxTimeoutForRead = 0; } } } ConnecttionJob job = new ConnecttionJob(); job.Address = ID; job.Port = Port; job.ConnectionType = connectionType; job.MaxTimeoutForRead = m_maxTimeoutForRead; job.TimeToWaitForMoreData = m_timeToWaitForMoreData; if (connectionTimeout == 0) { job.Connect(); } else { if (!job.Connect(connectionTimeout)) { oResult.set(ZebraConstants.PRINTER_STATUS_ERR_TIMEOUT); return; } } if (job.Connection != null && job.Printer != null) { m_connection = job.Connection; m_printer = job.Printer; oResult.set(ZebraConstants.PRINTER_STATUS_SUCCESS); return; } oResult.set(ZebraConstants.PRINTER_STATUS_ERR_NOT_CONNECTED); }
public void printStoredFormatWithArray(string formatPathOnPrinter, IReadOnlyList<string> vars, IMethodResult oResult) { Logger.Write("printStoredFormatWithArray call"); Logger.Write("formatPathOnPrinter: " + formatPathOnPrinter); Logger.Write("vars: ", vars); if (m_printer != null) { m_printer.GetFormatUtil().PrintStoredFormat(formatPathOnPrinter, vars.ToArray()); oResult.set(ZebraConstants.PRINTER_STATUS_SUCCESS); return; } oResult.set(ZebraConstants.PRINTER_STATUS_ERROR); }