예제 #1
0
 //метод очистки
 private void ClearMethod()
 {
     InputCodeTextBox.Clear();
     OutputCodeTextBox.Clear();
     InputDecodeTextBox.Clear();
     OutputDecodeTextBox.Clear();
     KF.Clear();
 }
예제 #2
0
        //кнопка "декодировать"
        private void DecodeButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                string str1 = InputDecodeTextBox.Text;
                OutputDecodeTextBox.Clear();
                if (str1 == String.Empty)
                {
                    throw new Exception("Пустая входная строка!");
                }

                string a = "";
                for (int i = 0; i < str1.Length; i++)
                {
                    var current = str1[i];
                    if (!char.IsDigit(current) && a == "")
                    {
                        OutputDecodeTextBox.Text += current.ToString();
                    }

                    else if (char.IsDigit(current))
                    {
                        a += current;
                    }
                    else
                    {
                        var count = int.Parse(a);
                        a = "";
                        for (int j = 0; j < count; j++)
                        {
                            OutputDecodeTextBox.Text += current.ToString();
                        }
                    }
                }
                if (a != "")
                {
                    OutputDecodeTextBox.Clear();
                    throw new Exception("Введён некорректный текст!");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }