示例#1
0
        /// <summary>
        /// 重绘前景方法
        /// </summary>
        /// <param name="paint">绘图对象</param>
        /// <param name="clipRect">裁剪区域</param>
        public override void onPaintBackground(FCPaint paint, FCRect clipRect)
        {
            base.onPaintBackground(paint, clipRect);
            int width = Width, height = Height;

            lock (m_barrages) {
                int barragesSize = m_barrages.Count;
                for (int i = 0; i < barragesSize; i++)
                {
                    Barrage brg  = m_barrages[i];
                    FCFont  font = brg.Font;
                    FCRect  rect = brg.Rect;
                    String  str  = brg.Text;
                    FCSize  size = paint.textSize(str, font);
                    rect.right  = rect.left + size.cx;
                    rect.bottom = rect.top + size.cy;
                    brg.Rect    = rect;
                    long color = brg.Color;
                    int  mode  = brg.Mode;
                    if (mode == 1)
                    {
                        int a = 0, r = 0, g = 0, b = 0;
                        FCColor.toArgb(null, color, ref a, ref r, ref g, ref b);
                        a     = a * brg.Tick / 400;
                        color = FCColor.argb(a, r, g, b);
                    }
                    paint.drawText(str, color, font, rect);
                }
            }
            if (m_progress > 0)
            {
                int    tWidth    = 500;
                int    tHeight   = 60;
                int    showWidth = m_progress * 500 / 100;
                FCRect pRect     = new FCRect((width - tWidth) / 2, (height - tHeight) / 2, (width + tWidth) / 2, (height + tHeight) / 2);
                paint.fillRect(FCColor.argb(255, 0, 0), pRect);
                FCRect pRect2 = new FCRect((width - tWidth) / 2, (height - tHeight) / 2, (width - tWidth) / 2 + showWidth, (height + tHeight) / 2);
                paint.fillRect(FCColor.argb(255, 255, 0), pRect2);
                paint.drawRect(FCColor.argb(255, 255, 255), 1, 0, pRect);
                FCFont pFont = new FCFont("微软雅黑", 20, true, false, false);
                FCSize pSize = paint.textSize(m_progressText, pFont);
                FCDraw.drawText(paint, m_progressText, FCColor.argb(0, 0, 0), pFont, (width - pSize.cx) / 2, (height - pSize.cy) / 2);
            }
        }
示例#2
0
        /// <summary>
        /// 颜色转换为字符
        /// </summary>
        /// <param name="color">颜色</param>
        /// <returns>字符</returns>
        public static String convertColorToStr(long color)
        {
            if (color == FCColor.None)
            {
                return("Empty");
            }
            else if (color == FCColor.Back)
            {
                return("Control");
            }
            else if (color == FCColor.Border)
            {
                return("ControlBorder");
            }
            else if (color == FCColor.Text)
            {
                return("ControlText");
            }
            else if (color == FCColor.DisabledBack)
            {
                return("DisabledControl");
            }
            else if (color == FCColor.DisabledText)
            {
                return("DisabledControlText");
            }
            int a = 0, r = 0, g = 0, b = 0;

            FCColor.toArgb(null, color, ref a, ref r, ref g, ref b);
            String str = String.Empty;

            if (a == 255)
            {
                str = String.Format("{0},{1},{2}", r, g, b);
            }
            else
            {
                str = String.Format("{0},{1},{2},{3}", a, r, g, b);
            }
            return(str);
        }
示例#3
0
        /// <summary>
        /// 单元格点击事件
        /// </summary>
        /// <param name="cell">单元格</param>
        /// <param name="mp">坐标</param>
        /// <param name="button">按钮</param>
        /// <param name="clicks">点击次数</param>
        /// <param name="delta">滚轮值</param>
        public override void onCellClick(FCGridCell cell, FCTouchInfo touchInto)
        {
            base.onCellClick(cell, touchInto);
            List <FCGridRow> rows = m_rows;
            int rowsSize          = rows.Count;

            for (int i = 0; i < rowsSize; i++)
            {
                FCGridRow         row   = rows[i];
                List <FCGridCell> cells = row.getCells();
                int cellsSize           = cells.Count;
                for (int j = 0; j < cellsSize; j++)
                {
                    FCGridControlCell cCell = cells[j] as FCGridControlCell;
                    if (cCell != null)
                    {
                        if (row == cell.Row)
                        {
                            cCell.Control.TextColor = FCDraw.FCCOLORS_TEXTCOLOR4;
                        }
                        else
                        {
                            cCell.Control.TextColor = FCColor.Text;
                        }
                    }
                }
            }
            if (touchInto.m_firstTouch)
            {
                if (touchInto.m_clicks == 1)
                {
                    if (!cell.AllowEdit && cell is GridColorCell)
                    {
                        GridColorCell colorCell   = cell as GridColorCell;
                        ColorDialog   colorDialog = new ColorDialog();
                        colorDialog.AllowFullOpen  = true;
                        colorDialog.AnyColor       = true;
                        colorDialog.SolidColorOnly = false;
                        int a = 0, r = 0, g = 0, b = 0;
                        FCColor.toArgb(Native.Paint, FCStr.convertStrToColor(colorCell.getString()), ref a, ref r, ref g, ref b);
                        colorDialog.Color = Color.FromArgb(a, r, g, b);
                        if (colorDialog.ShowDialog() == DialogResult.OK)
                        {
                            Color newColor = colorDialog.Color;
                            a = newColor.A;
                            r = newColor.R;
                            g = newColor.G;
                            b = newColor.B;
                            colorCell.setString(FCStr.convertColorToStr(FCColor.argb(a, r, g, b)));
                            FCGridCell nameCell = cell.Row.getCell("PROPERTYNAME");
                            if (nameCell != null)
                            {
                                m_designerDiv.saveUndo();
                                String name        = nameCell.Name;
                                String value       = cell.Text;
                                int    targetsSize = m_targets.Count;
                                for (int i = 0; i < targetsSize; i++)
                                {
                                    FCView target = m_targets[i];
                                    m_xml.setProperty(target, name, value);
                                    if (m_collectionWindow != null)
                                    {
                                        m_collectionWindow.onPropertyChanged(name, value);
                                    }
                                    target.update();
                                }
                                //恢复正确的值
                                String rightValue = "", type = "";
                                for (int i = 0; i < targetsSize; i++)
                                {
                                    m_targets[i].getProperty(name.ToLower(), ref rightValue, ref type);
                                }
                                cell.Text = rightValue;
                                Native.update();
                                Native.invalidate();
                            }
                        }
                        colorDialog.Dispose();
                    }
                    //字体单元格
                    else if (!cell.AllowEdit && cell is GridFontCell)
                    {
                        GridFontCell fontCell   = cell as GridFontCell;
                        FontDialog   fontDialog = new FontDialog();
                        fontDialog.Font = getFont(FCStr.convertStrToFont(fontCell.getString()));
                        if (fontDialog.ShowDialog() == DialogResult.OK)
                        {
                            Font newFont = fontDialog.Font;
                            fontCell.setString(FCStr.convertFontToStr(new FCFont(newFont.Name, newFont.Size, newFont.Bold, newFont.Underline, newFont.Italic, newFont.Strikeout)));
                            FCGridCell nameCell = cell.Row.getCell("PROPERTYNAME");
                            if (nameCell != null)
                            {
                                m_designerDiv.saveUndo();
                                String name        = nameCell.Name;
                                String value       = cell.Text;
                                int    targetsSize = m_targets.Count;
                                for (int i = 0; i < targetsSize; i++)
                                {
                                    FCView target = m_targets[i];
                                    m_xml.setProperty(target, name, value);
                                    if (m_collectionWindow != null)
                                    {
                                        m_collectionWindow.onPropertyChanged(name, value);
                                    }
                                    target.update();
                                }
                                //恢复正确的值
                                String rightValue = "", type = "";
                                for (int i = 0; i < targetsSize; i++)
                                {
                                    m_targets[i].getProperty(name.ToLower(), ref rightValue, ref type);
                                }
                                cell.Text = rightValue;
                                Native.update();
                                Native.invalidate();
                            }
                        }
                    }
                    //单击编辑框
                    else if (cell is FCGridButtonCell)
                    {
                        FCButton cButton = (cell as FCGridButtonCell).Button;
                        if (cButton.Tag != null)
                        {
                            String collectionName = cButton.Tag.ToString();
                            int    targetsSize    = m_targets.Count;
                            if (targetsSize > 0)
                            {
                                FCView           target           = m_targets[0];
                                CollectionWindow collectionWindow = new CollectionWindow(m_native);
                                collectionWindow.CollectionName = collectionName;
                                collectionWindow.DesignerDiv    = m_designerDiv;
                                collectionWindow.Target         = target;
                                collectionWindow.Xml            = m_xml;
                                collectionWindow.IsWinForm      = false;
                                collectionWindow.showDialog();
                            }
                        }
                    }
                }
            }
        }
示例#4
0
        /// <summary>
        /// 获取白色风格的颜色
        /// </summary>
        /// <param name="color">颜色</param>
        /// <returns>新的颜色</returns>
        private static long getWhiteColor(long dwPenColor)
        {
            long color = dwPenColor;

            if (color < FCColor.None)
            {
                if (color > FCCOLORS_USERCOLOR)
                {
                    if (color == FCColor.Back)
                    {
                        color = FCColor.argb(255, 255, 255);
                    }
                    else if (color == FCColor.Border)
                    {
                        color = FCColor.argb(200, 200, 200);
                    }
                    else if (color == FCColor.Text)
                    {
                        color = FCColor.argb(0, 0, 0);
                    }
                    else if (color == FCColor.DisabledBack)
                    {
                        color = FCColor.argb(25, 255, 255, 255);
                    }
                    else if (color == FCColor.DisabledText)
                    {
                        color = 3289650;
                    }
                    else if (color == FCColor.Hovered)
                    {
                        color = FCColor.argb(150, 200, 200, 200);
                    }
                    else if (color == FCColor.Pushed)
                    {
                        color = FCColor.argb(150, 150, 150, 150);
                    }
                }
                else if (color == FCCOLORS_BACKCOLOR)
                {
                    color = FCColor.argb(255, 255, 255);
                }
                else if (color == FCCOLORS_BACKCOLOR2)
                {
                    color = FCColor.argb(230, 230, 230);
                }
                else if (color == FCCOLORS_BACKCOLOR3)
                {
                    color = FCColor.argb(25, 100, 100, 100);
                }
                else if (color == FCCOLORS_BACKCOLOR4)
                {
                    color = FCColor.argb(25, 0, 0, 0);
                }
                else if (color == FCCOLORS_BACKCOLOR5)
                {
                    color = FCColor.argb(75, 51, 153, 255);
                }
                else if (color == FCCOLORS_BACKCOLOR6)
                {
                    color = FCColor.argb(50, 51, 153, 255);
                }
                else if (color == FCCOLORS_BACKCOLOR7)
                {
                    color = FCColor.argb(100, 255, 255, 255);
                }
                else if (color == FCCOLORS_BACKCOLOR8)
                {
                    color = FCColor.argb(50, 105, 217);
                }
                else if (color == FCCOLORS_BACKCOLOR9)
                {
                    color = FCColor.argb(75, 215, 99);
                }
                else if (color == FCCOLORS_TEXTCOLOR)
                {
                    color = FCColor.argb(0, 0, 0);
                }
                else if (color == FCCOLORS_TEXTCOLOR2)
                {
                    color = FCColor.argb(112, 112, 112);
                }
                else if (color == FCCOLORS_TEXTCOLOR3)
                {
                    color = FCColor.argb(100, 255, 255, 255);
                }
                else if (color == FCCOLORS_TEXTCOLOR4)
                {
                    color = FCColor.argb(255, 255, 255);
                }
                else if (color == FCCOLORS_LINECOLOR)
                {
                    color = FCColor.argb(100, 100, 100);
                }
                else if (color == FCCOLORS_LINECOLOR2)
                {
                    color = FCColor.argb(0, 105, 217);
                }
                else if (color == FCDraw.FCCOLORS_UPCOLOR)
                {
                    color = FCColor.argb(255, 82, 82);
                }
                else if (color == FCDraw.FCCOLORS_DOWNCOLOR)
                {
                    color = FCColor.argb(80, 255, 80);
                }
                else if (color == FCDraw.FCCOLORS_LINECOLOR3)
                {
                    color = FCColor.argb(5, 255, 255, 255);
                }
                else if (color == FCCOLORS_SELECTEDROWCOLOR)
                {
                    color = FCColor.argb(0, 105, 217);
                }
                else if (color == FCCOLORS_HOVEREDROWCOLOR)
                {
                    color = FCColor.argb(200, 240, 240, 240);
                }
                else if (color == FCCOLORS_ALTERNATEROWCOLOR)
                {
                    color = FCColor.argb(200, 245, 245, 245);
                }
                else if (color == FCDraw.FCCOLORS_WINDOWTEXTCOLOR)
                {
                    color = FCColor.argb(0, 0, 0);
                }
                else if (color == FCDraw.FCCOLORS_WINDOWBACKCOLOR)
                {
                    color = FCColor.argb(255, 255, 255);
                }
                else if (color == FCDraw.FCCOLORS_WINDOWBACKCOLOR2)
                {
                    color = FCColor.argb(100, 255, 255, 255);
                }
                else if (color == FCDraw.FCCOLORS_WINDOWBACKCOLOR3)
                {
                    color = FCColor.argb(230, 255, 255, 255);
                }
                else if (color == FCDraw.FCCOLORS_WINDOWCROSSLINECOLOR)
                {
                    color = FCColor.argb(100, 100, 100);
                }
                else if (color == FCDraw.FCCOLORS_WINDOWCROSSLINECOLOR2)
                {
                    color = FCColor.argb(10, 255, 255, 255);
                }
                else if (color == FCDraw.FCCOLORS_WINDOWCONTENTBACKCOLOR)
                {
                    color = FCColor.argb(235, 255, 255, 255);
                }
            }
            if (m_style == 2 || m_style == 3)
            {
                int a = 0, r = 0, g = 0, b = 0;
                FCColor.toArgb(null, color, ref a, ref r, ref g, ref b);
                if (m_style == 2)
                {
                    return(FCColor.argb(a, (r + g + b) / 3, (r + g + b) / 3, (r + g + b) / 3));
                }
                else if (m_style == 3)
                {
                    return(FCColor.argb(a, 255 - r, 255 - g, 255 - b));
                }
            }
            return(color);
        }