本文整理汇总了C#中Distance.Format方法的典型用法代码示例。如果您正苦于以下问题:C# Distance.Format方法的具体用法?C# Distance.Format怎么用?C# Distance.Format使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Distance
的用法示例。
在下文中一共展示了Distance.Format方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CoordSystemForm_Shown
private void CoordSystemForm_Shown(object sender, EventArgs e)
{
CadastralMapModel map = CadastralMapModel.Current;
ISpatialSystem sys = map.SpatialSystem;
systemNameLabel.Text = sys.Name;
epsgNumberLabel.Text = sys.EpsgNumber.ToString();
// Display mean elevation and geoid separation in the current data entry units.
EditingController ec = EditingController.Current;
DistanceUnit eUnit = ec.EntryUnit;
DistanceUnit meters = EditingController.GetUnits(DistanceUnitType.Meters);
// The mean elevation & geoid separation fields are always editable (even
// if the map contains stuff). The values are used to calculate the ground
// area of polygons.
Distance elev = new Distance(sys.MeanElevation.Meters, meters);
meanElevationTextBox.Text = elev.Format(eUnit, true);
Distance sep = new Distance(sys.GeoidSeparation.Meters, meters);
geoidSeparationTextBox.Text = sep.Format(eUnit, true);
}
示例2: InitOp
void InitOp(NewCircleOperation op, bool isUpdate)
{
// Get the center point and display its ID, preceded by a "+" char.
m_Center = op.Center;
centerTextBox.Text = String.Format("+{0}", m_Center.FormattedKey);
// Get the observation that was used to specify the radius.
Observation radius = op.Radius;
// Make a copy of the relevant info, depending on whether the
// radius was entered, or specified as an offset point.
if (radius is OffsetPoint)
{
// Radius was specified as an offset point.
OffsetPoint offset = (radius as OffsetPoint);
m_RadiusPoint = offset.Point;
m_RadiusDistance = null;
// Display the ID of the offset point, preceded with a "+" char.
radiusTextBox.Text = String.Format("+{0}", m_RadiusPoint.FormattedKey);
if (isUpdate)
{
// If there are any incident arcs that were added using
// a NewLineOperation (on the same circle), disallow the
// ability to change the offset point.
// @devnote Long story. In short, if the offset point
// gets changed, the user could move it anywhere, so quite
// a sophisticated UI could be needed to re-define where
// the curves should go (failing that, if you let the user
// change things, one end of the curve moves, but not the
// end that met the offset point => looks bent). This is a
// problem even if the curves have subsequently been
// de-activated.
LineFeature line = op.Line;
Circle circle = line.Circle;
Debug.Assert(circle!=null);
if (circle.HasArcsAt(m_RadiusPoint))
radiusTextBox.Enabled = false;
}
}
else
{
// Radius is (or should be) an entered distance.
m_RadiusPoint = null;
Distance dist = (radius as Distance);
if (dist==null)
{
MessageBox.Show("NewCircleForm.InitOp - Unexpected radius observation.");
return;
}
m_RadiusDistance = new Distance(dist);
// Display the radius (will call OnChangeRadius).
radiusTextBox.Text = m_RadiusDistance.Format();
}
// Ensure points are drawn ok.
PaintAll();
}
示例3: ShowOffset
/// <summary>
/// Displays any offset info for a direction.
/// </summary>
/// <param name="dir">The direction that may have an offset.</param>
void ShowOffset(Direction dir)
{
// Initialize offset-related data members.
m_IsRight = true;
m_OffsetDistance = null;
m_OffsetPoint = null;
// Return if there is no offset.
Offset offset = dir.Offset;
if (offset==null)
return;
// It could be one of 2 types of offset.
if (offset is OffsetDistance)
{
OffsetDistance dist = (offset as OffsetDistance);
// Display the offset distance, in the current data entry units.
// Setting the window text will end up calling OnChangeOffset,
// which calls OnOffsetDistance, where it will be deduced that
// we have an offset to the right. This may or may not be correct.
m_OffsetDistance = dist.Offset;
DistanceUnit entry = EditingController.Current.EntryUnit;
offsetTextBox.Text = m_OffsetDistance.Format(entry, true);
// Override whatever we got above.
m_IsRight = dist.IsRight;
if (m_IsRight)
SetOffsetRight();
else
SetOffsetLeft();
}
else
{
// It SHOULD be an offset point.
OffsetPoint point = (offset as OffsetPoint);
if (point!=null)
{
// Display the ID of the offset point.
m_OffsetPoint = point.Point;
ShowKey(offsetTextBox, m_OffsetPoint);
// Disable (and turn off) the radio buttons to allow right or left specification.
TurnRadioOff(leftRadioButton);
TurnRadioOff(rightRadioButton);
}
else
MessageBox.Show("GetDirectionControl.ShowOffset - Unexpected type of offset.");
}
}
示例4: InitUpdate
void InitUpdate(LineExtensionOperation pop)
{
Form parent = ParentForm;
parent.Text = "Update Line Extension";
m_ExtendLine = pop.ExtendedLine;
m_IsExtendFromEnd = pop.IsExtendFromEnd;
m_Length = new Distance(pop.Length);
// Was an extension line added?
m_WantLine = (pop.NewLine!=null);
// Scroll the entity combo to the previously defined
// entity type for the extension point.
PointFeature point = pop.NewPoint;
IEntity ent = point.EntityType;
if (ent != null)
pointTypeComboBox.SelectEntity(ent);
// Display the original observed length.
lengthTextBox.Text = m_Length.Format();
// Display the point key (if any)
idComboBox.DropDownStyle = ComboBoxStyle.DropDown;
idComboBox.Text = point.FormattedKey;
}
示例5: GetDistance
/// <summary>
/// Gets the distance string to annotate a line with.
/// </summary>
/// <param name="len">The adjusted length (in meters on the ground).</param>
/// <param name="dist">The observed length (if any).</param>
/// <param name="drawObserved">Draw the observed distance?</param>
/// <returns>The distance string (null if the distance is supposed to be the
/// observed distance, but there is no observed distance.</returns>
protected string GetDistance(double len, Distance dist, bool drawObserved)
{
// Return if we are drawing the observed distance, and we don't have one.
if (drawObserved && dist == null)
return null;
// Get the current display units.
EditingController ec = EditingController.Current;
DistanceUnit dunit = ec.DisplayUnit;
string distr = String.Empty;
// If we are drawing the observed distance
if (drawObserved)
{
// Display the units only if the distance does not
// correspond to the current data entry units.
if (dunit.UnitType == DistanceUnitType.AsEntered)
dunit = ec.EntryUnit;
if (!dist.EntryUnit.Equals(dunit))
distr = dist.Format(true); // with units abbreviation
else
distr = dist.Format(false); // no units abbreviation
}
else
{
// Drawing adjusted distance.
// If the current display units are "as entered"
if (dunit.UnitType == DistanceUnitType.AsEntered)
{
// What's the current data entry unit?
DistanceUnit eunit = ec.EntryUnit;
// Display the units only if the distance does not
// correspond to the current data entry units.
if (dist != null)
{
DistanceUnit entryUnit = dist.EntryUnit;
if (entryUnit != eunit)
distr = entryUnit.Format(len, true); // with abbrev
else
distr = entryUnit.Format(len, false); // no abbrev
}
else
{
// No observed length, so format the actual length using
// the current data entry units (no abbreviation).
distr = eunit.Format(len, false);
}
}
else
{
// Displaying in a specific display unit. Format the
// result without any units abbreviation.
distr = dunit.Format(len, false);
}
}
// Never show distances with a leading negative sign.
if (distr.StartsWith("-"))
distr = distr.Substring(1);
return distr;
}
示例6: ShowDistance
/// <summary>
/// Displays info for a specific distance observation.
/// </summary>
/// <param name="from">The point the distance was observed from.</param>
/// <param name="obsv">The distance observation (either a <see cref="Distance"/>,
/// or an <see cref="OffsetPoint"/>)</param>
/// <param name="line">The line to show (null if no line).</param>
void ShowDistance(PointFeature from, Observation obsv, LineFeature line)
{
// If we have an arc, define its entity type and scroll the
// entity combo box to that type. Note that when the string
// is selected, it is important that m_From and m_Distance
// are null; otherwise <mf CdGetDist::OnSelChangeLineType>
// may automatically move on to the next page of the wizard
// dialog.
m_From = null;
m_Distance = null;
m_LineType = null;
if (line!=null)
{
m_LineType = line.EntityType;
lineTypeComboBox.SelectEntity(m_LineType);
}
// Define the from-point of the distance
m_From = from;
fromPointTextBox.Text = m_From.FormattedKey;
// What sort of distance observation do we have?
m_ObservedDistance = null; // m_pDistance
m_DistancePoint = null;
m_Distance = null;
if (obsv is Distance)
{
// Display the distance in the original data entry units.
Distance dist = (obsv as Distance);
m_Distance = new Distance(dist);
distanceTextBox.Text = m_Distance.Format();
// Create the appropriate distance observation (this is what
// gets picked up when we actually go to work out the intersection.
// (was on the last page of the property sheet -- see CdIntersectTwo)
m_ObservedDistance = m_Distance;
}
else
{
// It SHOULD be an offset point.
OffsetPoint off = (obsv as OffsetPoint);
if (off==null)
throw new Exception("GetDistanceControl.ShowDistance - Unexpected type of distance.");
// Get the point involved & display it's ID.
m_DistancePoint = off.Point;
distanceTextBox.Text = m_DistancePoint.FormattedKey;
// Create the appropriate distance observation
m_OffsetPoint = new OffsetPoint(m_DistancePoint);
m_ObservedDistance = m_OffsetPoint;
}
}