private void btnEncodeDecode_Click(object sender, EventArgs e)
{
try
{
Base method = GetMethod();
bool encode = (string)(((Button)sender).Tag) == "encode";
string result;
Stopwatch stopwatch = new Stopwatch();
stopwatch.Start();
result = encode ? method.EncodeString(tbInput.Text) : method.DecodeToString(tbInput.Text);
stopwatch.Stop();
tbOutput.Text = result;
tbTime.Text = stopwatch.Elapsed.ToString();
tbOutputLength.Text = result.Length.ToString();
tbOutputSize.Text = method.Encoding.GetByteCount(result).ToString();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error");
}
}