private void ComplexEdit(object sender, TextChangedEventArgs e) { if (!_cantrigger) { return; } try { var tb = sender as TextBox; switch (tb.Name) { case "TbRealValue": case "TbImaginaryValue": var cmp = Complex; _cantrigger = false; TbAbs.Text = cmp.Magnitude.ToString(); TbAngle.Text = TrigFunctions.ArcTan(cmp.Imaginary / cmp.Real).ToString(); _cantrigger = true; break; case "TbAbs": case "TbAngle": var cmplx = TypeFunctions.CplxPolar(Convert.ToDouble(TbAbs.Text), Convert.ToDouble(TbAngle.Text)); _cantrigger = false; TbRealValue.Text = cmplx.Real.ToString(); TbImaginaryValue.Text = cmplx.Imaginary.ToString(); _cantrigger = true; break; } } catch (Exception) { _cantrigger = true; } }