コード例 #1
0
 private void _findDeviceButton_Click(object sender, System.EventArgs e)
 {
     try
     {
         _deviceModel.StopSignal();
         var deviceSearchForm = new DeviceSearchForm();
         if (deviceSearchForm.ShowDialog(this) == DialogResult.OK)
         {
             if (deviceSearchForm.SelectedDevice != null)
             {
                 _deviceLabel.Text = deviceSearchForm.SelectedDevice.ToString();
                 _deviceModel.SelectDevice(deviceSearchForm.SelectedDevice);
             }
             else
             {
                 _deviceLabel.Text = "Not selected";
             }
         }
     }
     catch (Exception exc)
     {
         MessageBox.Show($"Cannot connect to device: {exc.Message}", "Connection error", MessageBoxButtons.OK,
                         MessageBoxIcon.Error);
     }
 }
コード例 #2
0
ファイル: MainForm.cs プロジェクト: maslovvladimir/samples
        private void _findDeviceButton_Click(object sender, System.EventArgs e)
        {
            _deviceModel.StopSignal();
            var deviceSearchForm = new DeviceSearchForm();

            if (deviceSearchForm.ShowDialog(this) == DialogResult.OK)
            {
                if (deviceSearchForm.SelectedDevice != null)
                {
                    _deviceLabel.Text = deviceSearchForm.SelectedDevice.ToString();
                    _deviceModel.SelectDevice(deviceSearchForm.SelectedDevice);
                }
                else
                {
                    _deviceLabel.Text = "Not selected";
                }
            }
        }