} //OnMouseDown #endregion #region OnMouseUp /// <summary> /// Raises the MouseUp event. /// </summary> /// <param name="e">Event Args</param> protected override void OnMouseUp(MouseEventArgs e) { base.OnMouseUp(e); if (e.Button != MouseButtons.Left) { return; } //Notify the playhead is changed on mouse released if (mouseSelection.Action == TimelineMouseAction.movePlayhead) { OnPlayheadChanged(new TimelinePlayheadChangedEventArgs(PlayHeadTime)); } //Clear mouseSelection mouseSelection = TimelineMouseSelection.NoSelection; //Console.WriteLine("Mouse Up!"); }
public Timeline() { InitializeComponent(); //Make the component use a doublebuffer, which will reduce flicker made by //redrawing the control SetStyle(ControlStyles.OptimizedDoubleBuffer, true); SetStyle(ControlStyles.UserPaint, true); SetStyle(ControlStyles.AllPaintingInWmPaint, true); SetStyle(ControlStyles.DoubleBuffer, true); ResizeRedraw = true; //Redraw the component everytime the form gets resized //Set timewidth to default TimeWidth = DefaultTimeWidth; //Set scrollbar to the beginning ScrollBar.Value = 0; DrawLocationLabels = true; //Set leftboundTime SetBoundTimes(0); //Create the list of timestamps playheadBarTimes = new List <Timestamp>(); //Set the timestamps SetPlayheadBarTimes(); //Set the zoom level zoomLevel = Zoom.DefaultLevel; //Set the mouseSelection to no selection mouseSelection = TimelineMouseSelection.NoSelection; Redraw(); SetScrollBarValues(); }
/// <summary> /// Raises the MouseDown event. /// </summary> /// <param name="e">Event Args</param> protected override void OnMouseDown(MouseEventArgs e) { base.OnMouseDown(e); if (e.Button != MouseButtons.Left) { return; } double mouseClickTime = XCoordinateToTime(e.X); RectangleF playheadBarRect = new RectangleF(XCaptionOrigin, 0, Width - LocationLabels.PixelWidth, PlayheadBarHeight); if (playheadBarRect.Contains(e.Location)) { //Set Action mouseSelection = new TimelineMouseSelection(TimelineMouseAction.movePlayhead); //Set playhead time based on click location //PlayHeadTime = mouseClickTime; //Invoke PlayheadChanged event //OnPlayheadChanged(new TimelinePlayheadChangedEventArgs(PlayHeadTime)); Redraw(); //redraw the playhead } else { foreach (Caption c in CaptionList) { //If the mouse click is not in the same Y location as c, then none of the following code //needs to be applied if (YCoordinateToScreenLocation(e.Y) != c.Location) { continue; } double beginX = TimeToXCoordinate(c.Begin); //X-Coord of c.Begin //If selecting the beginning of a caption if (e.X - CaptionSelectionPixelWidth <= beginX && beginX <= e.X + CaptionSelectionPixelWidth) { mouseSelection = new TimelineMouseSelection(TimelineMouseAction.changeCaptionBegin, c); break; } double endX = TimeToXCoordinate(c.End); //X-Coord of c.End //If selecting the end of the Caption if (e.X - CaptionSelectionPixelWidth <= endX && endX <= e.X + CaptionSelectionPixelWidth) { mouseSelection = new TimelineMouseSelection(TimelineMouseAction.changeCaptionEnd, c); break; } //If selecting the center of the caption if (beginX <= e.X && e.X <= endX) { mouseSelection = new TimelineMouseSelection(TimelineMouseAction.moveCaption, c, mouseClickTime - c.Begin); break; } } //foreach } //else //Console.WriteLine("Mouse Down!"); } //OnMouseDown