Example #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();
        }