Exemplo n.º 1
0
        private void DeleteSensorButton_Click(object sender, RoutedEventArgs e)
        {
            TxData[0] = Const.DELETE_SENSOR;
            if (SensorsInstalledList.Count == 0)
            {
                return;
            }
            byte   CurrentSensorNum = (byte)(SensorsInstalledList.Count - SensListBox.SelectedIndex - 1);
            string CurrentSensorSN  = SensorsInstalledList[CurrentSensorNum];

            if (CurrentSensorSN.StartsWith("10"))
            {
                CurrentSensorNum = byte.Parse(CurrentSensorSN.Substring(0, 2));
            }
            else
            {
                CurrentSensorNum = byte.Parse(CurrentSensorSN.Substring(0, 1));
            }
            TxData[1] = CurrentSensorNum;
            TxData[1]--;
            DataHanlderClass.PrintTextToOutput(TextOutput, string.Format("Sensor {0:0} ", CurrentSensorNum) + " deleted!");
            SensorsInstalledList.Remove(CurrentSensorSN);
            DataHanlderClass.CopyListToComboBox(SensListBox, MainWindow.SensorsInstalledList, true);
            SensLabel[CurrentSensorNum - 1].Content = "Deleted";
            HID_Write(TxData);
        }