public bool changedProps(bool report) { lblLower.Visible = txtLower.Visible = chkHasLimits.Checked; lblUpper.Visible = txtUpper.Visible = chkHasLimits.Checked; try { if (this.dof is AngularDOF) { AngularDOF dof = (AngularDOF)this.dof; dof.lowerLimit = chkHasLimits.Checked ? Convert.ToSingle(txtLower.Text) : float.NegativeInfinity; dof.upperLimit = chkHasLimits.Checked ? Convert.ToSingle(txtUpper.Text) : float.PositiveInfinity; } else if (this.dof is LinearDOF) { LinearDOF dof = (LinearDOF)this.dof; dof.lowerLimit = chkHasLimits.Checked ? Convert.ToSingle(txtLower.Text) : float.NegativeInfinity; dof.upperLimit = chkHasLimits.Checked ? Convert.ToSingle(txtUpper.Text) : float.PositiveInfinity; } return(true); } catch (FormatException) { if (report) { System.Windows.Forms.MessageBox.Show("Invalid number format"); } return(false); } }
void loadProps() { if (this.dof is AngularDOF) { AngularDOF dof = (AngularDOF)this.dof; chkHasLimits.Checked = dof.hasAngularLimits(); lblUpper.Visible = lblLower.Visible = txtUpper.Visible = txtLower.Visible = chkHasLimits.Checked; txtLower.Text = Convert.ToString(cacheLower = dof.lowerLimit); txtUpper.Text = Convert.ToString(cacheUpper = dof.upperLimit); lblLower.Text = "Lower (rad)"; lblUpper.Text = "Upper (rad)"; } else if (this.dof is LinearDOF) { LinearDOF dof = (LinearDOF)this.dof; chkHasLimits.Checked = dof.hasUpperLinearLimit() || dof.hasLowerLinearLimit(); lblUpper.Visible = lblLower.Visible = txtUpper.Visible = txtLower.Visible = chkHasLimits.Checked; txtLower.Text = Convert.ToString(cacheLower = dof.lowerLimit); txtUpper.Text = Convert.ToString(cacheUpper = dof.upperLimit); lblLower.Text = "Lower (cm)"; lblUpper.Text = "Upper (cm)"; } }
public void resetProps() { if (this.dof is AngularDOF) { AngularDOF dof = (AngularDOF)this.dof; dof.lowerLimit = cacheLower; dof.upperLimit = cacheUpper; } else if (this.dof is LinearDOF) { LinearDOF dof = (LinearDOF)this.dof; dof.lowerLimit = cacheLower; dof.upperLimit = cacheUpper; } }
public static bool hasAngularLimits(this AngularDOF dof) { return(!float.IsPositiveInfinity(dof.upperLimit) || !float.IsNegativeInfinity(dof.lowerLimit)); }