示例#1
0
        /// <summary>
        /// 更新布局方法
        /// </summary>
        public override void update()
        {
            base.update();
            int width = Width, height = Height;
            int uBottom = 0;

            if (m_upButton != null)
            {
                int     uWidth   = m_upButton.Width;
                FCPoint location = new FCPoint(width - uWidth, 0);
                m_upButton.Location = location;
                FCSize size = new FCSize(uWidth, height / 2);
                m_upButton.Size = size;
                uBottom         = m_upButton.Bottom;
                FCPadding oldPadding = Padding;
                FCPadding padding    = new FCPadding(oldPadding.left, oldPadding.top, uWidth + 3, oldPadding.bottom);
                Padding = padding;
            }
            if (m_downButton != null)
            {
                int     dWidth   = m_downButton.Width;
                FCPoint location = new FCPoint(width - dWidth, uBottom);
                m_downButton.Location = location;
                FCSize size = new FCSize(dWidth, height - uBottom);
                m_downButton.Size = size;
            }
        }
示例#2
0
 /// <summary>
 /// 创建网格
 /// </summary>
 public ToolBoxList()
 {
     BorderColor    = FCColor.None;
     LayoutStyle    = FCLayoutStyle.TopToBottom;
     Padding        = new FCPadding(5, 3, 5, 0);
     ShowVScrollBar = true;
 }
示例#3
0
        /// <summary>
        /// 更新布局方法
        /// </summary>
        public override void update()
        {
            base.update();
            int width = Width, height = Height;

            if (m_dropDownButton != null)
            {
                int dWidth = m_dropDownButton.Width;
                Padding = new FCPadding(0, 0, dWidth, 0);
                m_dropDownButton.Location = new FCPoint(width - dWidth, 0);
                m_dropDownButton.Size     = new FCSize(dWidth, height);
            }
        }
示例#4
0
        /// <summary>
        /// 多页夹的样式
        /// </summary>
        /// <param name="layoutStyle"></param>
        /// <param name="bounds"></param>
        /// <param name="padding"></param>
        /// <param name="margin"></param>
        /// <param name="left"></param>
        /// <param name="top"></param>
        /// <param name="width"></param>
        /// <param name="height"></param>
        /// <param name="tw"></param>
        /// <param name="th"></param>
        /// <param name="headerLocation"></param>
        public virtual void tabStyle(int layoutStyle, ref FCRect bounds, ref FCPadding padding,
                                     ref FCPadding margin, int left, int top, int width, int height,
                                     int tw, int th, ref FCPoint headerLocation)
        {
            switch (layoutStyle)
            {
            case 0:
                bounds.left      = padding.left;
                bounds.top       = padding.top;
                bounds.right     = width;
                bounds.bottom    = height - th;
                headerLocation.x = left;
                headerLocation.y = height - th;
                break;

            case 1:
                bounds.left      = tw;
                bounds.top       = padding.top;
                bounds.right     = width;
                bounds.bottom    = height;
                headerLocation.x = padding.left;
                headerLocation.y = top;
                break;

            case 2:
                bounds.left      = padding.left;
                bounds.top       = padding.top;
                bounds.right     = width - tw;
                bounds.bottom    = height;
                headerLocation.x = width - tw;
                headerLocation.y = top;
                break;

            case 3:
                bounds.left      = padding.left;
                bounds.top       = th;
                bounds.right     = width;
                bounds.bottom    = height;
                headerLocation.x = left;
                headerLocation.y = padding.top;
                break;
            }
        }
示例#5
0
        /// <summary>
        /// 重置布局
        /// </summary>
        public virtual bool onResetLayout()
        {
            bool reset = false;

            if (Native != null)
            {
                FCPadding padding = Padding;
                int       left = padding.left, top = padding.top;
                int       width       = Width - padding.left - padding.right;
                int       height      = Height - padding.top - padding.bottom;
                int       controlSize = m_controls.size();
                for (int i = 0; i < controlSize; i++)
                {
                    FCView control = m_controls.get(i);
                    if (control.Visible && control != HScrollBar && control != VScrollBar)
                    {
                        FCSize    size = control.Size;
                        int       cLeft = control.Left, cTop = control.Top, cWidth = size.cx, cHeight = size.cy;
                        int       nLeft = cLeft, nTop = cTop, nWidth = cWidth, nHeight = cHeight;
                        FCPadding margin = control.Margin;
                        switch (m_layoutStyle)
                        {
                        //自下而上
                        case FCLayoutStyle.BottomToTop: {
                            if (i == 0)
                            {
                                top = padding.top + height;
                            }
                            int lWidth = 0;
                            if (m_autoWrap)
                            {
                                lWidth = size.cx;
                                int lTop = top - margin.top - cHeight - margin.bottom;
                                if (lTop < padding.top)
                                {
                                    left += cWidth + margin.left;
                                    top   = height - padding.top;
                                }
                            }
                            else
                            {
                                lWidth = width - margin.left - margin.right;
                            }
                            top   -= cHeight + margin.bottom;
                            nLeft  = left + margin.left;
                            nWidth = lWidth;
                            nTop   = top;
                            break;
                        }

                        //从左向右
                        case FCLayoutStyle.LeftToRight: {
                            int lHeight = 0;
                            if (m_autoWrap)
                            {
                                lHeight = size.cy;
                                int lRight = left + margin.left + cWidth + margin.right;
                                if (lRight > width)
                                {
                                    left = padding.left;
                                    top += cHeight + margin.top;
                                }
                            }
                            else
                            {
                                lHeight = height - margin.top - margin.bottom;
                            }
                            left   += margin.left;
                            nLeft   = left;
                            nTop    = top + margin.top;
                            nHeight = lHeight;
                            left   += cWidth + margin.right;
                            break;
                        }

                        //从右向左
                        case FCLayoutStyle.RightToLeft: {
                            if (i == 0)
                            {
                                left = width - padding.left;
                            }
                            int lHeight = 0;
                            if (m_autoWrap)
                            {
                                lHeight = size.cy;
                                int lLeft = left - margin.left - cWidth - margin.right;
                                if (lLeft < padding.left)
                                {
                                    left = width - padding.left;
                                    top += cHeight + margin.top;
                                }
                            }
                            else
                            {
                                lHeight = height - margin.top - margin.bottom;
                            }
                            left   -= cWidth + margin.left;
                            nLeft   = left;
                            nTop    = top + margin.top;
                            nHeight = lHeight;
                            break;
                        }

                        //自上而下
                        case FCLayoutStyle.TopToBottom: {
                            int lWidth = 0;
                            if (m_autoWrap)
                            {
                                lWidth = size.cx;
                                int lBottom = top + margin.top + cHeight + margin.bottom;
                                if (lBottom > height)
                                {
                                    left += cWidth + margin.left + margin.right;
                                    top   = padding.top;
                                }
                            }
                            else
                            {
                                lWidth = width - margin.left - margin.right;
                            }
                            top   += margin.top;
                            nTop   = top;
                            nLeft  = left + margin.left;
                            nWidth = lWidth;
                            top   += cHeight + margin.bottom;
                            break;
                        }
                        }
                        //设置区域
                        if (cLeft != nLeft || cTop != nTop || cWidth != nWidth || cHeight != nHeight)
                        {
                            FCRect rect = new FCRect(nLeft, nTop, nLeft + nWidth, nTop + nHeight);
                            control.Bounds = rect;
                            reset          = true;
                        }
                    }
                }
            }
            return(reset);
        }
示例#6
0
        /// <summary>
        /// 重新布局
        /// </summary>
        public override void update()
        {
            if (Native == null)
            {
                return;
            }
            base.update();
            FCPadding padding = Padding;
            int       left = padding.left, top = padding.top;
            int       width       = Width - padding.left - padding.right;
            int       height      = Height - padding.top - padding.bottom;
            int       tabPageSize = m_tabPages.size();

            for (int i = 0; i < tabPageSize; i++)
            {
                FCTabPage tabPage      = m_tabPages.get(i);
                FCButton  headerButton = tabPage.HeaderButton;
                if (headerButton.Visible)
                {
                    FCPadding margin         = headerButton.Margin;
                    int       tw             = headerButton.Width + margin.left + margin.right;
                    int       th             = headerButton.Height + margin.top + margin.bottom;
                    FCRect    bounds         = new FCRect();
                    FCPoint   headerLocation = new FCPoint();
                    int       layout         = 0;
                    switch (m_layout)
                    {
                    case FCTabPageLayout.Bottom:
                        layout = 0;
                        break;

                    case FCTabPageLayout.Left:
                        layout = 1;
                        break;

                    case FCTabPageLayout.Right:
                        layout = 2;
                        break;

                    case FCTabPageLayout.Top:
                        layout = 3;
                        break;
                    }
                    tabStyle(layout, ref bounds, ref padding,
                             ref margin, left, top, width, height,
                             tw, th, ref headerLocation);
                    tabPage.Bounds         = bounds;
                    tabPage.HeaderLocation = headerLocation;
                    if (!m_useAnimation)
                    {
                        tabPage.HeaderButton.Location = headerLocation;
                    }
                    if (m_animationState > 0)
                    {
                        if (m_layout == FCTabPageLayout.Left || m_layout == FCTabPageLayout.Right)
                        {
                            headerLocation.y = headerButton.Top;
                        }
                        else if (m_layout == FCTabPageLayout.Bottom || m_layout == FCTabPageLayout.Top)
                        {
                            headerLocation.x = headerButton.Left;
                        }
                    }
                    headerButton.Location = headerLocation;
                    left += tw;
                    top  += th;
                }
                else
                {
                    tabPage.Visible = false;
                }
            }
        }
示例#7
0
        /// <summary>
        /// 重绘前景方法
        /// </summary>
        /// <param name="paint">绘图对象</param>
        /// <param name="clipRect">裁剪区域</param>
        public override void onPaintForeground(FCPaint paint, FCRect clipRect)
        {
            String text = Text;

            //绘制文字
            if (text != null && text.Length > 0)
            {
                int width = Width, height = Height;
                if (width > 0 && height > 0)
                {
                    FCFont    font      = Font;
                    FCSize    tSize     = paint.textSize(text, font);
                    long      linkColor = getPaintingLinkColor();
                    FCPoint   tPoint    = new FCPoint((width - tSize.cx) / 2, (height - tSize.cy) / 2);
                    FCPadding padding   = Padding;
                    switch (m_textAlign)
                    {
                    case FCContentAlignment.BottomCenter:
                        tPoint.y = height - tSize.cy;
                        break;

                    case FCContentAlignment.BottomLeft:
                        tPoint.x = padding.left;
                        tPoint.y = height - tSize.cy - padding.bottom;
                        break;

                    case FCContentAlignment.BottomRight:
                        tPoint.x = width - tSize.cx - padding.right;
                        tPoint.y = height - tSize.cy - padding.bottom;
                        break;

                    case FCContentAlignment.MiddleLeft:
                        tPoint.x = padding.left;
                        break;

                    case FCContentAlignment.MiddleRight:
                        tPoint.x = width - tSize.cx - padding.right;
                        break;

                    case FCContentAlignment.TopCenter:
                        tPoint.y = padding.top;
                        break;

                    case FCContentAlignment.TopLeft:
                        tPoint.x = padding.left;
                        tPoint.y = padding.top;
                        break;

                    case FCContentAlignment.TopRight:
                        tPoint.x = width - tSize.cx - padding.right;
                        tPoint.y = padding.top;
                        break;
                    }
                    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, linkColor, font, tRect);
                    }
                    else
                    {
                        paint.drawText(text, linkColor, font, tRect);
                    }
                    //画下划线
                    FCNative native = Native;
                    if (m_linkBehavior == FCLinkBehavior.AlwaysUnderLine || (m_linkBehavior == FCLinkBehavior.HoverUnderLine && (this == native.PushedControl || this == native.HoveredControl)))
                    {
                        paint.drawLine(linkColor, 1, 0, tPoint.x, tPoint.y + tSize.cy, tPoint.x + tSize.cx, tPoint.y + tSize.cy);
                    }
                }
            }
        }
示例#8
0
 /// <summary>
 /// 边距转换为字符
 /// </summary>
 /// <param name="padding">边距</param>
 /// <returns>字符</returns>
 public static String convertPaddingToStr(FCPadding padding)
 {
     return(String.Format("{0},{1},{2},{3}", padding.left, padding.top, padding.right, padding.bottom));
 }
示例#9
0
        /// <summary>
        /// 重绘前景方法
        /// </summary>
        /// <param name="paint">绘图对象</param>
        /// <param name="clipRect">裁剪区域</param>
        public override void onPaintForeground(FCPaint paint, FCRect clipRect)
        {
            String text = Text;

            //绘制文字
            if (text != null && text.Length > 0)
            {
                int width = Width, height = Height;
                if (width > 0 && height > 0)
                {
                    FCFont    font    = Font;
                    FCSize    tSize   = paint.textSize(text, font);
                    FCPoint   tPoint  = new FCPoint((width - tSize.cx) / 2, (height - tSize.cy) / 2);
                    FCPadding padding = Padding;
                    switch (m_textAlign)
                    {
                    case FCContentAlignment.BottomCenter:
                        tPoint.y = height - tSize.cy;
                        break;

                    case FCContentAlignment.BottomLeft:
                        tPoint.x = padding.left;
                        tPoint.y = height - tSize.cy - padding.bottom;
                        break;

                    case FCContentAlignment.BottomRight:
                        tPoint.x = width - tSize.cx - padding.right;
                        tPoint.y = height - tSize.cy - padding.bottom;
                        break;

                    case FCContentAlignment.MiddleLeft:
                        tPoint.x = padding.left;
                        break;

                    case FCContentAlignment.MiddleRight:
                        tPoint.x = width - tSize.cx - padding.right;
                        break;

                    case FCContentAlignment.TopCenter:
                        tPoint.y = padding.top;
                        break;

                    case FCContentAlignment.TopLeft:
                        tPoint.x = padding.left;
                        tPoint.y = padding.top;
                        break;

                    case FCContentAlignment.TopRight:
                        tPoint.x = width - tSize.cx - padding.right;
                        tPoint.y = padding.top;
                        break;
                    }
                    FCRect tRect     = new FCRect(tPoint.x, tPoint.y, tPoint.x + tSize.cx, tPoint.y + tSize.cy);
                    long   textColor = getPaintingTextColor();
                    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);
                    }
                }
            }
        }
示例#10
0
 /// <summary>
 /// 重置布局
 /// </summary>
 public virtual bool OnResetLayout()
 {
     if (Native != null)
     {
         if (m_columnsCount > 0 && m_rowsCount > 0 && m_columnStyles.size() > 0 && m_rowStyles.size() > 0)
         {
             int width = Width, height = Height;
             int tabControlsSize = m_tableControls.size();
             //获取行列的宽度
             int[] columnWidths = new int[m_columnsCount];
             int[] rowHeights   = new int[m_rowsCount];
             //获取列的宽度
             int allWidth = 0, allHeight = 0;
             for (int i = 0; i < m_columnsCount; i++)
             {
                 FCColumnStyle columnStyle = m_columnStyles.get(i);
                 int           cWidth      = 0;
                 FCSizeType    sizeType    = columnStyle.SizeType;
                 float         sWidth      = columnStyle.Width;
                 if (sizeType == FCSizeType.AbsoluteSize)
                 {
                     cWidth = (int)(sWidth);
                 }
                 else if (sizeType == FCSizeType.AutoFill)
                 {
                     cWidth = width - allWidth;
                 }
                 else if (sizeType == FCSizeType.PercentSize)
                 {
                     cWidth = (int)(width * sWidth);
                 }
                 columnWidths[i] = cWidth;
                 allWidth       += cWidth;
             }
             for (int i = 0; i < m_rowsCount; i++)
             {
                 FCRowStyle rowStyle = m_rowStyles.get(i);
                 //获取行的高度
                 int        rHeight  = 0;
                 FCSizeType sizeType = rowStyle.SizeType;
                 float      sHeight  = rowStyle.Height;
                 if (sizeType == FCSizeType.AbsoluteSize)
                 {
                     rHeight = (int)(sHeight);
                 }
                 else if (sizeType == FCSizeType.AutoFill)
                 {
                     rHeight = height - allHeight;
                 }
                 else if (sizeType == FCSizeType.PercentSize)
                 {
                     rHeight = (int)(height * sHeight);
                 }
                 rowHeights[i] = rHeight;
                 allHeight    += rHeight;
             }
             //控制控件的大小和位置
             for (int i = 0; i < tabControlsSize; i++)
             {
                 FCView    control = m_tableControls.get(i);
                 int       column  = m_columns[i];
                 int       row     = m_rows[i];
                 FCPadding margin  = control.Margin;
                 //获取横坐标和纵坐标
                 int cLeft = 0, cTop = 0;
                 for (int j = 0; j < column; j++)
                 {
                     cLeft += columnWidths[j];
                 }
                 for (int j = 0; j < row; j++)
                 {
                     cTop += rowHeights[j];
                 }
                 int cRight  = cLeft + columnWidths[column] - margin.right;
                 int cBottom = cTop + rowHeights[row] - margin.bottom;
                 cLeft += margin.left;
                 cTop  += margin.top;
                 if (cRight < cLeft)
                 {
                     cRight = cLeft;
                 }
                 if (cBottom < cTop)
                 {
                     cBottom = cTop;
                 }
                 control.Bounds = new FCRect(cLeft, cTop, cRight, cBottom);
             }
         }
     }
     return(true);
 }