private Dataflash ReadDataflash(BackgroundWorker worker = null)
 {
     m_simple = m_usbConnector.ReadDataflash(worker);
     return(m_simple.Build < MinimumSupportedBuildNumber
                         ? null
                         : m_manager.Read(m_simple.Data));
 }
        private void DeviceConnected(bool isConnected)
        {
            if (isConnected)
            {
                System.Diagnostics.Trace.WriteLine("Connected " + DateTime.Now);

                try
                {
                    m_dataflash = m_connector.ReadDataflash();
                }
                catch
                {
                    return;
                }

                m_connectedDeviceProductId = m_dataflash.ProductId;
                m_deviceInfo      = USBConnector.GetDeviceInfo(m_connectedDeviceProductId);
                m_hardwareVersion = (m_dataflash.HardwareVersion / 100f).ToString("0.00", CultureInfo.InvariantCulture);
                m_firmwareVersion = (m_dataflash.FirmwareVersion / 100f).ToString("0.00", CultureInfo.InvariantCulture);

                UpdateUI(() =>
                {
                    DeviceNameTextBox.Text      = m_deviceInfo.Name;
                    HardwareVersionTextBox.Text = m_hardwareVersion;
                    FirmwareVersionTextBox.Text = m_firmwareVersion;
                    BootModeTextBox.Text        = m_dataflash.LoadFromLdrom ? "LDROM" : "APROM";
                    UpdateStatusLabel.Text      = @"Device is ready.";
                    SetUpdaterButtonsState(true);
                });
            }
            else
            {
                System.Diagnostics.Trace.WriteLine("Disconnected " + DateTime.Now);
                m_connectedDeviceProductId = null;
                m_dataflash = null;

                UpdateUI(() =>
                {
                    DeviceNameTextBox.Clear();
                    HardwareVersionTextBox.Clear();
                    FirmwareVersionTextBox.Clear();
                    BootModeTextBox.Clear();
                    UpdateStatusLabel.Text = @"Waiting for device...";
                    SetUpdaterButtonsState(false);
                });
            }
        }