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 Remove(int K, int N) { Dependencies.Remove($"P({K},{N})"); for (int i = 0; i < Formulas.Count; i++) { FormulaSlot slot = Formulas[i]; if (slot.K == K && slot.N == N) { Formulas.RemoveAt(i); slot.Remove(); CheckIndices(); return; } } }
public void Deserialize(string s) { for (int i = Formulas.Count - 1; i >= 0; i--) { FormulaSlot slot = Formulas[i]; Remove(slot.K, slot.N); } var l = s.Split('@'); for (int i = 0; i + 2 < l.Length; i += 3) { int K, N; if (!int.TryParse(l[i], out K) || !int.TryParse(l[i + 1], out N)) { continue; } string text = l[i + 2]; var slot = AddSlot(K, N); slot.Input.Text = text; } }