Beispiel #1
0
        private void btnManageDict_Click(object sender, EventArgs e)
        {
            //
            ManageDict frm = new ManageDict(cbbKeypad.SelectedIndex);

            frm.ShowDialog();
        }
Beispiel #2
0
        private void MainDict_Load(object sender, EventArgs e)
        {
            //kiểm tra khởi động cùng windows
            if (rkApp.GetValue("iDict") == null)
            {
                cmsStartWithWindows.Checked = false;
            }
            else
            {
                cmsStartWithWindows.Checked = true;
            }
            //load từ điển và các thiết lập
            path = Application.StartupPath;
            //
            //strFileName = path + "\\resources\\msagent\\genie.acs";
            strFileName = path + "\\resources\\msagent\\vrgirl.acs";
            //strFileName = "\\" + CBSelectStyle.SelectedItem.ToString() + ".acs";

            // Hien thi agent
            ShowAgent();
            // Doc loi chao mung.
            CharacterEx.Speak("Hi, I'm a virtual girl, also your assistant. Thanks for using iDict, a multi language, multi function and very smart dictionary. Nice day!", null, out dwReqID);
            string[] tmpArray = File.ReadAllLines(path + "\\stored.dat");
            establish = tmpArray[0];
            listDict  = new string[tmpArray.Length - 1];
            for (i = 1; i < tmpArray.Length; i++)
            {
                listDict[i - 1] = tmpArray[i];
            }
            if (listDict.Length > 0)
            {
                Dicts = new Dict[listDict.Length];
                bool notFoundDict = false;
                for (i = 0; i < Dicts.Length; i++)
                {
                    if (File.Exists(path + "\\Dictionary\\" + listDict[i] + ".idt"))
                    {
                        Dicts[i] = new Dict(path + "\\Dictionary\\" + listDict[i] + ".idt");
                        tabDictList.TabPages.Add(Dicts[i].dln[3]);
                    }
                    else
                    {
                        notFoundDict = true;
                        Dicts[i]     = null;
                    }
                }
                //nếu không thấy từ điển thì ghi lại file stored.dat
                if (notFoundDict == true)
                {
                    StreamWriter stw = File.CreateText(path + "\\stored.dat");
                    stw.Write(establish);
                    for (i = 0; i < Dicts.Length; i++)
                    {
                        if (Dicts[i] != null)
                        {
                            stw.Write("\r\n" + Dicts[i].fileName);
                        }
                    }
                    stw.Flush();
                    stw.Close();
                    Application.Restart();
                    return;
                }
                //load item vào combobox
                if (File.Exists(path + "\\Items.txt"))
                {
                    StreamReader str = new StreamReader(path + "\\Items.txt");
                    int          i   = 0;
                    while ((tmp = str.ReadLine()) != null && i < 50)
                    {
                        cbbWord.Items[i] = tmp;
                        i++;
                    }
                    str.Close();
                }
                //bắt đầu thiết lập thuộc tính cho từ điển
                cbbKeypad.SelectedIndex = int.Parse(establish[0].ToString());
            }
            else
            {
                DialogResult result = MessageBox.Show("There's no database in the dictionary. Do you want to create or use the one?", "Announcement", MessageBoxButtons.YesNo);
                if (result == DialogResult.Yes)
                {
                    ManageDict frm = new ManageDict(cbbKeypad.SelectedIndex);
                    frm.ShowDialog();
                }
                else
                {
                    MessageBox.Show("The application can't run without at least a database.", "Announcement");
                }
                Application.Exit();
                return;
            }
            // Lay giong phat am
            foreach (ISpeechObjectToken t in voice.GetVoices("", ""))
            {
                cbbVoice.Items.Add(t.GetAttribute("Name"));
            }
            miniDict    = new MiniDict(Dicts.Length);
            similarWord = new string[15 * tabDictList.TabCount];
            listLength  = (lstWordsList.Height - 4) / lstWordsList.ItemHeight;
            listDict    = new string[listLength];
            for (i = 0; i < listDict.Length; i++)
            {
                lstWordsList.Items.Add("");
            }
            OpenDict();
        }