/// <summary>
 /// Нажатие кнопки "стрелочка" - трансформация
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void TransformStartButton_Click(object sender, EventArgs e)
 {
     Debug.WriteLine("TransformStartButton clicked");
     try
     {
         if (allRules == null)
         {
             Debug.WriteLine("allRules was null");
             hash = RulesInputRichTextBox.Text.GetHashCode();
             Debug.WriteLine("got hash: " + hash.ToString());
             allRules = transformationComponent.TransformToRules(RulesInputRichTextBox.Text, true);
             Debug.WriteLine("parsed rules succesfully");
         }
         var text = transformationComponent.Transform(InputTestRichTextBox.Text,
                                                      allRules,
                                                      SourceLangTextBox.Text,
                                                      TargetLangTextBox.Text);
         OutputRichTextBox.Text = text;
         Debug.WriteLine("parsed model succesfully");
         Debug.WriteLine("----------Result------------");
         Debug.WriteLine(text);
         Debug.WriteLine("----------------------------");
     }
     catch (Exception ex)
     {
         Debug.WriteLine(ex);
         OutputRichTextBox.AppendException(ex);
     }
 }
        /// <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);
            }
        }