Пример #1
0
        public string Quadrant2Str(AI.Quadrant q)
        {
            string s = "";

            if (q.first)
            {
                s += "A";
            }
            if (q.second)
            {
                s += "B";
            }
            if (q.third)
            {
                s += "C";
            }
            return(s);
        }
Пример #2
0
        public List <Stroke> MatchStroke(string stroke, AI.Quadrant q, int language)
        {
            bool b = true;

REDO:
            conn = new System.Data.SQLite.SQLiteConnection(@"Data Source=CoreInkLib.dll");
            conn.Open();
            SQLiteCommand    sqc = new SQLiteCommand("SELECT * FROM strokes WHERE directions = '" + stroke + "' AND quadrant='" + Quadrant2Str(q) + "' AND lang = " + language.ToString() + ";", conn);
            SQLiteDataReader sqr = sqc.ExecuteReader();
            List <Stroke>    l   = new List <Stroke>();

            while (sqr.Read())
            {
                Stroke st = new Stroke();
                st.sid        = Convert.ToInt32(sqr[0]);
                st.vid        = Convert.ToInt32(sqr[1]);
                st.cid        = Convert.ToInt32(sqr[2]);
                st.thisstroke = Convert.ToInt32(sqr[5]);
                st.quadrant   = sqr[4].ToString();
                sqc           = new SQLiteCommand("SELECT ifnull(phase,0) FROM strokes WHERE vid = " + st.vid.ToString() + " AND phase >" + st.thisstroke.ToString() + " AND lang=" + language.ToString() + ";", conn);
                st.nextstroke = Convert.ToInt32(sqc.ExecuteScalar());
                foreach (char c in sqr[3].ToString())
                {
                    st.directions.Add(Convert.ToInt32(c.ToString()));
                }
                if (b == false)
                {
                    st.quadrant = "C";
                }
                l.Add(st);
            }
            conn.Close();
            if (q.third && l.Count == 0 && b)
            {
                q.third = false; q.second = true; b = false;
                goto REDO;
            }
            return(l);
        }
Пример #3
0
 public List <Stroke> MatchStroke(string stroke, AI.Quadrant q)
 {
     return(MatchStroke(stroke, q, 0));
 }
Пример #4
0
 public CoreInk.AI.Quadrant getQuadrants()
 {
     CoreInk.AI.Quadrant q = new AI.Quadrant();
     foreach (Point p in points)
     {
         if (p.Y < first - (first / 2))
             q.first = true;
         if (p.Y > first + (first / 3) && p.Y < second - (first / 3))
         {
             q.second = true;
         }
         if (p.Y > second + (first / 2))
             q.third = true;
     }
     if (!q.first && !q.second && !q.third)
     {
         if (points.Count > 0)
         {
             Point p = points[0];
             if (p.Y < first)
                 q.first = true;
             if (p.Y > first && p.Y < second)
                 q.second = true;
             if (p.Y > second)
                 q.third = true;
         }
     }
     return q;
 }