Пример #1
0
        /// <summary>
        /// 字符转换为横向排列方式
        /// </summary>
        /// <param name="str">字符</param>
        /// <returns>字符</returns>
        public static FCHorizontalAlign convertStrToHorizontalAlign(String str)
        {
            str = str.ToLower();
            FCHorizontalAlign horizontalAlign = FCHorizontalAlign.Center;

            if (str == "right")
            {
                horizontalAlign = FCHorizontalAlign.Right;
            }
            else if (str == "inherit")
            {
                horizontalAlign = FCHorizontalAlign.Inherit;
            }
            else if (str == "left")
            {
                horizontalAlign = FCHorizontalAlign.Left;
            }
            return(horizontalAlign);
        }
Пример #2
0
        /// <summary>
        /// 横向排列方式转换为字符
        /// </summary>
        /// <param name="horizontalAlign">横向排列方式</param>
        /// <returns>字符</returns>
        public static String convertHorizontalAlignToStr(FCHorizontalAlign horizontalAlign)
        {
            String str = "";

            if (horizontalAlign == FCHorizontalAlign.Center)
            {
                str = "Center";
            }
            else if (horizontalAlign == FCHorizontalAlign.Right)
            {
                str = "Right";
            }
            else if (horizontalAlign == FCHorizontalAlign.Inherit)
            {
                str = "Inherit";
            }
            else if (horizontalAlign == FCHorizontalAlign.Left)
            {
                str = "Left";
            }
            return(str);
        }
Пример #3
0
        /// <summary>
        /// 重绘方法
        /// </summary>
        /// <param name="paint">绘图对象</param>
        /// <param name="rect">矩形</param>
        /// <param name="clipRect">裁剪矩形</param>
        /// <param name="isAlternate">是否交替行</param>
        public virtual void onPaint(FCPaint paint, FCRect rect, FCRect clipRect, bool isAlternate)
        {
            int clipW = clipRect.right - clipRect.left;
            int clipH = clipRect.bottom - clipRect.top;

            if (clipW > 0 && clipH > 0)
            {
                if (m_grid != null && m_row != null && m_column != null)
                {
                    //判断选中
                    String text     = getPaintText();
                    bool   selected = false;
                    if (m_grid.SelectionMode == FCGridSelectionMode.SelectCell)
                    {
                        ArrayList <FCGridCell> selectedCells = m_grid.SelectedCells;
                        int selectedCellSize = selectedCells.size();
                        for (int i = 0; i < selectedCellSize; i++)
                        {
                            if (selectedCells.get(i) == this)
                            {
                                selected = true;
                                break;
                            }
                        }
                    }
                    else if (m_grid.SelectionMode == FCGridSelectionMode.SelectFullColumn)
                    {
                        ArrayList <FCGridColumn> selectedColumns = m_grid.SelectedColumns;
                        int selectedColumnsSize = selectedColumns.size();
                        for (int i = 0; i < selectedColumnsSize; i++)
                        {
                            if (selectedColumns.get(i) == m_column)
                            {
                                selected = true;
                                break;
                            }
                        }
                    }
                    else if (m_grid.SelectionMode == FCGridSelectionMode.SelectFullRow)
                    {
                        ArrayList <FCGridRow> selectedRows = m_grid.SelectedRows;
                        int selectedRowsSize = selectedRows.size();
                        for (int i = 0; i < selectedRowsSize; i++)
                        {
                            if (selectedRows.get(i) == m_row)
                            {
                                selected = true;
                                break;
                            }
                        }
                    }
                    //获取颜色
                    FCFont            font            = null;
                    long              backColor       = FCColor.None;
                    long              textColor       = FCColor.None;
                    bool              autoEllipsis    = m_grid.AutoEllipsis;
                    FCHorizontalAlign horizontalAlign = m_column.CellAlign;
                    if (m_style != null)
                    {
                        if (m_style.AutoEllipsis)
                        {
                            autoEllipsis = m_style.AutoEllipsis;
                        }
                        backColor = m_style.BackColor;
                        if (m_style.Font != null)
                        {
                            font = m_style.Font;
                        }
                        textColor = m_style.TextColor;
                        if (m_style.Align != FCHorizontalAlign.Inherit)
                        {
                            horizontalAlign = m_style.Align;
                        }
                    }
                    FCGridRowStyle rowStyle = m_grid.RowStyle;
                    if (isAlternate)
                    {
                        FCGridRowStyle alternateRowStyle = m_grid.AlternateRowStyle;
                        if (alternateRowStyle != null)
                        {
                            rowStyle = alternateRowStyle;
                        }
                    }
                    if (rowStyle != null)
                    {
                        if (backColor == FCColor.None)
                        {
                            if (selected)
                            {
                                backColor = rowStyle.SelectedBackColor;
                            }
                            else if (m_row == m_grid.HoveredRow)
                            {
                                backColor = rowStyle.HoveredBackColor;
                            }
                            else
                            {
                                backColor = rowStyle.BackColor;
                            }
                        }
                        if (font == null)
                        {
                            font = rowStyle.Font;
                        }
                        if (textColor == FCColor.None)
                        {
                            if (selected)
                            {
                                textColor = rowStyle.SelectedTextColor;
                            }
                            else if (m_row == m_grid.HoveredRow)
                            {
                                textColor = rowStyle.HoveredTextColor;
                            }
                            else
                            {
                                textColor = rowStyle.TextColor;
                            }
                        }
                    }
                    paint.fillRect(backColor, rect);
                    FCSize  tSize  = paint.textSize(text, font);
                    FCPoint tPoint = new FCPoint(rect.left + 1, rect.top + clipH / 2 - tSize.cy / 2);
                    int     width  = rect.right - rect.left;
                    if (tSize.cx < width)
                    {
                        if (horizontalAlign == FCHorizontalAlign.Center)
                        {
                            tPoint.x = rect.left + (rect.right - rect.left - tSize.cx) / 2;
                        }
                        else if (horizontalAlign == FCHorizontalAlign.Right)
                        {
                            tPoint.x = rect.right - tSize.cx - 2;
                        }
                    }
                    FCRect tRect = new FCRect(tPoint.x, tPoint.y, tPoint.x + tSize.cx, tPoint.y + tSize.cy);
                    if (autoEllipsis && (tRect.right > clipRect.right || tRect.bottom > clipRect.bottom))
                    {
                        if (tRect.right > clipRect.right)
                        {
                            tRect.right = clipRect.right;
                        }
                        if (tRect.bottom > clipRect.bottom)
                        {
                            tRect.bottom = clipRect.bottom;
                        }
                        paint.drawTextAutoEllipsis(text, textColor, font, tRect);
                    }
                    else
                    {
                        paint.drawText(text, textColor, font, tRect);
                    }
                }
            }
        }