private ClsPolinom.Polinom PolinomFromTextBlock(TextBlock textBlock) { ClsPolinom.Polinom retPolinom = new ClsPolinom.Polinom(); string strPolinom = ""; // isFunction = true; TextBlock tb = new TextBlock(); foreach (Inline il in tbkPolinom.Inlines) { Run run = new Run(); TextRange tr = new TextRange(il.ContentStart, il.ContentEnd); run.Text = tr.Text; strPolinom += tr.Text; run.BaselineAlignment = il.BaselineAlignment; tb.Inlines.Add(run); } retPolinom = ClsPolinom.Polinom.PolinomFromString(strPolinom); return(retPolinom); }
private void btnPol_Click(object sender, RoutedEventArgs e) { try { string strPolinom = ""; TextBlock tb = new TextBlock(); foreach (Inline il in tbkPolinom.Inlines) { Run run = new Run(); TextRange tr = new TextRange(il.ContentStart, il.ContentEnd); run.Text = tr.Text; strPolinom += tr.Text; run.BaselineAlignment = il.BaselineAlignment; tb.Inlines.Add(run); } if (isFunction == false) { if (modulo == 0) { poli1 = ClsPolinom.Polinom.PolinomFromString(strPolinom); } else { poli1 = ClsPolinom.Polinom.calcPolinomToZp(ClsPolinom.Polinom.PolinomFromString(strPolinom), modulo); } } isFunction = true; lbLog.Items.Add(tb); // } } catch (Exception ex) { } }
private void equal_Click(object sender, RoutedEventArgs e) { try { if (poli1 != null) { string strPolinom = ""; isFunction = true; TextBlock tb = new TextBlock(); foreach (Inline il in tbkPolinom.Inlines) { Run run = new Run(); TextRange tr = new TextRange(il.ContentStart, il.ContentEnd); run.Text = tr.Text; strPolinom += tr.Text; run.BaselineAlignment = il.BaselineAlignment; tb.Inlines.Add(run); } if (modulo == 0) { poli2 = ClsPolinom.Polinom.PolinomFromString(strPolinom); } else { poli2 = ClsPolinom.Polinom.calcPolinomToZp(ClsPolinom.Polinom.PolinomFromString(strPolinom), modulo); } lbLog.Items.Add(tb); } lbLog.Items.Add(new TextBlock(new Run("="))); switch (actFunction) { case '+': resPoli = poli1 + poli2; break; case '-': resPoli = poli1 - poli2; break; case '*': resPoli = poli1 * poli2; break; case '/': resPoli = poli1 / poli2; break; case '%': resPoli = poli1 % poli2; break; } if (modulo != 0) { resPoli = ClsPolinom.Polinom.calcPolinomToZp(resPoli, modulo); } displayPolinom(resPoli); tbkPolinom.Inlines.Clear(); isFunction = false; isExponent = false; } catch (Exception ex) { MessageBox.Show(ex.Message); } }