private void ButtonEditClick(object sender, RoutedEventArgs e)
 {
     try
     {
         var keyValuePair   = (KeyValuePair <int, BIPLight>)DataGridSequences.SelectedItem;
         var bipLightWindow = new BipLightWindow(keyValuePair.Value, _bipLink.Description);
         bipLightWindow.ShowDialog();
         if (bipLightWindow.DialogResult.HasValue && bipLightWindow.DialogResult.Value)
         {
             //Clicked OK
             if (!bipLightWindow.IsDirty)
             {
                 //User made no changes
                 return;
             }
             _bipLink.BIPLights[keyValuePair.Key] = bipLightWindow.BIPLight;
             DataGridSequences.DataContext        = _bipLink.BIPLights;
             DataGridSequences.ItemsSource        = _bipLink.BIPLights;
             DataGridSequences.Items.Refresh();
             _isDirty = true;
         }
         SetFormState();
     }
     catch (Exception ex)
     {
         Common.ShowErrorMessageBox(ex);
     }
 }
        private void AddBIPLight()
        {
            var bipLightWindow = new BipLightWindow();

            bipLightWindow.ShowDialog();
            if (bipLightWindow.DialogResult.HasValue && bipLightWindow.DialogResult.Value)
            {
                _bipLink.BIPLights.Add(GetNewKeyValue(), bipLightWindow.BIPLight);

                DataGridSequences.DataContext = _bipLink.BIPLights;
                DataGridSequences.ItemsSource = _bipLink.BIPLights;
                DataGridSequences.Items.Refresh();
                _isDirty = true;
            }
            SetFormState();
        }
        private void ButtonAddClick(object sender, RoutedEventArgs e)
        {
            try
            {
                var bipLightWindow = new BipLightWindow();
                bipLightWindow.ShowDialog();
                if (bipLightWindow.DialogResult.HasValue && bipLightWindow.DialogResult.Value)
                {
                    _bipLink.BIPLights.Add(GetNewKeyValue(), bipLightWindow.BIPLight);

                    DataGridSequences.DataContext = _bipLink.BIPLights;
                    DataGridSequences.ItemsSource = _bipLink.BIPLights;
                    DataGridSequences.Items.Refresh();
                    _isDirty = true;
                }
                SetFormState();
            }
            catch (Exception ex)
            {
                Common.ShowErrorMessageBox(ex);
            }
        }
        private void EditBIPLight()
        {
            var keyValuePair   = (KeyValuePair <int, BIPLight>)DataGridSequences.SelectedItem;
            var bipLightWindow = new BipLightWindow(keyValuePair.Value, _bipLink.Description);

            bipLightWindow.ShowDialog();
            if (bipLightWindow.DialogResult.HasValue && bipLightWindow.DialogResult.Value)
            {
                //Clicked OK
                if (!bipLightWindow.IsDirty)
                {
                    //User made no changes
                    return;
                }
                _bipLink.BIPLights[keyValuePair.Key] = bipLightWindow.BIPLight;
                DataGridSequences.DataContext        = _bipLink.BIPLights;
                DataGridSequences.ItemsSource        = _bipLink.BIPLights;
                DataGridSequences.Items.Refresh();
                _isDirty = true;
            }
            SetFormState();
        }