private void ListDataType() { ListData.Items.Clear(); ListData.BeginUpdate(); for (var i = 0; i < packets.Count; ++i) { var data = packets[i]; ListData.Items.Add($"Index: {i} Type: {data.Type} Value: {data.GetData()} Bytes: {data.GetArrayString()}"); } ListData.EndUpdate(); }
public void UpdateUI(object state) { if (state is string) { textBox1.AppendText((string)state); } else if (state is WriteToForm) { if ((state as WriteToForm).writeToList.Length > 0) { ListData.BeginUpdate(); ListData.Items.Add((state as WriteToForm).writeToList); ListData.EndUpdate(); } if ((state as WriteToForm).writeToText.Length > 0) { textBox1.AppendText((state as WriteToForm).writeToText); } if ((state as WriteToForm).incris) { progressBar1.Value++; } if ((state as WriteToForm).StrimStop) { CountThread--; if (CountThread == -1) { stopwatchwork.Stop(); textBox1.AppendText("Время работы всех потоков : " + stopwatchwork.ElapsedMilliseconds + " ms"); toolStripStatusLabel2.Text = "Всё нашли за " + stopwatchwork.ElapsedMilliseconds + " ms"; File.AppendAllText(textBox4.Text, textBox1.Text); timer1.Start(); } } } }
private void FindGo_Click(object sender, EventArgs e) { if (words == null) { return; } timer1.Stop(); stopwatchwork = new Stopwatch(); progressBar1.Minimum = 0; progressBar1.Maximum = words.Count + 1; progressBar1.Value = 0; progressBar1.Visible = true; int len = 0; LenCol = 50; CountItemsUp = 0; stopwatchwork.Start(); ListData.BeginUpdate(); ListData.Items.Clear(); ItemListAdd.Clear(); ResultTimeStrim = ""; //ItemListStop.Clear(); string substring = FindText.Text.ToLower(); if (FindType.SelectedIndex > 2) { int k = Convert.ToInt32(NumStream.Text); int Lenght = words.Count / k; int CountThread = 0; Array.Resize(ref ListThreadFind, k); Array.Clear(ListThreadFind, 0, k); for (int i = 0; i < words.Count; i = i + Lenght) { if (((words.Count - i) % (k - CountThread)) == 0) { Lenght = ((words.Count - i) / (k - CountThread)); } ListThreadFind[CountThread] = new MyThreadFind(); ListThreadFind[CountThread].OneShearchAddNow += OneShearchAddOk; ListThreadFind[CountThread].ShearchCompletedNow += ShearchCompletedNow; ListThreadFind[CountThread].NameThread = " Stream - " + CountThread; if (CountThread == k - 1) { Lenght = words.Count - i; } LogTextBox.AppendText(ListThreadFind[CountThread].NameThread + " c " + i + " по " + (i + Lenght - 1) + " в потоке " + Lenght + " элементов \r\n"); ListThreadFind[CountThread].MyThreadIni(words, i, Lenght, substring, FindType.SelectedIndex - 3, Convert.ToInt32(Distance.Text)); CountThread++; } CountThread--; timer2.Tag = 0; // счетчик переноса в ListBox timer2.Start(); } else { switch (FindType.SelectedIndex) { case 0: ShearhFunc = new ShearhFunction(L5.LevenshteinDistance.StrContains); break; case 1: ShearhFunc = new ShearhFunction(L5.LevenshteinDistance.WagnweFisher); break; case 2: ShearhFunc = new ShearhFunction(L5.LevenshteinDistance.DamerauLevenshteinDistance); break; default: break; } foreach (string s in words) { ShearchItemClass ShearchItem = ShearhFunc(s, substring); if (ShearchItem.Distance <= Convert.ToInt32(Distance.Text)) { ShearchItem.IndexItem = progressBar1.Value; len = TextRenderer.MeasureText((ListData.Items[ListData.Items.Add(ShearchItem)] as ShearchItemClass).ShearchString, ListData.Font).Width; if (LenCol < len) { LenCol = len + 10; } } progressBar1.Value++; } progressBar1.Value = progressBar1.Maximum; stopwatchwork.Stop(); TimeWorkStr.Text = "Время поиска " + stopwatchwork.ElapsedMilliseconds + " ms"; timer1.Start(); } if ((FindType.SelectedIndex == 2) || (FindType.SelectedIndex == 5)) { ListData.Items.Insert(0, "Строка , Редакционное предписание , Номер"); } else { ListData.Items.Insert(0, "Строка , , Номер"); } ListData.EndUpdate(); }