Inheritance: System.Windows.Forms.Control, IMessageFilter
        public override void Draw(Graphics g, TimeRuler ruler)
        {
            if (ruler.Orientation == enumOrientation.orHorizontal)
            {
                int iSecondPos = ruler.ScaleValueToPixel((double) _StartMillisecond);
                int x = iSecondPos - 1;
                int y1 = ruler.HeaderOffset/2, y2 = ruler.Height;
                g.DrawLine(new Pen(new SolidBrush(this.Color), 3), x, y1, x, y2);

                Point left = new Point(iSecondPos - y1, 1);
                Point right = new Point(iSecondPos + y1, 1);
                Point bottom = new Point(iSecondPos, ruler.HeaderOffset/2);
                Point[] trianglePoints = {left, right, bottom};
                g.FillPolygon(new SolidBrush(this.Color), trianglePoints, System.Drawing.Drawing2D.FillMode.Winding);

                g.DrawPolygon(new Pen(new SolidBrush(ruler.ForeColor)), trianglePoints);
            }
            else
            {
                int iSecondPos = ruler.ScaleValueToPixel((double) _StartMillisecond);
                int y = iSecondPos - 1;
                int x1 = ruler.HeaderOffset/2, x2 = ruler.Height;
                g.DrawLine(new Pen(new SolidBrush(this.Color), 3), x1, y, x2, y);

                Point left = new Point(1, iSecondPos - x1);
                Point right = new Point(1, iSecondPos + x1);
                Point bottom = new Point(ruler.HeaderOffset/2, iSecondPos);
                Point[] trianglePoints = {left, right, bottom};
                g.FillPolygon(new SolidBrush(this.Color), trianglePoints, System.Drawing.Drawing2D.FillMode.Winding);

                g.DrawPolygon(new Pen(new SolidBrush(ruler.ForeColor)), trianglePoints);
            }
        }
        public KeyFrameCollection(TimeRuler ruler)
        {
            // Must provide a valid manager instance
            if (ruler == null)
                throw new ArgumentNullException("TimeRuler");

            // Default the state
            _Ruler = ruler;
        }
        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();
        }
 public virtual void StartMove(System.Windows.Forms.MouseEventArgs e, TimeRuler ruler)
 {
 }
        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();
            }
        }
        public virtual 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 > ruler.ActualMillisecond &&
                !ruler.KeyFrames.Overlaps(lNewMillisecond, lNewMillisecond, this))
            {
                _StartMillisecond = lNewMillisecond;
                _EndMillisecond = _StartMillisecond;

                ruler.RedrawBitmap();
            }
        }
 public virtual bool IsHandleClick(System.Windows.Forms.MouseEventArgs e, TimeRuler ruler)
 {
     if(IsHandleClick(e, ruler, _StartMillisecond)) return true;
     if(IsHandleClick(e, ruler, _EndMillisecond)) return true;
     return false;
 }
        public virtual bool IsHandleClick(System.Windows.Forms.MouseEventArgs e, TimeRuler ruler, long lMillisecond)
        {
            int y1 = ruler.HeaderOffset/2;
            int y2 = ruler.HeaderOffset;
            int x1 = ruler.ScaleValueToPixel((double) lMillisecond) - (y2/2) - 1;
            int x2 = x1 + y2;
            bool bRetVal = false;

            if (ruler.Orientation == enumOrientation.orHorizontal)
            {
                if( (e.X >= x1) && (e.X <= x2) && (e.Y >= y1) && (e.Y <=y2) )
                    bRetVal = true;
            }
            else
            {
                if( (e.Y >= x1) && (e.Y <= x2) && (e.X >= y1) && (e.X <=y2) )
                    bRetVal = true;
            }

            return bRetVal;
        }
        public virtual void Draw(Graphics g, TimeRuler ruler)
        {
            if (ruler.Orientation == enumOrientation.orHorizontal)
            {
                int x = ruler.ScaleValueToPixel((double) _StartMillisecond) - 1;
                int y1 = ruler.HeaderOffset, y2 = ruler.Height;
                g.DrawLine(_DrawingPen, x, y1, x, y2);

                y1 = ruler.HeaderOffset/2;
                y2 = ruler.HeaderOffset - y1 - 1;
                x = ruler.ScaleValueToPixel((double) _StartMillisecond) - (y2/2) - 1;
                g.DrawEllipse(new Pen(new SolidBrush(ruler.ForeColor)), x, y1, y2, y2);
                g.FillEllipse(_DrawingBrush, x, y1, y2, y2);
            }
            else
            {
                int y = ruler.ScaleValueToPixel((double) _StartMillisecond) - 1;
                int x1 = ruler.HeaderOffset, x2 = ruler.Height;
                g.DrawLine(_DrawingPen, x1, y, x2, y);

                x1 = ruler.HeaderOffset/2;
                x2 = ruler.HeaderOffset - x1 - 1;
                y = ruler.ScaleValueToPixel((double) _StartMillisecond) - (x2/2) - 1;
                g.DrawEllipse(new Pen(new SolidBrush(ruler.ForeColor)), x1, y, x2, x2);
                g.FillEllipse(_DrawingBrush, x1, y, x2, x2);
            }
        }
        public virtual int DistanceFromHandle(System.Windows.Forms.MouseEventArgs e, TimeRuler ruler, long lMillisecond)
        {
            int iMousePosition = ((ruler.Orientation == enumOrientation.orHorizontal) ? e.X : e.Y);
            int x = ruler.ScaleValueToPixel((double) lMillisecond);

            return Math.Abs(x-iMousePosition);
        }
        public virtual bool CanBeMoved(TimeRuler ruler)
        {
            if( (_StartMillisecond <= ruler.ActualMillisecond) || (_EndMillisecond <= ruler.ActualMillisecond) )
                return false;

            return true;
        }
        public override void Draw(Graphics g, TimeRuler ruler)
        {
            if (ruler.Orientation == enumOrientation.orHorizontal)
            {
                int x1 = ruler.ScaleValueToPixel((double) _StartMillisecond) - 1;
                int y1 = ruler.HeaderOffset, y2 = ruler.Height;
                g.DrawLine(_DrawingPen, x1, y1, x1, y2);

                x1 = ruler.ScaleValueToPixel((double) _EndMillisecond) - 1;
                y1 = ruler.HeaderOffset;
                y2 = ruler.Height;
                g.DrawLine(_DrawingPen, x1, y1, x1, y2);

                y1 = ruler.HeaderOffset/2;
                y2 = ruler.HeaderOffset - y1;
                x1 = ruler.ScaleValueToPixel((double) _StartMillisecond) - 2;
                int x2 = ruler.ScaleValueToPixel((double) _EndMillisecond) ;
                x2 = x2 - x1;
                g.DrawRectangle(new Pen(new SolidBrush(ruler.ForeColor)), x1, y1, x2, y2);
                g.FillRectangle(_DrawingBrush, x1, y1, x2, y2);

                y1 = ruler.HeaderOffset/2;
                y2 = ruler.HeaderOffset - y1;
                x1 = ruler.ScaleValueToPixel((double) _StartMillisecond) - (y2/2) - 1;
                g.FillRectangle(new SolidBrush(ruler.ForeColor), x1, y1, y2, y2);

                y1 = ruler.HeaderOffset/2;
                y2 = ruler.HeaderOffset - y1;
                x1 = ruler.ScaleValueToPixel((double) _EndMillisecond) - (y2/2) - 1;
                g.FillRectangle(new SolidBrush(ruler.ForeColor), x1, y1, y2, y2);
            }
            else
            {
                int y1 = ruler.ScaleValueToPixel((double) _StartMillisecond) - 1;
                int x1 = ruler.HeaderOffset, x2 = ruler.Width;
                g.DrawLine(_DrawingPen, x1, y1, x2, y1);

                y1 = ruler.ScaleValueToPixel((double) _EndMillisecond) - 1;
                x1 = ruler.HeaderOffset;
                x2 = ruler.Height;
                g.DrawLine(_DrawingPen, x1, y1, x2, y1);

                x1 = ruler.HeaderOffset/2;
                x2 = ruler.HeaderOffset - x1;
                y1 = ruler.ScaleValueToPixel((double) _StartMillisecond) - 2;
                int y2 = ruler.ScaleValueToPixel((double) _EndMillisecond) ;
                y2 = y2 - y1;
                g.DrawRectangle(new Pen(new SolidBrush(ruler.ForeColor)), x1, y1, x2, y2);
                g.FillRectangle(_DrawingBrush, x1, y1, x2, y2);

                x1 = ruler.HeaderOffset/2;
                x2 = ruler.HeaderOffset - x1;
                y1 = ruler.ScaleValueToPixel((double) _StartMillisecond) - (x2/2) - 1;
                g.FillRectangle(new SolidBrush(ruler.ForeColor), x1, y1, x2, x2);

                x1 = ruler.HeaderOffset/2;
                y2 = ruler.HeaderOffset - y1;
                y1 = ruler.ScaleValueToPixel((double) _EndMillisecond) - (x2/2) - 1;
                g.FillRectangle(new SolidBrush(ruler.ForeColor), x1, y1, x2, x2);
            }
        }
        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();
            }
        }
        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();
            }
        }
 public override bool CanBeMoved(TimeRuler ruler)
 {
     return true;
 }