示例#1
0
        public KeyboardIME(string path)
        {
            this.name = path;
            path      = "Layouts\\" + path + ".dll";
            if (File.Exists(path))
            {
                FileStream    fs  = new FileStream(path, FileMode.Open, FileAccess.Read);
                DeflateStream dfs = new DeflateStream(fs, CompressionMode.Decompress);
                StreamReader  sr  = new StreamReader(dfs, Encoding.Unicode);
                al = new ArrayList();
                string  tempkey = "";
                int     state   = 0;
                IMEData imd     = new IMEData();
                while (!sr.EndOfStream)
                {
                    int  i   = sr.Read();
                    char ccc = (char)i;
                    switch (state)
                    {
                    case 0:
                        if (i != (int)'\t')
                        {
                            tempkey += (char)i;
                        }
                        else
                        {
                            state      = 1;
                            imd.key    = tempkey;
                            tempkey    = "";
                            imd.Values = new ArrayList();
                        }
                        break;

                    case 1:
                        if (i != (int)'\t' && i != (int)';')
                        {
                            tempkey += (char)i;
                        }
                        else if (i == (int)';')
                        {
                            imd.Values.Add(tempkey);
                            tempkey = "";
                        }
                        else if (i == (int)'\t')
                        {
                            al.Add(imd);
                            imd   = new IMEData();
                            state = 0;
                        }
                        break;
                    }
                }
                imd        = new IMEData();
                imd.key    = "MyInput.";
                imd.Values = new ArrayList();
                imd.Values.Add("ခေါ်​သ​လား​ခင်​ဗျာ​။");
                al.Add(imd);
            }
        }
示例#2
0
 public KeyboardIME(string path)
 {
     this.name = path;
     path = "Layouts\\" + path + ".dll";
     if (File.Exists(path))
     {
         FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read);
         DeflateStream dfs = new DeflateStream(fs, CompressionMode.Decompress);
         StreamReader sr = new StreamReader(dfs, Encoding.Unicode);
         al = new ArrayList();
         string tempkey = "";
         int state = 0;
         IMEData imd = new IMEData();
         while (!sr.EndOfStream)
         {
             int i = sr.Read();
             char ccc = (char)i;
             switch (state)
             {
                 case 0:
                     if (i != (int)'\t')
                     {
                         tempkey += (char)i;
                     }
                     else
                     {
                         state = 1;
                         imd.key = tempkey;
                         tempkey = "";
                         imd.Values = new ArrayList();
                     }
                     break;
                 case 1:
                     if (i != (int)'\t' && i != (int)';')
                     {
                         tempkey += (char)i;
                     }
                     else if (i == (int)';')
                     {
                         imd.Values.Add(tempkey);
                         tempkey = "";
                     }
                     else if (i == (int)'\t')
                     {
                         al.Add(imd);
                         imd = new IMEData();
                         state = 0;
                     }
                     break;
             }
         }
         imd = new IMEData();
         imd.key = "MyInput.";
         imd.Values = new ArrayList();
         imd.Values.Add("ခေါ်​သ​လား​ခင်​ဗျာ​။");
         al.Add(imd);
     }
 }
示例#3
0
        public bool Income(int vkCode)
        {
            try
            {
                Buffer bf    = new Buffer();
                string input = ((Keys)vkCode).ToString();
                int    num   = isNumber(vkCode);
                if (num > 0 && KeyCaches != null && num <= KeyCaches.Count)
                {
                    imf.Hide();
                    KeyCacher kch = (KeyCacher)KeyCaches[num - 1];
                    SendCH.Del(kch.match.Length);
                    KeyCacher sch = CaculatePossibleStaking(bf, kch.value);
                    //List<KeyCacher> suggestions = CaculatePossibleSuggestions(bf, kch.value);
                    if (sch != null)
                    {
                        KeyCaches = new ArrayList();
                        KeyCacher lx = new KeyCacher();
                        lx.num   = 1;
                        lx.value = sch.value;
                        lx.match = sch.match;
                        KeyCaches.Add(lx);
                        imf.SetText("1. " + sch.value);
                        FindCaretAndShow();
                        //bf.Append(kch.value);
                        tmp = new StringBuilder();
                        //SendCH.Send(kch.value);
                        foreach (char c in kch.value)
                        {
                            if (c != '\u200b')
                            {
                                iop.Income(c.ToString());
                            }
                        }
                        return(false);
                    }
                    else
                    {
                        //bf.Append(kch.value);
                        tmp = new StringBuilder();
                        string res = Preprocess(kch.value);
                        foreach (char c in res)
                        {
                            if (c != '\u200b')
                            {
                                foreach (string ch in iop.CompatibilityDecompose(c.ToString()))
                                {
                                    iop.Income(ch);
                                }
                            }
                        }
                        //SendCH.Send(kch.value);
                        KeyCaches = null;
                        return(false);
                    }
                }
                else if (vkCode == 0x20 || vkCode == 0x0d)
                {
                    if (KeyCaches != null)
                    {
                        imf.Hide();
                        KeyCacher kch = (KeyCacher)KeyCaches[0];
                        SendCH.Del(kch.match.Length);
                        KeyCacher sch = CaculatePossibleStaking(bf, kch.value);
                        if (sch != null)
                        {
                            KeyCaches = new ArrayList();
                            KeyCacher lx = new KeyCacher();
                            lx.num   = 1;
                            lx.value = sch.value;
                            lx.match = sch.match;
                            KeyCaches.Add(lx);
                            imf.SetText("1. " + sch.value);
                            //imf.Show();
                            FindCaretAndShow();
                            //bf.Append(kch.value);
                            tmp = new StringBuilder();
                            //SendCH.Send(kch.value);
                            foreach (char c in kch.value)
                            {
                                if (c != '\u200b')
                                {
                                    iop.Income(c.ToString());
                                }
                            }
                            return(false);
                        }
                        else
                        {
                            //bf.Append(kch.value);
                            tmp = new StringBuilder();
                            //SendCH.Send(kch.value);
                            string res = Preprocess(kch.value);
                            foreach (char c in res)
                            {
                                if (c != '\u200b')
                                {
                                    foreach (string ch in iop.CompatibilityDecompose(c.ToString()))
                                    {
                                        iop.Income(ch);
                                    }
                                }
                            }
                            KeyCaches = null;
                            return(false);
                        }
                    }
                    if (vkCode == 0x0d)
                    {
                        mfm.SystemKeyEvent();
                    }
                    tmp = new StringBuilder();
                    return(true);
                }
                else if (vkCode == 0x1b)
                {
                    KeyCaches = null;
                    tmp       = new StringBuilder();
                    imf.Hide();
                    return(false);
                }
                else
                {
                    if (vkCode == 0x08)
                    {
                        if (tmp.Length > 0)
                        {
                            tmp.Remove(tmp.Length - 1, 1);
                        }
                        else if (tmp.Length == 0)
                        {
                            imf.Hide();
                            string buffer = bf.getBuffer();
                            if (buffer.Length > 0)
                            {
                                int x = 0;
                                for (int i = buffer.Length - 2; i >= 0; i--)
                                {
                                    x++;
                                    if (buffer[i] == 0x200b)
                                    {
                                        SendCH.Del(x);
                                        bf.PopChars(x);
                                        return(false);
                                    }
                                }
                                if (buffer[buffer.Length - 1] == '\u200b')
                                {
                                    bf.PopChars(buffer.Length);
                                    SendCH.Del(buffer.Length);
                                }
                                else
                                {
                                    bf.PopChars(1);
                                    SendCH.Del(1);
                                }

                                return(false);
                            }
                        }
                    }
                    else
                    {
                        if (input.Length > 1)
                        {
                            if (input == "Oemtilde")
                            {
                                tmp.Append("`");
                            }
                            else if (input.StartsWith("D") && input.Length == 2)
                            {
                                tmp.Append(input[1]);
                            }
                            else if (input == "Oem1")
                            {
                                tmp.Append(";");
                            }
                            else if (input == "Oemcomma")
                            {
                                tmp.Append(",");
                            }
                            else if (input == "OemPeriod")
                            {
                                tmp.Append(".");
                            }
                            else if (input == "OemQuestion")
                            {
                                tmp.Append("/");
                            }
                            else
                            {
                                tmp.Append('-');
                            }
                        }
                        else
                        {
                            tmp.Append(input);
                        }
                    }
                    ArrayList al = new ArrayList();
                    IMEData   s  = kime.getData(tmp.ToString());
                    if (s != null)
                    {
                        KeyCaches = new ArrayList();
                        string str = "";
                        for (int i = 0; i < s.Values.Count; i++)
                        {
                            KeyCacher kch = new KeyCacher();
                            kch.num   = i + 1;
                            kch.value = s.Values[i].ToString();
                            kch.match = s.key;
                            KeyCaches.Add(kch);
                            str += (i + 1).ToString() + ". " + s.Values[i].ToString() + "  ";
                        }
                        imf.SetText(str);
                        FindCaretAndShow();

                        /*Point p = FindCaret();
                         * BackupState();
                         *  imf.ShowFormAt(p.X, p.Y - imf.Height);
                         * RestoreState();
                         * //*/
                    }
                    else
                    {
                        imf.Hide();
                        KeyCaches = null;
                    }
                    return(true);
                }
            }
            catch { return(true); }
        }