private void ComboBox_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     try
     {
         BipFactory.SetAllDark();
         if (string.IsNullOrEmpty(ComboBoxPosition.Text) || ComboBoxPosition.SelectedIndex == -1)
         {
             return;
         }
         if (string.IsNullOrEmpty(ComboBoxDelay.Text) || ComboBoxDelay.SelectedIndex == -1)
         {
             return;
         }
         if (string.IsNullOrEmpty(ComboBoxColor.Text) || ComboBoxColor.SelectedIndex == -1)
         {
             return;
         }
         if (string.IsNullOrEmpty(ComboBoxBIPPanel.Text) || ComboBoxBIPPanel.SelectedIndex == -1)
         {
             return;
         }
         SetFormState();
         _isDirty = true;
         ShowLED();
     }
     catch (Exception ex)
     {
         Common.ShowErrorMessageBox(100906, ex);
     }
 }
        private void PopulateComboBoxes()
        {
            try
            {
                BipFactory.SetAllDark();
                ComboBoxPosition.SelectionChanged -= ComboBox_OnSelectionChanged;
                ComboBoxPosition.Items.Clear();
                foreach (BIPLedPositionEnum position in Enum.GetValues(typeof(BIPLedPositionEnum)))
                {
                    var comboBoxItem = new ComboBoxItem();
                    comboBoxItem.Content = position;
                    ComboBoxPosition.Items.Add(comboBoxItem);
                }

                ComboBoxDelay.SelectionChanged -= ComboBox_OnSelectionChanged;
                ComboBoxDelay.Items.Clear();
                foreach (BIPLightDelays delay in Enum.GetValues(typeof(BIPLightDelays)))
                {
                    var comboBoxItem = new ComboBoxItem();
                    comboBoxItem.Content = delay;
                    ComboBoxDelay.Items.Add(comboBoxItem);
                    ComboBoxDelay.SelectedValue = BIPLightDelays.Zeroms;
                }

                ComboBoxColor.SelectionChanged -= ComboBox_OnSelectionChanged;
                ComboBoxColor.Items.Clear();
                foreach (PanelLEDColor color in Enum.GetValues(typeof(PanelLEDColor)))
                {
                    var comboBoxItem = new ComboBoxItem();
                    comboBoxItem.Content = color;
                    ComboBoxColor.Items.Add(comboBoxItem);
                }
                ComboBoxColor.SelectedValue = PanelLEDColor.GREEN;

                ComboBoxBIPPanel.SelectionChanged -= ComboBox_OnSelectionChanged;
                ComboBoxBIPPanel.Items.Clear();
                foreach (BacklitPanelBIP bip in BipFactory.GetBips())
                {
                    var comboBoxItem = new ComboBoxItem();
                    comboBoxItem.Content = bip.Hash;
                    ComboBoxBIPPanel.Items.Add(comboBoxItem);
                }

                if (_bipLight != null)
                {
                    ComboBoxPosition.SelectedValue = _bipLight.BIPLedPosition;
                    ComboBoxDelay.SelectedValue    = _bipLight.DelayBefore;
                    ComboBoxColor.SelectedValue    = _bipLight.LEDColor;
                    ComboBoxBIPPanel.SelectedValue = _bipLight.Hash;
                }
                ShowLED();
            }
            finally
            {
                ComboBoxPosition.SelectionChanged += ComboBox_OnSelectionChanged;
                ComboBoxDelay.SelectionChanged    += ComboBox_OnSelectionChanged;
                ComboBoxColor.SelectionChanged    += ComboBox_OnSelectionChanged;
                ComboBoxBIPPanel.SelectionChanged += ComboBox_OnSelectionChanged;
            }
        }