private void button2Higher_Click(object sender, EventArgs e)
        {
            var items = getIndicesToOp();

            if (items.Count > 1)
            {
                MessageBox.Show("选中的词典个数大于1,功能暂未实现!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            List <DictInfo> dicts2Higher = new List <DictInfo>();

            foreach (var item in items)
            {
                int i = (int)item;
                if (i == 0)
                {
                    //包含第一个,无法再升高
                    MessageBox.Show("选中的词典包含第一个,无法再提升优先级!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    statusLabel.Text = "词典文件优先级提升失败。";
                    return;
                }
                dicts2Higher.Add(DictsInfoList[i]);
            }

            DictListHelper.SetupDictsInfo(dicts2Higher, DictOps.DictToHigher, FormMain.sqliteInstance);
            LoadDicts2ListView(listViewDictsManage);
            statusLabel.Text = "完成词典文件优先级提升任务。";
        }
        private void buttonRemoveDict_Click(object sender, EventArgs e)
        {
            var items = getIndicesToOp();

            if (items.Count == 0)
            {
                MessageBox.Show("没有选中要卸载的词典", "卸载词典", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            DialogResult dr = MessageBox.Show("即将卸载选中的" + items.Count + "个词典,是否确定?", "卸载词典", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (dr == DialogResult.No)
            {
                return;
            }
            else
            {
                List <DictInfo> dicts2Remove = new List <DictInfo>();

                foreach (var item in items)
                {
                    int i = (int)item;
                    dicts2Remove.Add(DictsInfoList[i]);
                }

                FormMain.sqliteInstance.DeleteTables(dicts2Remove.Select(i => i.DictName).ToList()); //Select中是个函数,对每个DictInfo获得其中的DictName。
                DictListHelper.SetupDictsInfo(dicts2Remove, DictOps.RemoveDicts, FormMain.sqliteInstance);
                LoadDicts2ListView(listViewDictsManage);
                statusLabel.Text = "完成词典文件删除任务。";
            }
        }
Пример #3
0
        private void ComboBox1_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar.Equals((char)13))
            {
                string text = comboBoxRegex.Text;
                if (!comboBoxRegex.Items.Contains(text))
                {
                    comboBoxRegex.Items.Add(comboBoxRegex.Text);
                }

                //TODO: 在词典搜索匹配text的所有词
                Regex         rg             = new Regex(text);
                List <string> wordList       = new List <string>();
                List <string> diNames2Search = DictListHelper.GetDictsInfo(FormMain.sqliteInstance).Where(i => i.IsChecked == 1).Select(di => di.DictName).ToList();
            }
        }