private void InitCommands() { ShowLayerDetailsCommand = new ShowLayerDetailsCommand(this); CalculateCommand = new CalculateCommand(this); DeleteLayerCommand = new DeleteLayerCommand(this); MoveLayerCommand = new MoveLayerCommand(this); }
public void Compute(char @operator, int operand) { ICommand command = new CalculateCommand(calculator, @operator, operand); command.Execute(); _commands.Add(command); _current++; }
public void Compute(Operations @operator, int operand) { ICommand command = new CalculateCommand(_calculator, @operator, operand); command.Execute(); _commands.Add(command); _commandIndex++; }
public ShellViewModel(IDatesRangeHelper dateRangeHelper, ICurrenciesListHelper currenciesListHelper, IRateHelper rateHelper) { _datesRangeHelper = dateRangeHelper; _currenciesListHelper = currenciesListHelper; _rateHelper = rateHelper; Calculate = new CalculateCommand(Calculator); CallGetRateAsync = new GetRateCommand(GetRateAsync, GetRateAsyncCanExecute); }
public async Task <ActionResult <IEnumerable <ParameterResource> > > Calculate(long scriptId, [FromBody] List <ParameterResource> userParameters, string lang = TranslationService.DefaultLanguageCode) { var command = new CalculateCommand { ScriptId = scriptId, LanguageCode = lang, InputData = userParameters, }; return(Ok(await Mediator.Send(command))); }
public List <ParameterResource> Calculate(long scriptId, ICollection <ParameterResource> parametersForCalculation) { var request = new CalculateCommand { ScriptId = scriptId, InputData = parametersForCalculation, LanguageCode = "empty" }; var results = CalculateCommand.Handle(request, CancellationToken.None).Result.ToList(); return(results); }
private void ResetAllInputValues() { _isPlanUpdating = true; foreach (var p in Payments) { // we mark all items as autogenerated to remove user overrides. // This will lead the calculation to ignore the user values and to use the calculated ones. p.Payment = new Currency(p.Payment); p.UnscheduledRepayment = new Currency(p.UnscheduledRepayment); } _isPlanUpdating = false; CalculateCommand.Execute(); }
public void CalculateCommand_WhenValidDataValueExists_ReturnsExpectedTotal() { //Arrange var stubFileRepo = new StubFileRepository(); string fileContent = "3, 5"; string expectedTotal = "8"; var model = new FileDataViewModel(stubFileRepo) { FileContent = fileContent }; var command = new CalculateCommand(); //Act command.Execute(model); //Assert Assert.AreEqual(expectedTotal, model.TotalValue); }
private void ApplyOnClick(object sender, EventArgs e) { var calculateModel = new CalculateRequest(_duration.Text, _amount.Text, _percent.Text, _type); ShowLoaderInMainThread(); ThreadPool.QueueUserWorkItem(w => { if (calculateModel.IsValid(ShowError)) { var commandDelegate = new CommandDelegate <CalculateResponce>(OnSuccess, ShowError, ShowErrorNotEnternet); var command = new CalculateCommand(LocalDb.Instance, commandDelegate); command.Execute(calculateModel); } DissmissLoaderInMainThread(); }); }
/// <summary> /// Calculates integral with given inputs. /// </summary> private async void ExecuteCalculateCommand(object parameter) { _isCalculating = true; CalculateCommand.RaiseCanExecuteChanged(); // Compiles formula expression and gets function pointer on formula. var cr = await _compiler.Compile(Formula).ConfigureAwait(false); if (cr.Errors.Count == 0) { // f is function pointer. var f = _compiler.GetLambda(cr); Result = await _calculator.Integrate(f, From, To, N); } Application.Current.Dispatcher.Invoke(() => { // Enables "Calculate" button. _isCalculating = false; CalculateCommand.RaiseCanExecuteChanged(); }); }
private void RaiseButtonCanExecute() { ImportCommand.RaiseCanExecuteChanged(); CalculateCommand.RaiseCanExecuteChanged(); ExportCommand.RaiseCanExecuteChanged(); }
private void PaymentViewModel_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { // whenever an item is modified inside we want the complete plan to be recalculated CalculateCommand.Execute(); }