当前位置: 首页>>代码示例>>C#>>正文


C# Range.ToDateTimeRange方法代码示例

本文整理汇总了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);
 }
开发者ID:shijiaxing,项目名称:SilverlightToolkit,代码行数:11,代码来源:DateTimeAxis.cs

示例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;
        }
开发者ID:kvervo,项目名称:HorizontalLoopingSelector,代码行数:73,代码来源:DateTimeAxis.cs

示例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);
        }
开发者ID:shijiaxing,项目名称:SilverlightToolkit,代码行数:22,代码来源:DateTimeAxis.cs


注:本文中的Range.ToDateTimeRange方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。