/// <summary> /// Кнопка "Парсинг текста правил" /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ParseRulesButton_Click(object sender, EventArgs e) { try { int gothash = RulesInputRichTextBox.Text.GetHashCode(); if (hash != gothash) { Debug.WriteLineIf(allRules == null, "allRules was null"); Debug.WriteLineIf(hash != RulesInputRichTextBox.Text.GetHashCode(), "hash was:" + hash + " got:" + gothash); hash = gothash; Debug.WriteLine("new hash:" + hash); allRules = transformationComponent.TransformToRules(RulesInputRichTextBox.Text, true); Debug.WriteLine("rules parsed succesful"); AutoCompleteStringCollection names = new AutoCompleteStringCollection(); names.AddRange(allRules.Languages.ToArray()); SourceLangTextBox.AutoCompleteCustomSource = names; SourceLangTextBox.AutoCompleteMode = AutoCompleteMode.Suggest; SourceLangTextBox.AutoCompleteSource = AutoCompleteSource.CustomSource; TargetLangTextBox.AutoCompleteCustomSource = names; TargetLangTextBox.AutoCompleteMode = AutoCompleteMode.Suggest; TargetLangTextBox.AutoCompleteSource = AutoCompleteSource.CustomSource; OutputRichTextBox.StartTimestamp(); OutputRichTextBox.AppendText(DateTime.Now.ToString() + ": Правила запарсены успешно\n", System.Drawing.Color.Black); OutputRichTextBox.EndTimestamp(); } else { Debug.WriteLine("rules where ready and same hash"); if (MessageBox.Show( "Похоже, входная строка не изменилась. Вы уверены, что хотите повторить парсинг?", "", MessageBoxButtons.YesNo) == DialogResult.Yes) { Debug.WriteLine("got yes"); hash = RulesInputRichTextBox.Text.GetHashCode(); Debug.WriteLine("new hash:" + hash); allRules = transformationComponent.TransformToRules(RulesInputRichTextBox.Text, true); Debug.WriteLine("rules parsed succesful"); } else { Debug.WriteLine("got not yes"); } } } catch (Exception ex) { Debug.WriteLine(ex); OutputRichTextBox.AppendException(ex); } }