Example #1
0
 /// <summary>
 /// Performs the arrange pass layout of the item when
 /// the final position and size of the item has been set.
 /// </summary>
 /// <param name="layoutInfo">Layout information.</param>
 /// <param name="stateInfo"></param>
 /// <param name="layoutBounds"></param>
 protected abstract void ArrangeOverride(
     GridLayoutInfo layoutInfo, GridLayoutStateInfo stateInfo, Rectangle layoutBounds);
Example #2
0
        private Size GetTextSize(
            GridLayoutInfo layoutInfo, TextRowVisualStyle style, int width)
        {
            Size size = Size.Empty;

            if (string.IsNullOrEmpty(_Text) == false)
            {
                if (_TextMarkup != null)
                {
                    size = GetMarkupTextSize(layoutInfo, style, width);
                }
                else
                {
                    eTextFormat tf = style.GetTextFormatFlags();

                    if (width <= 0)
                    {
                        if (style.AllowWrap == Tbool.True)
                            tf &= ~eTextFormat.WordBreak;
                    }

                    size = TextHelper.MeasureText(
                        layoutInfo.Graphics, _Text, style.Font, new Size(width, 0), tf);
                }
            }

            return (size);
        }
Example #3
0
 /// <summary>
 /// Performs the arrange pass layout of the item
 /// when final position and size of the item has been set
 /// </summary>
 /// <param name="layoutInfo">Layout information.</param>
 /// <param name="stateInfo"></param>
 /// <param name="layoutBounds">Layout bounds</param>
 protected override void ArrangeOverride(GridLayoutInfo layoutInfo,
     GridLayoutStateInfo stateInfo, Rectangle layoutBounds)
 {
     Size = ArrangeRow(layoutInfo, stateInfo, layoutBounds);
 }
Example #4
0
        private Size GetMaximumCellSize(GridItemsCollection rows,
            int firstRow, int lastRow, GridLayoutInfo layoutInfo, GridLayoutStateInfo layoutState)
        {
            Size size = Size.Empty;

            for (int i = firstRow; i < lastRow; i++)
            {
                if (i >= rows.Count)
                    break;

                GridContainer item = rows[i] as GridContainer;

                if (item != null)
                {
                    Size cellSize = Size.Empty;

                    if (item is GridRow)
                    {
                        cellSize = GetMaxRowCellSize(
                            (GridRow) item, layoutInfo, layoutState);
                    }
                    else if (item is GridGroup)
                    {
                        cellSize = GetMaximumCellSize(
                            item.Rows, 0, lastRow - i, layoutInfo, layoutState);
                    }

                    size.Width = Math.Max(size.Width, cellSize.Width);
                    size.Height = Math.Max(size.Height, cellSize.Height);
                }
            }

            return (size);
        }
Example #5
0
        /// <summary>
        /// Performs the layout of the item and sets the Size property to size that item will take.
        /// </summary>
        /// <param name="layoutInfo">Layout information.</param>
        /// <param name="stateInfo"></param>
        /// <param name="constraintSize"></param>
        protected override void MeasureOverride(
            GridLayoutInfo layoutInfo, GridLayoutStateInfo stateInfo, Size constraintSize)
        {
            Size sizeNeeded = MeasureRow(layoutInfo, stateInfo, constraintSize);

            if (constraintSize.Width > 0)
                sizeNeeded.Width = constraintSize.Width;

            Size = sizeNeeded;
        }
Example #6
0
        private int GetColumnWidthEx(GridLayoutInfo layoutInfo,
            GridLayoutStateInfo stateInfo, ColumnAutoSizeMode autoSizeMode,
            IEnumerable<GridElement> items, int maxHeight, ref int height)
        {
            int width = 0;

            foreach (GridElement item in items)
            {
                GridRow row = item as GridRow;

                if (row != null && row.Visible == true)
                {
                    if (ColumnIndex < row.GridPanel.Columns.Count)
                    {
                        if (ColumnIndex < row.Cells.Count)
                        {
                            GridCell cell = row.Cells[ColumnIndex];

                            if (maxHeight <= 0 || height < maxHeight)
                            {
                                MeasureCell(layoutInfo, stateInfo, autoSizeMode, row, cell);

                                width = Math.Max(width, cell.CellSize.Width);
                                height += cell.Size.Height;
                            }
                            else
                            {
                                cell.NeedsMeasured = true;
                            }
                        }
                        else
                        {
                            width = Math.Max(width, Width);
                        }
                    }

                    if (row.Rows != null && row.Expanded == true)
                    {
                        GridLayoutStateInfo itemStateInfo = new
                            GridLayoutStateInfo(stateInfo.GridPanel, stateInfo.IndentLevel + 1);

                        width = GetColumnWidth(layoutInfo, itemStateInfo,
                            autoSizeMode, row.Rows, width, maxHeight, ref height);
                    }
                }
                else
                {
                    if (item is GridGroup)
                    {
                        int n = GetColumnWidthEx(layoutInfo, stateInfo,
                            autoSizeMode, ((GridGroup) item).Rows, maxHeight, ref height);

                        width = Math.Max(width, n);
                    }
                }
            }

            return (width);
        }
Example #7
0
        /// <summary>
        /// Performs the arrange pass layout of the item when final position and size of the item has been set.
        /// </summary>
        /// <param name="layoutInfo">Layout information.</param>
        /// <param name="stateInfo"></param>
        /// <param name="layoutBounds">Layout bounds</param>
        protected override void ArrangeOverride(GridLayoutInfo layoutInfo,
            GridLayoutStateInfo stateInfo, Rectangle layoutBounds)
        {
            GridPanel panel = stateInfo.GridPanel;

            if (panel.ColumnHeader.Visible == true)
                panel.ColumnHeader.UpdateImageBounds(panel, this);

            if (NeedsFilterScan == true || panel.NeedsFilterScan == true)
            {
                NeedsFilterScan = false;

                if (FilterAutoScan == true)
                    FilterScan.BeginScan();
            }
        }
Example #8
0
        ///<summary>
        /// GridGetDetailRowHeightEventArgs
        ///</summary>
        ///<param name="gridPanel">Associated GridPanel</param>
        ///<param name="gridRow">Associated container row</param>
        ///<param name="layoutInfo"></param>
        ///<param name="sizeNeeded"></param>
        ///<param name="preHeight"></param>
        ///<param name="postHeight"></param>
        public GridGetDetailRowHeightEventArgs(GridPanel gridPanel,
            GridRow gridRow, GridLayoutInfo layoutInfo, Size sizeNeeded, int preHeight, int postHeight)
        {
            _GridPanel = gridPanel;
            _GridRow = gridRow;

            _SizeNeeded = sizeNeeded;
            _LayoutInfo = layoutInfo;

            _PreDetailHeight = preHeight;
            _PostDetailHeight = postHeight;
        }
Example #9
0
        private GridLayoutInfo GetGridLayoutInfo(Graphics g)
        {
            GridLayoutInfo layoutInfo = new GridLayoutInfo(g, GetGridItemBounds());

            layoutInfo.RightToLeft = (RightToLeft == RightToLeft.No);
            layoutInfo.DefaultVisualStyles = _DefaultVisualStyles; 

            return (layoutInfo);
        }
Example #10
0
        /// <summary>
        /// Performs the layout of the item and sets
        /// the Size property to size that item will take.
        /// </summary>
        /// <param name="layoutInfo">Layout information.</param>
        /// <param name="stateInfo"></param>
        /// <param name="constraintSize"></param>
        protected override void MeasureOverride(
            GridLayoutInfo layoutInfo, GridLayoutStateInfo stateInfo, Size constraintSize)
        {
            Size sizeNeeded = Size.Empty;

            GridPanel panel = stateInfo.GridPanel;

            if (panel.ShowRowHeaders == true)
                sizeNeeded.Width += panel.RowHeaderWidth;

            GridColumnCollection columns = _Columns;
            foreach (GridColumn column in columns)
            {
                Size size = MeasureHeader(layoutInfo, constraintSize, panel, column);

                if (column.Visible == true)
                {
                    sizeNeeded.Width += size.Width;
                    sizeNeeded.Height = Math.Max(size.Height, sizeNeeded.Height);
                }
            }

            if (_RowHeight > 0)
                sizeNeeded.Height = _RowHeight;

            Size = sizeNeeded;
        }
Example #11
0
        internal Size MeasureHeader(GridLayoutInfo layoutInfo,
            Size constraintSize, GridPanel panel, GridColumn column)
        {
            Size sizeNeeded = Size.Empty;

            ColumnHeaderVisualStyle style = GetSizingStyle(panel, column);

            Image image = (_ShowHeaderImages == true)
                ? style.GetImage(panel) : null;

            Alignment imageAlignment = style.ImageAlignment;
            Size imageSize = style.GetImageSize(image);

            if (style.IsOverlayImage == true)
                imageAlignment = Alignment.MiddleCenter;

            Size borderSize = style.GetBorderSize(true);

            int bwidth = (borderSize.Width * 2);
            int bheight = (borderSize.Height * 2);

            int width = constraintSize.Width > 0 ? column.Size.Width : 0;

            if (width > 0)
            {
                width -= bwidth;

                switch (imageAlignment)
                {
                    case Alignment.TopCenter:
                    case Alignment.MiddleCenter:
                    case Alignment.BottomCenter:
                        break;

                    default:
                        width -= imageSize.Width;
                        break;
                }
            }

            column.HeaderContentSize =
                MeasureHeaderText(layoutInfo.Graphics, column, style, new Size(width, 0));

            if (width == 0)
                column.HeaderTextSize = column.HeaderContentSize;

            switch (imageAlignment)
            {
                case Alignment.MiddleCenter:
                    sizeNeeded.Height = Math.Max(imageSize.Height, column.HeaderContentSize.Height) + bheight;
                    sizeNeeded.Width = Math.Max(column.HeaderContentSize.Width, imageSize.Width) + bwidth;
                    break;

                case Alignment.TopCenter:
                case Alignment.BottomCenter:
                    sizeNeeded.Width = Math.Max(column.HeaderContentSize.Width, imageSize.Width) + bwidth;
                    sizeNeeded.Height = column.HeaderContentSize.Height + imageSize.Height + bheight;
                    break;

                default:
                    sizeNeeded.Width = column.HeaderContentSize.Width + imageSize.Width + bwidth;
                    sizeNeeded.Height = Math.Max(imageSize.Height, column.HeaderContentSize.Height) + bheight;
                    break;
            }

            Alignment sortAlignment = (_SortImageAlignment == Alignment.NotSet)
                ? Alignment.TopCenter : _SortImageAlignment;

            Alignment filterAlignment = (_FilterImageAlignment == Alignment.NotSet)
                ? Alignment.MiddleLeft : _FilterImageAlignment;

            int imsHeight = 0;

            if (panel.SortLevel != SortLevel.None)
            {
                imsHeight = GetPartSizeNeeded(
                    GetAscendingSortImage(column), style, sortAlignment, ref sizeNeeded);
            }

            int imfHeight = 0;

            if (FilterCanBeVisible(panel) == true)
            {
                imfHeight = GetPartSizeNeeded(
                    GetFilterImage(column), style, filterAlignment, ref sizeNeeded);
            }

            if (imsHeight > 0 && imfHeight > 0)
            {
                if (VAlignment(sortAlignment) == VAlignment(filterAlignment))
                {
                    int n = Math.Max(imsHeight, imfHeight);

                    sizeNeeded.Height += n;

                    if (VAlignment(style.Alignment) == 1)
                        sizeNeeded.Height += n;
                }
                else
                    sizeNeeded.Height += (imsHeight + imfHeight);
            }
            else
            {
                int n = imsHeight + imfHeight;

                sizeNeeded.Height += n;

                if (VAlignment(style.Alignment) == 1)
                    sizeNeeded.Height += n;
            }

            sizeNeeded.Width += 8;
            sizeNeeded.Height += 4;

            column.HeaderSize = sizeNeeded;

            return (sizeNeeded);
        }
Example #12
0
 /// <summary>
 /// Performs the arrange pass layout of the item
 /// when final position and size of the item has been set.
 /// </summary>
 /// <param name="layoutInfo">Layout information.</param>
 /// <param name="stateInfo"></param>
 /// <param name="layoutBounds">Layout bounds</param>
 protected override void ArrangeOverride(GridLayoutInfo layoutInfo,
     GridLayoutStateInfo stateInfo, Rectangle layoutBounds)
 {
 }
Example #13
0
 /// <summary>
 /// Performs the layout of the item
 /// and sets the Size property to size that item will take.
 /// </summary>
 /// <param name="layoutInfo">Layout information.</param>
 /// <param name="stateInfo"></param>
 /// <param name="constraintSize"></param>
 protected abstract void MeasureOverride(
     GridLayoutInfo layoutInfo, GridLayoutStateInfo stateInfo, Size constraintSize);
Example #14
0
        /// <summary>
        /// This method is used by the items internally to invoke the arrange pass after
        /// location and size of the item has been set. Override ArrangeOverride method
        /// to perform internal arranging.
        /// </summary>
        /// <param name="layoutInfo"></param>
        /// <param name="stateInfo"></param>
        /// <param name="layoutBounds"></param>
        internal void Arrange(
            GridLayoutInfo layoutInfo, GridLayoutStateInfo stateInfo, Rectangle layoutBounds)
        {
            IsLayoutValid = true;

            _BoundsRelative = layoutBounds;

            ArrangeOverride(layoutInfo, stateInfo, layoutBounds);
        }
Example #15
0
        private int GetColumnWidth(GridLayoutInfo layoutInfo,
            GridLayoutStateInfo stateInfo, ColumnAutoSizeMode autoSizeMode,
            IEnumerable<GridElement> items, int width, int maxHeight, ref int height)
        {
            GridPanel panel = GridPanel;

            if (panel != null)
            {
                if (panel.VirtualMode == true)
                {
                    if (panel.VirtualRowCount > 0)
                    {
                        int n = GetVirtualColumnWidthEx(layoutInfo,
                            stateInfo, autoSizeMode, ref height);

                        width = Math.Max(width, n);
                    }
                }
                else
                {
                    int n = GetColumnWidthEx(layoutInfo,
                            stateInfo, autoSizeMode, items, maxHeight, ref height);

                    width = Math.Max(width, n);
                }
            }

            return (width);
        }
Example #16
0
        private void UpdateScrollBars(GridLayoutInfo layoutInfo)
        {
            if (_HScrollBarEnabled == true)
            {
                _HScrollBar.SmallChange = layoutInfo.ClientBounds.Width / 20;
                _HScrollBar.LargeChange = SViewRect.Width;
                _HScrollBar.Maximum = Math.Max(0, PrimaryGridSize.Width - 1);

                if (_HScrollBar.Value + SViewRect.Width > _HScrollBar.Maximum)
                {
                    _HScrollBar.Value = _HScrollBar.Maximum - SViewRect.Width;
                    _HScrollOffset = _HScrollBar.Value;
                }

                _HScrollBar.Refresh();
            }

            if (_VScrollBarEnabled == true)
            {
                _VScrollBar.SmallChange = layoutInfo.ClientBounds.Height / 20;
                _VScrollBar.LargeChange = SViewRect.Height;
                _VScrollBar.Maximum = Math.Max(0, PrimaryGridSize.Height - 1);

                if (_VScrollBar.Value + SViewRect.Height - 1 > _VScrollBar.Maximum)
                {
                    _VScrollBar.Value = _VScrollBar.Maximum - SViewRect.Height + 1;
                    _VScrollOffset = _VScrollBar.Value;
                }

                _VScrollBar.Refresh();
            }
        }
Example #17
0
        private int GetVirtualColumnWidthEx(GridLayoutInfo layoutInfo,
            GridLayoutStateInfo stateInfo, ColumnAutoSizeMode autoSizeMode, ref int height)
        {
            GridPanel panel = GridPanel;

            int start = panel.FirstOnScreenRowIndex;
            int end = panel.LastOnScreenRowIndex;

            int width = 0;

            for (int i = start; i <= end; i++)
            {
                GridRow row = panel.VirtualRows[i];

                if (ColumnIndex < row.GridPanel.Columns.Count)
                {
                    if (ColumnIndex < row.Cells.Count)
                    {
                        GridCell cell = row.Cells[ColumnIndex];

                        MeasureCell(layoutInfo, stateInfo, autoSizeMode, row, cell);

                        width = Math.Max(width, cell.CellSize.Width);
                        height += cell.Size.Height;
                    }
                    else
                    {
                        width = Math.Max(width, Width);
                    }
                }
            }

            return (width);
        }
Example #18
0
        private void EnableHScrollBar(GridLayoutInfo layoutInfo)
        {
            bool enable = _HScrollBarVisible && (_PrimaryGrid.Size.Width > layoutInfo.ClientBounds.Width);

            if (enable == true)
            {
                _HScrollBar.Location = new
                    Point(layoutInfo.ClientBounds.Left + 1,
                    layoutInfo.ClientBounds.Bottom - 1);

                int n = layoutInfo.ClientBounds.Width - 2;

                if (_VScrollBar.Visible == true)
                    n++;

                _HScrollBar.Width = n;
            }
            else
            {
                _HScrollBar.Value = 0;
                _HScrollOffset = 0;
            }

            _HScrollBarEnabled = enable;

            _HScrollBar.Enabled = enable;
            _HScrollBar.Visible = enable;
        }
Example #19
0
        private void MeasureCell(GridLayoutInfo layoutInfo, GridLayoutStateInfo stateInfo,
            ColumnAutoSizeMode autoSizeMode, GridRow row, GridCell cell)
        {
            if (cell.NeedsMeasured || NeedsMeasured || row.NeedsMeasured)
            {
                int rowHeight = row.GetRowHeight();

                if (rowHeight > 0)
                {
                    Size size = new Size(Width, rowHeight);

                    if (autoSizeMode != ColumnAutoSizeMode.None)
                    {
                        cell.Measure(layoutInfo, stateInfo, Size.Empty);

                        size.Width = cell.Size.Width;
                        size.Width += GetColumnIndent(stateInfo.IndentLevel);
                    }
                    else
                    {
                        cell.Measure(layoutInfo, stateInfo, size);
                    }

                    cell.Size = size;
                }
                else
                {
                    Size size = Size.Empty;

                    if (autoSizeMode == ColumnAutoSizeMode.None)
                    {
                        size.Width = Width;
                        size.Width -= GetColumnIndent(stateInfo.IndentLevel);
                        size.Width = Math.Max(1, size.Width);
                    }

                    cell.Measure(layoutInfo, stateInfo, new Size(size.Width, 0));

                    if (autoSizeMode != ColumnAutoSizeMode.None)
                    {
                        size = cell.Size;
                        size.Width += GetColumnIndent(stateInfo.IndentLevel);
                        cell.Size = size;
                    }
                    else
                    {
                        size = cell.Size;
                        size.Width = Width;
                        cell.Size = size;
                    }
                }

                cell.CellSize = cell.Size;
            }
        }
Example #20
0
        private void EnableVScrollBar(GridLayoutInfo layoutInfo)
        {
            bool enable = _VScrollBarVisible && (_PrimaryGrid.Size.Height > layoutInfo.ClientBounds.Height);

            if (enable == true)
            {
                _VScrollBar.Location = new
                    Point(layoutInfo.ClientBounds.Right - 1,
                    layoutInfo.ClientBounds.Top + 1);

                _VScrollBar.Height = layoutInfo.ClientBounds.Height - 2;
            }
            else
            {
                _VScrollBar.Value = 0;
                _VScrollOffset = 0;
            }

            _VScrollBarEnabled = enable;

            _VScrollBar.Enabled = enable;
            _VScrollBar.Visible = enable;
        }
Example #21
0
        ///<summary>
        /// This routine calculates and returns the maximum cell
        /// size from each cell in the column, as limited by the
        /// given row scope ('AllRows' or 'OnScreenRows').
        /// If 'includeHeader' is true, then the width of the header
        /// is included in the max calculation.
        ///</summary>
        ///<returns>Maximum cell size.</returns>
        public Size GetMaximumCellSize(RowScope scope, bool includeHeader)
        {
            Size size = Size.Empty;
            GridPanel panel = GridPanel;

            if (panel != null)
            {
                using (Graphics g = SuperGrid.CreateGraphics())
                {
                    GridLayoutInfo layoutInfo = new GridLayoutInfo(g, panel.BoundsRelative);
                    GridLayoutStateInfo layoutState = new GridLayoutStateInfo(panel, 0);

                    if (includeHeader == true)
                    {
                        Size oldSize = panel.ColumnHeader.Size;

                        panel.ColumnHeader.MeasureHeader(layoutInfo, Size.Empty, panel, this);

                        size.Width = _HeaderSize.Width;

                        panel.ColumnHeader.Size = oldSize;
                    }

                    if (panel.VirtualMode == true)
                    {
                        int firstRow = 0;
                        int lastRow = panel.VirtualRowCountEx;

                        if (scope == RowScope.OnScreenRows)
                        {
                            firstRow = panel.FirstOnScreenRowIndex;
                            lastRow = panel.LastOnScreenRowIndex + 1;
                        }

                        for (int i = firstRow; i < lastRow; i++)
                        {
                            GridRow row = panel.VirtualRows[i];
                            GridCell cell = row.Cells[ColumnIndex];

                            Size oldSize = cell.Size;

                            cell.Measure(layoutInfo, layoutState, Size.Empty);

                            int n = GetColumnIndent(layoutState.IndentLevel);

                            size.Width = Math.Max(size.Width, cell.Size.Width + n);
                            size.Height = Math.Max(size.Height, cell.Size.Height);

                            cell.Size = oldSize;
                        }
                    }
                    else
                    {
                        if (panel.Rows.Count > 0)
                        {
                            int firstRow = 0;
                            int lastRow = panel.Rows.Count;

                            if (scope == RowScope.OnScreenRows)
                            {
                                firstRow = panel.FirstOnScreenRowIndex;
                                lastRow = firstRow + 100;
                            }

                            Size cellSize = GetMaximumCellSize(
                                panel.Rows, firstRow, lastRow, layoutInfo, layoutState);

                            size.Width = Math.Max(size.Width, cellSize.Width);
                            size.Height = Math.Max(size.Height, cellSize.Height);
                        }
                    }
                }
            }

            return (size);
        }
Example #22
0
 private bool HorizontalIsOver(GridLayoutInfo layoutInfo)
 {
     return (_PrimaryGrid.Size.Width > layoutInfo.ClientBounds.Width);
 }
Example #23
0
        private Size GetMaxRowCellSize(GridRow row,
            GridLayoutInfo layoutInfo, GridLayoutStateInfo layoutState)
        {
            if (row.Cells.Count <= ColumnIndex)
                return (Size.Empty);

            GridCell cell = row.Cells[ColumnIndex];

            Size oldSize = cell.Size;

            cell.Measure(layoutInfo, layoutState, Size.Empty);

            Size size = cell.Size;
            size.Width += GetColumnIndent(layoutState.IndentLevel);

            cell.Size = oldSize;

            if (row.Rows.Count > 0 && row.Expanded == true)
            {
                layoutState.IndentLevel++;

                foreach (GridContainer item in row.Rows)
                {
                    if (item is GridRow)
                    {
                        Size cellSize =
                            GetMaxRowCellSize((GridRow)item, layoutInfo, layoutState);

                        size.Width = Math.Max(size.Width, cellSize.Width);
                        size.Height = Math.Max(size.Height, cellSize.Height);
                    }
                }

                layoutState.IndentLevel--;
            }

            return (size);
        }
Example #24
0
 private bool VerticalIsOver(GridLayoutInfo layoutInfo)
 {
     return (_PrimaryGrid.Size.Height > layoutInfo.ClientBounds.Height);
 }
Example #25
0
        protected virtual Size MeasureRow(
            GridLayoutInfo layoutInfo, GridLayoutStateInfo stateInfo, Size constraintSize)
        {
            Size sizeNeeded = Size.Empty;

            if (IsEmpty == false)
            {
                GridPanel panel = stateInfo.GridPanel;
                TextRowVisualStyle style = GetSizingStyle(stateInfo.GridPanel);

                Alignment imageAlignment = style.ImageAlignment;
                Size imageSize = style.GetImageSize(style.Image);

                if (style.IsOverlayImage == true)
                    imageAlignment = Alignment.MiddleCenter;

                int width = constraintSize.Width;

                if (width > 0)
                {
                    if (panel.IsSubPanel == false)
                        width = ViewRect.Width;

                    if (CanShowRowHeader(panel) == true)
                        width -= panel.RowHeaderWidth;

                    switch (imageAlignment)
                    {
                        case Alignment.TopCenter:
                        case Alignment.MiddleCenter:
                        case Alignment.BottomCenter:
                            break;

                        default:
                            width -= imageSize.Width;
                            break;
                    }
                }

                Size borderSize = style.GetBorderSize(true);

                if (constraintSize.Width > 0)
                    width -= borderSize.Width;

                Size size = GetTextSize(layoutInfo, style, width);

                switch (imageAlignment)
                {
                    case Alignment.MiddleCenter:
                        sizeNeeded.Height = Math.Max(imageSize.Height, size.Height) + borderSize.Height;
                        sizeNeeded.Width = Math.Max(size.Width, imageSize.Width) + borderSize.Width;
                        break;

                    case Alignment.TopCenter:
                    case Alignment.BottomCenter:
                        sizeNeeded.Width = Math.Max(size.Width, imageSize.Width) + borderSize.Width;
                        sizeNeeded.Height = size.Height + imageSize.Height + borderSize.Height;
                        break;

                    default:
                        sizeNeeded.Width = size.Width + imageSize.Width + borderSize.Width;
                        sizeNeeded.Height = Math.Max(imageSize.Height, size.Height) + borderSize.Height;
                        break;
                }

                if (RowHeight > 0)
                    sizeNeeded.Height = RowHeight;

                sizeNeeded.Height += 1;
            }

            return (sizeNeeded);
        }
Example #26
0
        /// <summary>
        /// Handles invocation of RowGetDetailHeight events
        /// </summary>
        internal void DoRowGetDetailHeightEvent(GridRow row, 
            GridLayoutInfo layoutInfo, Size sizeNeeded, ref int preHeight, ref int postHeight)
        {
            if (GetDetailRowHeight != null)
            {
                GridGetDetailRowHeightEventArgs ev = new
                    GridGetDetailRowHeightEventArgs(row.GridPanel, row, layoutInfo, sizeNeeded, preHeight, postHeight);

                GetDetailRowHeight(this, ev);

                preHeight = ev.PreDetailHeight;
                postHeight = ev.PostDetailHeight;
            }
        }
Example #27
0
        private Size GetMarkupTextSize(
            GridLayoutInfo layoutInfo, TextRowVisualStyle style, int width)
        {
            Graphics g = layoutInfo.Graphics;

            MarkupDrawContext d =
                new MarkupDrawContext(g, style.Font, style.TextColor, false);

            _TextMarkup.InvalidateElementsSize();
            _TextMarkup.Measure(new Size(width, 0), d);

            return (_TextMarkup.Bounds.Size);
        }
Example #28
0
        /// <summary>
        /// Performs the layout of the item and sets the Size property to size that item will take.
        /// </summary>
        /// <param name="layoutInfo">Layout information.</param>
        /// <param name="stateInfo"></param>
        /// <param name="constraintSize"></param>
        protected override void MeasureOverride(
            GridLayoutInfo layoutInfo, GridLayoutStateInfo stateInfo, Size constraintSize)
        {
            if (NeedsResized == true || NeedsMeasured == true || stateInfo.GridPanel.NeedsMeasured == true)
            {
                Size sizeNeeded = Size.Empty;

                ColumnAutoSizeMode autoSizeMode = GetAutoSizeMode();

                int baseWidth = MinimumWidth;

                switch (autoSizeMode)
                {
                    case ColumnAutoSizeMode.AllCells:
                    case ColumnAutoSizeMode.DisplayedCells:
                    case ColumnAutoSizeMode.ColumnHeader:
                        baseWidth = Math.Max(baseWidth, _HeaderSize.Width);
                        break;
                }

                int height = 0;

                switch (autoSizeMode)
                {
                    case ColumnAutoSizeMode.None:
                        sizeNeeded.Width = Math.Max(baseWidth, Width);
                        break;

                    case ColumnAutoSizeMode.AllCells:
                    case ColumnAutoSizeMode.AllCellsExceptHeader:
                        sizeNeeded.Width = GetColumnWidth(layoutInfo, stateInfo,
                            autoSizeMode, stateInfo.GridPanel.Rows, baseWidth, 0, ref height);
                        break;

                    case ColumnAutoSizeMode.ColumnHeader:
                        sizeNeeded = new Size(baseWidth, 0);
                        MarkRowsToMeasure(stateInfo.GridPanel.Rows);
                        break;

                    default:
                        sizeNeeded.Width = GetColumnWidth(layoutInfo, stateInfo, autoSizeMode,
                            stateInfo.GridPanel.Rows, baseWidth, layoutInfo.ClientBounds.Height, ref height);
                        break;
                }

                Size = sizeNeeded;

                NeedsResized = false;
            }
        }
Example #29
0
        protected virtual Size ArrangeRow(GridLayoutInfo layoutInfo,
            GridLayoutStateInfo stateInfo, Rectangle layoutBounds)
        {
            Size size = Size;

            size.Width = stateInfo.GridPanel.ColumnHeader.BoundsRelative.Width;

            return (size);
        }
Example #30
0
        /// <summary>
        /// This method is used by the items internally to invoke the measure pass to
        /// get item size. Override MeasureOverride method to perform actual measuring.
        /// </summary>
        /// <param name="layoutInfo">Holds contextual layout information.</param>
        /// <param name="stateInfo"></param>
        /// <param name="constraintSize"></param>
        internal void Measure(
            GridLayoutInfo layoutInfo, GridLayoutStateInfo stateInfo, Size constraintSize)
        {
            MeasureOverride(layoutInfo, stateInfo, constraintSize);

            NeedsMeasured = false;
        }