private void lstTriggers_SelectionChanged(MySelectableListItem lastSelected, MySelectableListItem newSelected) { bool isSel = newSelected != null; btnCopy.IsEnabled = isSel; btnDelete.IsEnabled = isSel; btnModify.IsEnabled = isSel; btnMoveDown.IsEnabled = isSel; btnMoveUp.IsEnabled = isSel; if (lstTriggers.isLastItemSelected()) { btnMoveDown.IsEnabled = false; } if (lstTriggers.isFirstItemSelected()) { btnMoveUp.IsEnabled = false; } if (lastSelected != newSelected) // Ignore the crap of this shit { if (lastSelected != null) { FrameworkElement ls = ((object[])lastSelected.CustomData)[0] as FrameworkElement; TriggerDefinitionPartProperties props = ((object[])lastSelected.CustomData)[2] as TriggerDefinitionPartProperties; props.FireSelectionChange(false); if (ls is RichTextBox) { ((RichTextBox)ls).Background = Brushes.White; ((RichTextBox)ls).Foreground = Brushes.Black; ls.InvalidateVisual(); } } if (newSelected != null) { FrameworkElement ls = ((object[])newSelected.CustomData)[0] as FrameworkElement; TriggerDefinitionPartProperties props = ((object[])newSelected.CustomData)[2] as TriggerDefinitionPartProperties; props.FireSelectionChange(true); if (ls is RichTextBox) { ((RichTextBox)ls).Background = selected; ((RichTextBox)ls).Foreground = Brushes.White; ls.InvalidateVisual(); } } } }
private void btnActDel_Click(object sender, RoutedEventArgs e) { MySelectableListItem sel = lstAct.CurrentlySelected; if (sel != null) { int selectedIndex = lstAct.SelectedIndex; if (lstAct.isLastItemSelected()) { selectedIndex--; } lstAct.Remove(sel); if (selectedIndex >= 0) // Select next item { lstAct.SelectedIndex = selectedIndex; } } TabControl_SelectionChanged(null, null); }