Ejemplo n.º 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;
 }
Ejemplo n.º 2
0
 public WritingPad()
 {
     InitializeComponent();
     first = this.Height / 3;
     second = first * 2;
     ai = new AI();
     buffer = new Bitmap(Width, Height);
     ClearBuffer();
    // XRefresh();
 }
Ejemplo n.º 3
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;
 }
Ejemplo n.º 4
0
 public bool OnWritten(List<Point> points, List<int> dirs, AI.Quadrant q, int AttachMode)
 {
     eventInitiated = true;
     string strstk = "";
     bool matched = false;
     foreach (int d in dirs)
         strstk += d.ToString();
     if (dirs.Count == 1 && dirs[0] == AI.Direction.W)
     {
         //textBox1.Text = textBox1.Text.Substring(0, textBox1.Text.Length - 1);
         pop(1);
         temp = new List<Stroke>();
         return true;
     }
     else if (dirs.Count == 1 && dirs[0] == AI.Direction.E && q.first == false)
     {
         Push(" ");
         temp = new List<Stroke>();
         return true;
     }
     List<Stroke> matching_strokes = Manager.MatchStroke(strstk, q, language);
     List<Stroke> attached_matches = StrokesAttached(temp, matching_strokes);
     if (attached_matches.Count == 0)
     {
         Stroke s = GetBestStroke(matching_strokes);
         if (s != null)
         {
             String strokeresult = Manager.MatchCharacter(s.cid).charx;
             if (q.second == true && q.third == false)
             {
                 if (s.quadrant == "C")
                 {
                     strokeresult = getStacked(strokeresult);
                 }
             }
             if (strokeresult == "\u1001")
             {
                 int a = Math.Abs(points[0].Y - writingPad1.first);
                 int b = Math.Abs(points[0].Y - writingPad1.second);
                 if (b < a)
                 {
                     strokeresult = "ေ";
                 }
             }
             Push(strokeresult);
             laststrokeresult = strokeresult;
         }
         else
         {
             laststrokeresult = "";
         }
         temp = StrokesNeedAttach(matching_strokes);
     }
     else
     {
         Stroke s = GetEndStroke(attached_matches);
         if (s != null)
         {
             String strokeresult = Manager.MatchCharacter(s.cid).charx;
             
             pop(laststrokeresult.Length);
             Push(strokeresult);
             laststrokeresult = strokeresult;
         }
         else
         {
             laststrokeresult = "";
         }
         temp = GetEndStrokeNeedsAttach(matching_strokes, attached_matches);
     }
     return matched;
 }
Ejemplo n.º 5
0
 public List<Stroke> MatchStroke(string stroke, AI.Quadrant q)
 {
     return MatchStroke(stroke, q, 0);
 }