private void Cell_TextChanged(object sender, TextChangedEventArgs e) { TextBox textBox = (TextBox)sender; string text = textBox.Text; try { Complex parsed = ComplexUtils.Parse(text); int i = Grid.GetRow(textBox) - 1; int j = Grid.GetColumn(textBox) - 1; Filter[i, j] = parsed; if (parsed == 0) { textBox.Background = COLOR_EMPTY; } else { textBox.Background = COLOR_VALUE; } } catch { textBox.Background = COLOR_ERROR; } }
private FormulaSlot AddSlot(int K, int N) { FormulaSlot slot = new FormulaSlot(this, K, N, elemPanel); Formulas.Add(slot); DependencyNode newNode = new DependencyNode($"P({K},{N})", slot.Input); newNode.ValueChanged += (value) => slot.Result.Text = ComplexUtils.ToNiceString(value); Dependencies.Add(newNode); return(slot); }
public void UpdateFromGrid() { int fullSize = cells.GetLength(0); Complex[,] P = new Complex[fullSize, fullSize]; for (int i = 0; i < fullSize; i++) { for (int j = 0; j < fullSize; j++) { P[i, j] = ComplexUtils.Parse(cells[i, j].Text); } } Filter = new Filter(P); }
private void BuildSolver() { SolutionInput input = BuildInput(); Filter P = input.Filter; Solver newSolver; string errorElem = ""; try { int n = P.Size; errorElem = "D"; double D = double.Parse(input.D); errorElem = "A0"; Complex A0 = ComplexUtils.Parse(input.A_0); errorElem = "K"; double K = double.Parse(input.K); errorElem = "T"; double T = double.Parse(input.T); errorElem = "M"; int M = int.Parse(input.t_count); errorElem = "N"; int N = int.Parse(input.x_count); double chi = Solver.GetChi(K, P[n, n], A0); Dependencies.Set(MathAliases.ConvertName("chi"), chi); errorElem = "u0"; IExpression expr = MainParser.Parse(input.u_0); textBlock_u0.Text = "u0 = " + expr.AsString(); string[] deps = MainParser.GetDependencies(expr); double[] u0 = MainParser.EvalArrayD(expr, Dependencies, deps, "x", 2 * Math.PI, N); errorElem = "solver"; newSolver = new Solver(P, T, N, M); ModelParams param = new ModelParams(A0, K, u0, D); newSolver.SetParams(param); curSolver = newSolver; } catch (Exception ex) { Logger.Write(errorElem + ": " + ex.Message); return; } }
public void Set(Complex[,] P) { int fullSize = P.GetLength(0); int size = (fullSize - 1) / 2; sizeInput.Text = size.ToString(); // cause Update() if (Size != size) { Update(size); } foreach (UIElement elem in matrixPanel.Children) { int i = Grid.GetRow(elem) - 1; int j = Grid.GetColumn(elem) - 1; if (elem is TextBox && 0 <= i && i < fullSize && 0 <= j && j < fullSize) { ((TextBox)elem).Text = ComplexUtils.ToNiceString(P[i, j]); } } Filter = new Filter(P); }