Example #1
0
        public override void MoveFrame(System.Windows.Forms.MouseEventArgs e, TimeRuler ruler)
        {
            int  iMousePosition  = ((ruler.Orientation == enumOrientation.orHorizontal) ? e.X : e.Y);
            long lNewMillisecond = (long)ruler.PixelToScaleValue(iMousePosition);

            if (lNewMillisecond > ruler.CurrentMillisecond)
            {
                int iStartDist = DistanceFromHandle(e, ruler, _StartMillisecond);
                int iEndDist   = DistanceFromHandle(e, ruler, _EndMillisecond);

                if (iStartDist < iEndDist)
                {
                    if (_StartMillisecond > ruler.CurrentMillisecond &&
                        !ruler.KeyFrames.Overlaps(lNewMillisecond, this._EndMillisecond, this))
                    {
                        _StartMillisecond = lNewMillisecond;
                    }
                }
                else
                {
                    if (_EndMillisecond > ruler.CurrentMillisecond &&
                        !ruler.KeyFrames.Overlaps(this._StartMillisecond, lNewMillisecond, this))
                    {
                        _EndMillisecond = lNewMillisecond;
                    }
                }

                ruler.RedrawBitmap();
            }
        }
Example #2
0
        public virtual void MoveFrame(long lStart, long lEnd, TimeRuler ruler)
        {
            if (lStart > ruler.ActualMillisecond &&
                _StartMillisecond > ruler.ActualMillisecond &&
                !ruler.KeyFrames.Overlaps(lStart, lStart, this))
            {
                _StartMillisecond = lStart;
                _EndMillisecond   = _StartMillisecond;

                ruler.RedrawBitmap();
            }
        }
Example #3
0
        public override void MoveFrame(System.Windows.Forms.MouseEventArgs e, TimeRuler ruler)
        {
            int  iMousePosition  = ((ruler.Orientation == enumOrientation.orHorizontal) ? e.X : e.Y);
            long lNewMillisecond = (long)ruler.PixelToScaleValue(iMousePosition);

            if (lNewMillisecond < ruler.ActualMillisecond)
            {
                _StartMillisecond = lNewMillisecond;
                _EndMillisecond   = _StartMillisecond;

                ruler.RedrawBitmap();
            }
        }
Example #4
0
        public override void MoveFrame(long lStart, long lEnd, TimeRuler ruler)
        {
            if (lStart > ruler.CurrentMillisecond && lEnd > ruler.CurrentMillisecond)
            {
                if (_StartMillisecond > ruler.CurrentMillisecond &&
                    !ruler.KeyFrames.Overlaps(lStart, this._EndMillisecond, this))
                {
                    _StartMillisecond = lStart;
                }

                if (_EndMillisecond > ruler.CurrentMillisecond &&
                    !ruler.KeyFrames.Overlaps(this._StartMillisecond, lEnd, this))
                {
                    _EndMillisecond = lEnd;
                }

                ruler.RedrawBitmap();
            }
        }
Example #5
0
        public override void EndMove(System.Windows.Forms.MouseEventArgs e, TimeRuler ruler)
        {
            int  iMousePosition  = ((ruler.Orientation == enumOrientation.orHorizontal) ? e.X : e.Y);
            long lNewMillisecond = (long)ruler.PixelToScaleValue(iMousePosition);

            KeyFrame keyClosest = ruler.KeyFrames.FindClosest(KeyFrame.enumKeyFrameType.Snapshot, lNewMillisecond, true);

            //If we can not find a single frame close to the current end position that is within the current time zone then move
            //it back to the currenttime. Otherwise move it to the closest key frame.
            if (keyClosest != null)
            {
                SetTimes(keyClosest.StartMillisecond);
                ruler.CurrentMillisecond = keyClosest.StartMillisecond;
                ruler.OnCurrentFrameMoved(keyClosest);
            }
            else
            {
                SetTimes(ruler.ActualMillisecond);
                ruler.CurrentMillisecond = ruler.ActualMillisecond;
                ruler.OnCurrentFrameMoved(null);
            }

            ruler.RedrawBitmap();
        }
Example #6
0
        public KeyFrame Add(KeyFrame keyFrame, bool bSuspendRedraw)
        {
            if ((keyFrame.StartMillisecond > _Ruler.EndMillisecond) || (keyFrame.EndMillisecond > _Ruler.EndMillisecond))
            {
                throw new System.Exception("You can not add a keyframe with a start/end time greater than the end time of the ruler.");
            }

            if (keyFrame.KeyFrameType == KeyFrame.enumKeyFrameType.Snapshot)
            {
                //First lets verify that there is not already a single frame at this time slice.
                foreach (KeyFrame frame in _arySingleFrames)
                {
                    if (frame.StartMillisecond == keyFrame.StartMillisecond)
                    {
                        return(null);
                    }
                }

                //Now lets make sure that it does not overlap with any of the video frames.
                KeyFrame.enumFrameTimeType iTimeType = KeyFrame.enumFrameTimeType.StartTime;
                foreach (KeyFrame frame in _aryMulitFrames)
                {
                    if (frame.Overlaps(keyFrame, ref iTimeType))
                    {
                        return(null);
                    }
                }

                _arySingleFrames.Add(keyFrame);
            }
            else if (keyFrame.KeyFrameType == KeyFrame.enumKeyFrameType.CurrentFrame)
            {
                if (_CurrentFrame != null)
                {
                    throw new System.Exception("There is alread a current frame defined.");
                }

                _CurrentFrame = keyFrame;
            }
            else
            {
                //First lets verify that there is not already a range frame overlapping this time slice.
                KeyFrame.enumFrameTimeType iTimeType = KeyFrame.enumFrameTimeType.StartTime;
                foreach (KeyFrame frame in _aryMulitFrames)
                {
                    if (frame.Overlaps(keyFrame, ref iTimeType))
                    {
                        //If it overlaps because of the start time then chunk it. If it overlaps because of the end time
                        //then lets see if we can come up with an end time that will work.
                        if (iTimeType == KeyFrame.enumFrameTimeType.StartTime)
                        {
                            return(null);
                        }
                        else
                        {
                            keyFrame.EndMillisecond = frame.StartMillisecond - 1;
                        }
                    }
                }

                //Now lets verify that there is not a single frame overlapping this video range.
                foreach (KeyFrame frame in _arySingleFrames)
                {
                    if (keyFrame.Overlaps(frame, ref iTimeType))
                    {
                        //Lets find whether the start or end point is closest and then then
                        //add the frame so it does not overlap.
                        if (Math.Abs(frame.StartMillisecond - keyFrame.StartMillisecond) < Math.Abs(frame.StartMillisecond - keyFrame.EndMillisecond))
                        {
                            //Start millisecond is closer to the single.
                            keyFrame.StartMillisecond = frame.StartMillisecond + 1;
                        }
                        else
                        {
                            //End millisecond is closer to the single.
                            keyFrame.EndMillisecond = frame.StartMillisecond - 1;
                        }
                    }
                }

                _aryMulitFrames.Add(keyFrame);
            }

            base.List.Add(keyFrame as object);

            if (!bSuspendRedraw)
            {
                _Ruler.RedrawBitmap();
            }

            return(keyFrame);
        }