本文整理汇总了C#中Range.ToDateTimeRange方法的典型用法代码示例。如果您正苦于以下问题:C# Range.ToDateTimeRange方法的具体用法?C# Range.ToDateTimeRange怎么用?C# Range.ToDateTimeRange使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Range
的用法示例。
在下文中一共展示了Range.ToDateTimeRange方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetPlotAreaCoordinate
/// <summary>
/// Returns the plot area coordinate of a value.
/// </summary>
/// <param name="value">The value to plot.</param>
/// <param name="currentRange">The range to use determine the coordinate.</param>
/// <param name="length">The length of the axis.</param>
/// <returns>The plot area coordinate of a value.</returns>
protected override UnitValue GetPlotAreaCoordinate(object value, Range<IComparable> currentRange, double length)
{
return GetPlotAreaCoordinate(value, currentRange.ToDateTimeRange(), length);
}
示例2: OverrideDataRange
protected override Range<IComparable> OverrideDataRange(Range<IComparable> range)
{
Range<IComparable> overriddenActualRange = range;
if (!overriddenActualRange.HasData)
{
int year = DateTime.Now.Year;
return new Range<IComparable>(new DateTime(year, 1, 1), new DateTime(year + 1, 1, 1));
}
// ActualLength of 1.0 or less maps all points to the same coordinate
if (range.HasData && this.ActualLength > 1.0)
{
IList<ValueMarginCoordinateAndOverlap> valueMargins = new List<ValueMarginCoordinateAndOverlap>();
foreach (ValueMargin valueMargin in
this.RegisteredListeners
.OfType<IValueMarginProvider>()
.SelectMany(provider => provider.GetValueMargins(this)))
{
valueMargins.Add(
new ValueMarginCoordinateAndOverlap
{
ValueMargin = valueMargin,
});
}
if (valueMargins.Count > 0)
{
double maximumPixelMarginLength =
valueMargins
.Select(valueMargin => valueMargin.ValueMargin.LowMargin + valueMargin.ValueMargin.HighMargin)
.MaxOrNullable().Value;
// Requested margin is larger than the axis so give up
// trying to find a range that will fit it.
if (maximumPixelMarginLength > this.ActualLength)
{
return range;
}
Range<DateTime> currentRange = range.ToDateTimeRange();
// Ensure range is not empty.
if (currentRange.Minimum == currentRange.Maximum)
{
int year = DateTime.Now.Year;
currentRange = new Range<DateTime>(new DateTime(year, 1, 1), new DateTime(year + 1, 1, 1));
}
// priming the loop
double actualLength = this.ActualLength;
ValueMarginCoordinateAndOverlap maxLeftOverlapValueMargin;
ValueMarginCoordinateAndOverlap maxRightOverlapValueMargin;
UpdateValueMargins(valueMargins, currentRange.ToComparableRange());
GetMaxLeftAndRightOverlap(valueMargins, out maxLeftOverlapValueMargin, out maxRightOverlapValueMargin);
while (maxLeftOverlapValueMargin.LeftOverlap > 0 || maxRightOverlapValueMargin.RightOverlap > 0)
{
long unitOverPixels = currentRange.GetLength().Value.Ticks / ((long) actualLength);
DateTime newMinimum = new DateTime(currentRange.Minimum.Ticks - (long)((maxLeftOverlapValueMargin.LeftOverlap + 0.5) * unitOverPixels));
DateTime newMaximum = new DateTime(currentRange.Maximum.Ticks + (long)((maxRightOverlapValueMargin.RightOverlap + 0.5) * unitOverPixels));
currentRange = new Range<DateTime>(newMinimum, newMaximum);
UpdateValueMargins(valueMargins, currentRange.ToComparableRange());
GetMaxLeftAndRightOverlap(valueMargins, out maxLeftOverlapValueMargin, out maxRightOverlapValueMargin);
}
return currentRange.ToComparableRange();
}
}
return range;
}
示例3: OnActualRangeChanged
/// <summary>
/// Updates the typed actual maximum and minimum properties when the
/// actual range changes.
/// </summary>
/// <param name="range">The actual range.</param>
protected override void OnActualRangeChanged(Range<IComparable> range)
{
ActualDateTimeRange = range.ToDateTimeRange();
if (range.HasData)
{
this.ActualMaximum = (DateTime)range.Maximum;
this.ActualMinimum = (DateTime)range.Minimum;
}
else
{
this.ActualMaximum = null;
this.ActualMinimum = null;
}
base.OnActualRangeChanged(range);
}