Ejemplo n.º 1
0
        /// <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);
        }
Ejemplo n.º 2
0
        /// <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();
        }
Ejemplo n.º 3
0
        /// <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();
        }
Ejemplo n.º 4
0
 public void GotoSlide(SongPartReference part, int slide)
 {
     control.ExecuteJavascript("presentation.gotoSlide("+part.OrderIndex+", "+slide+")");
 }
Ejemplo n.º 5
0
		/// <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();
		}
Ejemplo n.º 6
0
		/// <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();
		}
Ejemplo n.º 7
0
		/// <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;
		}
Ejemplo n.º 8
0
        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);
        }