Example #1
0
    private string CatchGesture()
    {
        List <Point2D> tmplist = new List <Point2D>();

        foreach (Point2D point in m_Point2dList)
        {
            Point2D newpoint = new Point2D(point.x, point.y);

            tmplist.Add(newpoint);
        }
        if (m_IsSingleDir)
        {
            return(JustGestureSingleDir(tmplist));
        }
        string retresult = TryToSingleDir(tmplist);

        if (retresult != "Unknow")
        {
            return(retresult);
        }
        //float timedis = 0;

        //float curtime = Time.time;

        RecognitionResult result = geometricrec.recognize(tmplist);

        //timedis = Time.time - curtime;

        if (m_IsEditMode)
        {
            GestureTest gesturetest = Singlton.getInstance("GestureTest") as GestureTest;

            m_LastPoint2dList.Clear();

            for (int i = 0; i < m_Point2dList.Count; i++)
            {
                Debug.LogWarning(" ==========>m_Point2dList[" + i + "]:  " + m_Point2dList[i].GetString());

                m_LastPoint2dList.Add(m_Point2dList[i]);

                gesturetest.SetPointToShow(m_Point2dList[i].ToVector3());
            }

            result.Print();
        }


        if (result.name.Contains("Rectangle"))
        {
            return("Rectangle");
        }
        else if (result.name.Contains("Triangle"))
        {
            return("Triangle");
        }
        else
        {
            return(result.name);
        }
    }
Example #2
0
    private void OnDrop()
    {
        if (m_Point2dList.Count < 2)
        {
            ClearPoints();

            return;
        }

        if (m_IsEditMode)
        {
            GestureTest getsset = Singlton.getInstance("GestureTest") as GestureTest;
            getsset.ClearPoints();
        }

        Debug.LogWarning("  m_Point2dList:  " + m_Point2dList.Count);

        string result = CatchGesture();

        Debug.LogWarning("@@@@@@@@@@@@@@@@=========>  result:  " + result);

        if (FuncGetGesture != null)
        {
            FuncGetGesture(result);
        }
        ClearPoints();
    }
 public GestureOptionEntry(string text, Texture2D icon, Vector2 iconSize, Vector2 position, float scale, Color color, TextAlignment alignment, GestureTest test, GestureHandler callback)
     : base(text, icon, iconSize, position, scale, color, alignment)
 {
     unlockedColor = color;
     this.callback = callback;
     this.test = test;
 }
 public void DisableGestureTest(GestureTest test)
 {
     if (gestures.ContainsKey(test))
         gestures.Remove(test);
 }
 public void EnableGestureTest(GestureTest test, GestureHandler callback)
 {
     gestures[test] = callback;
 }
 public void AddGestureOption(string actionString, GestureTest test, GestureHandler callback, Texture2D icon, float scale = 1.0f)
 {
     Vector2 pos;
     if (gestureOptions.Count == 0)
         pos = new Vector2(Main.windowSize.X * 0.5f, title.Position.Y + title.Size.Y / 2 + padding*3);
     else
         pos = new Vector2(Main.windowSize.X * 0.5f, gestureOptions[gestureOptions.Count - 1].Position.Y + gestureOptions[gestureOptions.Count - 1].Size.Y / 2 + padding);
     Vector2 screenDimensions = new Vector2(ScreenManager.GraphicsDevice.Viewport.Width, ScreenManager.GraphicsDevice.Viewport.Height);
     float newScale = (screenDimensions.X / 1920.0f) * scale;
     Vector2 iconSize = new Vector2(screenDimensions.X / 9.0f, screenDimensions.X / 9.0f);
     GestureOptionEntry newEntry = new GestureOptionEntry(actionString, icon,iconSize, pos, newScale, textColor, textAlignment, test, callback);
     backgroundPanelWidth = Math.Max(newEntry.Size.X,backgroundPanelWidth);
     gestureOptions.Add(newEntry);
     backgroundPanelDirty = true;
 }