本文整理汇总了C#中Speed.ToUnitType方法的典型用法代码示例。如果您正苦于以下问题:C# Speed.ToUnitType方法的具体用法?C# Speed.ToUnitType怎么用?C# Speed.ToUnitType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Speed
的用法示例。
在下文中一共展示了Speed.ToUnitType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnPaintOffScreen
/// <inheritdocs/>
protected override void OnPaintOffScreen(PaintEventArgs e)
{
PolarGraphics f = CreatePolarGraphics(e.Graphics);
// What altitude are we drawing?
#if PocketPC
Speed SpeedToRender = pSpeed;
#else
Speed speedToRender = new Speed(_valueInterpolator[_interpolationIndex], _pSpeed.Units);
#endif
// Cache drawing intervals and such to prevent a race condition
double minorInterval = _pMinorTickInterval.Value;
double majorInterval = _pMajorTickInterval.Value;
double cachedSpeedLabelInterval = _pSpeedLabelInterval.ToUnitType(_pMaximumSpeed.Units).Value;
Speed maxSpeed = _pMaximumSpeed.Clone();
double minorStep = _pMinorTickInterval.ToUnitType(_pMaximumSpeed.Units).Value;
double majorStep = _pMajorTickInterval.ToUnitType(_pMaximumSpeed.Units).Value;
// Draw tick marks
double angle;
PolarCoordinate start;
PolarCoordinate end;
#region Draw minor tick marks
if (minorInterval > 0)
{
for (double speed = 0; speed < maxSpeed.Value; speed += minorStep)
{
// Convert the speed to an angle
angle = speed * _conversionFactor + _pMinimumAngle.DecimalDegrees;
// Get the coordinate of the line's start
start = new PolarCoordinate(95, angle, Azimuth.South, PolarCoordinateOrientation.Clockwise);
end = new PolarCoordinate(100, angle, Azimuth.South, PolarCoordinateOrientation.Clockwise);
// And draw a line
Pen p = new Pen(_minorTickPenColor);
f.DrawLine(p, start, end);
p.Dispose();
}
}
#endregion
#region Draw major tick marks
if (majorInterval > 0)
{
using (Pen majorPen = new Pen(_majorTickPenColor))
{
for (double speed = 0; speed < maxSpeed.Value; speed += majorStep)
{
// Convert the speed to an angle
angle = speed * _conversionFactor + _pMinimumAngle.DecimalDegrees;
// Get the coordinate of the line's start
start = new PolarCoordinate(90, angle, Azimuth.South, PolarCoordinateOrientation.Clockwise);
end = new PolarCoordinate(100, angle, Azimuth.South, PolarCoordinateOrientation.Clockwise);
// And draw a line
f.DrawLine(majorPen, start, end);
}
#region Draw a major tick mark at the maximum speed
// Convert the speed to an angle
angle = maxSpeed.Value * _conversionFactor + _pMinimumAngle.DecimalDegrees;
// Get the coordinate of the line's start
start = new PolarCoordinate(90, angle, Azimuth.South, PolarCoordinateOrientation.Clockwise);
end = new PolarCoordinate(100, angle, Azimuth.South, PolarCoordinateOrientation.Clockwise);
// And draw a line
f.DrawLine(majorPen, start, end);
#endregion
}
}
#endregion
using (SolidBrush fontBrush = new SolidBrush(_speedLabelBrushColor))
{
if (cachedSpeedLabelInterval > 0)
{
for (double speed = 0; speed < maxSpeed.Value; speed += cachedSpeedLabelInterval)
{
// Convert the speed to an angle
angle = speed * _conversionFactor + _pMinimumAngle.DecimalDegrees;
// And draw a line
f.DrawCenteredString(new Speed(speed, maxSpeed.Units).ToString(_pSpeedLabelFormat, CultureInfo.CurrentCulture), Font, fontBrush,
new PolarCoordinate(75, angle, Azimuth.South, PolarCoordinateOrientation.Clockwise));
}
// Convert the speed to an angle
angle = maxSpeed.Value * _conversionFactor + _pMinimumAngle.DecimalDegrees;
// And draw the speed label
f.DrawCenteredString(maxSpeed.ToString(_pSpeedLabelFormat, CultureInfo.CurrentCulture), Font, fontBrush,
new PolarCoordinate(75, angle, Azimuth.South, PolarCoordinateOrientation.Clockwise));
}
//.........这里部分代码省略.........