コード例 #1
0
        private void DeviceConnected(bool isConnected)
        {
            if (isConnected)
            {
                var dataflash = m_updater.ReadDataFlash();
                m_connectedDeviceProductId = dataflash.ProductId;
                var deviceName = FirmwareUpdater.GetDeviceName(m_connectedDeviceProductId);

                UpdateUI(() =>
                {
                    DeviceNameTextBox.Text      = deviceName;
                    HardwareVersionTextBox.Text = dataflash.HardwareVersion.ToString("0.00", CultureInfo.InvariantCulture);
                    FirmwareVersionTextBox.Text = dataflash.FirmwareVersion.ToString("0.00", CultureInfo.InvariantCulture);
                    SetUpdaterButtonsState(true);
                });
            }
            else
            {
                UpdateUI(() =>
                {
                    DeviceNameTextBox.Clear();
                    HardwareVersionTextBox.Clear();
                    FirmwareVersionTextBox.Clear();
                    SetUpdaterButtonsState(false);
                });
                m_connectedDeviceProductId = null;
            }
        }
コード例 #2
0
        private void DeviceConnected(bool isConnected)
        {
            if (isConnected)
            {
                System.Diagnostics.Trace.WriteLine("Connected " + DateTime.Now);
                Dataflash dataflash;

                try
                {
                    dataflash = m_updater.ReadDataflash();
                }
                catch
                {
                    return;
                }

                m_connectedDeviceProductId = dataflash.ProductId;
                m_deviceName      = FirmwareUpdater.GetDeviceName(m_connectedDeviceProductId);
                m_hardwareVersion = dataflash.HardwareVersion.ToString("0.00", CultureInfo.InvariantCulture);
                m_firmwareVersion = dataflash.FirmwareVersion.ToString("0.00", CultureInfo.InvariantCulture);

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