/// <summary> /// Обработчик ввода номера с клавиатуры /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void txtNum_TextChanged(object sender, TextChangedEventArgs e) { if (txtNum == null) { return; } double typedInteger = 0; int initialCursorPos = txtNum.CaretIndex; if (double.TryParse(txtNum.Text, out typedInteger) || String.IsNullOrEmpty(txtNum.Text)) { NumValue = typedInteger; } else { txtNum.Text = NumValue.ToString(Formatting);//Вернуть прежнюю строку } //при этом нужно сохранить положение курсора если оно по какой-то причине сбросилось if (txtNum.CaretIndex < initialCursorPos) { txtNum.CaretIndex = initialCursorPos; } }
public void TestPairs() { NumValue valueTwo = new NumValue(2); Value pair = new PairValue <NumValue, NumValue>(valueTwo, valueTwo); Assert.AreEqual("< 2 , 2 >", pair.ToString()); Expression test = new PairExpression <NumExpression, NumExpression>(two, two); Assert.AreEqual("< 2 , 2 >", testAsync(test, 500).Result); var trueTest = new PairExpression <LogicExpression, LogicExpression>(logicTrue, logicTrue); Assert.AreEqual("< True , True >", testAsync(trueTest, 500).Result); var loopTest = new PairExpression <LogicExpression, LogicExpression>(logicLoop, logicTrue); Assert.AreEqual(False, testAsync(loopTest, 500).Result); var pairTest = new LogicProjL(trueTest); Assert.AreEqual(True, testAsync(pairTest, 500).Result); var pairLoop = new LogicProjR(loopTest); Assert.AreEqual(True, testAsync(pairLoop, 500).Result); var pairLoop2 = new LogicProjL(loopTest); Assert.AreEqual(Loop, testAsync(pairLoop2, 500).Result); }
private void txtNum_TextChanged(object sender, TextChangedEventArgs e) { if (txtNum == null) { return; } int numValue; if (!int.TryParse(txtNum.Text, out numValue)) { NumValue = numValue; txtNum.Text = NumValue.ToString(); } }
public async Task <Value> Visit <A>(IRecExpression <A> rec) where A : Expression { // A rec has an input, a start, and a step, which itself has two free vars // The idea is to find out what value the input is. // if it is zero we return the start // otherwise we evaluate the rec with an input one less, then put this through the step Value input = await Run(rec.Input); // we need this if (input is NumValue) { NumValue num = input as NumValue; if (num.Value == 0) { return(await Run(rec.Start)); } else { // this looks bad. Fix it int predecessor = num.Value - 1; NumValue newNum = new NumValue(predecessor); VariableSubstituter substNum = new VariableSubstituter(rec.NumVariableName, new NumConstant(predecessor)); Expression newRec = rec.Construct(new NumConstant(predecessor), rec.Start, rec.NumVariableName, rec.AccVariableName, rec.Step); VariableSubstituter substAcc = new VariableSubstituter(rec.AccVariableName, newRec); Expression temp = substNum.Substitute(rec.Step); Expression temp2 = substAcc.Substitute(temp); return(await Run(temp2)); } } else { throw new ArgumentException("In rec the input should evaluate to a Num"); } throw new NotImplementedException(); }
public NumericUpDown() { InitializeComponent(); txtNum.Text = NumValue.ToString(); }
public NumericUpDownControl() { InitializeComponent(); txtNum.Text = NumValue.ToString(Formatting); }
public override string ToString() { return(NumValue.ToString()); }
public IntUpDown() { InitializeComponent(); _textBox.Text = NumValue.ToString(); }