Ejemplo n.º 1
0
        public async Task <ActionResult <PrinterInfo> > PostPrinterInfo(PrinterInfo printerInfo)
        {
            _context.PrinterInfo.Add(printerInfo);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetPrinterInfo", new { id = printerInfo.Id }, printerInfo));
        }
Ejemplo n.º 2
0
 public Response <PrintJob> GetPrintJob(Token printToken, PrinterInfo printer)
 {
     return(new Response <PrintJob>
     {
         Success = true,
         AdditionalInfo = "Additional Info",
         Session = "Session",
         Value =
             new PrintJob
         {
             ApplicationOptions = new AppOptions[0],
             MustReturnCardData = false,
             PrintJobId = "printjobid",
             ProductBin = "123456",
             ProductFields = new Veneka.Indigo.Integration.ProductPrinting.ProductField[]
             {
                 new Veneka.Indigo.Integration.ProductPrinting.ProductField
                 {
                     Deleted = false,
                     Font = "Arial",
                     FontColourRGB = 1,
                     Printable = true,
                     PrintSide = 0,
                     ProductPrintFieldTypeId = 0,
                     Value = Encoding.UTF8.GetBytes("Some Text"),
                     X = 50,
                     Y = 100
                 }
             }
         }
     });
 }
Ejemplo n.º 3
0
        public async Task <IActionResult> PutPrinterInfo(int id, PrinterInfo printerInfo)
        {
            if (id != printerInfo.Id)
            {
                return(BadRequest());
            }

            _context.Entry(printerInfo).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!PrinterInfoExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Ejemplo n.º 4
0
        public string PreprocessGCode(string filename, PrinterInfo printerInfo, InternalPrinterProfile printerProfile, IPreprocessor processor, JobDetails bounds, int number)
        {
            var    fileInfo      = new FileInfo(filename);
            var    directoryName = fileInfo.DirectoryName;
            var    name          = fileInfo.Name;
            var    length        = name.IndexOf('_');
            string str;

            if (length > 0)
            {
                str = name.Substring(0, length) + "_" + number + "_" + processor.Name + "_processed.gcode";
            }
            else
            {
                str = name.Substring(0, name.Length - fileInfo.Extension.Length) + "_" + number + "_" + processor.Name + "_processed.gcode";
            }

            var gcodefilename = directoryName + Path.DirectorySeparatorChar.ToString() + str;
            var input_reader  = new GCodeFileReader(filename);
            var output_writer = new GCodeFileWriter(gcodefilename);

            if (!processor.ProcessGCode(input_reader, output_writer, printerInfo.calibration, bounds, printerProfile))
            {
                return(null);
            }

            input_reader.Close();
            output_writer.Close();
            return(gcodefilename);
        }
Ejemplo n.º 5
0
        public override void DoPrint(FlowDocument document)
        {
            var ph = document.PageHeight;
            var pw = document.PageWidth;
            var pp = document.PagePadding;
            var cg = document.ColumnGap;
            var cw = document.ColumnWidth;

            var q  = PrinterInfo.GetPrinter(Printer.ShareName);
            var pd = new PrintDialog {
                PrintQueue = q
            };

            if (pd.PrintQueue.FullName == Printer.ShareName || pd.ShowDialog().GetValueOrDefault(false))
            {
                document.PageHeight  = pd.PrintableAreaHeight;
                document.PageWidth   = pd.PrintableAreaWidth;
                document.PagePadding = new Thickness(25);
                document.ColumnGap   = 0;
                document.ColumnWidth = (document.PageWidth -
                                        document.ColumnGap -
                                        document.PagePadding.Left -
                                        document.PagePadding.Right);
                pd.PrintDocument(((IDocumentPaginatorSource)document).DocumentPaginator, "");
            }

            document.PageHeight  = ph;
            document.PageWidth   = pw;
            document.PagePadding = pp;
            document.ColumnGap   = cg;
            document.ColumnWidth = cw;
        }
Ejemplo n.º 6
0
        /*
         * Metodo que retorna el estado actual de las impresoras intaladas segun el subfijo HDP
         * Method that returns the current state of printers installed according to the subfix HDP
         */
        public String statePrinterHDP(String printerName)
        {
            String currentStatePrinter = "";
            string query = string.Format("SELECT * from Win32_Printer WHERE Name LIKE '%{0}'", printerName);
            ManagementObjectSearcher searcher = new ManagementObjectSearcher(query);

            searcher.Options.ReturnImmediately = true;
            ManagementObjectCollection coll = searcher.Get();

            foreach (ManagementObject printer in coll)
            {
                foreach (PropertyData property in printer.Properties)
                {
                    PrinterInfo printerFargo = new PrinterInfo(printerName);
                    if (printerFargo.CurrentActivity().ToString().Equals("CurrentActivityReady"))
                    {
                        currentStatePrinter = "Ready";
                    }
                    else if (printerFargo.CurrentActivity().ToString().Equals("CurrentActivityUnknown"))
                    {
                        currentStatePrinter = "Offline";
                    }
                }
            }
            return(currentStatePrinter);
        }
Ejemplo n.º 7
0
        public bool GetPrintJob(Token token, out IPrintJob printJob, out string additionalInfo)
        {
            OnUiUpdate(CardPrintingLogicResource.FetchPrintJobUi, false, true, EventArgs.Empty);

            printJob = null;

            PrinterInfo printerInfo = new PrinterInfo
            {
                FirmwareVersion = _printer.FirmwareVersion,
                Manufacturer    = _printer.Manufacturer,
                Model           = _printer.Model,
                SerialNo        = _printer.DeviceId
            };


            var printJobResp = _cardPrinting.GetPrintJob(token, printerInfo);

            if (printJobResp.Success)
            {
                printJob = printJobResp.Value;
            }

            additionalInfo = printJobResp.AdditionalInfo;

            return(printJobResp.Success);
        }
Ejemplo n.º 8
0
        private PrinterInfo[] GetPrinterInfoFromMemory(IntPtr prInfo, uint numPrinters)

        {
            PRINTER_INFO_1 pi = new PRINTER_INFO_1();



            PrinterInfo[] pInfo = new PrinterInfo[numPrinters];

            for (int i = 0; i < numPrinters; i++)

            {
                //把数据从非托管内存传送到到托管内存

                Marshal.PtrToStructure(prInfo, pi);



                pInfo[i].Name = Marshal.PtrToStringAuto(pi.pName);

                pInfo[i].Description = Marshal.PtrToStringAuto(pi.pDescription);

                pInfo[i].Comment = Marshal.PtrToStringAuto(pi.pComment);

                prInfo = new IntPtr(prInfo.ToInt32() + Marshal.SizeOf(typeof(PRINTER_INFO_1)));
            }

            return(pInfo);
        }
Ejemplo n.º 9
0
        public PrinterDetails(PrinterInfo printerInfo, ThemeConfig theme)
            : base(FlowDirection.TopToBottom)
        {
            this.printerInfo = printerInfo;
            this.theme       = theme;

            var headingRow = this.AddHeading(
                OemSettings.Instance.GetIcon(printerInfo.Make),
                printerInfo.Name);

            headingRow.AddChild(new HorizontalSpacer());
            headingRow.HAnchor = HAnchor.Stretch;

            var openButton = new TextButton("Open".Localize(), theme)
            {
                BackgroundColor = theme.AccentMimimalOverlay
            };

            openButton.Click += (s, e) =>
            {
                ApplicationController.Instance.OpenEmptyPrinter(printerInfo.ID).ConfigureAwait(false);
            };
            headingRow.AddChild(openButton);

            this.AddChild(headingRow);
        }
Ejemplo n.º 10
0
        private void CardPrintForm_Load(object sender, EventArgs e)
        {
            this.checkBox_cardFile_indent.Checked = Program.MainForm.AppInfo.GetBoolean(
                "card_print_form",
                "indent",
                true);

            if (string.IsNullOrEmpty(this.textBox_cardFile_cardFilename.Text) == true)
            {
                this.textBox_cardFile_cardFilename.Text = Program.MainForm.AppInfo.GetString(
                    "card_print_form",
                    "card_file_name",
                    "");
            }

            if (m_bTestingGridSetted == false)
            {
                this.checkBox_testingGrid.Checked = Program.MainForm.AppInfo.GetBoolean(
                    "card_print_form",
                    "print_testing_grid",
                    false);
            }

            if (this.PrinterInfo == null)
            {
                this.PrinterInfo = Program.MainForm.PreparePrinterInfo("缺省卡片");
            }

            SetTitle();
        }
Ejemplo n.º 11
0
        public override void DoPrint(FlowDocument document)
        {
            var ph = document.PageHeight;
            var pw = document.PageWidth;
            var pp = document.PagePadding;
            var cg = document.ColumnGap;
            var cw = document.ColumnWidth;

            var q  = PrinterInfo.GetPrinter(Printer.ShareName);
            var pd = new PrintDialog {
                PrintQueue = q
            };

            if (pd.PrintQueue.FullName == Printer.ShareName || pd.ShowDialog().GetValueOrDefault(false))
            {
                document.FontFamily = new System.Windows.Media.FontFamily(LocalSettings.PrintFontFamily);
                document.Typography.EastAsianWidths = FontEastAsianWidths.Half;
                document.PageHeight  = pd.PrintableAreaHeight;
                document.PageWidth   = pd.PrintableAreaWidth;
                document.PagePadding = new Thickness(25);
                document.ColumnGap   = 0;
                document.ColumnWidth = (document.PageWidth -
                                        document.ColumnGap -
                                        document.PagePadding.Left -
                                        document.PagePadding.Right);
                pd.PrintDocument(((IDocumentPaginatorSource)document).DocumentPaginator, "");
            }

            document.PageHeight  = ph;
            document.PageWidth   = pw;
            document.PagePadding = pp;
            document.ColumnGap   = cg;
            document.ColumnWidth = cw;
        }
Ejemplo n.º 12
0
        public void GetPrintJob_ICardPrintingGetPrintJobSuccess_ReturnsValidPrintJob()
        {
            // Arrange
            var printer = Substitute.For <IPrinter>();

            var token = new Token {
                DeviceID = "DeviceId", Session = "Session", Workstation = "Workstation"
            };
            // TODO: PrinterInfo need to be built from information from IPrinter
            var printerInfo = new PrinterInfo();

            var printingWebService = Substitute.For <ICardPrinting>();

            printingWebService.GetPrintJob(token, printerInfo).Returns(new Response <PrintJob>
            {
                AdditionalInfo = "Call was successful",
                Session        = "SessionString",
                Success        = true,
                Value          = new PrintJob()
            });

            var cardPrintLogic = new CardPrintingLogic(printingWebService, printer);

            // Act
            string    additionalInfo;
            IPrintJob printJob = null;
            var       success  = cardPrintLogic.GetPrintJob(token, out printJob, out additionalInfo);

            // Assert
            printingWebService.Received().GetPrintJob(token, printerInfo);
            success.Should().BeTrue(because: "The call to ICardPrinting returns success as true. Which should mean the calling method is successful");
            printJob.Should().NotBeNull(because: "Successful call to ICardPrinting should return a PrintJob object returned in output argument");
        }
Ejemplo n.º 13
0
 /// <summary>Constructor con parámetros de puerto serie
 /// </summary>
 /// <param name="portName">nombre del port (generalmente "com1")
 /// se pueden obtener los nombres disponibles usando System.IO.Ports.SerialPort.GetPortNames()</param>
 /// <param name="bauds">velocidad (generalmente 9600)</param>
 /// <param name="parity">tipo de paridad (generalmente None)</param>
 /// <param name="dataBits">bits de datos (generalmente 8)</param>
 /// <param name="stopBits">bits de parada (generalmente One)</param>
 /// <param name="info"></param>
 public SerialTextOnly(PrinterInfo info)
     : base(info)
 {
     try
     {
         commPort = new SerialPort(Name, int.Parse(info.Parameters[kBouds]), Parity.None, int.Parse(info.Parameters[kDatabits]), StopBits.One);
         IsOnLine = true;
         LastError = null;
         PaperCut = CutMode.Partial;
         PaperCutJump = 32;
         UseCrLf = false;
     }
     catch (IOException ex)
     {
         IsOnLine = false;
         LastErrorDesc = "Configuración de puerto no válida";
         LastError = ex.ToString();
     }
     catch (Exception ex)
     {
         IsOnLine = false;
         LastErrorDesc = "Error no contemplado";
         LastError = ex.ToString();
     }
 }
Ejemplo n.º 14
0
        private DialogResult UninstallPrinter(string printerName)
        {
            DialogResult dialogResult = DialogResult.Ignore;

            try
            {
                string warningMessage = string.Format("Are you sure you want to remove the {0} printer from the system?", printerName);
                dialogResult = MessageBox.Show(warningMessage, Text, MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

                if (dialogResult == DialogResult.Yes)
                {
                    PrinterInfo printerInfo = new PrinterInfo();
                    printerInfo.PrinterName = printerName;
                    printerInfo.MonitorName = printerName;
                    printerInfo.PortName    = printerName;

                    Printer.UnInstall(printerInfo);
                    MessageBox.Show("Uninstalling Printer Completed Successfully", Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception Ex)
            {
                MessageBox.Show(Ex.ToString(), Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }

            return(dialogResult);
        }
Ejemplo n.º 15
0
        public override void DoPrint(string[] lines)
        {
            var q    = PrinterInfo.GetPrinter(Printer.ShareName);
            var text = new FormattedDocument(lines, Printer.CharsPerLine).GetFormattedText();

            PrintFlowDocument(q, new FlowDocument(new Paragraph(new Run(text))));
        }
Ejemplo n.º 16
0
        private void ComboBoxAvailablePrinters_SelectedIndexChanged(object sender, EventArgs e)
        {
            TextBoxQueue.Text      = string.Empty;
            TextBoxProperties.Text = string.Empty;

            if (ComboBoxAvailablePrinters.SelectedIndex >= 0)
            {
                var printerName = ComboBoxAvailablePrinters.SelectedItem.ToString();
                var printerInfo = new PrinterInfo(printerName);

                SetQueueInfo(printerInfo);
                SetPropertiesInfo(printerInfo);

                if (PrinterInfo.IsOk)
                {
                    LabelState.Text      = "OK";
                    LabelState.ForeColor = Color.Green;
                }
                else
                {
                    LabelState.Text      = "NOT OK";
                    LabelState.ForeColor = Color.Red;
                }
            }
        }
        private void Save_Click(object sender, RoutedEventArgs e)
        {
            printerInfo = new PrinterInfo {
                Address = PrinterAddress_TextBox.Text
            };

            Connection       connection       = null;
            ZebraCardPrinter zebraCardPrinter = null;

            try {
                connection = new TcpConnection(printerInfo.Address, 9100);
                connection.Open();

                zebraCardPrinter  = ZebraCardPrinterFactory.GetInstance(connection);
                printerInfo.Model = zebraCardPrinter.GetPrinterInformation().Model;
                if (printerInfo.Model.ToLower().Contains("zxp1") || printerInfo.Model.ToLower().Contains("zxp3"))
                {
                    throw new ConnectionException("Printer model not supported");
                }
            } catch (Exception error) {
                printerInfo = null;
                MessageBoxHelper.ShowError(error.Message);
            } finally {
                ConnectionHelper.CleanUpQuietly(zebraCardPrinter, connection);
                Close();
            }
        }
Ejemplo n.º 18
0
        public override void StartupScript(IPublicFirmwareController connection, PrinterInfo info)
        {
            var num1 = (int)connection.WriteManualCommands("G91");

            connection.RequestEEPROMMapping();
            var num2 = (int)connection.WriteManualCommands("M576", "M578", "M572", "M581", "M117", "M114", "M404");
        }
Ejemplo n.º 19
0
        public override JobCreateResult Create(PrinterInfo printerInfo)
        {
            Status = JobStatus.SavingToFile;
            JobCreateResult jobCreateResult = base.Create(printerInfo);

            if (jobCreateResult.Result == ProcessReturn.SUCCESS)
            {
                try
                {
                    using (var gcodeFileReader = new GCodeFileReader(GCodeFilename))
                    {
                        using (var gcodeFileWriter = new GCodeFileWriter(Details.jobParams.outputfile, true))
                        {
                            GCode nextLine;
                            while ((nextLine = gcodeFileReader.GetNextLine(true)) != null)
                            {
                                gcodeFileWriter.Write(nextLine);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    jobCreateResult.Result = ProcessReturn.FAILURE;
                }
            }
            return(jobCreateResult);
        }
Ejemplo n.º 20
0
        private void SwitchToPrinter(PrinterInfo printerInfo)
        {
            // Switch to new printer
            PrinterDetails.SwitchPrinters(printerInfo.ID);

            this.DialogWindow.CloseOnIdle();
        }
Ejemplo n.º 21
0
        } // End  PollForPrinterPrinting

        private Boolean PollForPrinterReady(string printerName)
        {
            Boolean     returnCode;
            PrinterInfo printerInfo = new PrinterInfo(printerName);

            // Assume will work ok
            returnCode = true;

            int             iStatusTries = 100;
            CurrentActivity currentActivity;

            do
            {
                System.Threading.Thread.Sleep(1000);
                currentActivity = printerInfo.CurrentActivity();
                iStatusTries--;
            } while ((currentActivity != CurrentActivity.CurrentActivityReady) &&
                     (iStatusTries > 0)
                     );


            // Card did not make it to encoder in reasonable time.
            if (iStatusTries == 0)
            {
                returnCode = false;
            }

            return(returnCode);
        } // End PollForPrinterReady
Ejemplo n.º 22
0
        public override JobCreateResult Create(PrinterInfo printerInfo)
        {
            try
            {
                m_sGCodeFileOnSDCard = Details.jobParams.gcodefile;
            }
            catch (Exception ex)
            {
                return(new JobCreateResult(this, ProcessReturn.FAILURE, null));
            }
            FilamentSpool.TypeEnum filamentTypeFromName = FirmwareSDPrintJob.GetFilamentTypeFromName(Details.jobParams.gcodefile);
            switch (filamentTypeFromName)
            {
            case FilamentSpool.TypeEnum.NoFilament:
            case FilamentSpool.TypeEnum.OtherOrUnknown:
                return(new JobCreateResult(this, ProcessReturn.SUCCESS, null));

            default:
                if (FilamentProfile.CreateFilamentProfile(printerInfo.filament_info, MyPrinterProfile).Type != filamentTypeFromName)
                {
                    return(new JobCreateResult(null, ProcessReturn.FAILURE_FILAMENT_MISMATCH, null));
                }

                goto case FilamentSpool.TypeEnum.NoFilament;
            }
        }
Ejemplo n.º 23
0
        private void btnProperties_Click(object sender, EventArgs e)
        {
            string buttonPressed    = (sender as Button).Name;
            string buttonIndex      = buttonPressed[buttonPressed.Length - 1].ToString();
            int    pdfDocumentIndex = -1;

            if (int.TryParse(buttonIndex, out pdfDocumentIndex))
            {
                pdfDocumentIndex--;
                if (pdfDocumentIndex > -1 && pdfDocumentIndex < 5)
                {
                    if (pdfPrintPropertiesForms[pdfDocumentIndex] == null)
                    {
                        pdfPrintPropertiesForms[pdfDocumentIndex] = new PDFPrintPropertiesForm(cmbxPrinterNames.SelectedItem.ToString(), pdfDocumentIndex);
                        if (_printerInfo == null)
                        {
                            _printerInfo = PdfPrintTest.GetPrinterInfo(cmbxPrinterNames.SelectedItem.ToString());
                        }
                        pdfPrintPropertiesForms[pdfDocumentIndex].ApplyPrinterInfo(_printerInfo);
                        pdfPrintPropertiesForms[pdfDocumentIndex].ShowDialog();
                    }
                    else
                    {
                        pdfPrintPropertiesForms[pdfDocumentIndex].ShowDialog();
                    }
                }
            }
        }
Ejemplo n.º 24
0
        private void CardPrintForm_Load(object sender, EventArgs e)
        {
            this.checkBox_cardFile_indent.Checked = this.MainForm.AppInfo.GetBoolean(
    "card_print_form",
    "indent",
    true);

            if (string.IsNullOrEmpty(this.textBox_cardFile_cardFilename.Text) == true)
            {
                this.textBox_cardFile_cardFilename.Text = this.MainForm.AppInfo.GetString(
        "card_print_form",
        "card_file_name",
        "");
            }

            if (m_bTestingGridSetted == false)
            {
                this.checkBox_testingGrid.Checked = this.MainForm.AppInfo.GetBoolean(
                    "card_print_form",
                    "print_testing_grid",
                    false);
            }

            if (this.PrinterInfo == null)
            {
                this.PrinterInfo = this.MainForm.PreparePrinterInfo("缺省卡片");
            }

            SetTitle();
        }
Ejemplo n.º 25
0
        public Maria301Printer(int numuser)
        {
            try
            {
                _tp      = Type.GetTypeFromProgID("M301Ole.Document");
                _printer = Activator.CreateInstance(_tp);

                if (this.Init(numuser))
                {
                    this.Info = new PrinterInfo(_printer);

                    if (this.Info.HasError)
                    {
                        this.HasError    = true;
                        this.ErrorText   = "Ошибка PrinterInfo";
                        this.ErrorSender = "Maria301Printer";
                    }
                }
            }

            catch (Exception err)
            {
                this.HasError    = true;
                this.ErrorText   = "Ошибка M301Ole.Document " + err.Message;
                this.ErrorSender = "Type.GetTypeFromProgID";
            }
        }
Ejemplo n.º 26
0
        public bool StorePrinter(PrinterInfo printerInfo)
        {
            try
            {
                using (Context ctx = new Context())
                {
                    Console.WriteLine("Connection openned.");
                    ctx.DB.Open();

                    string query = "INSERT INTO Printers VALUES(@PrinterName, @SerialKey, @ExpireDate, @CustomerName)";

                    using (SqlCommand cmd = new SqlCommand(query, ctx.DB))
                    {
                        cmd.CommandType    = CommandType.Text;
                        cmd.CommandTimeout = 2500;

                        cmd.Parameters.Add(new SqlParameter("@PrinterName", SqlDbType.VarChar)).Value  = printerInfo.Name;
                        cmd.Parameters.Add(new SqlParameter("@SerialKey", SqlDbType.VarChar)).Value    = printerInfo.SerialKey;
                        cmd.Parameters.Add(new SqlParameter("@ExpireDate", SqlDbType.DateTime)).Value  = DateTime.Now.AddDays(15);
                        cmd.Parameters.Add(new SqlParameter("@CustomerName", SqlDbType.VarChar)).Value = printerInfo.Customer.Name;

                        cmd.ExecuteNonQuery();

                        return(true);
                    }
                }
            }
            catch (Exception er)
            {
                throw er;
            }
        }
Ejemplo n.º 27
0
        public void ProcessGCodeResult(GCode gcode, string resultFromPrinter, PrinterInfo printerInfo)
        {
            if (!gcode.hasM || gcode.M != 404)
            {
                return;
            }

            var num1 = (int)ClearPowerRecoveryFault(false);

            foreach (Match match in new Regex("(\\w*):(\\d+\\.?\\d?)").Matches(resultFromPrinter))
            {
                var str1 = match.Groups[2].Value;
                var str2 = match.Groups[1].Value;
                if (!(str2 == "RC"))
                {
                    if (!(str2 == "RR"))
                    {
                        if (!(str2 == "PS"))
                        {
                            if (!(str2 == "PI"))
                            {
                                if (!(str2 == "LX"))
                                {
                                    if (str2 == "LY")
                                    {
                                        m_fLocationY = SafeToFloat(match.Groups[2].Value);
                                    }
                                }
                                else
                                {
                                    m_fLocationX = SafeToFloat(match.Groups[2].Value);
                                }
                            }
                            else
                            {
                                m_iPI_ProgressIndicator = SafeToInt(match.Groups[2].Value);
                            }
                        }
                        else
                        {
                            var num2 = SafeToInt(match.Groups[2].Value);
                            if (3 <= num2)
                            {
                                num2 = 0;
                            }

                            m_oPrinterPowerRecovery.PrintingStatus = (PowerRecovery.PowerResetState)num2;
                        }
                    }
                    else
                    {
                        m_oPrinterPowerRecovery.iRR_Code = SafeToInt(match.Groups[2].Value);
                    }
                }
                else
                {
                    m_oPrinterPowerRecovery.iRC_Code = SafeToInt(match.Groups[2].Value);
                }
            }
        }
Ejemplo n.º 28
0
        public void GetPrintJob_ICardPrintingGetPrintJobUnsuccessful_ReturnPrintJobObject()
        {
            // Arrange
            var printingWebService = Substitute.For <ICardPrinting>();

            printingWebService.GetPrintJob(new Token(), new PrinterInfo()).ReturnsForAnyArgs(new Response <PrintJob>
            {
                AdditionalInfo = "Call was not successful",
                Session        = "SessionString",
                Success        = false,
                Value          = new PrintJob()
            });

            var printer = Substitute.For <IPrinter>();

            var cardPrintLogic = new CardPrintingLogic(printingWebService, printer);
            var token          = new Token();
            var printerInfo    = new PrinterInfo();

            // Act
            string    additionalInfo;
            IPrintJob printJob = null;
            var       success  = cardPrintLogic.GetPrintJob(token, out printJob, out additionalInfo);

            // Assert
            success.Should().BeFalse(because: "The call to ICardPrinting returns success as false. Which should mean the calling method is unsuccessful");
            printJob.Should().BeNull(because: "UnSuccessful call to ICardPrinting. Calling method should return a null PrintJob in output argument");
        }
Ejemplo n.º 29
0
        public override void DoPrint(string[] lines)
        {
            var q             = PrinterInfo.GetPrinter(Printer.ShareName);
            var text          = new FormattedDocument(lines, Printer.CharsPerLine).GetFormattedText();
            var customPrinter = _printerService.GetCustomPrinter(Printer.CustomPrinterName);

            customPrinter.Process(Printer, text);
        }
Ejemplo n.º 30
0
 public MainWindowViewModel()
 {
     recentlySelectedPrinters.AddFirst(new PrinterInfo {
         Address = "Select a Printer",
         Model   = ""
     });
     selectedPrinter = recentlySelectedPrinters.First.Value;
 }
Ejemplo n.º 31
0
Archivo: Printer.cs Proyecto: urish/M3D
 public Printer(string printer_serial_number, PrinterProfile profile, SpoolerClient client)
     : this(profile, client)
 {
     printer_info = new PrinterInfo
     {
         serial_number = new PrinterSerialNumber(printer_serial_number)
     };
 }
Ejemplo n.º 32
0
 public BaseController(PrinterConnection base_printer, PrinterInfo info, Logger logger, IBroadcastServer broadcastserver, InternalPrinterProfile printerProfile)
 {
     this.printerProfile  = printerProfile;
     this.base_printer    = base_printer;
     this.logger          = logger;
     printerInfo          = info;
     this.broadcastserver = broadcastserver;
 }
 protected TextOnlyPrinterBase(PrinterInfo info)
     : base(info)
 {
     if (info.Parameters != null)
     {
         MaxColumns = info.Parameters.ContainsKey(kColumns) ? int.Parse(info.Parameters[kColumns]) : 44;
     }
     Data = new StringBuilder();
 }
Ejemplo n.º 34
0
        private void btnCheckStatus_Click(object sender, EventArgs e)
        {
            var objPrinterInfo = new PrinterInfo(cbPrinter.SelectedItem.ToString());

            var printerData = new StringBuilder();
            printerData.Append("SerialNo:" + objPrinterInfo.SerialNumber + "\n");
            printerData.Append("Details:" + objPrinterInfo.ToString() + "\n");

            rtbDetails.Text = printerData.ToString();
        }
Ejemplo n.º 35
0
        /// <summary>
        /// Wait for the mag data to be finished being read from the encoder to the firmware.
        /// </summary>
        /// <returns>TRUE if mag data is ready to be read from the printer</returns>
        private bool WaitForMagReadFinish(string printerName)
        {
            // Assume that a failure will occur.
            bool result = false;
            StationStatus stationStatus;
            int m_timeout = 120000; // 2 minutes.
            bool bContinue = true;
            CurrentActivity currentActivity;
            int nTimer = Environment.TickCount;

            var printerInfo = new PrinterInfo(printerName);
            string driverName = GetDriverName(printerName);

            // For HDP8500 can monitor to see when the mag data has been fully read to the printers buffer.
            if (driverName.Contains("HDP8500"))
            {
                //// Because the firmware does not update the Mag StationStatus to CardNotPresent until the card is ejected we can not
                //// rely on that to tell the mag data is finished on second and later cards.
                //result = true;

                do
                {
                    currentActivity = printerInfo.CurrentActivity();

                    switch (currentActivity)
                    {
                        // Feed error?
                        case CurrentActivity.CurrentActivityException:
                            bContinue = false;
                            break;

                        default:
                            // Read to see if the station status indicates present BEFORE reading mag data.
                            stationStatus = printerInfo.StationStatus(Station.Magnetic);

                            // If card present then ok to read the data.
                            if (stationStatus == StationStatus.CardPresent)
                            {
                                result = true;
                                bContinue = false;
                            }
                            else
                            {
                                // Wait for next poll.
                                Thread.Sleep(500);
                                bContinue = true;
                            }

                            break;
                    }

                } while (((Environment.TickCount - nTimer) < m_timeout) && bContinue);

            }

            // For testing with HDP5000.
            else if (driverName.Contains("HDP5000"))
            {
                do
                {
                    currentActivity = printerInfo.CurrentActivity();

                    switch (currentActivity)
                    {
                        case CurrentActivity.CurrentActivityWaitingForEject:
                            // If the printer is holding the card then it is done.
                            // Sleep for a few seconds to make sure that the data has been read.
                            Thread.Sleep(5000);
                            result = true;
                            bContinue = false;
                            break;
                        case CurrentActivity.CurrentActivityException:
                            bContinue = false;
                            break;
                        default:
                            Thread.Sleep(1000);
                            bContinue = true;
                            break;
                    }

                } while (((Environment.TickCount - nTimer) < m_timeout) && bContinue);

            }

            // Must be Neo / Onyx model
            else
            {
                do
                {
                    currentActivity = printerInfo.CurrentActivity();

                    switch (currentActivity)
                    {
                        case CurrentActivity.CurrentActivityEncodeMagStrip:
                            // The DTC printers don't support getting the mag station status.
                            // Sleep for a few seconds to make sure that the data has been read.
                            Thread.Sleep(5000);
                            result = true;
                            bContinue = false;
                            break;
                        case CurrentActivity.CurrentActivityException:
                            bContinue = false;
                            break;
                        default:
                            Thread.Sleep(1000);
                            bContinue = true;
                            break;
                    }

                } while (((Environment.TickCount - nTimer) < m_timeout) && bContinue);
            }

            int howLong = (Environment.TickCount - nTimer);

            // Do something to breakpoint on.
            if (result == false)
            {
                if ((Environment.TickCount - nTimer) >= m_timeout)
                {
                }
            }

            return (result);
        }
Ejemplo n.º 36
0
        // 打印(根据卡片文件)
        /// <summary>
        /// 根据卡片文件进行打印
        /// </summary>
        /// <param name="bDisplayPrinterDialog">是否显示打印机对话框</param>
        /// <returns>-1: 出错; 0: 成功</returns>
        public int PrintFromCardFile(bool bDisplayPrinterDialog = true)
        {
            string strError = "";
            int nRet = this.BeginPrint(
                this.textBox_cardFile_cardFilename.Text,
                out strError);
            if (nRet == -1)
                goto ERROR1;

            stop.OnStop += new DigitalPlatform.StopEventHandler(stop_OnStop);
            stop.BeginLoop();

            this.EnableControls(false);
            /*
            Cursor oldCursor = this.Cursor;
            this.Cursor = Cursors.WaitCursor;
             * */
            this.estimate.StartEstimate();

            try
            {

                // Allow the user to choose the page range he or she would
                // like to print.
                printDialog1.AllowSomePages = true;

                // Show the help button.
                printDialog1.ShowHelp = true;

                // Set the Document property to the PrintDocument for 
                // which the PrintPage Event has been handled. To display the
                // dialog, either this property or the PrinterSettings property 
                // must be set 
                printDialog1.Document = this.document;

                if (this.PrinterInfo != null)
                {
                    string strPrinterName = document.PrinterSettings.PrinterName;
                    if (string.IsNullOrEmpty(this.PrinterInfo.PrinterName) == false
                        && this.PrinterInfo.PrinterName != strPrinterName)
                    {
                        this.document.PrinterSettings.PrinterName = this.PrinterInfo.PrinterName;
                        if (this.document.PrinterSettings.IsValid == false)
                        {
                            MessageBox.Show(this, "打印机 " + this.PrinterInfo.PrinterName + " 当前不可用,请重新选定打印机");
                            this.document.PrinterSettings.PrinterName = strPrinterName;
                            this.PrinterInfo.PrinterName = "";
                            bDisplayPrinterDialog = true;
                        }
                    }

                    PaperSize old_papersize = document.DefaultPageSettings.PaperSize;
                    if (string.IsNullOrEmpty(this.PrinterInfo.PaperName) == false
                        && this.PrinterInfo.PaperName != document.DefaultPageSettings.PaperSize.PaperName)
                    {
                        PaperSize found = null;
                        foreach (PaperSize ps in this.document.PrinterSettings.PaperSizes)
                        {
                            if (ps.PaperName.Equals(this.PrinterInfo.PaperName))
                            {
                                found = ps;
                                break;
                            }
                        }

                        if (found != null)
                            this.document.DefaultPageSettings.PaperSize = found;
                        else
                        {
                            MessageBox.Show(this, "打印机 " + this.PrinterInfo.PrinterName + " 的纸张类型 " + this.PrinterInfo.PaperName + " 当前不可用,请重新选定纸张");
                            document.DefaultPageSettings.PaperSize = old_papersize;
                            this.PrinterInfo.PaperName = "";
                            bDisplayPrinterDialog = true;
                        }
                    }

                    // 只要有一个打印机事项没有确定,就要出现打印机对话框
                    if (string.IsNullOrEmpty(this.PrinterInfo.PrinterName) == true
                        || string.IsNullOrEmpty(this.PrinterInfo.PaperName) == true)
                        bDisplayPrinterDialog = true;
                }
                else
                {
                    // 没有首选配置的情况下要出现打印对话框
                    bDisplayPrinterDialog = true;
                }

                DialogResult result = DialogResult.OK;
                if (bDisplayPrinterDialog == true)
                {
                    result = printDialog1.ShowDialog();
                }

                // If the result is OK then print the document.
                if (result == DialogResult.OK)
                {
                    try
                    {
                        if (bDisplayPrinterDialog == true)
                        {
                            // 记忆打印参数
                            if (this.PrinterInfo == null)
                                this.PrinterInfo = new PrinterInfo();
                            this.PrinterInfo.PrinterName = document.PrinterSettings.PrinterName;
                            this.PrinterInfo.PaperName = document.DefaultPageSettings.PaperSize.PaperName;
                            this.PrinterInfo.Landscape = document.DefaultPageSettings.Landscape;

                            SetTitle();
                        }

                        this.document.Print();
                    }
                    catch (Exception ex)
                    {
                        strError = "打印过程出错: " + ex.Message;
                        goto ERROR1;
                    }
                }
            }
            finally
            {
                /*
                this.Cursor = oldCursor;
                 * */
                this.EnableControls(true);

                stop.EndLoop();
                stop.OnStop -= new DigitalPlatform.StopEventHandler(stop_OnStop);

                this.stop.HideProgress();
            }

            this.EndPrint();
            return 0;
        ERROR1:
            MessageBox.Show(this, strError);
            return -1;
        }
Ejemplo n.º 37
0
        // 打印预览(根据卡片文件)
        /// <summary>
        /// 根据卡片文件进行打印预览
        /// </summary>
        /// <param name="bDisplayPrinterDialog">是否显示打印机对话框</param>
        /// <returns>-1: 出错; 0: 成功</returns>
        public int PrintPreviewFromCardFile(bool bDisplayPrinterDialog = false)
        {
            string strError = "";
            int nRet = this.BeginPrint(
                this.textBox_cardFile_cardFilename.Text,
                out strError);
            if (nRet == -1)
                goto ERROR1;

            stop.OnStop += new DigitalPlatform.StopEventHandler(stop_OnStop);
            stop.BeginLoop(); 
            this.EnableControls(false);
            this.estimate.StartEstimate();
            try
            {
                printDialog1.Document = this.document;

                if (this.PrinterInfo != null)
                {
                    string strPrinterName = document.PrinterSettings.PrinterName;
                    if (string.IsNullOrEmpty(this.PrinterInfo.PrinterName) == false
                        && this.PrinterInfo.PrinterName != strPrinterName)
                    {
                        this.document.PrinterSettings.PrinterName = this.PrinterInfo.PrinterName;
                        if (this.document.PrinterSettings.IsValid == false)
                        {
                            MessageBox.Show(this, "打印机 " + this.PrinterInfo.PrinterName + " 当前不可用,请重新选定打印机");
                            this.document.PrinterSettings.PrinterName = strPrinterName;
                            this.PrinterInfo.PrinterName = "";
                            bDisplayPrinterDialog = true;
                        }
                    }

                    PaperSize old_papersize = document.DefaultPageSettings.PaperSize;
                    if (string.IsNullOrEmpty(this.PrinterInfo.PaperName) == false
                        && this.PrinterInfo.PaperName != document.DefaultPageSettings.PaperSize.PaperName)
                    {
                        PaperSize found = null;
                        foreach (PaperSize ps in this.document.PrinterSettings.PaperSizes)
                        {
                            if (ps.PaperName.Equals(this.PrinterInfo.PaperName))
                            {
                                found = ps;
                                break;
                            }
                        }

                        if (found != null)
                            this.document.DefaultPageSettings.PaperSize = found;
                        else
                        {
                            MessageBox.Show(this, "打印机 " + this.PrinterInfo.PrinterName + " 的纸张类型 " + this.PrinterInfo.PaperName + " 当前不可用,请重新选定纸张");
                            document.DefaultPageSettings.PaperSize = old_papersize;
                            this.PrinterInfo.PaperName = "";
                            bDisplayPrinterDialog = true;
                        }
                    }

                    // 只要有一个打印机事项没有确定,就要出现打印机对话框
                    if (string.IsNullOrEmpty(this.PrinterInfo.PrinterName) == true
                        || string.IsNullOrEmpty(this.PrinterInfo.PaperName) == true)
                        bDisplayPrinterDialog = true;
                }
                else
                {
                    // 没有首选配置的情况下要出现打印对话框
                    bDisplayPrinterDialog = true;
                }

                DialogResult result = DialogResult.OK;
                if (bDisplayPrinterDialog == true)
                {
                    result = printDialog1.ShowDialog();

                    if (result == DialogResult.OK)
                    {
                        // 记忆打印参数
                        if (this.PrinterInfo == null)
                            this.PrinterInfo = new PrinterInfo();
                        this.PrinterInfo.PrinterName = document.PrinterSettings.PrinterName;
                        this.PrinterInfo.PaperName = document.DefaultPageSettings.PaperSize.PaperName;
                        this.PrinterInfo.Landscape = document.DefaultPageSettings.Landscape;
                        SetTitle();
                    }
                }

                printPreviewDialog1.Document = this.document;

                this.MainForm.AppInfo.LinkFormState(printPreviewDialog1, "labelprintform_printpreviewdialog_state");
                printPreviewDialog1.ShowDialog(this);
                this.MainForm.AppInfo.UnlinkFormState(printPreviewDialog1);

            }
            finally
            {
                this.EnableControls(true);
                stop.EndLoop();
                stop.OnStop -= new DigitalPlatform.StopEventHandler(stop_OnStop);

                this.stop.HideProgress();

            }

            this.EndPrint();
            return 0;
        ERROR1:
            MessageBox.Show(this, strError);
            return -1;
        }
Ejemplo n.º 38
0
        public  Maria301Printer(int numuser)
        {
            try
            {
                _tp = Type.GetTypeFromProgID("M301Ole.Document");
                _printer = Activator.CreateInstance(_tp);
         
            if (this.Init(numuser))
            {
                this.Info = new PrinterInfo(_printer);

                if (this.Info.HasError)
                {
                    this.HasError = true;
                    this.ErrorText = "Ошибка PrinterInfo";
                    this.ErrorSender = "Maria301Printer";
                }
            } 
            }

            catch (Exception err)
            {
                this.HasError = true;
                this.ErrorText = "Ошибка M301Ole.Document "+err.Message;
                this.ErrorSender = "Type.GetTypeFromProgID";
                
                
            }
    
        }
Ejemplo n.º 39
0
 public General(PrinterInfo info)
     : base(info)
 {
     IsOnLine = true;
 }
Ejemplo n.º 40
0
 public DriverTextOnly(PrinterInfo info)
     : base(info)
 {
     InitializeQueue();
 }
Ejemplo n.º 41
0
        public PrinterInfo GetPrinterInfoA()
        {
            byte[] rBytes = new byte[501];
            //for a total length of 192

            IntPtr pPrinterInfo = Marshal.AllocHGlobal(500);
            int res = GetPrinterInfo(hSession, pPrinterInfo);
            Marshal.Copy(pPrinterInfo, rBytes, 0, 500);
            Marshal.FreeHGlobal(pPrinterInfo);

            if (!(res == ERROR_SUCCESS)) {
                ThrowException("GetPrinterInfoA", res);
            }

            PrinterInfo pInfo = new PrinterInfo(rBytes);
            pInfo.LastEnduroMessage = this.GetLastEnduroMessage();
            return pInfo;
        }
Ejemplo n.º 42
0
        // 将 textBox_printerInfo 的打印机特性兑现到 PrintDocument 中
        bool FlushDcoumentPrinterInfo(out string strWarning)
        {
            strWarning = "";

            PrintDocument document = this.labelDesignControl1.PrintDocument;
            if (document == null)
                return false;

            bool bChanged = false;
            PrinterInfo printerInfo = new PrinterInfo("", this.textBox_printerInfo.Text);


#if NO
                string strPrinterName = document.PrinterSettings.PrinterName;
                if (string.IsNullOrEmpty(printerInfo.PrinterName) == false
                    && printerInfo.PrinterName != strPrinterName)
                {
                    string strOldName = document.PrinterSettings.PrinterName;
                    document.PrinterSettings.PrinterName = printerInfo.PrinterName;
                    if (document.PrinterSettings.IsValid == false)
                    {
                        document.PrinterSettings.PrinterName = strOldName;
                        // TODO: 可以在 textbox 边上出现一个感叹号
                    }
                }
#endif
            string strError = "";
            int nRet = 0;
            string strPrinterName = document.PrinterSettings.PrinterName;
            if (string.IsNullOrEmpty(printerInfo.PrinterName) == false
                && printerInfo.PrinterName != strPrinterName)
            {
                // 按照存储的打印机名选定打印机
                // <returns>0: 成功选定: 1: 没有选定,因为名字不可用。建议后面出现打印机对话框选定</returns>
                nRet = LabelPrintForm.SelectPrinterByName(document,
                    printerInfo.PrinterName,
                    out  strError);
                if (nRet == 1)
                {
                    strWarning = "打印机 " + printerInfo.PrinterName + " 当前不可用,请重新选定打印机";
                    printerInfo.PrinterName = "";
                    // bDisplayPrinterDialog = true;
                    // TODO: 可以在 textbox 边上出现一个感叹号
                }
                bChanged = true;
            }

#if NO
                PaperSize old_papersize = document.DefaultPageSettings.PaperSize;
                if (string.IsNullOrEmpty(printerInfo.PaperName) == false
                    && printerInfo.PaperName != document.DefaultPageSettings.PaperSize.PaperName)
                {
                    PaperSize found = null;
                    foreach (PaperSize ps in document.PrinterSettings.PaperSizes)
                    {
                        if (ps.PaperName.Equals(printerInfo.PaperName))
                        {
                            found = ps;
                            break;
                        }
                    }

                    if (found != null)
                        document.DefaultPageSettings.PaperSize = found;
                    else
                    {
                        // TODO: 可以在 textbox 边上出现一个感叹号
                    }
                }
#endif
            LabelParam label_param = this.LabelParam;
            // 需要自定义纸张
            if ((string.IsNullOrEmpty(label_param.DefaultPrinter) == true || string.IsNullOrEmpty(printerInfo.PaperName) == true)
                && label_param.PageWidth > 0
                && label_param.PageHeight > 0)
            {
                // bCustomPaper = true;

                PaperSize paper_size = new PaperSize("Custom Label",
                    (int)label_param.PageWidth,
                    (int)label_param.PageHeight);
                document.DefaultPageSettings.PaperSize = paper_size;
                bChanged = true;
            }
            else
            {
                if (string.IsNullOrEmpty(printerInfo.PaperName) == false)
                {
                    nRet = LabelPrintForm.SelectPaperByName(document,
                        printerInfo.PaperName,
                        printerInfo.Landscape,
                        true,   // false,
                        out strError);
                    if (nRet == 1)
                    {
                        if (string.IsNullOrEmpty(strWarning) == false)
                            strWarning += "; ";
                        else
                        {
                            if (string.IsNullOrEmpty(printerInfo.PrinterName) == false)
                                strWarning += "打印机 " + printerInfo.PrinterName + " 的";
                        }
                        strWarning += "纸张 " + printerInfo.PaperName + " 当前不可用,请重新选定纸张";
                        printerInfo.PaperName = "";
                        // bDisplayPrinterDialog = true;
                        // TODO: 可以在 textbox 边上出现一个感叹号
                    }
                    bChanged = true;
                }
            }

            // document.DefaultPageSettings.Landscape = label_param.Landscape;

            return bChanged;
        }
Ejemplo n.º 43
0
        // 选择打印机和纸张
        // parameters:
        //      bForceDialog    是否迫使出现打印机对话框
        // return:
        //      null    选择打印机的对话框被取消
        //      其他  返回 PrintDocument 对象
        PrintDocument SelectPrinterAndPaper(bool bForceDialog)
        {
            string strError = "";
            int nRet = 0;

            PrintDialog printDialog1 = new PrintDialog();

            bool bDisplayPrinterDialog = false;
            PrintDocument document = this.labelDesignControl1.PrintDocument;

            // new System.Drawing.Printing.PrintDocument();

            printDialog1.Document = document;

            PrinterInfo printerInfo = new PrinterInfo("", this.textBox_printerInfo.Text);

            if (printerInfo != null)
            {
                if (string.IsNullOrEmpty(printerInfo.PrinterName) == false
                    && string.IsNullOrEmpty(printerInfo.PaperName) == false)
                {
                    // 按照存储的打印机名选定打印机
                    nRet = LabelPrintForm.SelectPrinterByName(document,
                        printerInfo.PrinterName,
                        out  strError);
                    if (nRet == 1)
                    {
                        MessageBox.Show(this, "打印机 " + printerInfo.PrinterName + " 当前不可用,请重新选定打印机");
                        printerInfo.PrinterName = "";
                        bDisplayPrinterDialog = true;
                    }

                    if (bDisplayPrinterDialog == false
                        && string.IsNullOrEmpty(printerInfo.PaperName) == false)
                    {
                        nRet = LabelPrintForm.SelectPaperByName(document,
                            printerInfo.PaperName,
                            printerInfo.Landscape,
                            true,   // false,
                            out strError);
                        if (nRet == 1)
                        {
                            MessageBox.Show(this, "打印机 " + printerInfo.PrinterName + " 的纸张类型 " + printerInfo.PaperName + " 当前不可用,请重新选定纸张");
                            printerInfo.PaperName = "";
                            bDisplayPrinterDialog = true;
                        }
                    }

                    // 只要有一个打印机事项没有确定,就要出现打印机对话框
                    if (string.IsNullOrEmpty(printerInfo.PrinterName) == true
                        || string.IsNullOrEmpty(printerInfo.PaperName) == true)
                        bDisplayPrinterDialog = true;
                }
            }
            else
            {
                // 没有首选配置的情况下要出现打印对话框
                bDisplayPrinterDialog = true;
            }

#if NO
            // 如果一开始没有打印机信息 textbox 内容,则依 label_param 中的方向
            if (string.IsNullOrEmpty(this.textBox_printerInfo.Text) == true)
                document.DefaultPageSettings.Landscape = this.LabelParam.Landscape;
#endif

            DialogResult result = DialogResult.OK;
            if (bDisplayPrinterDialog == true
                || bForceDialog == true)
            {
                result = printDialog1.ShowDialog();

                if (result == DialogResult.OK)
                {
                    // 记忆打印参数
                    if (printerInfo == null)
                        printerInfo = new PrinterInfo();
                    printerInfo.PrinterName = document.PrinterSettings.PrinterName;
                    printerInfo.PaperName = PrintUtil.GetPaperSizeString(document.DefaultPageSettings.PaperSize);
                    printerInfo.Landscape = document.DefaultPageSettings.Landscape;

                    // 2014/3/27
                    // this.document.DefaultPageSettings = document.PrinterSettings.DefaultPageSettings;
                    nRet = LabelPrintForm.SelectPaperByName(document,
printerInfo.PaperName,
printerInfo.Landscape,
true,
out strError);
                    if (nRet == 1)
                    {
                        SelectPaperDialog paper_dialog = new SelectPaperDialog();
                        MainForm.SetControlFont(paper_dialog, this.Font, false);
                        paper_dialog.Comment = "纸张 " + printerInfo.PaperName + " 不在打印机 " + printerInfo.PrinterName + " 的可用纸张列表中。\r\n请重新选定纸张";
                        paper_dialog.Document = document;
                        paper_dialog.StartPosition = FormStartPosition.CenterParent;
                        paper_dialog.ShowDialog(this);

                        if (paper_dialog.DialogResult == System.Windows.Forms.DialogResult.Cancel)
                            return document;    // null

                    }

                    printerInfo.PaperName = PrintUtil.GetPaperSizeString(document.DefaultPageSettings.PaperSize);
                    printerInfo.Landscape = document.DefaultPageSettings.Landscape;

                    this.textBox_printerInfo.Text = printerInfo.GetText();

                    // document.DefaultPageSettings = document.PrinterSettings.DefaultPageSettings;
                }
                else
                    return null;
            }

            return document;
        }
Ejemplo n.º 44
0
        private void button_selectPrinter_Click(object sender, EventArgs e)
        {
#if NO
            PrintDialog printDialog1 = new PrintDialog();
            printDialog1.Document = new System.Drawing.Printing.PrintDocument();

            DialogResult result = printDialog1.ShowDialog();

            if (result == DialogResult.OK)
            {
                // 记忆打印参数

                // 记忆打印参数
                if (this.PrinterInfo == null)
                    this.PrinterInfo = new PrinterInfo();
                this.PrinterInfo.PrinterName = printDialog1.Document.PrinterSettings.PrinterName;
                this.PrinterInfo.PaperName = printDialog1.Document.DefaultPageSettings.PaperSize.PaperName;

                DisplayPrinterInfo();
            }
#endif
            bool bControl = (Control.ModifierKeys & Keys.Control) != 0;

            PrintDocument doc = SelectPrinterAndPaper(true);

            // 把页面宽度和高度强行设定为和当前纸张一致
            if (doc != null && bControl == false)
            {
                if (doc.DefaultPageSettings.Landscape == false)
                {
                    this.numericUpDown_pageWidth.UniverseValue = doc.DefaultPageSettings.PaperSize.Width;
                    this.numericUpDown_pageHeight.UniverseValue = doc.DefaultPageSettings.PaperSize.Height;
                }
                else
                {
                    this.numericUpDown_pageWidth.UniverseValue = doc.DefaultPageSettings.PaperSize.Height;
                    this.numericUpDown_pageHeight.UniverseValue = doc.DefaultPageSettings.PaperSize.Width;
                }
                // this.checkBox_landscape.Checked = doc.DefaultPageSettings.Landscape;
            }

            this.SetPrinterInfoWarning("");
        }
Ejemplo n.º 45
0
 // API Functions  //
 /// <summary>
 /// Registers the printer
 /// </summary>
 /// <param name="printerId">The printer ID to register</param>
 /// <param name="printerName">The "name" of the printer (as in windows)</param>
 /// <param name="printerLocation">The location of the printer</param>
 /// <param name="printerModel">The model of the printer</param>
 /// <returns></returns>
 public MabelResponse RegisterPrinter(int printerId, string printerName, string printerLocation, PrinterInfo info)
 {
     MabelResponse response = MakeRequest(
         new MabelRequest(
             this,
             "cardPrinter.register",
             new MabelPrinterRegisterParams( printerId ,printerName ,printerLocation,new MabelPrinterInfo(info))
          )
     );
     return response;
 }
Ejemplo n.º 46
0
        // 
        /// <summary>
        /// 打印预览(根据标签文件)
        /// </summary>
        /// <param name="bDisplayPrinterDialog">是否显示打印机设置对话框</param>
        /// <returns>-1: 出错; 0: 成功</returns>
        public int PrintPreviewFromLabelFile(bool bDisplayPrinterDialog = false)
        {
            string strError = "";

            int nRet = this.BeginPrint(
                this.textBox_labelFile_labelFilename.Text,
                this.textBox_labelDefFilename.Text,
                out strError);
            if (nRet == -1)
                goto ERROR1;

            this.document.PreviewMode = true;

            this.MainForm.OperHistory.AppendHtml("<div class='debug begin'>" + HttpUtility.HtmlEncode(DateTime.Now.ToLongTimeString()) + " 开始执行打印预览</div>");
            this.EnableControls(false);
            try
            {
                printDialog1.Document = this.document;

                if (this.PrinterInfo != null)
                {
                    string strPrinterName = document.PrinterSettings.PrinterName;
                    if (string.IsNullOrEmpty(this.PrinterInfo.PrinterName) == false
                        && this.PrinterInfo.PrinterName != strPrinterName)
                    {
                        this.document.PrinterSettings.PrinterName = this.PrinterInfo.PrinterName;
                        if (this.document.PrinterSettings.IsValid == false)
                        {
                            MessageBox.Show(this, "打印机 " + this.PrinterInfo.PrinterName + " 当前不可用,请重新选定打印机");
                            this.document.PrinterSettings.PrinterName = strPrinterName;
                            this.PrinterInfo.PrinterName = "";
                            bDisplayPrinterDialog = true;
                        }
                    }

                    PaperSize old_papersize = document.DefaultPageSettings.PaperSize;
                    if (string.IsNullOrEmpty(this.PrinterInfo.PaperName) == false
                        && this.PrinterInfo.PaperName != document.DefaultPageSettings.PaperSize.PaperName)
                    {
                        PaperSize found = null;
                        foreach (PaperSize ps in this.document.PrinterSettings.PaperSizes)
                        {
                            if (ps.PaperName.Equals(this.PrinterInfo.PaperName))
                            {
                                found = ps;
                                break;
                            }
                        }

                        if (found != null)
                            this.document.DefaultPageSettings.PaperSize = found;
                        else
                        {
                            MessageBox.Show(this, "打印机 " + this.PrinterInfo.PrinterName + " 的纸张类型 " + this.PrinterInfo.PaperName + " 当前不可用,请重新选定纸张");
                            document.DefaultPageSettings.PaperSize = old_papersize;
                            this.PrinterInfo.PaperName = "";
                            bDisplayPrinterDialog = true;
                        }
                    }

                    // 只要有一个打印机事项没有确定,就要出现打印机对话框
                    if (string.IsNullOrEmpty(this.PrinterInfo.PrinterName) == true
                        || string.IsNullOrEmpty(this.PrinterInfo.PaperName) == true)
                        bDisplayPrinterDialog = true;
                }
                else
                {
                    // 没有首选配置的情况下要出现打印对话框
                    bDisplayPrinterDialog = true;
                }

                DialogResult result = DialogResult.OK;
                if (bDisplayPrinterDialog == true)
                {
                    result = printDialog1.ShowDialog();

                    if (result == DialogResult.OK)
                    {
                        // 记忆打印参数
                        if (this.PrinterInfo == null)
                            this.PrinterInfo = new PrinterInfo();
                        this.PrinterInfo.PrinterName = document.PrinterSettings.PrinterName;
                        this.PrinterInfo.PaperName = document.DefaultPageSettings.PaperSize.PaperName;

                        // 2014/3/27
                        this.document.DefaultPageSettings = document.PrinterSettings.DefaultPageSettings;

                        SetTitle();
                    }
                }

                TracePrinterInfo();

                printPreviewDialog1.Document = this.document;

                this.MainForm.AppInfo.LinkFormState(printPreviewDialog1, "labelprintform_printpreviewdialog_state");
                printPreviewDialog1.ShowDialog(this);
                this.MainForm.AppInfo.UnlinkFormState(printPreviewDialog1);
            }
            finally
            {
                this.EnableControls(true);

                this.EndPrint();

                this.MainForm.OperHistory.AppendHtml("<div class='debug end'>" + HttpUtility.HtmlEncode(DateTime.Now.ToLongTimeString()) + " 结束执行打印预览</div>");
            }

            return 0;
        ERROR1:
            MessageBox.Show(this, strError);
            return -1;
        }
Ejemplo n.º 47
0
 public MabelPrinterInfo(PrinterInfo _info)
 {
     model = StripString(new String(_info.sModel).TrimEnd('\0'));
     modelId = _info.eModel;
     connected = _info.bPrinterConnected;
     printerSerial = StripString(new String(_info.sPrinterSerial));
     printHeadSerial = StripString(new String(_info.sPrintheadSerial));
     PCBSerial = StripString(new String(_info.sPCBSerial));
     firmwareVersion = StripString(new String(_info.sFirmwareVersion));
     esDensity = _info.iES_Density;
     handFeed = _info.iHandFeed;
     cardsPrinted = _info.iCardsPrinted;
     cardsOnPrintHead = _info.iCardsOnPrinthead;
     dyePanelsPrinted =  _info.iDyePanelsPrinted;
     cleansSinceShipped =  _info.iCleansSinceShipped;
     dyePanelsSinceCleaned =  _info.iDyePanelsSinceClean;
     cardsSinceCleaned = _info.iCardsSinceClean;
     cardsBetweenCleans =  _info.iCardsBetweenCleans;
     printHeadPosition = _info.iPrintHeadPosn;
     imageStartPosition =  _info.iImageStartPosn;
     imageEndPosition =  _info.iImageEndPosn;
     tagUID = StripString(new String(_info.sTagUID));
     shotsOnFilm =  _info.iShotsOnFilm;
     shotsUsed =  _info.iShotsUsed;
     filmType = StripString(new String(_info.sDyeFilmType));
     colourLength = _info.iColourLength;
     resinLength =_info.iResinLength;
     overcoatLength =  _info.iOvercoatLength;
     dyeFlags = _info.eDyeFlags;
     dob = _info.iDOB;
     dyeFilmMfrId =  _info.eDyeFilmManuf;
     dyeFilmProgId = _info.eDyeFilmProg;
     if (_info.LastEnduroMessage != null)
         lastMessage = StripString(_info.LastEnduroMessage);
 }
Ejemplo n.º 48
0
 protected SystemPrinter(PrinterInfo info)
 {
     Name = info.Name;
 }
Ejemplo n.º 49
0
        private void LabelPrintForm_Load(object sender, EventArgs e)
        {
#if NO
            if (this.MainForm != null)
            {
                MainForm.SetControlFont(this, this.MainForm.DefaultFont);
            }
#endif
#if NO
            this.Channel.Url = this.MainForm.LibraryServerUrl;

            this.Channel.BeforeLogin -= new BeforeLoginEventHandle(Channel_BeforeLogin);
            this.Channel.BeforeLogin += new BeforeLoginEventHandle(Channel_BeforeLogin);

            stop = new DigitalPlatform.Stop();
            stop.Register(MainForm.stopManager, true);	// 和容器关联
#endif

            if (string.IsNullOrEmpty(this.textBox_labelFile_labelFilename.Text) == true)
            {
                this.textBox_labelFile_labelFilename.Text = this.MainForm.AppInfo.GetString(
                    "label_print_form",
                    "label_file_name",
                    "");
            }

            if (string.IsNullOrEmpty(this.textBox_labelDefFilename.Text) == true)
            {
                this.textBox_labelDefFilename.Text = this.MainForm.AppInfo.GetString(
                    "label_print_form",
                    "label_def_file_name",
                    "");
            }

            if (this.m_bTestingGridSetted == false)
            {
                this.checkBox_testingGrid.Checked = this.MainForm.AppInfo.GetBoolean(
                    "label_print_form",
                    "print_testing_grid",
                    false);
            }

            string strWidths = this.MainForm.AppInfo.GetString(
                "label_print_form",
                "record_list_column_width",
                "");
            if (String.IsNullOrEmpty(strWidths) == false)
            {
                ListViewUtil.SetColumnHeaderWidth(this.listView_records,
                    strWidths,
                    true);
            }

            // 当前活动的property page
            string strActivePage = this.MainForm.AppInfo.GetString(
                "label_print_form",
                "active_page",
                "");

            if (String.IsNullOrEmpty(strActivePage) == false)
            {
                if (strActivePage == "itemrecords")
                    this.tabControl_main.SelectedTab = this.tabPage_itemRecords;
                else if (strActivePage == "labelfile")
                    this.tabControl_main.SelectedTab = this.tabPage_labelFile;
            }

            if (this.PrinterInfo == null)
            {
                this.PrinterInfo = this.MainForm.PreparePrinterInfo("缺省标签");
            }
            SetTitle();
        }
Ejemplo n.º 50
0
 private void manager_UpdateInfo(object sender, PrinterEventArgs e)
 {
     PrinterInfo info = e.Info;
     _lastInfo = info;
     UpdateInfo(info);
 }
Ejemplo n.º 51
0
        // 试图从标签定义文件中取得打印机信息,并显示在窗口标题上
        void LoadPrinterInfo()
        {
            string strError = "";

            if (String.IsNullOrEmpty(this.textBox_labelDefFilename.Text) == true)
            {
                strError = "尚未指定标签定义文件名";
                goto ERROR1;
            }

            LabelParam label_param = null;
            int nRet = LabelParam.Build(this.textBox_labelDefFilename.Text,
                out label_param,
                out strError);
            if (nRet == -1)
                goto ERROR1;

            // 记忆打印参数
            if (string.IsNullOrEmpty(label_param.DefaultPrinter) == false)
            {
                PrinterInfo temp = new PrinterInfo("缺省标签", label_param.DefaultPrinter);
                // 如果 label_param 中 Landscape 和 DefaultPrinter 不一致
                // temp.Landscape = label_param.Landscape;
                this.PrinterInfo = temp;
            }

            return;
        ERROR1:
            return;
        }
Ejemplo n.º 52
0
 private void UpdateInfo(PrinterInfo p)
 {
     if (tbPrinterStatus.InvokeRequired == false)
     {
         //tbPrinterStatus.Text = (p.bPrinterConnected) ? "Connected" : "Not Connected";
         String printerStatus = "";
         switch (p.status)
         {
             case MagiCardStatus.STATUS_READY:
                 printerStatus = "Ready";
                 break;
             case MagiCardStatus.STATUS_BUSY:
                 printerStatus = "BUSY";
                 break;
             case MagiCardStatus.STATUS_ERROR:
                 printerStatus = "ERROR";
                 break;
             case MagiCardStatus.STATUS_OFFLINE:
                 printerStatus = "Offline";
                 break;
             default:
                 printerStatus = "Unknown";
                 break;
         }
         tbPrinterStatus.Text = printerStatus;
         tbPrinterName.Text = new String(p.sModel);
         tbPrinterLastMessage.Text = p.LastEnduroMessage;
     } else
     {
         UpdateInfoDelegate updateInfo = new UpdateInfoDelegate(UpdateInfo);
         this.BeginInvoke(updateInfo, new object[] { p });
     }
 }
Ejemplo n.º 53
0
        /// <summary>
        /// 打印或打印预览
        /// </summary>
        /// <param name="strLabelDefFileName">标签定义文件</param>
        /// <param name="strLabelFileName">标签内容文件</param>
        /// <param name="bDisplayPrinterDialog">是否显示打印机设置对话框</param>
        /// <param name="bPrintPreview">是否进行打印预览。false 表示进行打印</param>
        /// <param name="strError">返回出错信息</param>
        /// <returns>-1: 出错; 0: 成功</returns>
        public int Print(
            string strLabelDefFileName,
            string strLabelFileName,
            bool bDisplayPrinterDialog,
            bool bPrintPreview,
            out string strError)
        {
            strError = "";
            int nRet = 0;

            this.MainForm.OperHistory.AppendHtml("<div class='debug begin'>" + HttpUtility.HtmlEncode(DateTime.Now.ToLongTimeString()) + " 开始执行打印"
                + (bPrintPreview == true ? "预览" : "")
                +"</div>");

            try
            {
                nRet = this.BeginPrint(
                    strLabelFileName,
                    strLabelDefFileName,
                    out strError);
                if (nRet == -1)
                    goto ERROR1;

                this.document.PreviewMode = bPrintPreview;

                this.EnableControls(false);
                Cursor oldCursor = this.Cursor;
                if (bPrintPreview == false)
                    this.Cursor = Cursors.WaitCursor;
                try
                {
                    bool bCustomPaper = false;

                    if (bPrintPreview == false)
                    {
                        // Allow the user to choose the page range he or she would
                        // like to print.
                        printDialog1.AllowSomePages = true;

                        // Show the help button.
                        printDialog1.ShowHelp = true;
                    }

                    printDialog1.Document = this.document;

                    if (this.PrinterInfo != null)
                    {

                        // this.OutputText("恢复以前的打印机名: " + this.PrinterInfo.PrinterName + ", 纸张名: " + this.PrinterInfo.PaperName);

#if NO
                        string strPrinterName = document.PrinterSettings.PrinterName;
                        if (string.IsNullOrEmpty(this.PrinterInfo.PrinterName) == false
                            && this.PrinterInfo.PrinterName != strPrinterName)
                        {
                            this.document.PrinterSettings.PrinterName = this.PrinterInfo.PrinterName;
                            if (this.document.PrinterSettings.IsValid == false)
                            {
                                this.document.PrinterSettings.PrinterName = strPrinterName;
                                MessageBox.Show(this, "打印机 " + this.PrinterInfo.PrinterName + " 当前不可用,请重新选定打印机");
                                this.PrinterInfo.PrinterName = "";
                                bDisplayPrinterDialog = true;
                            }
                        }
#endif
                        // 按照存储的打印机名选定打印机
                        nRet = SelectPrinterByName(this.document,
                            this.PrinterInfo.PrinterName,
                            out  strError);
                        if (nRet == 1)
                        {
                            MessageBox.Show(this, "打印机 " + this.PrinterInfo.PrinterName + " 当前不可用,请重新选定打印机");
                            this.PrinterInfo.PrinterName = "";
                            bDisplayPrinterDialog = true;
                        }

#if NO
                        PaperSize old_papersize = document.DefaultPageSettings.PaperSize;
                        if (string.IsNullOrEmpty(this.PrinterInfo.PaperName) == false
                            && this.PrinterInfo.PaperName != document.DefaultPageSettings.PaperSize.PaperName)
                        {
                            PaperSize found = null;
                            foreach (PaperSize ps in this.document.PrinterSettings.PaperSizes)
                            {
                                if (ps.PaperName.Equals(this.PrinterInfo.PaperName))
                                {
                                    found = ps;
                                    break;
                                }
                            }

                            if (found != null)
                                this.document.DefaultPageSettings.PaperSize = found;
                            else
                            {
                                MessageBox.Show(this, "打印机 " + this.PrinterInfo.PrinterName + " 的纸张类型 " + this.PrinterInfo.PaperName + " 当前不可用,请重新选定纸张");
                                document.DefaultPageSettings.PaperSize = old_papersize;
                                this.PrinterInfo.PaperName = "";
                                bDisplayPrinterDialog = true;
                            }
                        }
#endif

                        // 需要自定义纸张
                        if (string.IsNullOrEmpty(this.label_param.DefaultPrinter) == true
                            && this.label_param.PageWidth > 0
                            && this.label_param.PageHeight > 0)
                        {
                            bCustomPaper = true;

                            PaperSize paper_size = new PaperSize("Custom Label", 
                                (int)label_param.PageWidth,
                                (int)label_param.PageHeight);
                            this.document.DefaultPageSettings.PaperSize = paper_size;
                        }


                        if (// bDisplayPrinterDialog == false && 
                            bCustomPaper == false
                            && string.IsNullOrEmpty(this.PrinterInfo.PaperName) == false)
                        {
                            nRet = SelectPaperByName(this.document,
                                this.PrinterInfo.PaperName,
                                this.PrinterInfo.Landscape,
                                true,   // false,
                                out strError);
                            if (nRet == 1)
                            {
                                MessageBox.Show(this, "打印机 " + this.PrinterInfo.PrinterName + " 的纸张类型 " + this.PrinterInfo.PaperName + " 当前不可用,请重新选定纸张");
                                this.PrinterInfo.PaperName = "";
                                bDisplayPrinterDialog = true;
                            }
                        }

                        // 只要有一个打印机事项没有确定,就要出现打印机对话框
                        if (bCustomPaper == false)
                        {
                            if (string.IsNullOrEmpty(this.PrinterInfo.PrinterName) == true
                                || string.IsNullOrEmpty(this.PrinterInfo.PaperName) == true)
                                bDisplayPrinterDialog = true;
                        }
                    }
                    else
                    {
                        // 没有首选配置的情况下要出现打印对话框
                        bDisplayPrinterDialog = true;
                    }

                    // this.document.DefaultPageSettings.Landscape = label_param.Landscape;

                    DialogResult result = DialogResult.OK;
                    if (bDisplayPrinterDialog == true)
                    {
                        result = printDialog1.ShowDialog();

                        if (result == DialogResult.OK)
                        {
                            if (bCustomPaper == true)
                            {
                                PaperSize paper_size = new PaperSize("Custom Label",
                                    (int)label_param.PageWidth,
                                    (int)label_param.PageHeight);
                                this.document.DefaultPageSettings.PaperSize = paper_size;
                            }

                            // 记忆打印参数
                            if (this.PrinterInfo == null)
                                this.PrinterInfo = new PrinterInfo();

                            // this.OutputText("打印机对话框返回后,新选定的打印机名: " + document.PrinterSettings.PrinterName + ", 纸张名: " + document.DefaultPageSettings.PaperSize.PaperName);

                            this.PrinterInfo.PrinterName = document.PrinterSettings.PrinterName;
                            // this.PrinterInfo.PaperName = document.PrinterSettings.DefaultPageSettings.PaperSize.PaperName;  // document.DefaultPageSettings.PaperSize.PaperName
                            this.PrinterInfo.PaperName = PrintUtil.GetPaperSizeString(document.DefaultPageSettings.PaperSize);
                            this.PrinterInfo.Landscape = document.DefaultPageSettings.Landscape;

                            if (bCustomPaper == false)
                            {
                                // 2014/3/27
                                // this.document.DefaultPageSettings = document.PrinterSettings.DefaultPageSettings;
                                nRet = SelectPaperByName(this.document,
                                    this.PrinterInfo.PaperName,
                                    this.PrinterInfo.Landscape,
                                    true,
                                    out strError);
                                if (nRet == 1)
                                {
                                    // MessageBox.Show(this, "打印机 " + this.PrinterInfo.PrinterName + " 的纸张类型 " + this.PrinterInfo.PaperName + " 当前不可用,请重新选定纸张");
                                    //this.PrinterInfo.PaperName = "";
                                    //bDisplayPrinterDialog = true;

                                    this.OutputText("打印机对话框返回后,经过检查,纸张 " + this.PrinterInfo.PaperName + " 不在打印机 " + this.PrinterInfo.PrinterName + " 的可用纸张列表中。出现对话框让用户重新选择纸张");


                                    SelectPaperDialog paper_dialog = new SelectPaperDialog();
                                    MainForm.SetControlFont(paper_dialog, this.Font, false);
                                    paper_dialog.Comment = "纸张 " + this.PrinterInfo.PaperName + " 不在打印机 " + this.PrinterInfo.PrinterName + " 的可用纸张列表中。\r\n请重新选定纸张";
                                    paper_dialog.Document = this.document;
                                    this.MainForm.AppInfo.LinkFormState(paper_dialog, "paper_dialog_state");
                                    paper_dialog.ShowDialog(this);
                                    this.MainForm.AppInfo.UnlinkFormState(paper_dialog);

                                    if (paper_dialog.DialogResult == System.Windows.Forms.DialogResult.Cancel)
                                        return 0;

                                    this.OutputText("对话框中新选定的纸张名: " + document.DefaultPageSettings.PaperSize.PaperName);
                                }
                            }

                            this.PrinterInfo.PaperName = PrintUtil.GetPaperSizeString(document.DefaultPageSettings.PaperSize);
                            this.PrinterInfo.Landscape = document.DefaultPageSettings.Landscape;

                            SetTitle();
                        }
                        else
                            return 0;
                    }

                    TracePrinterInfo();

                    if (bPrintPreview == true)
                    {
                        printPreviewDialog1.Document = this.document;

                        this.MainForm.AppInfo.LinkFormState(printPreviewDialog1, "labelprintform_printpreviewdialog_state");
                        printPreviewDialog1.ShowDialog(this);
                        this.MainForm.AppInfo.UnlinkFormState(printPreviewDialog1);
                    }
                    else
                    {
                        this.document.Print();
                    }
                }
                finally
                {
                    if (bPrintPreview == false)
                        this.Cursor = oldCursor;
                    this.EnableControls(true);

                    this.EndPrint();    // 关闭标签文件。后面才能删除
                }
            }
            finally
            {
                this.MainForm.OperHistory.AppendHtml("<div class='debug end'>" + HttpUtility.HtmlEncode(DateTime.Now.ToLongTimeString()) + " 结束执行打印"
                + (bPrintPreview == true ? "预览" : "")
                + "</div>");
            }

            return 0;
        ERROR1:
            return -1;
        }