Exemple #1
0
        /// <summary>
        /// Gets the distance position of the entity preceeding a given point. If the point
        /// is in between entities the starting point of the matching entity
        /// is returned.
        /// </summary>
        /// <param name="point">The point.</param>
        /// <returns>The distance position.</returns>
        public double GetPreviousScrollValue(double point)
        {
            double offset = trackDCC.GetCumulatedDistanceAt(start);
            double d      = trackDCC.GetPreviousScrollValue(point + offset);

            if (double.IsNaN(d) || d < offset || d - offset > TotalDistance)
            {
                return(double.NaN);
            }
            return(d - offset);
        }
Exemple #2
0
        /// <summary>
        /// Gets the distance position of the entity preceeding a given point. If the point
        /// is in between entities the starting point of the matching entity
        /// is returned.
        /// </summary>
        /// <param name="point">The point.</param>
        /// <returns>The distance position.</returns>
        public double GetPreviousScrollValue(double point)
        {
            int    index       = IndexOfCumulatedDistance(point);
            double nestedStart = GetCumulatedDistanceAt(index);
            double delta       = point - nestedStart;

            if (delta > 0)
            {
                IDistanceCounterCollection nestedDcc = GetNestedDistances(index);
                if (nestedDcc != null)
                {
                    double r = nestedDcc.GetPreviousScrollValue(delta);
                    if (!double.IsNaN(r) && r >= 0 && r < nestedDcc.TotalDistance)
                    {
                        return(nestedStart + r);
                    }
                }

                return(GetCumulatedDistanceAt(index));
            }

            index = GetPreviousVisibleIndex(index);

            if (index >= 0 && index < Count)
            {
                nestedStart = GetCumulatedDistanceAt(index);

                IDistanceCounterCollection nestedDcc = GetNestedDistances(index);
                if (nestedDcc != null)
                {
                    //WPF-29115 - We have set the DetailsViewPadding, the TotalDistance is calculated based in padding,
                    //but we have calculated the index divided the TotalDistance by DefalultLine size so index should be wrong.
                    //So before processing the calculation minus the paddingDistance.
                    delta = nestedDcc.TotalDistance - (nestedDcc as DistanceRangeCounterCollection).paddingDistance;
                    double r = nestedDcc.GetPreviousScrollValue(delta);
                    if (!double.IsNaN(r) && r >= 0 && r < nestedDcc.TotalDistance)
                    {
                        return(nestedStart + r);
                    }
                }

                return(nestedStart);
            }

            return(double.NaN);
        }
        /// <summary>
        /// Gets the distance position of the entity preceeding a given point. If the point
        /// is in between entities the starting point of the matching entity
        /// is returned.
        /// </summary>
        /// <param name="point">The point.</param>
        /// <returns>The distance position.</returns>
        public double GetPreviousScrollValue(double point)
        {
            int    index       = IndexOfCumulatedDistance(point);
            double nestedStart = GetCumulatedDistanceAt(index);
            double delta       = point - nestedStart;

            if (delta > 0)
            {
                IDistanceCounterCollection nestedDcc = GetNestedDistances(index);
                if (nestedDcc != null)
                {
                    double r = nestedDcc.GetPreviousScrollValue(delta);
                    if (!double.IsNaN(r) && r >= 0 && r < nestedDcc.TotalDistance)
                    {
                        return(nestedStart + r);
                    }
                }

                return(GetCumulatedDistanceAt(index));
            }

            index = GetPreviousVisibleIndex(index);

            if (index >= 0 && index < Count)
            {
                nestedStart = GetCumulatedDistanceAt(index);

                IDistanceCounterCollection nestedDcc = GetNestedDistances(index);
                if (nestedDcc != null)
                {
                    delta = nestedDcc.TotalDistance;
                    double r = nestedDcc.GetPreviousScrollValue(delta);
                    if (!double.IsNaN(r) && r >= 0 && r < nestedDcc.TotalDistance)
                    {
                        return(nestedStart + r);
                    }
                }

                return(nestedStart);
            }

            return(double.NaN);
        }