Esempio n. 1
0
        /// <summary>
        /// Returns the first and last point for the given lines in a region.
        /// </summary>
        /// <param name="region">The region.</param>
        /// <param name="first">The index of the first line.</param>
        /// <param name="last">The index of the last line.</param>
        /// <param name="allowEstimatesForOutOfViewLines">if set to <c>true</c> allow estimates for out of view lines.</param>
        /// <returns></returns>
        public override DoubleSpan RangeToPoints(ScrollAxisRegion region, int first, int last, bool allowEstimatesForOutOfViewLines)
        {
            VisibleLinesCollection lines = GetVisibleLines();

            // If line is visible use already calculated values,
            // otherwise get value from Distances
            VisibleLineInfo line1 = lines.GetVisibleLineAtLineIndex(first);
            VisibleLineInfo line2 = lines.GetVisibleLineAtLineIndex(last);

            double p1, p2;

            p1 = line1 == null?Distances.GetCumulatedDistanceAt(first) : GetCumulatedOrigin(line1);

            p2 = line2 == null?Distances.GetCumulatedDistanceAt(last + 1) : GetCumulatedCorner(line2);

            return(RangeToPointsHelper(region, p1, p2));
        }
Esempio n. 2
0
        private DoubleSpan RangeToPointsHelper(ScrollAxisRegion region, double p1, double p2)
        {
            VisibleLinesCollection lines = GetVisibleLines();

            switch (region)
            {
            case ScrollAxisRegion.Header:
                if (HeaderLineCount > 0)
                {
                    return(new DoubleSpan(p1, p2));
                }
                else
                {
                    return(DoubleSpan.Empty);
                }

            case ScrollAxisRegion.Footer:
                if (IsFooterVisible)
                {
                    VisibleLineInfo l  = lines[lines.FirstFooterVisibleIndex];
                    double          p3 = Distances.TotalDistance - this.FooterExtent;
                    p1 += l.Origin - p3;
                    p2 += l.Origin - p3;
                    return(new DoubleSpan(p1, p2));
                }
                else
                {
                    return(DoubleSpan.Empty);
                }

            case ScrollAxisRegion.Body:
                p1 += HeaderExtent - ScrollBar.Value;
                p2 += HeaderExtent - ScrollBar.Value;
                return(new DoubleSpan(p1, p2));
            }

            return(DoubleSpan.Empty);
        }
Esempio n. 3
0
        protected override DropPosition GetDropPosition(DragEventArgs args, RowColumnIndex rowColumnIndex)
        {
            bool             canDrop       = true;
            var              p             = args.GetPosition(this.TreeGrid);
            var              treeNode      = this.TreeGrid.GetNodeAtRowIndex(rowColumnIndex.RowIndex);
            ScrollAxisRegion columnRegion  = ScrollAxisRegion.Body;
            var              treeGridPanel = TreeGrid.GetTreePanel();

            if (treeGridPanel.FrozenColumns > 0)
            {
                columnRegion = ScrollAxisRegion.Header;
            }
            var rowRect = treeGridPanel.RangeToRect(ScrollAxisRegion.Body, columnRegion, rowColumnIndex, true, false);
            var node    = treeNode;

            if (!canDrop)
            {
                return(DropPosition.None);
            }
            else if (p.Y > rowRect.Y + 15 && p.Y < rowRect.Y + 35)
            {
                return(DropPosition.DropAsChild);
            }
            else if (p.Y < rowRect.Y + 15)
            {
                return(DropPosition.DropAbove);
            }
            else if (p.Y > rowRect.Y + 35)
            {
                return(DropPosition.DropBelow);
            }
            else
            {
                return(DropPosition.Default);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Gets the dropping position of a dragging row.
        /// </summary>
        /// <param name="args">An <see cref="T:Windows.UI.Xaml.DragEventArgs">DragEventArgs</see> that contains the event data.</param>
        /// <param name="rowColumnIndex">
        /// Specified index on which the mouse is hovered.
        /// </param>
        /// <returns>
        /// Returns appropriate drop position <see cref="Syncfusion.UI.Xaml.TreeGrid.DropPosition"/> if row can drop at the specified index otherwise none.
        /// </returns>
        protected virtual DropPosition GetDropPosition(DragEventArgs args, RowColumnIndex rowColumnIndex)
        {
            bool             canDrop      = true;
            var              p            = args.GetPosition(this.TreeGrid);
            var              treeNode     = this.TreeGrid.GetNodeAtRowIndex(rowColumnIndex.RowIndex);
            ScrollAxisRegion columnRegion = ScrollAxisRegion.Body;

            if (TreeGrid.TreeGridPanel.FrozenColumns > 0)
            {
                columnRegion = ScrollAxisRegion.Header;
            }
            var rowRect = this.TreeGrid.TreeGridPanel.RangeToRect(ScrollAxisRegion.Body, columnRegion, rowColumnIndex, true, false);
            var node    = treeNode;
            var nodes   = GetNodes(args);

            if (nodes != null)
            {
                foreach (var draggingNode in nodes)
                {
                    node = treeNode;
                    while (node != null)
                    {
                        if (node == draggingNode)
                        {
                            canDrop = false;
                            break;
                        }
                        node = node.ParentNode;
                    }
                    if (!canDrop)
                    {
                        break;
                    }
                }
            }

            if (!canDrop)
            {
                return(DropPosition.None);
            }
            else if (p.Y > rowRect.Y + 15 && p.Y < rowRect.Y + 35)
            {
                if (!treeNode.IsExpanded)
                {
                    if (CanAutoExpand)
                    {
                        timer.Interval = autoExpandDelay;
                        timer.Tick    -= Timer_Tick;
                        autoExpandNode = treeNode;
                        StartTimer();
                    }
                }
                return(DropPosition.DropAsChild);
            }
            else if (p.Y < rowRect.Y + 15)
            {
                return(DropPosition.DropAbove);
            }
            else if (p.Y > rowRect.Y + 35)
            {
                return(DropPosition.DropBelow);
            }
            else
            {
                return(DropPosition.Default);
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Returns the first and last point for the given lines in a region.
        /// </summary>
        /// <param name="region">The region.</param>
        /// <param name="first">The index of the first line.</param>
        /// <param name="last">The index of the last line.</param>
        /// <param name="allowEstimatesForOutOfViewLines">if set to <c>true</c> allow estimates for out of view lines.</param>
        /// <returns></returns>
        public override DoubleSpan RangeToPoints(ScrollAxisRegion region, int first, int last, bool allowEstimatesForOutOfViewLines)
        {
            VisibleLinesCollection visibleLines = this.GetVisibleLines();
            bool            firstVisible, lastVisible;
            VisibleLineInfo firstLine, lastLine;

            GetLinesAndVisibility(first, last, true, out firstVisible, out lastVisible, out firstLine, out lastLine);

            if (firstLine == null || lastLine == null)
            {
                return(DoubleSpan.Empty);
            }

            if (allowEstimatesForOutOfViewLines)
            {
                switch (region)
                {
                case ScrollAxisRegion.Header:
                    if (!firstLine.IsHeader)
                    {
                        return(DoubleSpan.Empty);
                    }
                    break;

                case ScrollAxisRegion.Footer:
                    if (!lastLine.IsFooter)
                    {
                        return(DoubleSpan.Empty);
                    }
                    break;

                case ScrollAxisRegion.Body:
                    if (firstLine.IsFooter || lastLine.IsHeader)
                    {
                        return(DoubleSpan.Empty);
                    }
                    break;
                } // switch

                return(new DoubleSpan(firstLine.Origin, lastLine.Corner));
            }
            else
            {
                switch (region)
                {
                case ScrollAxisRegion.Header:
                {
                    if (!firstLine.IsHeader)
                    {
                        return(DoubleSpan.Empty);
                    }

                    if (!lastVisible || !lastLine.IsHeader)
                    {
                        double corner = firstLine.Corner;
                        for (int n = firstLine.LineIndex + 1; n <= last; n++)
                        {
                            corner += GetLineSize(n);
                        }

                        return(new DoubleSpan(firstLine.Origin, corner));
                    }

                    return(new DoubleSpan(firstLine.Origin, lastLine.Corner));
                }

                case ScrollAxisRegion.Footer:
                {
                    if (!lastLine.IsFooter)
                    {
                        return(DoubleSpan.Empty);
                    }

                    if (!firstVisible || !firstLine.IsFooter)
                    {
                        double origin = lastLine.Origin;
                        for (int n = lastLine.LineIndex - 1; n >= first; n--)
                        {
                            origin -= GetLineSize(n);
                        }

                        return(new DoubleSpan(origin, lastLine.Corner));
                    }

                    return(new DoubleSpan(firstLine.Origin, lastLine.Corner));
                }

                case ScrollAxisRegion.Body:
                {
                    if (firstLine.IsFooter || lastLine.IsHeader)
                    {
                        return(DoubleSpan.Empty);
                    }

                    double origin = firstLine.Origin;
                    if (!firstVisible || firstLine.Region != ScrollAxisRegion.Body)
                    {
                        origin = HeaderExtent;
                        for (int n = ScrollLineIndex - 1; n >= first; n--)
                        {
                            origin -= GetLineSize(n);
                        }
                    }

                    double corner = lastLine.Corner;
                    if (!lastVisible || lastLine.Region != ScrollAxisRegion.Body)
                    {
                        corner = LastBodyVisibleLine.Corner;
                        for (int n = LastBodyVisibleLine.LineIndex + 1; n <= last; n++)
                        {
                            corner += GetLineSize(n);
                        }
                    }

                    return(new DoubleSpan(origin, corner));
                }
                } // switch

                return(new DoubleSpan(firstLine.Origin, lastLine.Corner));
            }
        }