public void UngroupSelectedBlocks() { using (ActionManager.CreateTransaction()) { foreach (var groupVM in SelectedBlocks.OfType <GroupBlockViewModel>().ToArray()) { SelectedBlocks.Remove(groupVM); GroupBlock group = (GroupBlock)groupVM.GetModel(); ActionManager.RecordRemove(model.Blocks, group); foreach (Block b in group.Children.ToArray()) { // create an independent copy of the block so transforming its time back to global reference frame does not screw up undo Block independentBlock = Block.FromXML(model, b.ToXML()); independentBlock.StartTime += group.StartTime; ActionManager.RecordRemove(group.Children, b); ActionManager.RecordAdd(model.Blocks, independentBlock); SelectBlock(BlockViewModel.FromModel(this, independentBlock), CompositionMode.Additive); } } } }
// ===== Commands ===== public void SelectBlock(BlockViewModel block, CompositionMode compositionMode) { Debug.WriteLine("single select (mode: {0}, block: {1})", compositionMode, block); switch (compositionMode) { case CompositionMode.None: SelectedBlocks.Clear(); if (block != null && !SelectedBlocks.Contains(block)) { SelectedBlocks.Add(block); } break; case CompositionMode.Additive: if (block != null && !SelectedBlocks.Contains(block)) { SelectedBlocks.Add(block); } break; case CompositionMode.Subtractive: if (block != null) { SelectedBlocks.Remove(block); } break; } }
private void RemoveDrop(object sender, DragEventArgs e) { var source = (Block)e.Data.GetData(typeof(Block)); if (source.Count != 0) { SelectedBlocks.Remove(source); UpdateString(); } }
private void RemoveButton_Click(object sender, RoutedEventArgs e) { var selected = new object[selectedBlockList.SelectedItems.Count]; selectedBlockList.SelectedItems.CopyTo(selected, 0); foreach (var block in selected) { SelectedBlocks.Remove((Block)block); } selectedBlockList.UnselectAll(); UpdateString(); }
private void SelectUnselectedBlock(TimetableBlock block) { var timetableBlock = Timetable.Blocks.SingleOrDefault(b => b.StartDate == block.StartDate); if (CheckSelection(block)) { SelectedBlocks.Remove(block); timetableBlock.WorkItem = null; } else { SelectedBlocks.Add(block); } }
private void RemoveSelected(object sender, KeyEventArgs e) { if (e.Key != Key.Delete) { return; } var selected = new object[selectedBlockList.SelectedItems.Count]; selectedBlockList.SelectedItems.CopyTo(selected, 0); foreach (var block in selected) { SelectedBlocks.Remove((Block)block); } selectedBlockList.UnselectAll(); UpdateString(); }