コード例 #1
0
 /// <summary>
 /// 设置属性
 /// </summary>
 /// <param name="name">属性名称</param>
 /// <param name="value">属性值</param>
 public virtual void setProperty(String name, String value)
 {
     if (name == "align")
     {
         if (m_style == null)
         {
             m_style = new FCGridCellStyle();
         }
         m_style.Align = FCStr.convertStrToHorizontalAlign(value);
     }
     else if (name == "allowedit")
     {
         AllowEdit = FCStr.convertStrToBool(value);
     }
     else if (name == "autoellipsis")
     {
         if (m_style == null)
         {
             m_style = new FCGridCellStyle();
         }
         m_style.AutoEllipsis = FCStr.convertStrToBool(value);
     }
     else if (name == "backcolor")
     {
         if (m_style == null)
         {
             m_style = new FCGridCellStyle();
         }
         m_style.BackColor = FCStr.convertStrToColor(value);
     }
     else if (name == "colspan")
     {
         ColSpan = FCStr.convertStrToInt(value);
     }
     else if (name == "font")
     {
         if (m_style == null)
         {
             m_style = new FCGridCellStyle();
         }
         m_style.Font = FCStr.convertStrToFont(value);
     }
     else if (name == "textcolor")
     {
         if (m_style == null)
         {
             m_style = new FCGridCellStyle();
         }
         m_style.TextColor = FCStr.convertStrToColor(value);
     }
     else if (name == "name")
     {
         Name = value;
     }
     else if (name == "rowspan")
     {
         RowSpan = FCStr.convertStrToInt(value);
     }
     else if (name == "text")
     {
         Text = value;
     }
 }
コード例 #2
0
        /// <summary>
        /// 重绘方法
        /// </summary>
        /// <param name="paint">绘图对象</param>
        /// <param name="rect">矩形</param>
        /// <param name="clipRect">裁剪矩形</param>
        /// <param name="isAlternate">是否交替行</param>
        public override void onPaint(FCPaint paint, FCRect rect, FCRect clipRect, bool isAlternate)
        {
            int       clipW = clipRect.right - clipRect.left;
            int       clipH = clipRect.bottom - clipRect.top;
            FCGrid    grid  = Grid;
            FCGridRow row   = Row;

            if (clipW > 0 && clipH > 0 && grid != null && Column != null && row != null && TargetColumn != null)
            {
                int          width      = rect.right - rect.left;
                int          height     = rect.bottom - rect.top;
                int          scrollH    = 0;
                FCHScrollBar hscrollBar = grid.HScrollBar;
                if (hscrollBar != null && hscrollBar.Visible)
                {
                    scrollH = hscrollBar.Pos;
                }
                FCFont          font         = null;
                long            backColor    = FCColor.None;
                long            textColor    = FCColor.None;
                bool            autoEllipsis = m_tree.AutoEllipsis;
                FCGridCellStyle style        = Style;
                if (style != null)
                {
                    if (style.AutoEllipsis)
                    {
                        autoEllipsis = style.AutoEllipsis;
                    }
                    backColor = style.BackColor;
                    if (style.Font != null)
                    {
                        font = style.Font;
                    }
                    textColor = style.TextColor;
                }
                FCGridRowStyle rowStyle = grid.RowStyle;
                if (isAlternate)
                {
                    FCGridRowStyle alternateRowStyle = grid.AlternateRowStyle;
                    if (alternateRowStyle != null)
                    {
                        rowStyle = alternateRowStyle;
                    }
                }
                if (rowStyle != null)
                {
                    bool selected = false;
                    ArrayList <FCGridRow> selectedRows = grid.SelectedRows;
                    int selectedRowsSize = selectedRows.size();
                    for (int i = 0; i < selectedRowsSize; i++)
                    {
                        if (selectedRows[i] == row)
                        {
                            selected = true;
                            break;
                        }
                    }
                    if (backColor == FCColor.None)
                    {
                        //选中
                        if (selected)
                        {
                            backColor = rowStyle.SelectedBackColor;
                        }
                        //悬停
                        else if (Row == 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 (Row == Grid.HoveredRow)
                        {
                            textColor = rowStyle.HoveredTextColor;
                        }
                        //普通
                        else
                        {
                            textColor = rowStyle.TextColor;
                        }
                    }
                }
                //绘制背景
                paint.fillRect(backColor, rect);
                FCRect headerRect = TargetColumn.Bounds;
                headerRect.left += Grid.HorizontalOffset - scrollH;
                headerRect.top  += Grid.VerticalOffset - scrollH;
                int left = headerRect.left;
                //绘制复选框
                if (m_tree.CheckBoxes)
                {
                    int    cw           = m_tree.CheckBoxSize.cx;
                    int    ch           = m_tree.CheckBoxSize.cy;
                    FCRect checkBoxRect = new FCRect();
                    checkBoxRect.left   = left;
                    checkBoxRect.top    = rect.top + (height - ch) / 2;
                    checkBoxRect.right  = checkBoxRect.left + cw;
                    checkBoxRect.bottom = checkBoxRect.top + ch;
                    onPaintCheckBox(paint, checkBoxRect);
                    left += cw + 10;
                }
                //绘制折叠展开的标志
                int nw = m_tree.NodeSize.cx;
                int nh = m_tree.NodeSize.cy;
                if (m_nodes.size() > 0)
                {
                    FCRect nodeRect = new FCRect();
                    nodeRect.left   = left;
                    nodeRect.top    = rect.top + (height - nh) / 2;
                    nodeRect.right  = nodeRect.left + nw;
                    nodeRect.bottom = nodeRect.top + nh;
                    onPaintNode(paint, nodeRect);
                }
                left    += nw + 10;
                m_indent = left;
                String text = getPaintText();
                //绘制文字
                if (text != null)
                {
                    FCSize tSize = paint.textSize(text, font);
                    FCRect tRect = new FCRect();
                    tRect.left   = left;
                    tRect.top    = rect.top + (row.Height - tSize.cy) / 2;
                    tRect.right  = tRect.left + tSize.cx;
                    tRect.bottom = tRect.top + 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);
                    }
                }
            }
            onPaintControl(paint, rect, clipRect);
        }
コード例 #3
0
 /// <summary>
 /// 获取属性值
 /// </summary>
 /// <param name="name">属性名称</param>
 /// <param name="value">返回属性值</param>
 /// <param name="type">返回属性类型</param>
 public virtual void getProperty(String name, ref String value, ref String type)
 {
     if (name == "align")
     {
         type = "enum:FCHorizontalAlign";
         FCGridCellStyle style = Style;
         if (style != null)
         {
             value = FCStr.convertHorizontalAlignToStr(style.Align);
         }
     }
     else if (name == "allowedit")
     {
         type  = "bool";
         value = FCStr.convertBoolToStr(AllowEdit);
     }
     else if (name == "autoellipsis")
     {
         type = "bool";
         FCGridCellStyle style = Style;
         if (style != null)
         {
             value = FCStr.convertBoolToStr(style.AutoEllipsis);
         }
     }
     else if (name == "backcolor")
     {
         type = "color";
         FCGridCellStyle style = Style;
         if (style != null)
         {
             value = FCStr.convertColorToStr(style.BackColor);
         }
     }
     else if (name == "colspan")
     {
         type  = "int";
         value = FCStr.convertIntToStr(ColSpan);
     }
     else if (name == "font")
     {
         type = "font";
         FCGridCellStyle style = Style;
         if (style != null && style.Font != null)
         {
             value = FCStr.convertFontToStr(style.Font);
         }
     }
     else if (name == "name")
     {
         type  = "String";
         value = Name;
     }
     else if (name == "rowspan")
     {
         type  = "int";
         value = FCStr.convertIntToStr(RowSpan);
     }
     else if (name == "text")
     {
         type  = "String";
         value = Text;
     }
     else if (name == "textcolor")
     {
         type = "color";
         FCGridCellStyle style = Style;
         if (style != null)
         {
             value = FCStr.convertColorToStr(style.TextColor);
         }
     }
     else
     {
         type  = "undefined";
         value = "";
     }
 }