private void OnUnitInput(object o, InputArgs args) { SpinButton spin = (SpinButton) o; try { args.NewValue = UnitConversions.LengthToMm(spin.Text); } catch (FormatException) { args.NewValue = 0.0; } args.RetVal = 1; }
private void OnWarrantyInput(object o, InputArgs args) { SpinButton spin = (SpinButton) o; if(spin.Text == "∞" || spin.Text == "infinite"){ args.NewValue = -1; args.RetVal = 1; } else OnRelativeTimeSpanInput(o,args); }
public static void OnTimeInput (object o, InputArgs args) { SpinButton spinButton = o as SpinButton; try { args.NewValue = TimeTextToMilliseconds(spinButton.Text); } catch (Exception) { args.NewValue = spinButton.Value; } args.RetVal = 1; }
private void OnRelativeTimeSpanInput(object o, InputArgs args){ SpinButton spin = (SpinButton) o; double val; try { if(spin.Text == "") val = 0; else val = RelativeTimeSpan.Parse(spin.Text).Months; } catch { val = spin.Value; } args.NewValue = val; args.RetVal = 1; }
/* These functions are used by glade that gets them using reflection. * Therefore the warning that the function is not used is disabled. */ #pragma warning disable 169 private void OnCreateIdInput(object o, InputArgs args) { SpinButton spin = (SpinButton)o; uint id; if(spin.Text == "") args.NewValue = 0; else if( uint.TryParse(spin.Text,out id) && !Items.IsIdUsed(id)) // if the id is readable and unused args.NewValue = id; else // don't alter the spin buttons value if id is not an int or used args.NewValue = spin.Value; args.RetVal = 1; }