Пример #1
0
        private bool SetOffsets(string cardType)
        {
            bool       offsetsSet = false;
            PrinterOps prnOps     = new PrinterOps();

            try {
                prnOps = new PrinterOps();
                if (!prnOps.DiscoverUSBPrinters())
                {
                    throw new Exception(prnOps.printerError);
                }

                if (!prnOps.OpenConnection())
                {
                    prnOps = null;
                    throw new Exception(prnOps.printerError);
                }

                int max = 0;
                int min = 0;
                prnOps.GetSmartOffsetRange(cardType, out min, out max);

                if (this.nbOffset.Value < min)
                {
                    this.nbOffset.Value   = 0;
                    this.nbOffset.Minimum = min;
                    this.nbOffset.Value   = min;
                }
                else
                {
                    this.nbOffset.Minimum = min;
                }
                if (this.nbOffset.Value > max)
                {
                    this.nbOffset.Value   = 0;
                    this.nbOffset.Maximum = max;
                    this.nbOffset.Value   = max;
                }
                else
                {
                    this.nbOffset.Maximum = max;
                }

                string offsetRange = "Offset range is " + min.ToString() + " to " + max.ToString();
                System.Windows.Forms.ToolTip toolTip = new System.Windows.Forms.ToolTip();
                toolTip.SetToolTip(this.nbOffset, offsetRange);
                offsetsSet = true;
            } catch {
            } finally {
                if (prnOps != null)
                {
                    prnOps.CloseConnection();
                    prnOps = null;
                }
            }
            return(offsetsSet);
        }
Пример #2
0
        private bool CheckForPrinter(ref string errMsg)
        {
            bool found = false;

            try {
                if (!prnOps.DiscoverUSBPrinters())
                {
                    throw new Exception(prnOps.printerError);
                }
                found = true;
            } catch (Exception ex) {
                errMsg = ex.Message;
            }
            return(found);
        }