void compilarToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Checker ch = new Checker();

            RTB.SelectAll();
            RTB.SelectionColor = Color.Red;
            RTB.Select(0, 0);

            Pbar.Minimum = 0;
            Pbar.Maximum = 20;
            Pbar.Step    = 1;
            Pbar.Value   = 0;

            int aux = 0;

            for (int i = 0; i < 40; i++)
            {
                //si la palabra existe busca hasta donde se encuentra la ultima palabra
                while (aux < RTB.Text.LastIndexOf(ch.findWord(i)))
                {
                    //busca la palabra y la selecciona desde un caracter espesificado (aux) hasta el final del texto
                    RTB.Find(ch.findWord(i), aux, RTB.Text.Length, RichTextBoxFinds.None);
                    //cambia el color a... verde agua?
                    RTB.SelectionColor = Color.Aqua;
                    //busca la palabra a partir de una posision indicada y guarda la posicion +1 para buscar la siguiente
                    aux = RTB.Text.IndexOf(ch.findWord(i), aux) + 1;
                }
                Pbar.PerformStep();
                //resetea la posicion
                aux = 0;
            }
        }
Exemple #2
0
        private void WorkToBefore_Click(object sender, EventArgs e)
        {
            if (TaskListB.Items.Count < 1)
            {
                MessageBox.Show("目标TagList 为空,无法执行该操作");
                return;
            }
            List <Tag> tags = new List <Tag>();

            Pbar.Value   = 0;
            Pbar.Maximum = TaskListB.Items.Count;
            Pbar.Step    = 1;
            int stepNum   = Convert.ToInt32(taskNameNumStep.Text);
            int CurrentID = Convert.ToInt32(taskNameStartNum.Text);

            foreach (string TagName in TaskListB.Items)
            {
                try
                {
                    Tag tag    = null;
                    var Return = tagList.Find(
                        delegate(Tag tag1)
                    {
                        tag = tag1;
                        return(tag1.get_Name() == TagName); //需要修改为检查ID 名称可重复
                    });                                     // Check Repeact
                    if (Return != null)                     //
                    {
                        string prestr = string.Empty, endstr = string.Empty;
                        if (!string.IsNullOrEmpty(taskNameFrontStr.Text))
                        {
                            prestr = taskNameFrontStr.Text + "_";
                        }
                        if (!string.IsNullOrEmpty(taskNameRearStr.Text))
                        {
                            endstr = "_" + taskNameRearStr.Text;
                        }
                        string TagNewName = prestr + taskNameTagName.Text + (CurrentID) + endstr;
                        CurrentID += stepNum;
                        tag.SetName(TagNewName);
                        tags.Add(tag);
                    }
                }
                catch (Exception)
                {
                    throw;
                }
                Pbar.PerformStep();
            }
            TaskListB.Items.Clear();// 重新刷新 记录表B
            if (tags != null)
            {
                foreach (Tag tag in tags)
                {
                    string TagName = tag.get_Name();
                    TaskListB.Items.Add(TagName);
                }
            }
            TaskListA.Items.Clear();// 重新刷新 记录表Ba
            if (tagList != null)
            {
                foreach (Tag tag in tagList)
                {
                    string TagName = tag.get_Name();
                    TaskListA.Items.Add(TagName);
                }
            }
            Pbar.Value = Pbar.Maximum;
        }