コード例 #1
0
        protected override void OnMouseMove(MouseEventArgs e)
        {
            base.OnMouseMove(e);
            _hoverPoint = Point.Empty;
            if (_bMouseDown)
            {
                if (_moveLine != null)
                {
                    if (_moveLineStart)
                    {
                        _moveLine.StartPoint.X = e.X;
                        _moveLine.StartPoint.Y = e.Y;
                    }
                    else
                    {
                        _moveLine.EndPoint.X = e.X;
                        _moveLine.EndPoint.Y = e.Y;
                    }
                    _moveLine.RecalculateSummaryPoint();
                    return;
                }
                _pointEnd = new Point(e.X, e.Y);
            }
            else
            {
                Cursor = Cursors.Arrow;

                _hoverDepthLine =
                    TripWires.FirstOrDefault(
                        d =>
                        e.X > d.SummaryPoint.X && e.X <d.SummaryPoint.X + d.SummaryWidth &&
                                                       e.Y> d.SummaryPoint.Y &&
                        e.Y < d.SummaryPoint.Y + 15);
                if (_hoverDepthLine != null)
                {
                    Cursor = Cursors.Hand;
                }
                else
                {
                    double minD = 10;
                    _moveLine = null;
                    foreach (var dl in TripWires)
                    {
                        var d =
                            Math.Sqrt(Math.Pow(dl.StartPoint.X - e.X, 2) + Math.Pow(dl.StartPoint.Y - e.Y, 2));
                        if (d < minD)
                        {
                            minD           = d;
                            _moveLine      = dl;
                            _moveLineStart = true;
                            Cursor         = Cursors.Hand;
                            _hoverPoint    = dl.StartPoint;
                        }
                        d = Math.Sqrt(Math.Pow(dl.EndPoint.X - e.X, 2) + Math.Pow(dl.EndPoint.Y - e.Y, 2));
                        if (d < minD)
                        {
                            minD           = d;
                            _moveLine      = dl;
                            _moveLineStart = false;
                            Cursor         = Cursors.Hand;
                            _hoverPoint    = dl.EndPoint;
                        }
                    }
                }
            }
            Invalidate();
        }
コード例 #2
0
ファイル: KinectStream.cs プロジェクト: vmail/main
        private static bool ProcessIntersection(Point a, Point b, DepthLine dl)
        {
            var c = dl.StartPoint;
            var d = dl.EndPoint;

            float ua = (d.X - c.X) * (a.Y - c.Y) - (d.Y - c.Y) * (a.X - c.X);
            float ub = (b.X - a.X) * (a.Y - c.Y) - (b.Y - a.Y) * (a.X - c.X);
            float denominator = (d.Y - c.Y) * (b.X - a.X) - (d.X - c.X) * (b.Y - a.Y);

            //bool intersection, coincident;

            if (Math.Abs(denominator) <= 0.00001f)
            {
                if (Math.Abs(ua) <= 0.00001f && Math.Abs(ub) <= 0.00001f)
                {
                    return true;
                    //intersection = coincident = true;
                    //intersectionPoint = (A + B) / 2;
                }
            }
            else
            {
                ua /= denominator;
                ub /= denominator;

                if (ua >= 0 && ua <= 1 && ub >= 0 && ub <= 1)
                {
                    return true;
                    //intersection = true;
                    //intersectionPoint.X = A.X + ua * (B.X - A.X);
                    //intersectionPoint.Y = A.Y + ua * (B.Y - A.Y);
                }
            }
            return false;
        }
コード例 #3
0
ファイル: EditDepthLine.cs プロジェクト: tdhieu/iSpy
 public EditDepthLine(DepthLine dl)
 {
     _dl = dl;
     InitializeComponent();
 }
コード例 #4
0
ファイル: EditDepthLine.cs プロジェクト: John-Leitch/iSpy
 public EditDepthLine(DepthLine dl)
 {
     _dl = dl;
     InitializeComponent();
 }
コード例 #5
0
        protected override void OnMouseUp(MouseEventArgs e)
        {
            base.OnMouseUp(e);

            _bMouseDown = false;

            SaveTripWires();

            if (_hoverDepthLine != null)
            {
                _pointStart = Point.Empty;
                _pointEnd = Point.Empty;
                OnBoundsChanged();
                return;
            }
            if (_moveLine != null)
            {
                _moveLine.RecalculateSummaryPoint();
                _pointStart = Point.Empty;
                _pointEnd = Point.Empty;
                _moveLine = null;
                OnBoundsChanged();
                return;
            }

            int endX = e.X;
            int endY = e.Y;

            _pointEnd = new Point(endX, endY);

            if (Math.Sqrt(Math.Pow(endX - _pointStart.X, 2) + Math.Pow(endY - _pointStart.Y, 2)) < 5)
            {
                return;
            }
            var start = new Point();
            var stop = new Point();

            start.X = _pointStart.X;
            if (_pointEnd.X < _pointStart.X)
                start.X = _pointEnd.X;
            start.Y = _pointStart.Y;
            if (_pointEnd.Y < _pointStart.Y)
                start.Y = _pointEnd.Y;

            stop.X = _pointEnd.X;
            if (_pointEnd.X < _pointStart.X)
                stop.X = _pointStart.X;
            stop.Y = _pointEnd.Y;
            if (_pointEnd.Y < _pointStart.Y)
                stop.Y = _pointStart.Y;

            TripWires.Add(new DepthLine(_pointStart, _pointEnd));
            SaveTripWires();

            _pointStart = Point.Empty;
            _pointEnd = Point.Empty;
            OnBoundsChanged();
        }
コード例 #6
0
        protected override void OnMouseMove(MouseEventArgs e)
        {
            base.OnMouseMove(e);
            _hoverPoint = Point.Empty;
            if (_bMouseDown)
            {
                if (_moveLine != null)
                {
                    if (_moveLineStart)
                    {
                        _moveLine.StartPoint.X = e.X;
                        _moveLine.StartPoint.Y = e.Y;
                    }
                    else
                    {
                        _moveLine.EndPoint.X = e.X;
                        _moveLine.EndPoint.Y = e.Y;
                    }
                    _moveLine.RecalculateSummaryPoint();
                    return;
                }
                _pointEnd = new Point(e.X, e.Y);
            }
            else
            {
                Cursor = Cursors.Arrow;

                _hoverDepthLine =
                    TripWires.FirstOrDefault(
                        d =>
                        e.X > d.SummaryPoint.X && e.X < d.SummaryPoint.X + d.SummaryWidth &&
                        e.Y > d.SummaryPoint.Y &&
                        e.Y < d.SummaryPoint.Y + 15);
                if (_hoverDepthLine != null)
                {
                    Cursor = Cursors.Hand;
                }
                else
                {
                    double minD = 10;
                    _moveLine = null;
                    foreach (var dl in TripWires)
                    {
                        var d =
                            Math.Sqrt(Math.Pow(dl.StartPoint.X - e.X, 2) + Math.Pow(dl.StartPoint.Y - e.Y, 2));
                        if (d < minD)
                        {
                            minD = d;
                            _moveLine = dl;
                            _moveLineStart = true;
                            Cursor = Cursors.Hand;
                            _hoverPoint = dl.StartPoint;
                        }
                        d = Math.Sqrt(Math.Pow(dl.EndPoint.X - e.X, 2) + Math.Pow(dl.EndPoint.Y - e.Y, 2));
                        if (d < minD)
                        {
                            minD = d;
                            _moveLine = dl;
                            _moveLineStart = false;
                            Cursor = Cursors.Hand;
                            _hoverPoint = dl.EndPoint;
                        }
                    }
                }
            }
            Invalidate();
        }