Example #1
0
        public void DoRefresh(object obj)
        {
            try
            {
                canDeviceInfo = false;
                canPrint      = false;
                PrinterSearch search  = new PrinterSearch();
                var           devices = search.SearchForConnectedPrinters();

                if (devices.Count() > 0)
                {
                    Printers        = devices;
                    SelectedPrinter = devices[0];
                    canDeviceInfo   = true;
                    canPrint        = StartupProperties.Action == StartupProperties.Actions.PrintCard && !string.IsNullOrEmpty(StartupProperties.Token);
                }
                else
                {
                    Printers = new IPrinter[0];
                }
            }
            catch (Exception ex)
            {
                Error    = ex.StackTrace;
                Printers = new IPrinter[0];
            }
        }
        public void DoDeviceSearch(object obj)
        {
            CanDeviceInfo               =
                CanPinTest              =
                    CanPrintTest        =
                        CanDeviceSearch = false;
            CommandManager.InvalidateRequerySuggested();

            KeyValuePair <int, string> selectedItem;

            if (obj is KeyValuePair <int, string> )
            {
                selectedItem = (KeyValuePair <int, string>)obj;
            }
            else
            {
                throw new Exception();
            }

            Task.Factory.StartNew(() =>
            {
                Error = String.Empty;
                Info  = "Searching for Devices";
                if (selectedItem.Key == 0)
                {
                    var printerSearch = new PrinterSearch();
                    Devices           = printerSearch.SearchForConnectedPrinters();
                }
                else if (selectedItem.Key == 1)
                {
                    var pinPadSearch = new PINPadSearch();
                    Devices          = pinPadSearch.SearchForConnectedPINPads();
                }
                else
                {
                }

                if (Devices.Length > 0)
                {
                    CanDeviceInfo = true;
                    CanPinTest    = selectedItem.Key == 1;
                    CanPrintTest  = selectedItem.Key == 0;
                }

                Info = "Done Searching";
            })
            .ContinueWith(manifest =>
            {
                CanDeviceSearch = true;
                CommandManager.InvalidateRequerySuggested();
            }, TaskScheduler.FromCurrentSynchronizationContext());
        }
Example #3
0
        public void GetDeviceListTest()
        {
            PrinterSearch search = new PrinterSearch();

            var printers = search.SearchForConnectedPrinters();

            //var printers = ZebraZXP3.GetDeviceList();

            if (printers.Length > 0)
            {
                using (printers[0])
                {
                    string errMsg;
                    short  alarm;
                    printers[0].Print();
                }
            }
        }