private void ButtonInitialize_Click(object sender, RoutedEventArgs e)
        {
            if (radioButtonInitialize_PortUsb.IsChecked.Value)
            {
                //For USB communication, no parameters needed
                m_TelidControl = new TelidControl();
            }
            else
            {
                //For serial/bluetooth, get needed parameters
                byte portType = 0;
                if (radioButtonInitialize_PortBt.IsChecked.Value)
                {
                    portType = 2;
                }
                var readerPortSetings = InterfaceCommunicationSettings.GetForSerialDevice(portType, textBoxInitialize_PortName.Text);
                m_TelidControl = new TelidControl(readerPortSetings);
            }
            //On this event the read-progress is notified
            m_TelidControl.ReadLogProtocol_ProgressPercentageUpdated += TelidControl_ReadLogProtocol_ProgressPercentageUpdated;
            //On this event the result of the "StartInitialize" process is notified
            m_TelidControl.InitializeCompleted += TelidControl_InitializeCompleted;
            //On this event the result of the Start
            m_TelidControl.ReadCompleted += TelidControl_ReadCompleted;

            //Start Initialize
            m_TelidControl.StartInitialize();
        }
Exemplo n.º 2
0
        private async void ButtonInitialize_ClickAsync(object sender, RoutedEventArgs e)
        {
            if (radioButtonInitialize_PortUsb.IsChecked.Value)
            {
                //For USB communication, no parameters needed
                m_TelidControl = new TelidControl();
            }
            else
            {
                //For serial/bluetooth, get needed parameters
                byte portType = 0;
                if (radioButtonInitialize_PortBt.IsChecked.Value)
                {
                    portType = 2;
                }
                var readerPortSetings = InterfaceCommunicationSettings.GetForSerialDevice(portType, textBoxInitialize_PortName.Text);
                m_TelidControl = new TelidControl(readerPortSetings);
            }
            //On this event the read-progress is notified
            m_TelidControl.ReadLogProtocol_ProgressPercentageUpdated += TelidControl_ReadLogProtocol_ProgressPercentageUpdated;

            //Initialize
            if (await m_TelidControl.InitializeAsync())
            {
                //Initialize worked --> Enable UI & enable BackgroundWorker to check Reader-ID
                textBlock_ReaderInfo.Text = "Initialize Result: True";
                if (m_Worker.IsBusy != true)
                {
                    // Start the asynchronous operation.
                    m_Worker.RunWorkerAsync();
                }
            }
            else
            {
                //Initialize didn't work --> disable UI
                textBlock_ReaderInfo.Text = "Initialize Result: False";
                SetUiEnabled(false, 0);
            }
        }