private void HandleCardClicked(IDMigrationStepCard c, MouseEvent e) { if (!e.ShiftPressed) { lastClickedBeforeShift = c; } // For a card to be clicked, there must be at least one card, therefore this should never throw an exception if (lastClickedBeforeShift == null) { lastClickedBeforeShift = Cards[0]; } if (e.ShiftPressed) { DeselectAll(false); var start = lastClickedBeforeShift.Index; var end = c.Index; // Swap the indices if (start > end) { var t = start; start = end; end = t; } for (var i = start; i <= end; i++) { SelectStep(i, true, false); } OnSelectionChanged(); } else { if (e.ControlPressed) { ToggleStepSelection(c.Index, true); } else { var otherSelectedSteps = SelectedStepIndices.Clone(); otherSelectedSteps.Remove(c.Index); if (otherSelectedSteps.Count == 0) { ToggleStepSelection(c.Index); } else { SelectStep(c.Index); } } } }
public void CopySelectedSteps() { var indices = new int[SelectedStepIndices.Count]; SelectedStepIndices.CopyTo(indices); clipboard = new List <SourceTargetRange>(indices.Length); foreach (var i in indices) { clipboard.Add(Cards[i].StepRange); } }
public void RemoveSelectedSteps() { var indices = new int[SelectedStepIndices.Count]; SelectedStepIndices.CopyTo(indices); for (var i = indices.Length - 1; i >= 0; i--) { editor.RemoveIDMigrationStep(Cards[indices[i]].StepRange); stepList.Remove(Cards[indices[i]]); Cards.RemoveAt(indices[i]); } ClearSelectedSteps(); OnSelectionChanged(); // Fix indices for (var i = 0; i < Cards.Count; i++) { Cards[i].Index = i; } UpdateNoStepDialogVisibility(TabRanges); }
private void ClearSelectedSteps() { SelectedStepIndices.Clear(); SelectedSteps.Clear(); }
private void RemoveSelectedStep(int index) { SelectedStepIndices.Remove(index); SelectedSteps.Remove(Cards[index].StepRange); }
// Helper functions to avoid unwanted bugs private void AddSelectedStep(int index) { SelectedStepIndices.Add(index); SelectedSteps.Add(Cards[index].StepRange); }