ToString() public method

Returns a System.String that represents the current ThermalDotNet.ThermalPrinter.
public ToString ( ) : string
return string
Ejemplo n.º 1
0
        public static void Main(string[] args)
        {
            string printerPortName = "/dev/tty.usbserial-A600dP3F";

            //Serial port init
            SerialPort printerPort = new SerialPort(printerPortName, 9600);

            if (printerPort != null)
            {
                Console.WriteLine ("Port ok");
                if (printerPort.IsOpen)
                    {
                        printerPort.Close();
                    }
            }

            Console.WriteLine ("Opening port");

            try {
                printerPort.Open();
            } catch{
                Console.WriteLine ("I/O error");
                Environment.Exit(0);
            }

            //Printer init
            ThermalPrinter printer = new ThermalPrinter(printerPort,2,180,2);
            printer.WakeUp();
            Console.WriteLine(printer.ToString());

            //TestReceipt(printer);

            //System.Threading.Thread.Sleep(5000);
            //printer.SetBarcodeLeftSpace(25);
            //TestBarcode(printer);

            //System.Threading.Thread.Sleep(5000);
            //TestImage(printer);

            //System.Threading.Thread.Sleep(5000);

            printer.WriteLineSleepTimeMs = 200;
            printer.WriteLine("Default style");
            printer.WriteLine("PrintingStyle.Bold",ThermalPrinter.PrintingStyle.Bold);
            printer.WriteLine("PrintingStyle.DeleteLine",ThermalPrinter.PrintingStyle.DeleteLine);
            printer.WriteLine("PrintingStyle.DoubleHeight",ThermalPrinter.PrintingStyle.DoubleHeight);
            printer.WriteLine("PrintingStyle.DoubleWidth",ThermalPrinter.PrintingStyle.DoubleWidth);
            printer.WriteLine("PrintingStyle.Reverse",ThermalPrinter.PrintingStyle.Reverse);
            printer.WriteLine("PrintingStyle.Underline",ThermalPrinter.PrintingStyle.Underline);
            printer.WriteLine("PrintingStyle.Updown",ThermalPrinter.PrintingStyle.Updown);
            printer.WriteLine("PrintingStyle.ThickUnderline",ThermalPrinter.PrintingStyle.ThickUnderline);
            printer.SetAlignCenter();
            printer.WriteLine("BIG TEXT!",((byte)ThermalPrinter.PrintingStyle.Bold +
                (byte)ThermalPrinter.PrintingStyle.DoubleHeight +
                (byte)ThermalPrinter.PrintingStyle.DoubleWidth));
            printer.SetAlignLeft();
            printer.WriteLine("Default style again");

            printer.LineFeed(3);
            printer.Sleep();
            Console.WriteLine("Printer is now offline.");
            printerPort.Close();
        }