private void PerformDuplicateShape(object obj) { if (SelectedElements.Count == 0) { return; } var duplicates = new List <ShapeViewModel>(); foreach (var shape in SelectedElements) { var duplicateModel = new UMLShape(shape.Shape.X, shape.Shape.Y, shape.Shape.Height, shape.Shape.Width, shape.Shape.Type); var duplicate = new ShapeViewModel(duplicateModel); if (duplicate.Type == EShape.Initial) { return; } duplicates.Add(duplicate); } foreach (var shape in duplicates) { Shapes.Add(shape); } IUndoRedoCommand cmd = new DuplicateCommand(duplicates, this); _undoRedo.InsertInUndoRedo(cmd); }
public void Should_Duplicate_FoldersAndChildItems() { var jobScheduler = Substitute.For <IJobScheduler>(); var settingsStore = Substitute.For <ISettingsStore>(); var rootItem = new RootItem(); var folder = new Folder(); var item1 = new Item(); var item2 = new Item(); rootItem.Add(folder); folder.Add(item1); folder.Add(item2); var command = new DuplicateCommand(folder); var handler = new DuplicateCommandHandler(jobScheduler, settingsStore); handler.Handle(command); Assert.IsTrue(rootItem.Items.Count == 2); var newFolder = rootItem.Items[1]; Assert.IsTrue(newFolder.Items.Count == 2); Assert.AreSame(newFolder, newFolder.Items[0].Parent); Assert.AreSame(newFolder, newFolder.Items[1].Parent); jobScheduler.Received(1).Schedule(newFolder, true); settingsStore.Received(1).TrySave(); }
void RefreshCommands() { MasterNewCommand.RaiseCanExecuteChanged(); DuplicateCommand.RaiseCanExecuteChanged(); MasterDeleteCommand.RaiseCanExecuteChanged(); MasterSearchCommand.RaiseCanExecuteChanged(); }
public void Should_Duplicate_Schedule_And_Save() { var jobScheduler = Substitute.For <IJobScheduler>(); var settingsStore = Substitute.For <ISettingsStore>(); var item = Substitute.For <Item>(); var clone = new Item(); var command = new DuplicateCommand(item); var handler = new DuplicateCommandHandler(jobScheduler, settingsStore); item.Duplicate().Returns(clone); handler.Handle(command); item.Received().Duplicate(); jobScheduler.Received().Schedule(clone, true); settingsStore.Received().TrySave(); }