Ejemplo n.º 1
0
        public PinSelectViewModel()
        {
            StartPINCommand = new RelayCommand(DoPINSelect, param => this.canExecute);
            RefreshCommand  = new RelayCommand(DoRefresh, param => this.canExecute);

            try
            {
                _token = StartupProperties.URL.ToString();
            }
            catch (Exception ex)
            {
                _token = ex.Message;
            }

            PINPadSearch search  = new PINPadSearch();
            var          devices = search.SearchForConnectedPINPads();

            if (devices.Count() > 0)
            {
                PINPads = devices;
            }
            else
            {
                PINPads = new IPINPad[0];
            }
        }
Ejemplo n.º 2
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());
        }
Ejemplo n.º 3
0
        public void DoRefresh(object obj)
        {
            PINPadSearch search  = new PINPadSearch();
            var          devices = search.SearchForConnectedPINPads();

            if (devices.Count() > 0)
            {
                PINPads        = devices;
                SelectedPINPad = devices[0];
            }
            else
            {
                PINPads = new IPINPad[0];
            }
        }