private void MenuItemDeleteClick(object sender, RoutedEventArgs e) { if (AnnoTierStatic.Selected.IsDiscreteOrFree) { if (annoDataGrid.SelectedItems.Count > 0) { AnnoListItem[] selected = new AnnoListItem[annoDataGrid.SelectedItems.Count]; annoDataGrid.SelectedItems.CopyTo(selected, 0); annoDataGrid.SelectedIndex = -1; AnnoTier track = AnnoTierStatic.Selected; foreach (AnnoListItem s in selected) { AnnoTierSegment segment = track.GetSegment(s); if (segment != null) { track.RemoveSegment(segment); } } } } else if (AnnoTierStatic.Selected.IsContinuous) { AnnoListItem[] selected = new AnnoListItem[annoDataGrid.SelectedItems.Count]; annoDataGrid.SelectedItems.CopyTo(selected, 0); annoDataGrid.SelectedIndex = -1; foreach (AnnoListItem s in selected) { s.Score = double.NaN; } AnnoTier.Selected.TimeRangeChanged(MainHandler.Time); } }
private void changeAnnoTierSegmentHandler(AnnoTierSegment segment, EventArgs e) { if (IsPlaying()) { Stop(); Play(); } foreach (AnnoListItem item in control.annoListControl.annoDataGrid.Items) { if (segment.Item.Start == item.Start) { control.annoListControl.annoDataGrid.SelectedItem = item; control.annoListControl.annoDataGrid.ScrollIntoView(control.annoListControl.annoDataGrid.SelectedItem); break; } } }
public void Redo(int level) { for (int i = 1; i <= level; i++) { if (_RedoActionsCollection.Count == 0) { return; } ChangeRepresentationObject Undostruct = _RedoActionsCollection.Pop(); if (Undostruct.Action == ActionType.Delete) { ((AnnoTier)Container).DeleteSegment((AnnoTierSegment)Undostruct.UiElement); ChangeRepresentationObject ChangeRepresentationObjectForDelete = this.MakeChangeRepresentationObjectForDelete(Undostruct.UiElement); _UndoActionsCollection.Push(ChangeRepresentationObjectForDelete); } else if (Undostruct.Action == ActionType.Insert) { AnnoListItem ali = ((AnnoTierSegment)Undostruct.UiElement).Item; ((AnnoTier)Container).AnnoList.AddSorted(ali); AnnoTierSegment at = ((AnnoTier)Container).AddSegment(ali); ChangeRepresentationObject ChangeRepresentationObjectForInsert = this.MakeChangeRepresentationObjectForInsert(at); _UndoActionsCollection.Push(ChangeRepresentationObjectForInsert); } else if (Undostruct.Action == ActionType.Resize) { Canvas.SetLeft(Undostruct.UiElement, Undostruct.Margin.X); Undostruct.UiElement.Width = Undostruct.Width; Undostruct.Start = ((AnnoTierSegment)Undostruct.UiElement).Item.Start; Undostruct.Stop = ((AnnoTierSegment)Undostruct.UiElement).Item.Stop; Undostruct.Duration = ((AnnoTierSegment)Undostruct.UiElement).Item.Duration; ChangeRepresentationObject ChangeRepresentationObjectForResize = this.MakeChangeRepresentationObjectForResize(Undostruct.Margin.X, Undostruct.UiElement); _UndoActionsCollection.Push(ChangeRepresentationObjectForResize); } else if (Undostruct.Action == ActionType.Move) { Canvas.SetLeft(Undostruct.UiElement, Undostruct.Margin.X); Undostruct.UiElement.Width = Undostruct.Width; Undostruct.Start = ((AnnoTierSegment)Undostruct.UiElement).Item.Start; Undostruct.Stop = ((AnnoTierSegment)Undostruct.UiElement).Item.Stop; Undostruct.Duration = ((AnnoTierSegment)Undostruct.UiElement).Item.Duration; ChangeRepresentationObject ChangeRepresentationObjectForMove = this.MakeChangeRepresentationObjectForMove(Undostruct.Margin.X, Undostruct.UiElement); _UndoActionsCollection.Push(ChangeRepresentationObjectForMove); } else if (Undostruct.Action == ActionType.Split) { //resize element Canvas.SetLeft(Undostruct.UiElement, Undostruct.Margin.X); Undostruct.UiElement.Width = Undostruct.Width; Undostruct.Start = ((AnnoTierSegment)Undostruct.UiElement).Item.Start; Undostruct.Stop = ((AnnoTierSegment)Undostruct.UiElement).Item.Stop; Undostruct.Duration = Undostruct.Stop - Undostruct.Start; //delete added element AnnoListItem ali = ((AnnoTierSegment)Undostruct.NextUiElement).Item; ((AnnoTier)Container).AnnoList.AddSorted(ali); AnnoTierSegment at = ((AnnoTier)Container).AddSegment(ali); ChangeRepresentationObject ChangeRepresentationObjectForSplit = this.MakeChangeRepresentationObjectForSplit(Undostruct.Margin.X, Undostruct.UiElement, at); _UndoActionsCollection.Push(ChangeRepresentationObjectForSplit); } } if (EnableDisableUndoRedoFeature != null) { EnableDisableUndoRedoFeature(null, null); } }