|
16 | 16 | using System.Threading.Tasks;
|
17 | 17 | using System.Timers;
|
18 | 18 | using System.Windows.Forms;
|
| 19 | +using org.mariuszgromada.math.mxparser; |
19 | 20 |
|
20 | 21 | namespace MissionPlanner.GCSViews.ConfigurationView
|
21 | 22 | {
|
@@ -378,8 +379,13 @@ private void Params_CellValueChanged(object sender, DataGridViewCellEventArgs e)
|
378 | 379 | double max = 0;
|
379 | 380 |
|
380 | 381 | var value = (string)Params[e.ColumnIndex, e.RowIndex].Value;
|
| 382 | + value = value.Replace(',', '.'); |
381 | 383 |
|
382 |
| - var newvalue = float.Parse(value.Replace(',', '.'), CultureInfo.InvariantCulture); |
| 384 | + var newvalue = (float) new Expression(value).calculate(); |
| 385 | + if (float.IsNaN(newvalue) || float.IsInfinity(newvalue)) |
| 386 | + { |
| 387 | + throw new Exception(); |
| 388 | + } |
383 | 389 |
|
384 | 390 | var readonly1 = ParameterMetaDataRepository.GetParameterMetaData(
|
385 | 391 | Params[Command.Index, e.RowIndex].Value.ToString(),
|
@@ -420,9 +426,12 @@ private void Params_CellValueChanged(object sender, DataGridViewCellEventArgs e)
|
420 | 426 | }
|
421 | 427 |
|
422 | 428 | Params[e.ColumnIndex, e.RowIndex].Style.BackColor = Color.Green;
|
423 |
| - log.InfoFormat("Queue change {0} = {1}", Params[Command.Index, e.RowIndex].Value, Params[e.ColumnIndex, e.RowIndex].Value); |
424 |
| - _changes[Params[Command.Index, e.RowIndex].Value] = |
425 |
| - float.Parse((((string)Params[e.ColumnIndex, e.RowIndex].Value).Replace(',','.')),CultureInfo.InvariantCulture); |
| 429 | + log.InfoFormat("Queue change {0} = {1} ({2})", Params[Command.Index, e.RowIndex].Value, Params[e.ColumnIndex, e.RowIndex].Value, newvalue); |
| 430 | + _changes[Params[Command.Index, e.RowIndex].Value] = newvalue; |
| 431 | + |
| 432 | + Params.CellValueChanged -= Params_CellValueChanged; |
| 433 | + Params[e.ColumnIndex, e.RowIndex].Value = newvalue; |
| 434 | + Params.CellValueChanged += Params_CellValueChanged; |
426 | 435 | }
|
427 | 436 | catch (Exception)
|
428 | 437 | {
|
|
0 commit comments