public InterceptForm(UnitShape unit, UnitShape target, UnitSystem unitSystem, bool disableControls) : this() { if (target != null) { if (unit != null) { txtBearing.Text = ManeuveringBoard.GetAngleString(ManeuveringBoard.AngleBetween(unit.Position, target.Position)); txtRange.Text = ManeuveringBoard.GetDistanceString((target.Position - unit.Position).Length, unitSystem); txtBearing.Enabled = txtRange.Enabled = !disableControls; txtSpeed.Select(); } txtCourse.Text = ManeuveringBoard.GetAngleString(target.Direction); txtTargetSpeed.Text = ManeuveringBoard.GetSpeedString(target.Speed, unitSystem); txtCourse.Enabled = txtTargetSpeed.Enabled = !disableControls; } if (unit == null) { radVector.Enabled = radWaypoint.Enabled = btnOK.Enabled = false; } this.unit = unit; this.target = target; this.unitSystem = unitSystem; UpdateSolution(); }
public BackgroundScaleForm(double pixels, double meters, UnitSystem unitSystem) : this() { lblPixels.Text = pixels.ToString("0.##") + " pixels represents..."; txtLength.Text = ManeuveringBoard.GetDistanceString(meters, unitSystem); txtLength.Tag = meters; txtLength.WasChanged = false; this.unitSystem = unitSystem; }
void FillRelativeTo(ChangeTrackingTextBox txtBearing, ChangeTrackingTextBox txtDistance, Point2 relativePoint) { double angle = ManeuveringBoard.AngleBetween(relativePoint, posDataPoint.Value); txtBearing.Text = (angle * MathConst.RadiansToDegrees).ToString("0.##"); txtBearing.Tag = angle; double distance = relativePoint.DistanceTo(posDataPoint.Value); txtDistance.Text = ManeuveringBoard.GetDistanceString(distance, unitSystem); txtDistance.Tag = distance; txtBearing.WasChanged = txtDistance.WasChanged = false; }
public ShapeDataForm(Shape shape, UnitSystem unitSystem) : this() { if (shape == null) { throw new ArgumentNullException(); } this.unitSystem = unitSystem; txtName.Text = shape.Name; lblParent.Text = shape.Parent == null ? "<none>" : string.IsNullOrEmpty(shape.Parent.Name) ? "<unnamed shape>" : shape.Parent.Name; UnitShape unit = shape as UnitShape; if (unit != null) { txtSize.Enabled = false; txtDirection.Tag = unit.Direction; txtDirection.Text = (unit.Direction * MathConst.RadiansToDegrees).ToString("0.##"); txtSpeed.Tag = unit.Speed; txtSpeed.Text = ManeuveringBoard.GetSpeedString(unit.Speed, unitSystem); cmbType.SelectedIndex = (int)unit.Type; if (unit.Parent == null) { chkRelative.Enabled = false; } else { chkRelative.Checked = unit.IsMotionRelative; } } else { txtSpeed.Enabled = false; chkRelative.Enabled = false; cmbType.Enabled = false; LineShape line = shape as LineShape; if (line != null) { double angle = ManeuveringBoard.AngleBetween(line.Start, line.End), length = line.Length; txtDirection.Text = (angle * MathConst.RadiansToDegrees).ToString("0.##"); txtDirection.Tag = angle; txtSize.Text = ManeuveringBoard.GetDistanceString(length, unitSystem); txtSize.Tag = length; } else { CircleShape circle = shape as CircleShape; if (circle != null) { txtDirection.Enabled = false; txtSize.Text = ManeuveringBoard.GetDistanceString(circle.Radius, unitSystem); txtSize.Tag = circle.Radius; lblSize.Text = "Radius"; } else { throw new NotImplementedException(); } } } // set these to false, since they may have been set to true by the programmatic changes above directionTextChanged = sizeTextChanged = speedTextChanged = false; }