コード例 #1
0
ファイル: ScrollTip.cs プロジェクト: waffle-iron/nequeo
        private void DragScrollBegin(Orientation orientation)
        {
            if (!this.ShouldDisplayScrollTip)
            {
                return;
            }

            DataGridContext dataGridContext = DataGridControl.GetDataGridContext(this);

            if (dataGridContext == null)
            {
                return;
            }

            if (dataGridContext.DataGridControl == null)
            {
                return;
            }

            // Update items scrolling orientation and pixel scrolling
            m_itemsScrollingOrientation = ScrollViewerHelper.GetItemScrollingOrientation(dataGridContext.DataGridControl);

            if (m_itemsScrollingOrientation != orientation)
            {
                return;
            }

            this.Visibility = Visibility.Visible;

            this.IsPixelScrolling = ScrollViewerHelper.IsPixelScrolling(dataGridContext.DataGridControl, dataGridContext.DataGridControl.ItemsHost, dataGridContext.DataGridControl.ScrollViewer);

            this.RefreshScrollTipContent(m_scrollViewerTemplateHelper.GetScrollBar(orientation));
        }
コード例 #2
0
        public static FrameworkElement GetLastVisibleContainer(
            DataGridControl gridControl,
            FrameworkElement container,
            ScrollViewer scrollViewer)
        {
            FrameworkElement retval = null;

            if (ScrollViewerHelper.IsPixelScrolling(gridControl, container, scrollViewer) == false)
            {
                //This means that the panel is performing Item Scrolling

                //if the panel is Vertically scrolling the items (means the Horizontal Axis is Pixel scrolling)
                if (ScrollViewerHelper.GetItemScrollingOrientation(gridControl, container, scrollViewer) == Orientation.Vertical)
                {
                    retval = ScrollViewerHelper.ProcessLastVisibleContainer(gridControl,
                                                                            scrollViewer.VerticalOffset,
                                                                            scrollViewer.ViewportHeight,
                                                                            scrollViewer.HorizontalOffset,
                                                                            scrollViewer.ViewportWidth,
                                                                            Orientation.Vertical);
                }
                //the panel is Horizontally scrolling the items (means the Vertically Axis is Pixel scrolling)
                else
                {
                    retval = ScrollViewerHelper.ProcessLastVisibleContainer(gridControl,
                                                                            scrollViewer.HorizontalOffset,
                                                                            scrollViewer.ViewportWidth,
                                                                            scrollViewer.VerticalOffset,
                                                                            scrollViewer.ViewportHeight,
                                                                            Orientation.Horizontal);
                }
            }
            else
            {
                Point pt = new Point();

                if ((container is VirtualizingPanel) ||
                    (container is DataGridItemsHost) ||
                    (scrollViewer == null))
                {
                    pt.X = 0;
                    pt.Y = 0;
                }
                else
                {
                    pt.X = scrollViewer.HorizontalOffset;
                    pt.Y = scrollViewer.VerticalOffset;
                }

                Size size = new Size((scrollViewer != null) ? scrollViewer.ViewportWidth : container.ActualWidth,
                                     (scrollViewer != null) ? scrollViewer.ViewportHeight : container.ActualHeight);

                Rect visibleRect = new Rect(pt, size);

                RectangleGeometry geo = new RectangleGeometry(visibleRect);

                lock (ScrollViewerHelper.Current)
                {
                    m_sVisibleChildList.Clear();
                    m_sGridControl = gridControl;

                    VisualTreeHelper.HitTest(container,
                                             new HitTestFilterCallback(ScrollViewerHelper.MyFilterFunct),
                                             new HitTestResultCallback(ScrollViewerHelper.UselessResultCallback),
                                             new GeometryHitTestParameters(geo));

                    m_sGridControl = null;

                    FrameworkElement  preservedChild  = null;
                    Nullable <Vector> preservedOffset = null;

                    foreach (FrameworkElement child in m_sVisibleChildList)
                    {
                        Vector itemOffset = VisualTreeHelper.GetOffset(child);

                        Rect itemRect = new Rect(itemOffset.X, itemOffset.Y, child.ActualWidth, child.ActualHeight);

                        itemRect.Intersect(visibleRect);

                        switch (gridControl.ItemsPrimaryAxis)
                        {
                        case PrimaryAxis.Vertical:
                            if (DoubleUtil.AreClose(itemRect.Width, 0) == false)
                            {
                                if (DoubleUtil.AreClose(itemRect.Height, child.ActualHeight) == true)
                                {
                                    if (ScrollViewerHelper.IsABetterLastRow(preservedChild, preservedOffset, itemOffset) == true)
                                    {
                                        preservedChild  = child;
                                        preservedOffset = itemOffset;
                                    }
                                }
                            }
                            break;

                        case PrimaryAxis.Horizontal:
                            if (DoubleUtil.AreClose(itemRect.Width, child.ActualWidth) == true)
                            {
                                if (DoubleUtil.AreClose(itemRect.Height, 0) == false)
                                {
                                    if (ScrollViewerHelper.IsABetterLastRow(preservedChild, preservedOffset, itemOffset) == true)
                                    {
                                        preservedChild  = child;
                                        preservedOffset = itemOffset;
                                    }
                                }
                            }
                            break;

                        case PrimaryAxis.Both:
                            if ((DoubleUtil.AreClose(itemRect.Width, child.ActualWidth) == true) &&
                                (DoubleUtil.AreClose(itemRect.Height, child.ActualHeight) == true))
                            {
                                if (ScrollViewerHelper.IsABetterLastRow(preservedChild, preservedOffset, itemOffset) == true)
                                {
                                    preservedChild  = child;
                                    preservedOffset = itemOffset;
                                }
                            }
                            break;

                        case PrimaryAxis.None:
                            if (itemRect.IsEmpty == false)
                            {
                                if ((DoubleUtil.AreClose(itemRect.Height, 0) == false) && (DoubleUtil.AreClose(itemRect.Width, 0) == false))
                                {
                                    if (ScrollViewerHelper.IsABetterLastRow(preservedChild, preservedOffset, itemOffset) == true)
                                    {
                                        preservedChild  = child;
                                        preservedOffset = itemOffset;
                                    }
                                }
                            }
                            break;
                        }
                    }

                    retval = preservedChild;
                }//end lock (protection of shared static members with GetFirstVisibleItem() )
            }


            return(retval);
        }