示例#1
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;
 }
示例#2
0
 private string Stroke2Int(Stroke s)
 {
     string st = "";
     foreach (int i in s.directions)
     {
         st += i.ToString();
     }
     return (st);
 }
示例#3
0
 private Stroke Int2Stroke(string s)
 {
     Stroke st = new Stroke();
     foreach (char c in s)
     {
         st.directions.Add(Convert.ToInt32(c.ToString()));
     }
     return st;
 }