[chronojump] Encoder extra mass fixes problems if introduced mass is above max
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] Encoder extra mass fixes problems if introduced mass is above max
- Date: Mon, 5 Mar 2018 11:10:33 +0000 (UTC)
commit 23a61b27535af438dc74b4ed53d36670f979e530
Author: Xavier de Blas <xaviblas gmail com>
Date: Mon Mar 5 12:09:44 2018 +0100
Encoder extra mass fixes problems if introduced mass is above max
glade/app1.glade | 6 ++++++
src/gui/encoder.cs | 25 ++++++++++++++++++++++---
2 files changed, 28 insertions(+), 3 deletions(-)
---
diff --git a/glade/app1.glade b/glade/app1.glade
index f77e908..313b955 100644
--- a/glade/app1.glade
+++ b/glade/app1.glade
@@ -1601,6 +1601,9 @@
<placeholder/>
</child>
<child>
+ <placeholder/>
+ </child>
+ <child>
<widget class="GtkLabel"
id="label_start_selector_jumps">
<property name="visible">True</property>
<property name="can_focus">False</property>
@@ -23027,6 +23030,9 @@ then click this button.</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
<packing>
<property name="expand">False</property>
diff --git a/src/gui/encoder.cs b/src/gui/encoder.cs
index 4f460b9..c9845ca 100644
--- a/src/gui/encoder.cs
+++ b/src/gui/encoder.cs
@@ -1010,12 +1010,31 @@ public partial class ChronoJumpWindow
void on_entry_raspberry_extra_weight_changed (object o, EventArgs args)
{
if(entry_raspberry_extra_weight.Text == "" || entry_raspberry_extra_weight.Text == "00")
+ {
+ //if introduced data is empty: leave empty
entry_raspberry_extra_weight.Text = "0";
- else if(Util.IsNumber(entry_raspberry_extra_weight.Text, false)) //cannot be decimal
- spin_encoder_extra_weight.Value = Convert.ToInt32(entry_raspberry_extra_weight.Text);
- else
+ }
+ else if(! Util.IsNumber(entry_raspberry_extra_weight.Text, false)) //cannot be decimal
+ {
+ //if introduced data is not number: put old data
entry_raspberry_extra_weight.Text = spin_encoder_extra_weight.Value.ToString();
+ }
+ else {
+ //everything is ok: put new data
+ //but if weight is out of range, use min or max
+ int weight = Convert.ToInt32(entry_raspberry_extra_weight.Text);
+ double min = 0;
+ double max = 0;
+ spin_encoder_extra_weight.GetRange(out min, out max);
+ if(weight < min)
+ entry_raspberry_extra_weight.Text = min.ToString();
+ else if(weight > max)
+ entry_raspberry_extra_weight.Text = max.ToString();
+ else
+ spin_encoder_extra_weight.Value = weight;
+ }
+ //update top label
label_encoder_top_extra_mass.Text = entry_raspberry_extra_weight.Text + " Kg";
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]