private void importedVideoLabel_MouseDown(object sender, MouseButtonEventArgs e) { //Add the video at 0 zero seconds on the timeline. //TODO: Make the user drag it to the spot in the timeline they want. Label clickedLabel = (Label)sender; //Open the video file so we can get its length VideoFrameReader reader = importedVideos[(string)clickedLabel.Content]; double length = reader.Duration.TotalSeconds; //Create a timeline entry for it TimelineEntry newEntry = new TimelineEntry((string)clickedLabel.Content, 0, length, null); //Add it to the timeline timelineView.GetLayer(0).AddEntry(newEntry); }
/// <summary> /// Adds an entry to the timeline /// </summary> /// <param name="timelineEntry"></param> public void AddEntry(TimelineEntry timelineEntry) { timelineEntries.Add(timelineEntry); //Create a control for this entry TimelineEntryControl entryControl = new TimelineEntryControl(timelineEntry, this); entryControls.Add(timelineEntry, entryControl); entriesCanvas.Children.Add(entryControl); //Position the control entryControl.UpdateInterface(); //Subscribe to the control's events entryControl.UserResized += EntryControl_UserResized; }
/// <summary> /// Removes an entry from the timeline /// </summary> /// <param name="timelineEntry"></param> public void RemoveEntry(TimelineEntry timelineEntry) { //Don't go on if that entry doesn't exist if (!timelineEntries.Contains(timelineEntry)) { return; } //Remove timeline entry timelineEntries.Remove(timelineEntry); //Remove its control TimelineEntryControl entryControl = entryControls[timelineEntry]; entryControls.Remove(timelineEntry); entriesCanvas.Children.Remove(entryControl); //Unsubscribe from events entryControl.UserResized -= EntryControl_UserResized; }
public TimelineEntryControl(TimelineEntry timelineEntry, TimelineLayerView parentLayerView) { this.timelineEntry = timelineEntry; this.parentLayerView = parentLayerView; InitializeComponent(); //Initialize the drag monitors leftHandleDragMonitor = new MouseDragMonitor(leftHandle, MouseButton.Left); leftHandleDragMonitor.DragMoved += LeftHandleDragMonitor_DragMoved; leftHandleDragMonitor.DragReleased += LeftHandleDragMonitor_DragReleased; rightHandleDragMonitor = new MouseDragMonitor(rightHandle, MouseButton.Left); rightHandleDragMonitor.DragMoved += RightHandleDragMonitor_DragMoved; rightHandleDragMonitor.DragReleased += RightHandleDragMonitor_DragReleased; moveDragMonitor = new MouseDragMonitor(visibleRectangle, MouseButton.Left); moveDragMonitor.DragMoved += MoveDragMonitor_DragMoved; moveDragMonitor.DragReleased += MoveDragMonitor_DragReleased; }