/// <summary> /// Adds a blank item after the current point in the time line. /// </summary> /// <param name="timeLineItemViewModel"></param> public void AddTimeLineItem(TimeLineItemViewModel timeLineItemViewModel) { TimeLineItems.Insert(TimeLineItems.IndexOf(SelectedTimeLineItem) + 1, timeLineItemViewModel); SelectedTimeLineItem = timeLineItemViewModel; NotifyOfPropertyChange(() => CanRemoveItem); NotifyOfPropertyChange(() => TimeLineItems); }
/// <summary> /// Removes the time line item at the end or after the current selection. /// </summary> public void RemoveTimeLineItem() { if (CanRemoveItem) { int index = TimeLineItems.IndexOf(SelectedTimeLineItem); TimeLineItemViewModel toRemove = SelectedTimeLineItem; // If not last item, select next, otherwise select last SelectedTimeLineItem = SelectedTimeLineItem != TimeLineItems.Last() ? TimeLineItems[index + 1] : TimeLineItems[TimeLineItems.Count() - 2]; TimeLineItems.Remove(toRemove); NotifyOfPropertyChange(() => CanRemoveItem); NotifyOfPropertyChange(() => TimeLineItems); } }
/// <summary> /// Removes the time line item at the end or after the current selection. /// </summary> public void RemoveTimeLineItem() { if (CanRemoveItem) { int index = TimeLineItems.IndexOf(SelectedTimeLineItem); TimeLineItems.Remove(SelectedTimeLineItem); if (index != TimeLineItems.Count) { SelectedTimeLineItem = TimeLineItems[index]; } else { SelectedTimeLineItem = TimeLineItems.Last(); } NotifyOfPropertyChange(() => CanRemoveItem); NotifyOfPropertyChange(() => TimeLineItems); } }