예제 #1
0
 public string GetSDKPrinterVersion()
 {
     ZBRPrinter printer = null;
     int major, minor, engLevel;
     string pVersion = "";
     try {
         printer = new ZBRPrinter();
         printer.GetSDKVer(out major, out minor, out engLevel);
         if (major > 0 || minor > 0 || engLevel > 0) {
             pVersion = major.ToString() + "." + minor.ToString() + "." + engLevel.ToString();
         }
     } catch (Exception e) {
         MessageBox.Show(e.ToString());
     } finally {
         printer = null;
     }
     return pVersion;
 }
예제 #2
0
 public string GetSDKPrinterVersion()
 {
     // method called on FrmMain.cs in order to obtain printer version
     ZBRPrinter printer = null;  //creates printer variable from the ZBRPrinter.cs class initialized to null
     int major, minor, engLevel;  //integers to hold major, minor, and engine level DLL values of the ZBRPrinter class
     string pVersion = "";  //creates pVersion string initialized to an empty string, used to hold final printer version numerical data
     try {
         printer = new ZBRPrinter();   //creates new ZBRPrinter object and stores in printer
         printer.GetSDKVer(out major, out minor, out engLevel); //calls to the getSDKVer method of printer, passing major, minor, and engine level variables by reference
         if (major > 0 || minor > 0 || engLevel > 0) { //if major, minor, or engine levels have values that's greater than their default values of 0...
             pVersion = major.ToString() + "." + minor.ToString() + "." + engLevel.ToString();
             //convert all three values to string, concatenated with a period seperating each, and store the whole string value in pVersion variable - it will appear in label on About page
         }
     } catch (Exception e) { //exception handler
         MessageBox.Show(e.ToString());
     } finally {  //finally block runs whether there is an exception or not
         printer = null; //sets printer object to null after it has been used
     }
     return pVersion; //return resulting printer DLL version string
 }
예제 #3
0
        private bool IsPrinterAvailable(string driverName)
        {
            ZBRPrinter printer = null;
            try {
                printer = new ZBRPrinter();
                int error = 0;

                int result = printer.Open(driverName, out error);
                if ((result == 1) && (error == 0)) {
                    return true;
                }
            } catch (Exception e) {
                MessageBox.Show(e.ToString());
            } finally {
                printer = null;
            }
            return false;
        }
예제 #4
0
파일: FrmMain.cs 프로젝트: broc923/capstone
        private bool IsPrinterAvailable(string driverName)
        {
            //boolean method to test whether the printer is available using driverName parameter
            ZBRPrinter printer = null; //creates printer variable from the ZBRPrinter.cs class initialized to null
            try {
                printer = new ZBRPrinter(); //creates new ZBRPrinter object and stores in printer
                int error = 0; //initial value of errors is 0 meaning printer is available, but will change if errors are detected

                int result = printer.Open(driverName, out error); //passes IsPrinterAvailable method param as an argument to Open method of printer object and stores in result variable
                if ((result == 1) && (error == 0)) { //if the result variable is set to 1 and there are no errors...
                    return true; //return true - the printer is available
                }
            } catch (Exception e) { //exception handler
                MessageBox.Show(e.ToString()); //catches and displays resulting errors to prevent program crash
            } finally { //finally block runs whether there is an exception or not
                printer = null; //sets printer object to null after it has been used to determine if printer is available
            }
            return false; //else return false - the printer is unavailable
        }