public void ShouldCallRemoveElementOnTimelineModelWhenUnExecute() { var track = new Track { TrackType = TrackType.Visual }; this.timelineModel.Tracks.Add(track); var position = TimeCode.FromAbsoluteTime(10, SmpteFrameRate.Smpte30); var element = new TimelineElement { Position = position, Asset = new VideoAsset { Duration = TimeCode.FromAbsoluteTime(30, SmpteFrameRate.Smpte30), FrameRate = SmpteFrameRate.Smpte30, Title = "Test Video #1" } }; var command = new AddElementCommand(this.timelineModel, track, element); command.Execute(); var addedElement = this.timelineModel.AddElementArgument; Assert.IsFalse(this.timelineModel.RemoveElementCalled); command.UnExecute(); Assert.IsTrue(this.timelineModel.RemoveElementCalled); Assert.AreEqual(addedElement, this.timelineModel.RemoveElementArgument); }
public void ShouldCallAddElementOnTimelineModelWhenAssetIsAudioAsset() { var track = new Track { TrackType = TrackType.Audio }; this.timelineModel.Tracks.Add(track); var position = TimeCode.FromAbsoluteTime(5, SmpteFrameRate.Smpte30); var element = new TimelineElement { Position = position, Asset = new AudioAsset { Duration = 2, Title = "Test Audio #1" } }; var command = new AddElementCommand(this.timelineModel, track, element); Assert.IsFalse(this.timelineModel.AddElementCalled); command.Execute(); Assert.IsTrue(this.timelineModel.AddElementCalled); Assert.AreEqual(element, this.timelineModel.AddElementArgument); }
public void ShouldCallAddElementOnTimelineModelWhenAssetIsImageAsset() { var track = new Track { TrackType = TrackType.Visual }; this.sequenceModel.Tracks.Add(track); var position = TimeCode.FromAbsoluteTime(20, SmpteFrameRate.Smpte30); var element = new TimelineElement { Position = position, Asset = new ImageAsset { Title = "Test Image #1" } }; var command = new AddElementCommand(this.sequenceModel, track, element); Assert.IsFalse(this.sequenceModel.AddElementCalled); command.Execute(); Assert.IsTrue(this.sequenceModel.AddElementCalled); Assert.AreEqual(element, this.sequenceModel.AddElementArgument); }
private void AddElementExecute([NotNull] object newObject) { if (newObject == null) { throw new Exception("Element to add can't be null"); } if (newObject is Element element) { AddElementCommand addElementCommand = new AddElementCommand(element, this); addElementCommand.Execute(); MyCommandManager.AddToList(addElementCommand); if (element is PortModel) { RenumberPorts(Elements); } } }
/// <summary> /// Initializes a new instance of the <see cref="MainWindow"/> class. /// </summary> public MainWindow() { this.InitializeComponent(); this.ObservableElements = new ObservableCollection <Element>(); this.FixedElements = new List <Element> { new Element { Position = new Point3D(0, 0, 0), Material = Materials.Red, Radius = 1 }, new Element { Position = new Point3D(-0.757, 0.586, 0), Material = Materials.White, Radius = 0.6 }, new Element { Position = new Point3D(0.757, 0.586, 0), Material = Materials.White, Radius = 0.6 } }; this.FixedElementsPositonsBinding = new List <Element> { new Element { Positions = new Point3DCollection { new Point3D(-1, 1, 1.85), new Point3D(-1, -1, 1.85), new Point3D(1, -1, 1.85), new Point3D(1, 1, 1.85) } }, }; this.DataContext = this; this.AddElementCommand = new DelegateCommand(() => { if (this.ObservableElements.Count % 3 == 1) { var modelBuilder = new MeshBuilder(); modelBuilder.AddCylinder(new Point3D(0, 0, 0), new Point3D(0, 1, 0), 0.75, 15); ModelElement model = new ModelElement1(); if (this.ObservableElements.Count % 2 == 0) { model = new ModelElement2(); } model.IsVisible = true; model.Model = new GeometryModel3D { Material = new DiffuseMaterial(System.Windows.Media.Brushes.Orange), BackMaterial = new DiffuseMaterial(System.Windows.Media.Brushes.Orange), Geometry = modelBuilder.ToMesh() }; model.Position = new Point3D(0, -3, this.ObservableElements.Count); this.ObservableElements.Add(model); } else if (this.ObservableElements.Count % 2 == 0) { this.ObservableElements.Add(new SphereElement { Position = new Point3D(-2, -3, this.ObservableElements.Count), Material = Materials.Green, Radius = 0.4 }); } else { this.ObservableElements.Add(new CubeElement { Position = new Point3D(2, -3, this.ObservableElements.Count) }); } }); this.DeleteElementCommand = new DelegateCommand(() => { this.ObservableElements.RemoveAt(this.ObservableElements.Count - 1); }, () => this.ObservableElements.Count > 0); this.AddElementsCommand = new DelegateCommand(() => { for (int a = 0; a < 250; a++) { AddElementCommand.Execute(null); } }); this.AddUIElementCommand = new DelegateCommand(() => { ModelElement model = new ModelElement3 { IsVisible = true, Color = Colors.Pink }; model.Position = new Point3D(0, -3, this.ObservableElements.Count); this.ObservableElements.Add(model); }); }