예제 #1
0
            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);
            }
예제 #2
0
            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);
            }
예제 #3
0
 public override void getStatus(IMethodResult oResult)
 {
     if (status)
     {
         oResult.set(SENSOR_STATUS_STARTED);
     }
     else
     {
         oResult.set(SENSOR_STATUS_READY);
     }
 }
예제 #4
0
            public void getIsConnected(IMethodResult oResult)
            {
                Logger.Write("getIsConnected call");

                if (m_connection != null)
                {
                    oResult.set(m_connection.IsConnected());
                }
                else
                {
                    oResult.set(false);
                }
            }
예제 #5
0
            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);
            }
예제 #6
0
            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);
            }
예제 #7
0
            public void sendConnectFinish(string status, IMethodResult oResult)
            {
                IReadOnlyDictionary <string, string> printerResult = new IReadOnlyDictionary <string, string>();

                printerResult[ZebraConstants.HK_STATUS] = status;
                oResult.set(printerResult);
            }
예제 #8
0
            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;
            }
예제 #9
0
            public void getViewportWidth(IMethodResult oResult)
            {
                // implement this method in C# here
                MainPage mp = getMainPage();

                oResult.set(mp != null ? mp.getScreenWidth() : 0);
            }
예제 #10
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);
                }
            }
예제 #11
0
            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);
            }
예제 #12
0
            public void enumerate(IMethodResult oResult)
            {
                rho.common.Vector <String> arIDs = new rho.common.Vector <String>();
                arIDs.addElement("back");

                oResult.set(arIDs);
            }
예제 #13
0
 /// <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);
     }
 }
예제 #14
0
            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;
            }
예제 #15
0
            /// <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);
                }
            }
예제 #16
0
            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);
            }
예제 #17
0
            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());
                }
            }
예제 #18
0
            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);
            }
예제 #19
0
            /*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());
            }
예제 #20
0
            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);
                }
            }
예제 #21
0
 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);
     }
 }
예제 #22
0
            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);
            }
예제 #23
0
            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));
                }
            }
예제 #24
0
            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);
            }
예제 #25
0
            /// <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");
            }
예제 #26
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);
            }
예제 #27
0
            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);
            }
예제 #28
0
            /// <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");
            }
예제 #29
0
            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);
            }
예제 #30
0
            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);
            }
예제 #31
0
        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);
        }
예제 #32
0
 public void getFullScreen(IMethodResult oResult)
 {
     MainPage mp = getMainPage();
     oResult.set(mp != null ? mp.isFullscreen() : false);
 }
예제 #33
0
 public void getEnableWebPlugins(IMethodResult oResult)
 {
     // implement this method in C# here
     oResult.set(true);
 }
예제 #34
0
        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);
        }
예제 #35
0
 public void currentURL(int tabIndex, IMethodResult oResult)
 {
     MainPage mp = getMainPage();
     oResult.set(mp != null ? mp.getCurrentURL(tabIndex) : "");
 }
예제 #36
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);
            }
        }
예제 #37
0
 public void getCacheSize(IMethodResult oResult)
 {
     // implement this method in C# here
     oResult.set(0);
 }
예제 #38
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);
        }
예제 #39
0
        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);
        }
예제 #40
0
 public void stopSearch(IMethodResult oResult)
 {
     oResult.set(ZebraConstants.PRINTER_STATUS_SUCCESS);
 }
예제 #41
0
        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);
        }
예제 #42
0
 public void sendConnectFinish(string status, IMethodResult oResult)
 {
     IReadOnlyDictionary<string, string> printerResult = new IReadOnlyDictionary<string, string>();
     printerResult[ZebraConstants.HK_STATUS] = status;
     oResult.set(printerResult);
 }
예제 #43
0
 public void getViewportEnabled(IMethodResult oResult)
 {
     // implement this method in C# here
     oResult.set(true);
 }
예제 #44
0
 public void getAcceptLanguage(IMethodResult oResult)
 {
     // implement this method in C# here
     oResult.set("en");
 }
예제 #45
0
 public void getViewportWidth(IMethodResult oResult)
 {
     // implement this method in C# here
     MainPage mp = getMainPage();
     oResult.set(mp != null ? mp.getScreenWidth() : 0);
 }
예제 #46
0
 public void getTextZoomLevel(IMethodResult oResult)
 {
     // implement this method in C# here
     oResult.set(1.0);
 }
예제 #47
0
 public void getEnableCache(IMethodResult oResult)
 {
     // implement this method in C# here
     oResult.set(false);
 }
예제 #48
0
        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);
        }
예제 #49
0
 public void getZoomPage(IMethodResult oResult)
 {
     // implement this method in C# here
     oResult.set(1.0);
 }
예제 #50
0
 public void currentTabIndex(IMethodResult oResult)
 {
     MainPage mp = getMainPage();
     oResult.set(mp != null ? mp.tabbarGetCurrent() : 0);
 }
예제 #51
0
 public void getActiveTab(IMethodResult oResult)
 {
     MainPage mp = getMainPage();
     oResult.set(mp != null ? mp.tabbarGetCurrent() : 0);
 }
예제 #52
0
 public void isCreated(IMethodResult oResult)
 {
     MainPage mp = getMainPage();
     oResult.set(mp != null ? (mp.tabbarIsStarted() != 0) : false);
 }
예제 #53
0
 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);
 }
예제 #54
0
 public void getScrollTechnique(IMethodResult oResult)
 {
     // implement this method in C# here
     oResult.set("natural");
 }
예제 #55
0
 public void getEnablePageLoadingIndication(IMethodResult oResult)
 {
     // implement this method in C# here
     oResult.set(false);
 }
예제 #56
0
 public void getFontFamily(IMethodResult oResult)
 {
     // implement this method in C# here
     oResult.set("Arial");
 }
예제 #57
0
 public void getNavigationTimeout(IMethodResult oResult)
 {
     // implement this method in C# here
     oResult.set(0);
 }
예제 #58
0
 public void getUserAgent(IMethodResult oResult)
 {
     // implement this method in C# here
     oResult.set("IE/" + System.Environment.OSVersion.ToString());
 }
예제 #59
0
        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);
        }
예제 #60
0
        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);
        }