public void onDragDelta(object sender, DragDeltaEventArgs e)
        {
            var tvch = TableViewUtils.GetAncestorByType <TableViewColumnHeader>(this);

            if (tvch != null)
            {
                var width = tvch.Width + e.HorizontalChange;
                tvch.AdjustWidth(width);
            }
        }
        internal TableViewColumnHeader GetColumnHeaderAtLocation(Point loc)
        {
            var uie = InputHitTest(loc) as FrameworkElement;

            if (uie != null)
            {
                return(TableViewUtils.FindParent <TableViewColumnHeader>(uie));
            }
            return(null);
        }
        protected override void OnIsItemsHostChanged(bool oldIsItemsHost, bool newIsItemsHost)
        {
            base.OnIsItemsHostChanged(oldIsItemsHost, newIsItemsHost);

            var rowPresenter = TableViewUtils.FindParent <TableViewCellsPresenter>(this);

            if (rowPresenter != null)
            {
                rowPresenter.CellsPanel = this;
                ParentTableView         = rowPresenter.ParentTableView;
                this.Style = ParentTableView.CellsPanelStyle;
            }
        }
Ejemplo n.º 4
0
        public override void MeasureChild(Android.Views.View child, int widthUsed, int heightUsed)
        {
            int columnPosition = GetPosition(child);
            // Get cached width size of column and cell
            int cacheWidth       = mCellLayoutManager.GetCacheWidth(mYPosition, columnPosition);
            int columnCacheWidth = mColumnHeaderLayoutManager.GetCacheWidth(columnPosition);

            // Already each of them is same width size.
            if (cacheWidth != -1 && cacheWidth == columnCacheWidth)
            {
                // Control whether we need to set width or not.
                if (child.MeasuredWidth != cacheWidth)
                {
                    TableViewUtils.SetWidth(child, cacheWidth);
                }
            }
            else
            {
                Android.Views.View columnHeaderChild = mColumnHeaderLayoutManager.FindViewByPosition(columnPosition);
                if (columnHeaderChild == null)
                {
                    return;
                }

                // Need to calculate which one has the broadest width ?
                FitWidthSize(child, mYPosition, columnPosition, cacheWidth, columnCacheWidth, columnHeaderChild);
            }

            // Control all of the rows which has same column position.
            if (ShouldFitColumns(columnPosition, mYPosition))
            {
                if (mLastDx < 0)
                {
                    Log.Warn(LogTag, "x: " + columnPosition + " y: " + mYPosition + " fitWidthSize " + "left side ");
                    mCellLayoutManager.FitWidthSize(columnPosition, true);
                }
                else
                {
                    mCellLayoutManager.FitWidthSize(columnPosition, false);
                    Log.Warn(LogTag, "x: " + columnPosition + " y: " + mYPosition + " fitWidthSize " + "right side");
                }

                mNeedFitForVerticalScroll = false;
            }

            // It need to be cleared to prevent unnecessary calculation.
            mNeedFitForHorizontalScroll = false;
        }
        internal object GetItemAtLocation(Point loc)
        {
            var uie = InputHitTest(loc) as FrameworkElement;

            if (uie != null)
            {
                var rowPresenter = TableViewUtils.GetAncestorByType <TableViewCellsPresenter>(uie);

                if (rowPresenter != null)
                {
                    return(rowPresenter.Item);
                }
            }

            return(null);
        }
Ejemplo n.º 6
0
        private void FitWidthSize(Android.Views.View child, int row, int column, int cellWidth, int columnHeaderWidth,
                                  Android.Views.View columnHeaderChild)
        {
            if (cellWidth == -1)
            {
                // Alternatively, TableViewUtils.getWidth(child);
                cellWidth = child.MeasuredWidth;
            }

            if (columnHeaderWidth == -1)
            {
                // Alternatively, TableViewUtils.getWidth(columnHeaderChild)
                columnHeaderWidth = columnHeaderChild.MeasuredWidth;
            }

            if (cellWidth != 0)
            {
                if (columnHeaderWidth > cellWidth)
                {
                    cellWidth = columnHeaderWidth;
                }
                else
                {
                    if (cellWidth > columnHeaderWidth)
                    {
                        columnHeaderWidth = cellWidth;
                    }
                }

                // Control whether column header needs to be change interns of width
                if (columnHeaderWidth != columnHeaderChild.Width)
                {
                    TableViewUtils.SetWidth(columnHeaderChild, columnHeaderWidth);
                    mNeedFitForVerticalScroll   = true;
                    mNeedFitForHorizontalScroll = true;
                }

                // Set the value to cache it for column header.
                mColumnHeaderLayoutManager.SetCacheWidth(column, columnHeaderWidth);
            }

            // Set the width value to cache it for cell .
            TableViewUtils.SetWidth(child, cellWidth);
            mCellLayoutManager.SetCacheWidth(row, column, cellWidth);
        }
        internal int GetCellIndexAtLocation(Point loc)
        {
            var uie = InputHitTest(loc) as FrameworkElement;

            if (uie != null)
            {
                var rowPresenter = TableViewUtils.GetAncestorByType <TableViewCellsPresenter>(uie);

                if (rowPresenter != null)
                {
                    var cell = TableViewUtils.FindParent <TableViewCell>(uie);
                    if (cell != null)
                    {
                        return(rowPresenter.ItemContainerGenerator.IndexFromContainer(cell));
                    }
                }
            }
            return(-1);
        }
Ejemplo n.º 8
0
        public override void MeasureChild(Android.Views.View child, int widthUsed, int heightUsed)
        {
            // If has fixed width is true, than calculation of the column width is not necessary.
            if (mTableView.HasFixedWidth())
            {
                base.MeasureChild(child, widthUsed, heightUsed);
                return;
            }

            int position   = GetPosition(child);
            int cacheWidth = GetCacheWidth(position);

            // If the width value of the cell has already calculated, then set the value
            if (cacheWidth != -1)
            {
                TableViewUtils.SetWidth(child, cacheWidth);
            }
            else
            {
                base.MeasureChild(child, widthUsed, heightUsed);
            }
        }
Ejemplo n.º 9
0
        private void Fit2(int xPosition, int yPosition, int columnCachedWidth, Android.Views.View column,
                          ColumnLayoutManager childLayoutManager)
        {
            int cellCacheWidth = GetCacheWidth(yPosition, xPosition);

            Android.Views.View cell = childLayoutManager.FindViewByPosition(xPosition);
            // Control whether the cell needs to be fitted by column header or not.
            if (cell != null)
            {
                if (cellCacheWidth != columnCachedWidth || mNeedSetLeft)
                {
                    // This is just for setting width value
                    if (cellCacheWidth != columnCachedWidth)
                    {
                        cellCacheWidth = columnCachedWidth;
                        TableViewUtils.SetWidth(cell, cellCacheWidth);
                        SetCacheWidth(yPosition, xPosition, cellCacheWidth);
                    }

                    // The left & right values of Column header can be considered. Because this
                    // method will be worked
                    // after drawing process of main thread.
                    if (column.Left != cell.Left || column.Right != cell.Right)
                    {
                        // TODO: + 1 is for decoration item. It should be gotten from a generic
                        // method  of layoutManager
                        // Set right & left values
                        cell.Left  = column.Left;
                        cell.Right = column.Right + 1;
                        childLayoutManager.LayoutDecoratedWithMargins(cell, cell.Left, cell.Top, cell.Right,
                                                                      cell.Bottom);
                        mNeedSetLeft = true;
                    }
                }
            }
        }
Ejemplo n.º 10
0
        private int Fit(int xPosition, int yPosition, int left, int right, int columnCachedWidth)
        {
            CellRecyclerView child = (CellRecyclerView)FindViewByPosition(yPosition);

            if (child != null)
            {
                ColumnLayoutManager childLayoutManager = (ColumnLayoutManager)child.GetLayoutManager();
                int cellCacheWidth      = GetCacheWidth(yPosition, xPosition);
                Android.Views.View cell = childLayoutManager.FindViewByPosition(xPosition);
                // Control whether the cell needs to be fitted by column header or not.
                if (cell != null)
                {
                    if (cellCacheWidth != columnCachedWidth || mNeedSetLeft)
                    {
                        // This is just for setting width value
                        if (cellCacheWidth != columnCachedWidth)
                        {
                            cellCacheWidth = columnCachedWidth;
                            TableViewUtils.SetWidth(cell, cellCacheWidth);
                            SetCacheWidth(yPosition, xPosition, cellCacheWidth);
                        }

                        // Even if the cached values are same, the left & right value wouldn't change.
                        // mNeedSetLeft & the below lines for it.
                        if (left != IgnoreLeft && cell.Left != left)
                        {
                            // Calculate scroll distance
                            int scrollX = Math.Max(cell.Left, left) - Math.Min(cell.Left, left);
                            // Update its left
                            cell.Left = left;
                            int offset = mHorizontalListener.GetScrollPositionOffset();
                            // It shouldn't be scroll horizontally and the problem is gotten just for
                            // first visible item.
                            if (offset > 0 && xPosition == childLayoutManager.FindFirstVisibleItemPosition() &&
                                mCellRecyclerView.ScrollState != RecyclerView.ScrollStateIdle)
                            {
                                int scrollPosition = mHorizontalListener.GetScrollPosition();
                                offset = mHorizontalListener.GetScrollPositionOffset() + scrollX;
                                // Update scroll position offset value
                                mHorizontalListener.SetScrollPositionOffset(offset);
                                // Scroll considering to the desired value.
                                childLayoutManager.ScrollToPositionWithOffset(scrollPosition, offset);
                            }
                        }

                        if (cell.Width != cellCacheWidth)
                        {
                            if (left != IgnoreLeft)
                            {
                                // TODO: + 1 is for decoration item. It should be gotten from a
                                // generic method  of layoutManager
                                // Set right
                                right      = cell.Left + cellCacheWidth + 1;
                                cell.Right = right;
                                childLayoutManager.LayoutDecoratedWithMargins(cell, cell.Left, cell.Top, cell.Right,
                                                                              cell.Bottom);
                            }

                            mNeedSetLeft = true;
                        }
                    }
                }
            }

            return(right);
        }