Exemplo n.º 1
0
        /// <summary>
        /// Handles mouse move events while in the "Moving" state.
        /// </summary>
        /// <param name="location">Mouse location on the grid.</param>
        private void MouseMove_DragMoving(Point location)
        {
            // if we don't have anything selected, there's no point dragging anything...
            if (!_marksSelectionManager.SelectedMarks.Any() || _mouseDownMark == null)
            {
                return;
            }

            TimeSpan dt = pixelsToTime(location.X - _moveResizeStartLocation.X);

            // If we didn't move, get outta here.
            if (dt == TimeSpan.Zero)
            {
                return;
            }


            // Calculate what our actual dt value will be.
            TimeSpan earliest = _marksMoveResizeInfo.OriginalMarks.Values.Min(x => x.StartTime);

            if ((earliest + dt) < TimeSpan.Zero)
            {
                dt = -earliest;
            }

            TimeSpan latest = _marksMoveResizeInfo.OriginalMarks.Values.Max(x => x.EndTime);

            if ((latest + dt) > TimeInfo.TotalTime)
            {
                dt = TimeInfo.TotalTime - latest;
            }

            foreach (var markTimeInfo in _marksMoveResizeInfo.OriginalMarks)
            {
                markTimeInfo.Key.StartTime = markTimeInfo.Value.StartTime + dt;
            }

            _timeLineGlobalEventManager.OnMarksMoving(new MarksMovingEventArgs(_marksSelectionManager.SelectedMarks.ToList()));
            _timeLineGlobalEventManager.OnAlignmentActivity(new AlignmentEventArgs(true, new[] { _mouseDownMark.StartTime, _mouseDownMark.EndTime }));

            //Invalidate();
        }
Exemplo n.º 2
0
		protected override void OnMouseMove(MouseEventArgs e)
		{
			base.OnMouseMove(e);

			if (m_button == System.Windows.Forms.MouseButtons.Left)
			{
				switch (m_mouseState)
				{
					case MouseState.Normal:
						return;

					case MouseState.DragWait:
						// Move enough to be considered a drag?
						if (Math.Abs(e.X - m_mouseDownX) <= maxDxForClick)
							return;
						m_mouseState = MouseState.Dragging;
						OnBeginDragTimeRange();
						PlaybackStartTime = pixelsToTime(e.X) + VisibleTimeStart;
						PlaybackEndTime = null;
						goto case MouseState.Dragging;

					case MouseState.Dragging:
						int start, end;
						if (e.X > m_mouseDownX)
						{
							// Start @ mouse down, end @ mouse current
							start = m_mouseDownX;
							end = e.X;
						}
						else
						{
							// Start @ mouse current, end @ mouse down
							start = e.X;
							end = m_mouseDownX;
						}

						PlaybackStartTime = pixelsToTime(start) + VisibleTimeStart;
						PlaybackEndTime = pixelsToTime(end) + VisibleTimeStart;
						return;
					case MouseState.DraggingMark:

						var newTime = pixelsToTime(e.X) + VisibleTimeStart;
						var diff = newTime - _dragLastTime;
						_marksSelectionManager.SelectedMarks.ToList().ForEach(x => x.StartTime += diff);
						_dragLastTime = newTime;
						if (Convert.ToInt16(newTime.Minutes) >= 10)
						{
							markTime = string.Format("{0:mm\\:ss\\.fff}", newTime);
						}
						else if (Convert.ToInt16(newTime.Minutes) >= 1)
						{
							markTime = string.Format("{0:m\\:ss\\.fff}", newTime);
						}
						else if (Convert.ToInt16(newTime.Seconds) >= 10)
						{
							markTime = string.Format("{0:ss\\.fff}", newTime);
						}
						else if (Convert.ToInt16(newTime.Seconds) <= 9)
						{
							markTime = string.Format("{0:s\\.fff}", newTime);
						}

						_timeLineGlobalEventManager.OnMarksMoving(new MarksMovingEventArgs(_marksSelectionManager.SelectedMarks.ToList()));
						_timeLineGlobalEventManager.OnAlignmentActivity(new AlignmentEventArgs(true, new[] { _mouseDownMark.StartTime, _mouseDownMark.EndTime }));

						break;
					case MouseState.ResizeRuler:
						//Adjusts Ruler Height
						if (e.Location.Y > 40)
							Height = e.Location.Y + 1;
						break;
					default:
						throw new Exception("Invalid MouseState. WTF?!");
				}
			}
			else
			{
				// We'll get to this point if there is no mouse button selected
				var marks = MarksAt(pixelsToTime(e.X) + VisibleTimeStart);
				if (marks.Any())
				{
					Cursor = Cursors.VSplit;
					_timeLineGlobalEventManager.OnAlignmentActivity(new AlignmentEventArgs(true, new[] { marks.First().StartTime}));
				}
				else if (e.Location.Y <= Height - 1 && e.Location.Y >= Height - 6)
				{
					Cursor = Cursors.HSplit;
				}
				else
				{
					Cursor = Cursors.Hand;
					_timeLineGlobalEventManager.OnAlignmentActivity(new AlignmentEventArgs(false, null));
				}
			}
		}