示例#1
0
        private void setPanelStatus(Sensor sensor, RoundedGroupBox p)
        {
            Label l = p.Controls.OfType<Label>().Where(a => a.Name.EndsWith(@"DeviceIdLbl")).FirstOrDefault();
            Button bSearch = p.Controls.OfType<Button>().Where(a => a.Name.EndsWith(@"SearchBtn")).FirstOrDefault();
            Button bPair = p.Controls.OfType<Button>().Where(a => a.Name.EndsWith(@"PairBtn")).FirstOrDefault();
            string devId = @"";
            if (sensor.IsPaired)
            {
                devId = sensor.DeviceNumber.ToString();
                bPair.Text = @"Unpair";
                bPair.Enabled = true;
            }
            else
            {
                bPair.Text = @"Pair";
                bPair.Enabled = (sensor.Status == SensorStatus.Connected);
                devId = (sensor.Status == SensorStatus.Connected) ? sensor.DeviceNumber.ToString() : @" -";
            }

            l.Text = "Device ID: " + devId;
            switch (sensor.Status)
            {
                case SensorStatus.Disconnected:
                    p.CaptionBackColor = Color.Gray;
                    bSearch.Text = @"Search";
                    bSearch.Enabled = true;
                    break;
                case SensorStatus.Disconnecting:
                    p.CaptionBackColor = Color.FromArgb(255, 250, 239, 192);
                    bSearch.Text = @"Disconnecting";
                    bSearch.Enabled = false;
                    break;
                case SensorStatus.Searching:
                    p.CaptionBackColor = Color.FromArgb(255, 237, 194, 24);
                    bSearch.Text = @"Searching";
                    bSearch.Enabled = false;
                    break;
                case SensorStatus.Connected:
                    p.CaptionBackColor = Color.FromArgb(255, 227, 14, 31);
                    bSearch.Text = @"Disconnect";
                    bSearch.Enabled = true;
                    break;
            }
            // Get the current output data
            InterfaceDatum _outputDatum = CycliInterface.Instance().GetOutputDatum();
        }
示例#2
0
 private void SearchButtonClicked(Sensor sensor, RoundedGroupBox p)
 {
     if (sensor.Status == SensorStatus.Disconnected)
     {
         sensor.Search();
     }
     else
     {
         sensor.Disconnect();
     }
     setPanelStatus(sensor, p);
 }