/// <summary> /// Adds a part to the part order (can be undone). /// </summary> /// <param name="part">The part to add.</param> /// <param name="index">The index where to insert it in the order. If omitted, append at the end.</param> /// <returns>A reference to the part in the order.</returns> public SongPartReference AddPartToOrder(SongPart part, int index = -1) { if (Parts.IndexOf(part) < 0) { throw new ArgumentException("part has not been added to this song"); } SongPartReference reference = null; Action redo = () => { if (index < 0) { index = Order.Count; } reference = new SongPartReference(part); order.Insert(index, reference); }; Action undo = () => { order.RemoveAt(index); }; Undo.ChangeFactory.OnChanging(this, undo, redo, "AddPartToOrder"); redo(); return(reference); }
/// <summary> /// Removes a part from the order (can be undone). /// </summary> /// <param name="reference">The part to remove, identified by a <see cref="SongPartReference"/>.</param> public void RemovePartFromOrder(SongPartReference reference) { int index = Order.IndexOf(reference); Action redo = () => { order.RemoveAt(index); //OnNotifyPropertyChanged("PartOrder"); }; Action undo = () => { order.Insert(index, reference); //OnNotifyPropertyChanged("PartOrder"); }; Undo.ChangeFactory.OnChanging(this, undo, redo, "RemovePartFromOrder"); redo(); }
/// <summary> /// Moves a part in the order (can be undone). /// </summary> /// <param name="reference">The reference in the order to the part to move.</param> /// <param name="target">The target index.</param> public void MovePartInOrder(SongPartReference reference, int target) { if (target >= Order.Count) { target = Order.Count - 1; } int index = Order.IndexOf(reference); Action redo = () => { order.RemoveAt(index); order.Insert(target, reference); }; Action undo = () => { order.RemoveAt(target); order.Insert(index, reference); }; Undo.ChangeFactory.OnChanging(this, undo, redo, "MovePartInOrder"); redo(); }
public void GotoSlide(SongPartReference part, int slide) { control.ExecuteJavascript("presentation.gotoSlide("+part.OrderIndex+", "+slide+")"); }
/// <summary> /// Moves a part in the order (can be undone). /// </summary> /// <param name="reference">The reference in the order to the part to move.</param> /// <param name="target">The target index.</param> public void MovePartInOrder(SongPartReference reference, int target) { if (target >= Order.Count) target = Order.Count - 1; int index = Order.IndexOf(reference); Action redo = () => { order.RemoveAt(index); order.Insert(target, reference); }; Action undo = () => { order.RemoveAt(target); order.Insert(index, reference); }; Undo.ChangeFactory.OnChanging(this, undo, redo, "MovePartInOrder"); redo(); }
/// <summary> /// Adds a part to the part order (can be undone). /// </summary> /// <param name="part">The part to add.</param> /// <param name="index">The index where to insert it in the order. If omitted, append at the end.</param> /// <returns>A reference to the part in the order.</returns> public SongPartReference AddPartToOrder(SongPart part, int index = -1) { if (Parts.IndexOf(part) < 0) throw new ArgumentException("part has not been added to this song"); SongPartReference reference = null; Action redo = () => { if (index < 0) index = Order.Count; reference = new SongPartReference(part); order.Insert(index, reference); }; Action undo = () => { order.RemoveAt(index); }; Undo.ChangeFactory.OnChanging(this, undo, redo, "AddPartToOrder"); redo(); return reference; }
public void PartReferenceNotify() { var partRef = new SongPartReference(part); bool notified = false; partRef.Part.PropertyChanged += (sender, args) => { notified = true; }; Assert.False(notified); part.Name = "NewPartName"; Assert.Equal(new SongPartReference(song, "NewPartName").Part, partRef.Part); Assert.True(notified); notified = false; Assert.Equal(1, UndoStackSize); Undo(); Assert.True(notified); notified = false; Redo(); Assert.True(notified); Assert.Equal(new SongPartReference(song, "NewPartName").Part, partRef.Part); }