Beispiel #1
0
        bool checkGestureStart()
        {
            if (!misgesStart)
            {
                //
                if (!checkContinuous())     // continuous stoped;
                {
                    // check times;
                    if (mtqueue > 10)
                    {
                        //if (!misContinuous)
                        //{
                        //Console.WriteLine("continuous end,len="+mgesdlen.ToString());
                        // check the distance, speed;
                        updateMaxOneDirSumSet();

                        // +ls> a mistable consumed me a lot of time here;
                        int dis = Math.Abs(mdOneDirSum[mgesdlen - 1]);
                        if (dis > mgesDistanceMin)
                        {
                            //double speed = (double)dis / (double)mtqueue;
                            double speed = mgesSpeedAvg;
                            //Console.WriteLine("try start dis=" + dis.ToString()+",spd="+speed.ToString("f2"));
                            if (speed > mgesSpeedStartMin)
                            {
                                misgesStart = true;

                                // record status;
                                mgesBeginPos    = new Point(mxpos[0], mypos[0]);
                                mgesPeakPos     = mtickPos;//new Point(mxnow, mynow);
                                mgesPeakDis     = GestureCommon.calDistance(mgesBeginPos, mgesPeakPos);
                                mgesPeakDisAxis = (double)dis;
                                Console.WriteLine(">>ges start," + speed.ToString("f2") + ",(" + mgesBeginPos.X.ToString() + "," + mgesBeginPos.Y.ToString());
                            }
                            else
                            {
                                Console.WriteLine("..start check failed=speed .." + speed.ToString("f2"));
                            }
                        }
                        else
                        {
                            Console.WriteLine("..start check failed=distance ..");
                        }
                    }
                    else
                    {
                        Console.WriteLine("..start check failed=time..");
                    }

                    if (!misgesStart)
                    {
                        Console.WriteLine("<<x ges start failed.size=" + mgesdlen.ToString());
                        resetState();
                    }
                }
            }
            return(misgesStart);
        }
        void TickUpdate(int x, int y)
        {
            mtickPositionLast  = mtickPositionNow;
            mtickPositionNow.X = x; mtickPositionNow.Y = y;

            mtickDistance = GestureCommon.calDistance(mtickPositionNow, mtickPositionLast);
            mtickSpeed    = mtickDistance / mtickTime;

            // save; 2021-01-22;
            //mtextman.WriteLine(x.ToString() + "," + y.ToString() + "," + mtickSpeed.ToString("f4"));
        }
Beispiel #3
0
        //



        void updatePosition()
        {
            WinApis.GetCursorPos(ref mtickPos);
            mdx = mtickPos.X - mtickPosLast.X;
            mdy = mtickPos.Y - mtickPosLast.Y;

            mtickDis   = GestureCommon.calDistance(mtickPos, mtickPosLast);
            mtickspeed = mtickDis / (double)mtickktime;

            mtickPosLast = mtickPos;
        }
Beispiel #4
0
        public int CalAreaIndex(Point p0, Point p1)
        {
            //pbm> the distance is in pixel unit.
            // should be in metric unit;

            double dx  = GestureCommon.cDx(p1, p0);
            double dy  = GestureCommon.cDy(p1, p0);
            double dis = GestureCommon.calDistance(p1, p0);
            double cos = dx / dis;

            //Console.WriteLine("(dx,dy,dis,cos)=" + dx.ToString() + "," + dy.ToString()
            //    + "," + dis.ToString("{.00}") + "," + cos.ToString("{0.0000}"));

            return(ckArea(cos, dy >= 0));
        }
        bool CheckGesStop()
        {
            bool stop = false;

            mgesStartedTime += mtickTime;

            if (mgesStartedTime > mgesDurationTime) // stop when moving overtime;
            {
                Console.WriteLine("stop:overtime");
                return(true);
            }

            mgesdisnow = GestureCommon.calDistance(mgesBeginPos, mtickPositionNow);
            RecordMaxDis();

            bool inside = CheckStartArea();

            //Console.WriteLine(inside.ToString());
            if (!inside && (mgesturestate == 1))
            {
                mgesturestate = 2;
                //Console.WriteLine(mgesturestate.ToString());
            }
            if (inside && (mgesturestate == 2))
            {
                mgesturestate = 3;
                //Console.WriteLine("stop:back");
                //stop = true;
            }

            //double disnow = cDis(mgesptstart, mtickptnow);
            double avgnow = mdismax / mgesStartedTime;

            if (avgnow < mSpeedStatic)//2.0)
            {
                Console.WriteLine(avgnow.ToString());
                stop = true;
            }
            //if (mtickvelocity < mvelocitymin) // stop when moving slow;
            //{
            //    // 2021-01-18; double check?
            //    if (++mgestrystopcnt >= mgestrystopmax)
            //        stop = true;
            //}

            return(stop);
        }
        bool CheckGesture()
        {
            mgesDistance = GestureCommon.calDistance(mgesEndPos, mgesBeginPos);

            if (mgesDistance < mdismax)  // 2021-01-17, use the maximum point;
            {
                mgesDistance = mdismax;
                mgesEndPos   = mptdismax;
            }


            bool b1 = (mgesDistance > mgesDistanceMin);//checkDistance();
            bool b2 = (mgesturestate > 1);

            Console.WriteLine(mdismax.ToString() + "," + mgesturestate.ToString());
            return(b1 && b2);
            //return (checkDistance()); //   { mgesstopcnt = mgesgap;  }
        }
        public void ts_dis(MouseEventArgs e)
        {
            mv.X = e.X;
            mv.Y = e.Y;

            int    dis  = (int)GestureCommon.calDistance(mv, mo);
            int    dis2 = GestureCommon.cDis2(mv, mo);
            int    dx   = GestureCommon.cDx(mv, mo);
            int    dy   = GestureCommon.cDy(mv, mo);
            double tan  = GestureCommon.cTan(mv, mo);

            Console.Out.WriteLine(" (dis,dis2,dx,dy,tan)=("
                                  + dis.ToString() + ","
                                  + dis2.ToString() + ","
                                  + dx.ToString() + ","
                                  + dy.ToString() + ","
                                  + tan.ToString("{0.00}") + ")");
        }
        public void onMove2(int x, int y)
        {
            mdtnow = DateTime.Now;
            mts    = mdtnow.Subtract(mdtlast);
            int dt = (int)mts.TotalMilliseconds;    // time difference;

            if (dt > mtres)
            {
                mtickPositionNow.X = x; mtickPositionNow.Y = y;
                double ds = GestureCommon.calDistance(mtickPositionNow, mtickPositionLast);  // distance;

                // update;
                mtickPositionLast = mtickPositionNow;
                mdtlast           = mdtnow;

                // cal;
                double dv = ds / dt;                // velosity;

                //Console.Out.WriteLine(">dv=" + dv.ToString());
                onVelocity(dv);
            }
        }