コード例 #1
0
        // Builds the _cardTypes ArrayList
        //     from the selected printer
        // --------------------------------------------------------------------------------------------------
        private int CardTypesInit(ref ZXPSampleCode z, string deviceName)
        {
            Job job = null;

            try
            {
                _cardTypeList.Clear();

                job = new Job();

                if (!ConnectToPrinter(ref z, ref job, deviceName))
                {
                    return(0);
                }

                z.GetCardTypeList(ref job);
                if (z.CardTypeList != null)
                {
                    Array array = (Array)z.CardTypeList;
                    for (int i = 0; i < array.GetLength(0); i++)
                    {
                        _cardTypeList.Add((string)array.GetValue(i));
                    }
                }
                else
                {
                    MessageBox.Show("No ZMotif devices found");
                    this.Refresh();
                }
            }
            catch (Exception e)
            {
                MessageBox.Show("cboCardTypeInit Exception: " + e.Message);
            }
            finally
            {
                DisconnectFromPrinter(ref z, ref job);
                job = null;
            }
            return(_cardTypeList.Count);
        }