Example #1
0
 /// <summary>
 /// 创建填空
 /// </summary>
 public Sky()
 {
     BackColor   = COLOR.ARGB(255, 255, 255);
     BorderColor = COLOR.EMPTY;
     ForeColor   = COLOR.ARGB(0, 0, 0);
     Font        = new FONT("Arial", 80, true, false, true);
 }
Example #2
0
        /// <summary>
        /// 绘制文字
        /// </summary>
        /// <param name="paint">绘图对象</param>
        /// <param name="text">文字</param>
        /// <param name="dwPenColor">颜色</param>
        /// <param name="font">字体</param>
        /// <param name="x">横坐标</param>
        /// <param name="y">纵坐标</param>
        public static void DrawText(CPaint paint, String text, long dwPenColor, FONT font, int x, int y)
        {
            SIZE tSize = paint.TextSize(text, font);
            RECT tRect = new RECT(x, y, x + tSize.cx, y + tSize.cy);

            paint.DrawText(text, dwPenColor, font, tRect);
        }
Example #3
0
 /// <summary>
 /// 创建填空
 /// </summary>
 public Sky()
 {
     BackColor   = COLOR.EMPTY;
     BorderColor = COLOR.EMPTY;
     Font        = new FONT("微软雅黑", 100, true, false, true);
     ForeColor   = COLOR.ARGB(255, 255, 40, 40);
 }
Example #4
0
        //load fonts
        private static bool InitFont()
        {
            /* We will use the lower case letters from Allegro's normal font and the
             * uppercase letters from the font in unifont.dat
             */
            FONT f1 = load_font("unifont.dat", NULL, NULL);

            if (!f1)
            {
                set_gfx_mode(GFX_TEXT, 0, 0, 0, 0);
                allegro_message("Cannot find unifont.dat in current directory.\n");
                return(false);
            }

            /* Extract character ranges */
            FONT f2 = extract_font_range(font, ' ', 'A' - 1);
            FONT f3 = extract_font_range(f1, 'A', 'Z');
            FONT f4 = extract_font_range(font, 'Z' + 1, 'z');
            FONT f5;

            /* Merge fonts */
            font = merge_fonts(f4, f5 = merge_fonts(f2, f3));

            /* Destroy temporary fonts */
            destroy_font(f1);
            destroy_font(f2);
            destroy_font(f3);
            destroy_font(f4);
            destroy_font(f5);

            return(true);
        }
Example #5
0
 /// <summary>
 /// 绘制有下划线的数字
 /// </summary>
 /// <param name="paint">绘图对象</param>
 /// <param name="value">值</param>
 /// <param name="digit">保留小数位数</param>
 /// <param name="font">字体</param>
 /// <param name="fontColor">文字颜色</param>
 /// <param name="zeroAsEmpty">0是否为空</param>
 /// <param name="x">横坐标</param>
 /// <param name="y">纵坐标</param>
 /// <returns>绘制的横坐标</returns>
 public static int DrawUnderLineNum(CPaint paint, double value, int digit, FONT font, long fontColor, bool zeroAsEmpty, int x, int y)
 {
     if (zeroAsEmpty && value == 0)
     {
         String text = "-";
         SIZE   size = paint.TextSize(text, font);
         CDraw.DrawText(paint, text, fontColor, font, x, y);
         return(size.cx);
     }
     else
     {
         String[] nbs = CStr.GetValueByDigit(value, digit).Split(new String[] { "." }, StringSplitOptions.RemoveEmptyEntries);
         if (nbs.Length == 1)
         {
             SIZE size = paint.TextSize(nbs[0], font);
             CDraw.DrawText(paint, nbs[0], fontColor, font, x, y);
             return(size.cx);
         }
         else
         {
             SIZE decimalSize = paint.TextSize(nbs[0], font);
             SIZE size        = paint.TextSize(nbs[1], font);
             CDraw.DrawText(paint, nbs[0], fontColor, font, x, y);
             CDraw.DrawText(paint, nbs[1], fontColor, font, x
                            + decimalSize.cx + 1, y);
             paint.DrawLine(fontColor, 1, 0, x
                            + decimalSize.cx + 1, y + decimalSize.cy,
                            x + decimalSize.cx + size.cx, y + decimalSize.cy);
             return(decimalSize.cx + size.cx);
         }
     }
 }
Example #6
0
 internal ConsoleDataBlock(byte[] bytes, int offset)
 {
     BlockSize              = BitConverter.ToUInt32(bytes, offset);
     Name                   = (EXTRA_DATA_TYPE)BitConverter.ToUInt32(bytes, offset + 0x04);
     FillAttribute          = (FILL)BitConverter.ToUInt16(bytes, offset + 0x08);
     PopupFillAttribute     = (FILL)BitConverter.ToUInt16(bytes, offset + 0x0A);
     ScreenBufferSizeX      = BitConverter.ToInt16(bytes, offset + 0x0C);
     ScreenBufferSizeY      = BitConverter.ToInt16(bytes, offset + 0x0E);
     WindowSizeX            = BitConverter.ToInt16(bytes, offset + 0x10);
     WindowSizeY            = BitConverter.ToInt16(bytes, offset + 0x12);
     WindowOriginX          = BitConverter.ToInt16(bytes, offset + 0x14);
     WindowOriginY          = BitConverter.ToInt16(bytes, offset + 0x16);
     FontSize               = BitConverter.ToUInt32(bytes, offset + 0x20);
     FontFamily             = (FONT)BitConverter.ToUInt32(bytes, offset + 0x24);
     FontWeight             = BitConverter.ToUInt32(bytes, offset + 0x28);
     FaceName               = Encoding.Unicode.GetString(bytes, offset + 0x2C, 0x40);
     CursorSize             = BitConverter.ToUInt32(bytes, offset + 0x30);
     FullScreen             = BitConverter.ToUInt32(bytes, offset + 0x34) != 0;
     QuickEdit              = BitConverter.ToUInt32(bytes, offset + 0x38) != 0;
     InsertMode             = BitConverter.ToUInt32(bytes, offset + 0x3C) != 0;
     AutoPosition           = BitConverter.ToUInt32(bytes, offset + 0x40) != 0;
     HistoryBufferSize      = BitConverter.ToUInt32(bytes, offset + 0x44);
     NumberOfHistroyBuffers = BitConverter.ToUInt32(bytes, offset + 0x48);
     HistoryNoDup           = BitConverter.ToUInt32(bytes, offset + 0x4C) != 0;
     // More research needed
     ColorTable = Helper.GetSubArray(bytes, offset + 0x50, 0x40);
 }
        public SharedResource(bool newbook)
        {
            FONT font = new FONT();
            font.Height = 200;
            font.OptionFlags = 0;
            font.ColorIndex = 32767;
            font.Weight = 400;
            font.Escapement = 0;
            font.Underline = 0;
            font.CharacterSet = 1;
            font.Name = "Arial";
            //Fonts.Add(font);

            for (ushort i = 0; i < 21; i++) // required by MS Excel 2003
            {
                XF xf = new XF();
                xf.Attributes = 252;
                xf.CellProtection = 65524;
                xf.PatternColorIndex = 64;
                xf.PatternBackgroundColorIndex = 130;
                xf.FontIndex = 0;
                xf.FormatIndex = i;
                ExtendedFormats.Add(xf);
            }

            MaxNumberFormatIndex = 163;
            GetXFIndex(CellFormat.General);

            SharedStringTable = new SST();
        }
Example #8
0
 /// <summary>
 /// 控件添加方法
 /// </summary>
 public override void OnAdd()
 {
     base.OnAdd();
     if (m_closeButton == null)
     {
         m_closeButton      = new WindowButton();
         m_closeButton.Name = "btnClose";
         SIZE buttonSize = new SIZE(20, 20);
         m_closeButton.Size = buttonSize;
         AddControl(m_closeButton);
     }
     if (m_maxOrRestoreButton == null)
     {
         m_maxOrRestoreButton       = new WindowButton();
         m_maxOrRestoreButton.Name  = "btnMaxOrRestore";
         m_maxOrRestoreButton.Style = WindowButtonStyle.Max;
         SIZE buttonSize = new SIZE(20, 20);
         m_maxOrRestoreButton.Size = buttonSize;
         AddControl(m_maxOrRestoreButton);
         m_maxOrRestoreButton.RegisterEvent(new ControlMouseEvent(ClickButton), EVENTID.CLICK);
     }
     if (m_minButton == null)
     {
         m_minButton       = new WindowButton();
         m_minButton.Name  = "btnMin";
         m_minButton.Style = WindowButtonStyle.Min;
         SIZE buttonSize = new SIZE(20, 20);
         m_minButton.Size = buttonSize;
         AddControl(m_minButton);
         m_minButton.RegisterEvent(new ControlMouseEvent(ClickButton), EVENTID.CLICK);
     }
     Font = new FONT("微软雅黑", 14, true, false, false);
 }
Example #9
0
        /// <summary>
        /// 重绘方法
        /// </summary>
        /// <param name="paint">绘图对象</param>
        /// <param name="clipRect">裁剪区域</param>
        public override void OnPaint(CPaint paint, RECT clipRect)
        {
            int width  = Width;
            int height = Height;

            if (width > 0 && height > 0)
            {
                //绘制背景
                RECT drawRect = new RECT(0, 0, width, height);
                paint.FillRect(GetPaintingBackColor(), clipRect);
                paint.DrawImage("file='Logo.png'", new RECT(30, 50, 300, 150));
                if (m_showRecord)
                {
                    double num        = Convert.ToDouble(m_stopWatch.ElapsedMilliseconds);
                    String highRecord = "HIGH " + m_high.ToString("0.000");
                    FONT   font       = Font;
                    SIZE   tSize      = paint.TextSize(highRecord, font);
                    paint.DrawText(highRecord, ForeColor, font, new RECT(Width / 2 - tSize.cx / 2, 5, Width, 20));
                    String nowRecord = "TIME" + ((num / 1000.0)).ToString("0.000");
                    paint.DrawText(nowRecord, ForeColor, font, new RECT(0, 5, 100, 20));
                }
                m_plane.OnPaintBackground(paint);
                for (int i = 0; i < m_bullets.Count; i++)
                {
                    Bullet bullet = m_bullets[i];
                    bullet.OnPaintBackground(paint);
                }
            }
        }
Example #10
0
 /// <summary>
 /// 创建标签
 /// </summary>
 /// <param name="battle">战场</param>
 public Play(Battle battle)
 {
     m_battle    = battle;
     BorderColor = COLOR.EMPTY;
     Font        = new FONT("SimSun", 16, true, false, true);
     ForeColor   = COLOR.ARGB(255, 255, 255);
 }
Example #11
0
 /// <summary>
 /// 重绘前景方法
 /// </summary>
 /// <param name="paint">绘图对象</param>
 /// <param name="clipRect">裁剪区域</param>
 public override void OnPaintBackground(CPaint paint, RECT clipRect)
 {
     base.OnPaintBackground(paint, clipRect);
     lock (m_barrages)
     {
         int barragesSize = m_barrages.Count;
         for (int i = 0; i < barragesSize; i++)
         {
             Barrage brg  = m_barrages[i];
             FONT    font = brg.Font;
             RECT    rect = brg.Rect;
             String  str  = brg.Text;
             SIZE    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;
                 COLOR.ToARGB(null, color, ref a, ref r, ref g, ref b);
                 a     = a * brg.Tick / 400;
                 color = COLOR.ARGB(a, r, g, b);
             }
             paint.DrawText(str, color, font, rect);
         }
     }
 }
Example #12
0
        /// <summary>
        /// 绘制背景
        /// </summary>
        /// <param name="paint">绘图对象</param>
        /// <param name="clipRect">裁剪区域</param>
        public override void OnPaintBackground(CPaint paint, RECT clipRect)
        {
            int  width = Width - 1, height = Height - 1;
            RECT drawRect = new RECT(0, 0, width, height);

            paint.FillRect(COLOR.ARGB(0, 0, 0), drawRect);
            int  outSize = 40;
            int  oX = width / 2, oY = height / 2, r = (width - outSize * 2) / 2;
            long innerBorderColor = COLOR.ARGB(100, 100, 100);

            int[] angles = new int[] { 240, 180, 120, 60, 0, -60 };
            int[] rs     = new int[] { r, r * 2 / 3, r / 3 };
            for (int i = 0; i < 3; i++)
            {
                POINT[] drawPoints = new POINT[6];
                for (int j = 0; j < 6; j++)
                {
                    drawPoints[j] = GetCyclePoint(oX, oY, rs[i], angles[j]);
                }
                paint.DrawPolygon(innerBorderColor, 1, 0, drawPoints);
            }
            FONT pFont = new FONT("微软雅黑", 16, false, false, false);

            POINT[] points     = GetTitlePoints();
            int     pointsSize = points.Length;

            String[] strs   = new String[] { "业务", "情商", "学识", "智商", "管理", "技术" };
            int[]    values = new int[6];
            if (m_dimension != null)
            {
                values = new int[] { m_dimension.m_business, m_dimension.m_EQ, m_dimension.m_knowledge,
                                     m_dimension.m_IQ, m_dimension.m_lead, m_dimension.m_technology };
            }
            POINT [] scopePoints = GetScopePoints();
            for (int i = 0; i < pointsSize; i++)
            {
                int   bSize  = 5;
                POINT bPoint = points[i];
                RECT  bRect  = new RECT(bPoint.x - bSize, bPoint.y - bSize, bPoint.x + bSize, bPoint.y + bSize);
                SIZE  pSize  = paint.TextSize(strs[i], pFont);
                if (i == 0 || i == 5)
                {
                    bPoint.y -= 20;
                }
                CDraw.DrawText(paint, strs[i], m_sysColors[i], pFont, bPoint.x - pSize.cx / 2, bPoint.y - pSize.cy / 2);
                int   iSize = 5;
                POINT cp    = GetCyclePoint(oX, oY, r, angles[i]);
                paint.DrawLine(innerBorderColor, 1, 0, oX, oY, cp.x, cp.y);
                paint.FillEllipse(m_sysColors[i], new RECT(cp.x - iSize, cp.y - iSize, cp.x + iSize, cp.y + iSize));
                String text  = String.Format("({0})", CStr.ConvertIntToStr(values[i]));
                SIZE   sSize = paint.TextSize(text, pFont);
                CDraw.DrawText(paint, text, m_sysColors[i], pFont, bPoint.x - sSize.cx / 2, bPoint.y + sSize.cy / 2);
            }
            if (m_dimension != null)
            {
                paint.FillGradientPolygon(COLOR.ARGB(200, 50, 105, 217), COLOR.ARGB(200, 50, 105, 217), scopePoints, 90);
                paint.DrawPolygon(COLOR.ARGB(100, 255, 255, 255), 1, 0, scopePoints);
            }
        }
Example #13
0
        /// <summary>
        /// 绘制前景方法
        /// </summary>
        /// <param name="paint">绘图对象</param>
        /// <param name="clipRect">裁剪区域</param>
        public override void OnPaintForeground(CPaint paint, RECT clipRect)
        {
            RECT bounds = Bounds;
            int  width  = bounds.right - bounds.left;
            int  height = bounds.bottom - bounds.top;

            if (width > 0 && height > 0)
            {
                if (m_ssLatestData != null && m_szLatestData != null && m_cyLatestData != null)
                {
                    long titleColor = CDraw.PCOLORS_FORECOLOR2;
                    FONT font       = new FONT("SimSun", 16, false, false, false);
                    FONT indexFont  = new FONT("Arial", 14, true, false, false);
                    long grayColor  = CDraw.PCOLORS_FORECOLOR4;
                    //上证指数
                    long indexColor = CDraw.GetPriceColor(m_ssLatestData.m_close, m_ssLatestData.m_lastClose);
                    int  left       = 1;
                    CDraw.DrawText(paint, "上证", titleColor, font, left, 3);
                    left += 40;
                    paint.DrawLine(grayColor, 1, 0, left, 0, left, height);
                    String amount     = (m_ssLatestData.m_amount / 100000000).ToString("0.0") + "亿";
                    SIZE   amountSize = paint.TextSize(amount, indexFont);
                    CDraw.DrawText(paint, amount, titleColor, indexFont, width / 3 - amountSize.cx, 3);
                    left += (width / 3 - 40 - amountSize.cx) / 4;
                    int length = CDraw.DrawUnderLineNum(paint, m_ssLatestData.m_close, 2, indexFont, indexColor, false, left, 3);
                    left  += length + (width / 3 - 40 - amountSize.cx) / 4;
                    length = CDraw.DrawUnderLineNum(paint, m_ssLatestData.m_close - m_ssLatestData.m_lastClose, 2, indexFont, indexColor, false, left, 3);
                    //深证指数
                    left = width / 3;
                    paint.DrawLine(grayColor, 1, 0, left, 0, left, height);
                    indexColor = CDraw.GetPriceColor(m_szLatestData.m_close, m_szLatestData.m_lastClose);
                    CDraw.DrawText(paint, "深证", titleColor, font, left, 3);
                    left += 40;
                    paint.DrawLine(grayColor, 1, 0, left, 0, left, height);
                    amount     = (m_szLatestData.m_amount / 100000000).ToString("0.0") + "亿";
                    amountSize = paint.TextSize(amount, indexFont);
                    CDraw.DrawText(paint, amount, titleColor, indexFont, width * 2 / 3 - amountSize.cx, 3);
                    left  += (width / 3 - 40 - amountSize.cx) / 4;
                    length = CDraw.DrawUnderLineNum(paint, m_szLatestData.m_close, 2, indexFont, indexColor, false, left, 3);
                    left  += length + (width / 3 - 40 - amountSize.cx) / 4;
                    length = CDraw.DrawUnderLineNum(paint, m_szLatestData.m_close - m_szLatestData.m_lastClose, 2, indexFont, indexColor, false, left, 3);
                    //创业指数
                    left = width * 2 / 3;
                    paint.DrawLine(grayColor, 1, 0, left, 0, left, height);
                    indexColor = CDraw.GetPriceColor(m_cyLatestData.m_close, m_cyLatestData.m_lastClose);
                    CDraw.DrawText(paint, "创业", titleColor, font, left, 3);
                    left += 40;
                    paint.DrawLine(grayColor, 1, 0, left, 0, left, height);
                    amount     = (m_cyLatestData.m_amount / 100000000).ToString("0.0") + "亿";
                    amountSize = paint.TextSize(amount, indexFont);
                    CDraw.DrawText(paint, amount, titleColor, indexFont, width - amountSize.cx, 3);
                    left  += (width / 3 - 40 - amountSize.cx) / 4;
                    length = CDraw.DrawUnderLineNum(paint, m_cyLatestData.m_close, 2, indexFont, indexColor, false, left, 3);
                    left  += (width / 3 - 40 - amountSize.cx) / 4 + length;
                    length = CDraw.DrawUnderLineNum(paint, m_cyLatestData.m_close - m_cyLatestData.m_lastClose, 2, indexFont, indexColor, false, left, 3);
                    paint.DrawRect(grayColor, 1, 0, new RECT(0, 0, width - 1, height - 1));
                }
            }
        }
Example #14
0
 /// <summary>
 /// 创建填空
 /// </summary>
 public Sky()
 {
     BackColor    = COLOR.ARGB(0, 0, 100, 255);
     BorderColor  = COLOR.EMPTY;
     Font         = new FONT("Arial", 16, false, false, false);
     ForeColor    = COLOR.ARGB(255, 255, 255);
     ResourcePath = DataCenter.GetAppPath() + "\\config";
 }
Example #15
0
        /// <summary>
        /// 重绘方法
        /// </summary>
        /// <param name="paint">绘图对象</param>
        /// <param name="clipRect">裁剪区域</param>
        public override void OnPaint(CPaint paint, RECT clipRect)
        {
            int width  = Width;
            int height = Height;

            if (width > 0 && height > 0)
            {
                //绘制背景
                RECT drawRect = new RECT(0, 0, width, height);
                paint.FillRect(GetPaintingBackColor(), clipRect);
                for (int i = 0; i < m_bullets.Count; i++)
                {
                    Bullet bullet = m_bullets[i];
                    bullet.OnPaintBackground(paint);
                }
                String text   = String.Format("{0}/{1}", m_score, m_total);
                FONT   font   = Font;
                SIZE   tSize  = paint.TextSize(text, font);
                POINT  tPoint = new POINT(width / 2 - tSize.cx / 2, 10);
                RECT   tRect  = new RECT(tPoint.x, tPoint.y, tPoint.x + tSize.cx, tSize.cy);
                //paint.DrawText(text, ForeColor, font, tRect);
                int pointsSize = m_points.Count;
                for (int i = 0; i < pointsSize; i++)
                {
                    POINT point = m_points[i];
                    RECT  pRect = new RECT(point.x - 10, point.y - 10, point.x + 10, point.y + 10);
                    paint.FillGradientEllipse(COLOR.ARGB(50, 0, 0, 0), COLOR.ARGB(50, 30, 30, 30), pRect, 90);
                    paint.DrawEllipse(COLOR.ARGB(50, 100, 100, 100), 1, 0, pRect);
                }
                String title  = "随机选拔";
                FONT   tiFont = new FONT("微软雅黑", 30, true, false, false);
                SIZE   tiSize = paint.TextSize(title, tiFont);
                RECT   tiRect = new RECT();
                tiRect.left   = (width - tiSize.cx) / 2;
                tiRect.top    = height - 120;
                tiRect.right  = tiRect.left + tiSize.cx;
                tiRect.bottom = tiRect.top + tiSize.cy;
                paint.DrawText(title, COLOR.ARGB(255, 0, 0), tiFont, tiRect);
                int membersSize = m_members.Count;
                if (membersSize > 0)
                {
                    int avgWidth = width / membersSize, mLeft = 0;
                    for (int i = 0; i < membersSize; i++)
                    {
                        FONT   mFont  = new FONT("微软雅黑", 35, true, false, false);
                        String member = m_members[i];
                        SIZE   mSize  = paint.TextSize(member, mFont);
                        RECT   mRect  = new RECT();
                        mRect.left   = mLeft + (avgWidth - mSize.cx) / 2;
                        mRect.top    = height - 80;
                        mRect.right  = mRect.left + mSize.cx;
                        mRect.bottom = mRect.top + mSize.cy;
                        paint.DrawText(member, m_sysColors[m_random.Next(0, m_sysColors.Length)], mFont, mRect);
                        mLeft += avgWidth;
                    }
                }
            }
        }
Example #16
0
 /// <summary>
 /// 创建战场
 /// </summary>
 public Battle()
 {
     m_timerID = GetNewTimerID();
     //初始化颜色
     BorderColor = COLOR.ARGB(112, 112, 112);
     BackColor   = COLOR.ARGB(255, 255, 255);
     ForeColor   = COLOR.ARGB(255, 255, 255);
     Font        = new FONT("Arial", 100, false, false, false);
 }
Example #17
0
        /// <summary>
        /// 重绘方法
        /// </summary>
        /// <param name="paint">绘图对象</param>
        /// <param name="rect">矩形</param>
        /// <param name="clipRect">裁剪矩形</param>
        /// <param name="isAlternate">是否交替行</param>
        public override void OnPaint(CPaint paint, RECT rect, RECT clipRect, bool isAlternate)
        {
            int clipW = clipRect.right - clipRect.left;
            int clipH = clipRect.bottom - clipRect.top;

            if (clipW > 0 && clipH > 0)
            {
                GridA      grid   = Grid;
                GridRow    row    = Row;
                GridColumn column = Column;
                if (grid != null && row != null && column != null)
                {
                    //判断选中
                    String         text             = Text;
                    bool           selected         = false;
                    List <GridRow> selectedRows     = grid.SelectedRows;
                    int            selectedRowsSize = selectedRows.Count;
                    for (int i = 0; i < selectedRowsSize; i++)
                    {
                        if (selectedRows[i] == row)
                        {
                            selected = true;
                            break;
                        }
                    }
                    //获取颜色
                    FONT          font      = null;
                    long          foreColor = COLOR.EMPTY;
                    GridCellStyle style     = Style;
                    if (style != null)
                    {
                        if (style.Font != null)
                        {
                            font = style.Font;
                        }
                        foreColor = style.ForeColor;
                    }
                    SecurityFilterInfo info = (row as SecurityFilterResultRow).Info;
                    if (info.GetValue("FILTER") != 1)
                    {
                        foreColor = CDraw.PCOLORS_FORECOLOR8;
                    }
                    SIZE  tSize  = paint.TextSize(text, font);
                    POINT tPoint = new POINT(rect.left + 1, rect.top + clipH / 2 - tSize.cy / 2);
                    if (column.Name == "colCode")
                    {
                        tPoint.x = rect.right - tSize.cx;
                    }
                    RECT tRect = new RECT(tPoint.x, tPoint.y, tPoint.x + tSize.cx, tPoint.y + tSize.cy);
                    paint.DrawText(text, foreColor, font, tRect);
                    if (selected)
                    {
                        paint.DrawLine(CDraw.PCOLORS_LINECOLOR, 2, 0, rect.left, rect.bottom - 1, rect.right, rect.bottom - 1);
                    }
                }
            }
        }
Example #18
0
        /// <summary>
        /// 重绘背景方法
        /// </summary>
        /// <param name="paint">绘图对象</param>
        /// <param name="clipRect">裁剪区域</param>
        public override void OnPaintBackground(CPaint paint, RECT clipRect)
        {
            int width  = Width;
            int height = Height;

            if (width > 0 && height > 0)
            {
                //绘制背景
                RECT drawRect = new RECT(0, 0, width, height);
                //paint.DrawGradientRect(COLOR.ARGB(200, 90, 120, 24), COLOR.ARGB(200, 122, 156, 40), drawRect, 0, 90);
                paint.DrawRoundRect(COLOR.ARGB(200, 90, 120, 24), 1, 0, drawRect, 5);
                if (m_play.GameState != GameState.Begin)
                {
                    //绘制分数
                    FONT   font     = Font;
                    String strScore = m_eatCount.ToString();
                    SIZE   tSize    = paint.TextSize(strScore, font);
                    //修正透明度
                    if (m_play.GameState == GameState.Playing)
                    {
                        //减少
                        if (m_alphaDirection == 0)
                        {
                            m_alpha -= 5;
                        }
                        //增加
                        else if (m_alphaDirection == 1)
                        {
                            m_alpha += 5;
                        }
                        //改变变动方向
                        if (m_alpha > 50)
                        {
                            m_alphaDirection = 0;
                            m_alpha          = 50;
                        }
                        else if (m_alpha < 20)
                        {
                            m_alphaDirection = 1;
                            m_alpha          = 20;
                        }
                    }
                    else
                    {
                        m_alpha = 50;
                    }
                    RECT tRect = new RECT();
                    tRect.left   = drawRect.right / 2 - tSize.cx / 2;
                    tRect.top    = drawRect.bottom / 2 - tSize.cy / 2;
                    tRect.right  = tRect.left + tSize.cx;
                    tRect.bottom = tRect.top + tSize.cy;
                    paint.DrawText(strScore, COLOR.ARGB(m_alpha * 3, 255, 255, 255), font, tRect);
                }
            }
        }
Example #19
0
        /// <summary>
        /// 重绘层
        /// </summary>
        /// <param name="sender">调用者</param>
        /// <param name="paint">绘图对象</param>
        /// <param name="clicpRect">裁剪区域</param>
        private void PaintDiv(Object sender, CPaint paint, RECT clicpRect)
        {
            DivA div = sender as DivA;
            int  width = div.Width, height = div.Height;
            RECT drawRect = new RECT(0, 0, width, height);

            if (m_mode == 5)
            {
                paint.FillGradientRect(COLOR.ARGB(200, 255, 40, 24), COLOR.ARGB(200, 255, 255, 40), drawRect, 0, m_tick % 360);
            }
            else
            {
                paint.FillGradientRect(COLOR.ARGB(200, 90, 120, 24), COLOR.ARGB(200, 122, 156, 40), drawRect, 0, 0);
            }
            RECT bounds        = m_lblTime.Bounds;
            RECT fullBloodRect = new RECT(bounds.left, bounds.bottom, bounds.left + 400, bounds.bottom + 15);

            paint.FillRect(COLOR.ARGB(255, 0, 0), fullBloodRect);
            int  bloodWidth = (int)(m_currentTick / m_totalTick * 400);
            RECT bloodRect  = new RECT(bounds.left, bounds.bottom, bounds.left + bloodWidth, bounds.bottom + 15);

            if (bloodWidth < 40)
            {
                paint.FillRect(COLOR.ARGB(255, 150, 0), bloodRect);
            }
            else if (bloodWidth < 120)
            {
                paint.FillRect(COLOR.ARGB(255, 200, 0), bloodRect);
            }
            else
            {
                paint.FillRect(COLOR.ARGB(255, 255, 0), bloodRect);
            }
            if (m_currentQuestion != null && m_currentQuestion.m_type == "极限")
            {
                String[] strs   = m_txtAnswer.Text.Split(new String[] { "\r" }, StringSplitOptions.RemoveEmptyEntries);
                int      cCount = 0;
                foreach (String str in strs)
                {
                    if (str == "for(int i = 0; i < 100; i++)")
                    {
                        cCount++;
                    }
                }
                String strLine = cCount.ToString();
                FONT   tFont   = new FONT("微软雅黑", 100, true, false, true);
                SIZE   tSize   = paint.TextSize(strLine, tFont);
                RECT   tRect   = new RECT();
                tRect.left   = (width - tSize.cx) / 2;
                tRect.top    = (height - tSize.cy) / 2;
                tRect.right  = tRect.left + tSize.cx;
                tRect.bottom = tRect.top + tSize.cy;
                paint.DrawText(strLine, COLOR.ARGB(200, 255, 255, 255), tFont, tRect);
            }
        }
Example #20
0
 /// <summary>
 /// 创建窗体
 /// </summary>
 public WindowEx()
 {
     BackColor     = COLOR.EMPTY;
     BorderColor   = CDraw.PCOLORS_LINECOLOR3;
     CaptionHeight = 23;
     Font          = new FONT("SimSun", 14, true, false, false);
     ForeColor     = COLOR.EMPTY;
     Opacity       = 0;
     ResourcePath  = DataCenter.GetAppPath() + "\\config";
     ShadowColor   = CDraw.PCOLORS_BACKCOLOR5;
 }
Example #21
0
        /// <summary>
        /// 重绘前景方法
        /// </summary>
        /// <param name="paint">绘图对象</param>
        /// <param name="clipRect">裁剪区域</param>
        public override void OnPaintForeground(CPaint paint, RECT clipRect)
        {
            int  width  = Width;
            int  height = Height;
            FONT font   = new FONT("微软雅黑", 14, true, false, false);

            if (m_tick != 0)
            {
                font.m_fontSize += 2;
            }
            long   foreColor = GetPaintingForeColor();
            String backImage = GetPaintingBackImage();
            int    border    = m_tick;

            if (border > 10)
            {
                border = 10;
            }
            int  imgWidth  = 88 - (10 - border);
            int  imgHeight = 88 - (10 - border);
            int  gap       = 15;
            RECT imageRect = new RECT((width - imgWidth) / 2, (height - imgHeight) / 2 - gap, (width + imgWidth) / 2, (height + imgHeight) / 2 - gap);

            if (backImage != null && backImage.Length > 0)
            {
                if (m_tick != 0)
                {
                    paint.SetOpacity((float)(0.5 + border * 0.05f));
                }
                paint.DrawImage(backImage, imageRect);
                paint.SetOpacity(1);
            }
            if (m_text != null && m_name.Length > 0)
            {
                SIZE tSize = paint.TextSize(m_text, font);
                RECT tRect = new RECT();
                tRect.left   = (width - tSize.cx) / 2;
                tRect.top    = imageRect.bottom + gap;
                tRect.right  = tRect.left + tSize.cx;
                tRect.bottom = tRect.top + tSize.cy;
                paint.DrawText(m_text, foreColor, font, tRect);
            }
            if (m_direction == 1)
            {
                int pointsSize = m_points.Count;
                for (int i = 0; i < pointsSize; i++)
                {
                    POINT point = m_points[i];
                    RECT  pRect = new RECT(point.x - 10, point.y - 10, point.x + 10, point.y + 10);
                    paint.FillGradientEllipse(COLOR.ARGB(50, 255, 255, 255), COLOR.ARGB(50, 220, 220, 220), pRect, 90);
                    paint.DrawEllipse(COLOR.ARGB(50, 100, 100, 100), 1, 0, pRect);
                }
            }
        }
Example #22
0
 /// <summary>
 /// 创建窗体
 /// </summary>
 public WindowEx()
 {
     BackColor     = COLOR.EMPTY;
     BorderColor   = CDraw.PCOLORS_LINECOLOR3;
     CaptionHeight = 25;
     Font          = new FONT("微软雅黑", 14, false, false, false);
     ForeColor     = COLOR.EMPTY;
     Opacity       = 0;
     ShadowColor   = CDraw.PCOLORS_BACKCOLOR5;
     ShadowSize    = 0;
 }
Example #23
0
        /// <summary>
        /// 绘图方法
        /// </summary>
        /// <param name="sender">调用者</param>
        /// <param name="paint">绘图</param>
        /// <param name="clipRect">裁剪区域</param>
        private void PaintDiv(object sender, CPaint paint, RECT clipRect)
        {
            List <DialogInfo> dialogs      = DataCenter.DialogService.m_dialogs;
            int dialogsSize                = dialogs.Count;
            Dictionary <String, int> names = new Dictionary <String, int>();

            for (int i = 0; i < dialogsSize; i++)
            {
                DialogInfo dialog = dialogs[i];
                if (names.ContainsKey(dialog.m_name))
                {
                    names[dialog.m_name] = names[dialog.m_name] + 1;
                }
                else
                {
                    names[dialog.m_name] = 1;
                }
            }
            List <DialogData> datas = new List <DialogData>();

            foreach (String key in names.Keys)
            {
                DialogData data = new DialogData();
                data.m_name  = key;
                data.m_times = names[key];
                datas.Add(data);
            }
            datas.Sort(new DialogDataCompare());
            int width = m_divDialogs.Width, height = m_divDialogs.Height;
            int datasSize = datas.Count;

            if (datasSize > 0)
            {
                int    paddingLeft = 50, paddingRight = 50, paddingTop = 20, paddingBottom = 20;
                int    top   = paddingTop;
                int    pSize = (height - paddingTop - paddingBottom) / datasSize;
                double max   = 0;
                for (int i = 0; i < datasSize; i++)
                {
                    DialogData data = datas[i];
                    if (i == 0)
                    {
                        max = data.m_times;
                    }
                    int wSize = (int)((width - paddingLeft - paddingRight) * data.m_times / max);
                    CDraw.DrawText(paint, data.m_name, COLOR.ARGB(0, 0, 0), m_divDialogs.Font, 5, top);
                    paint.FillGradientRect(m_sysColors[i % m_sysColors.Length], m_sysColors[(i + 1) % m_sysColors.Length], new RECT(paddingLeft, top + 2, paddingLeft + wSize, top + 12), 2, 0);
                    FONT font = new FONT("微软雅黑", 14, false, false, false);
                    CDraw.DrawText(paint, data.m_times.ToString(), COLOR.ARGB(0, 0, 0), font, paddingLeft + wSize, top);
                    top += pSize;
                }
            }
        }
Example #24
0
 /// <summary>
 /// 重绘前景方法
 /// </summary>
 /// <param name="paint">绘图对象</param>
 /// <param name="clipRect">裁剪区域</param>
 public override void OnPaintBackground(CPaint paint, RECT clipRect)
 {
     base.OnPaintBackground(paint, clipRect);
     lock (m_barrages)
     {
         int barragesSize = m_barrages.Count;
         for (int i = 0; i < barragesSize; i++)
         {
             Barrage brg  = m_barrages[i];
             FONT    font = brg.Font;
             RECT    rect = brg.Rect;
             String  str  = brg.Text;
             SIZE    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;
                 COLOR.ToARGB(null, color, ref a, ref r, ref g, ref b);
                 a     = a * brg.Tick / 400;
                 color = COLOR.ARGB(a, r, g, b);
             }
             if (mode == 2)
             {
                 POINT[] points = new POINT[5];
                 int     mWidth = rect.right - rect.left, mHeight = rect.bottom - rect.top;
                 points[0] = new POINT(rect.left, rect.top + mHeight / 2 + 1);
                 points[1] = new POINT(rect.left + 20, rect.top);
                 points[2] = new POINT(rect.right, rect.top);
                 points[3] = new POINT(rect.right, rect.bottom);
                 points[4] = new POINT(rect.left + 20, rect.bottom);
                 RECT drawRect = new RECT(rect.left - 30, rect.top - 10, rect.right + 30, rect.bottom + 10);
                 paint.DrawImage("file='fire2.jpg' highcolor='150,150,150' lowcolor='0,0,0'", drawRect);
                 //paint.FillGradientPolygon(COLOR.ARGB(255, 120, 40), COLOR.ARGB(255, 80, 40), points, 90);
             }
             else
             {
                 paint.DrawText(str, color, font, rect);
             }
         }
     }
 }
Example #25
0
        public override void OnPaint(CPaint paint, RECT rect, RECT clipRect, bool isAlternate)
        {
            RECT textRect = new RECT(rect.left + 10, rect.top + 2, rect.right - 10, rect.bottom - 2);

            paint.FillRoundRect(CDraw.PCOLORS_BACKCOLOR, textRect, 3);
            String text   = Text;
            FONT   font   = new FONT();
            SIZE   tSize  = paint.TextSize(text, font);
            RECT   tRect  = new RECT();
            int    width  = textRect.right - textRect.left;
            int    height = textRect.bottom - textRect.top;

            tRect.left   = textRect.left + (width - tSize.cx) / 2;
            tRect.top    = textRect.top + (height - tSize.cy) / 2;
            tRect.right  = tRect.left + tSize.cx;
            tRect.bottom = tRect.top + tSize.cy;
            paint.DrawText(text, COLOR.ARGB(255, 255, 255), font, tRect);
        }
Example #26
0
        /// <summary>
        /// 获取格式化字体
        /// </summary>
        /// <param name="text">文字</param>
        /// <param name="font">字体</param>
        /// <param name="font">颜色</param>
        /// <returns>格式化字体</returns>
        private FormattedText GetFont(String text, FONT font, long dwPenColor)
        {
            FormattedText ft = new FormattedText(text, CultureInfo.CurrentCulture, FlowDirection.LeftToRight, new Typeface(font.m_fontFamily), font.m_fontSize, GetBrush(dwPenColor));

            if (font.m_bold)
            {
                ft.SetFontWeight(FontWeights.Bold);
            }
            if (font.m_italic)
            {
                ft.SetFontStyle(FontStyles.Italic);
            }
            if (font.m_underline)
            {
                ft.SetTextDecorations(TextDecorations.Underline);
            }
            return(ft);
        }
Example #27
0
        /// <summary>
        /// 绘制文字
        /// </summary>
        /// <param name="text">文字</param>
        /// <param name="dwPenColor">颜色</param>
        /// <param name="font">字体</param>
        /// <param name="rect">矩形区域</param>
        public virtual void DrawText(String text, long dwPenColor, FONT font, RECTF rect)
        {
            int           strX = (int)(rect.left + m_offsetX);
            int           strY = (int)(rect.top + m_offsetY);
            FormattedText ft   = null;

            if (m_scaleFactorX != -1 || m_scaleFactorY != -1)
            {
                float fontSize = font.m_fontSize * (m_scaleFactorX + m_scaleFactorY) / 2;
                FONT  newFont  = new FONT(font.m_fontFamily, fontSize, font.m_bold, font.m_underline, font.m_italic);
                ft = GetFont(text, newFont, dwPenColor);
            }
            else
            {
                ft = GetFont(text, font, dwPenColor);
            }
            m_context.DrawText(ft, new Point(strX, strY));
        }
Example #28
0
        /// <summary>
        /// 重绘表格
        /// </summary>
        /// <param name="paint"></param>
        /// <param name="rect"></param>
        /// <param name="clipRect"></param>
        /// <param name="isAlternate"></param>
        public override void OnPaint(CPaint paint, RECT rect, RECT clipRect, bool isAlternate)
        {
            rect.left  += 2;
            rect.right += 2;
            RECT          cRect = new RECT(rect.left, rect.top - 1, rect.right, rect.bottom + 1);
            GridCellStyle style = Style;

            if (style == null)
            {
                style = new GridCellStyle();
            }
            paint.FillRect(style.BackColor, cRect);
            String text  = Text;
            FONT   font  = m_grid.Font;
            SIZE   tSize = paint.TextSize(text, font);
            RECT   tRect = new RECT();

            //字体默认居左
            tRect.left   = cRect.left + 1;
            tRect.right  = cRect.left + tSize.cx;
            tRect.top    = ((cRect.bottom - cRect.top) / 2 + cRect.top) - tSize.cy / 2;
            tRect.bottom = ((cRect.bottom - cRect.top) / 2 + cRect.top) + tSize.cy / 2;
            HorizontalAlignA align = style.Align;

            if (align == HorizontalAlignA.Center)
            {
                tRect.left  = ((cRect.right - cRect.left) / 2 + cRect.left) - tSize.cx / 2;
                tRect.right = ((cRect.right - cRect.left) / 2 + cRect.left) + tSize.cx / 2;
            }
            if (align == HorizontalAlignA.Right)
            {
                tRect.left  = (cRect.right - tSize.cx);
                tRect.right = cRect.right - 1;
            }
            paint.DrawText(text, style.ForeColor, font, tRect);
            int lw = cRect.right - cRect.left;
            int lh = cRect.bottom - cRect.top;

            paint.DrawLine(COLOR.ARGB(0, 0, 255), 1, 0, new POINT(cRect.left, cRect.top), new POINT(cRect.right, cRect.top));
        }
Example #29
0
        /// <summary>
        /// 重绘单元格方法
        /// </summary>
        /// <param name="paint">绘图对象</param>
        /// <param name="rect">矩形</param>
        /// <param name="clipRect">裁剪区域</param>
        /// <param name="isAlternate">是否交替行</param>
        public override void OnPaint(CPaint paint, RECT rect, RECT clipRect, bool isAlternate)
        {
            String text      = Text;
            FONT   titleFont = new FONT("微软雅黑", 18, true, false, false);
            SIZE   tSize     = paint.TextSize(text, titleFont);

            paint.DrawText(text, COLOR.ARGB(238, 199, 16), titleFont, new RECT(rect.left, rect.top + 5, 0, 0));
            String strStar = "";

            for (int i = 0; i < m_rate; i++)
            {
                strStar += "★";
            }
            paint.DrawText(strStar, COLOR.ARGB(255, 255, 80), titleFont, new RECT(rect.left + tSize.cx, rect.top + 5, 0, 0));
            FONT contentFont = new FONT("微软雅黑", 14, false, false, false);

            paint.DrawText("---" + m_content + "---", COLOR.ARGB(255, 255, 255), contentFont, new RECT(rect.left, rect.top + tSize.cy + 10, 0, 0));
            FONT awardFont = new FONT("微软雅黑", 16, false, false, false);

            paint.DrawText(m_award, COLOR.ARGB(80, 255, 255), awardFont, new RECT(rect.left, rect.top + tSize.cy + 30, 0, 0));
            paint.DrawLine(COLOR.ARGB(100, 100, 100), 1, 2, rect.left, rect.bottom, rect.right, rect.bottom);
        }
Example #30
0
        /// <summary>
        /// 重绘背景方法
        /// </summary>
        /// <param name="paint">绘图对象</param>
        /// <param name="clipRect">裁剪区域</param>
        public override void OnPaintBackground(CPaint paint, RECT clipRect)
        {
            int width  = Width;
            int height = Height;

            if (width > 0 && height > 0)
            {
                String text = null;
                switch (m_gameState)
                {
                //失败
                case GameState.Lose:
                    text = "游戏失败,按回车重新开始";
                    break;

                //暂停
                case GameState.Suspend:
                    text = "游戏暂停,按回车回到游戏";
                    break;

                //开始
                case GameState.Begin:
                    text = "按回车开始游戏";
                    break;
                }
                //绘制文字
                if (text != null)
                {
                    FONT font     = Font;
                    SIZE textSize = paint.TextSize(text, font);
                    RECT tRect    = new RECT();
                    tRect.left   = width / 2 - textSize.cx / 2;
                    tRect.top    = height / 2 - textSize.cy / 2;
                    tRect.right  = tRect.left + textSize.cx;
                    tRect.bottom = tRect.top + textSize.cy;
                    paint.DrawText(text, GetPaintingForeColor(), font, tRect);
                }
            }
        }
Example #31
0
 /// <summary>
 /// 重绘前景方法
 /// </summary>
 /// <param name="paint">绘图对象</param>
 /// <param name="clipRect">裁剪区域</param>
 public override void OnPaintForeground(CPaint paint, RECT clipRect)
 {
     if (m_day != null)
     {
         int    width    = m_bounds.right - m_bounds.left;
         int    height   = m_bounds.bottom - m_bounds.top;
         String dayStr   = m_day.Day.ToString();
         FONT   font     = new FONT("微软雅黑", 18, false, false, false);
         SIZE   textSize = paint.TextSize(dayStr, font);
         RECT   tRect    = new RECT();
         tRect.left   = m_bounds.left + (width - textSize.cx) / 2;
         tRect.top    = m_bounds.top + (height - textSize.cy) / 2;
         tRect.right  = tRect.left + textSize.cx;
         tRect.bottom = tRect.top + textSize.cy;
         paint.DrawText(dayStr, GetPaintingForeColor(), font, tRect);
         String           date   = String.Format("{0}{1}{2}", m_day.Year, m_day.Month, m_day.Day);
         List <EventInfo> events = DataCenter.CalendarService.GetEvents(date);
         int eventsSize          = events.Count;
         if (eventsSize > 0)
         {
             String eventStr = eventsSize.ToString();
             FONT   eFont    = new FONT("Arial", 16, false, false, true);
             SIZE   eSize    = paint.TextSize(eventStr, eFont);
             RECT   eRect    = new RECT();
             eRect.left   = m_bounds.left + (width - eSize.cx) / 2;
             eRect.top    = m_bounds.top + height - eSize.cy - 5;
             eRect.right  = eRect.left + eSize.cx;
             eRect.bottom = eRect.top + eSize.cy;
             RECT ellipseRect = new RECT();
             ellipseRect.left   = m_bounds.left + (width - (int)(eSize.cx * 1.5)) / 2;
             ellipseRect.top    = eRect.top + eSize.cy / 2 - 10;
             ellipseRect.right  = ellipseRect.left + (int)(eSize.cx * 1.5);
             ellipseRect.bottom = ellipseRect.top + (int)(eSize.cx * 1.5);
             paint.FillEllipse(COLOR.ARGB(255, 0, 0), ellipseRect);
             paint.DrawText(eventsSize.ToString(), COLOR.ARGB(255, 255, 255), eFont, eRect);
         }
     }
 }
Example #32
0
 internal ConsoleDataBlock(byte[] bytes, int offset)
 {
     BlockSize = BitConverter.ToUInt32(bytes, offset);
     Name = (EXTRA_DATA_TYPE)BitConverter.ToUInt32(bytes, offset + 0x04);
     FillAttribute = (FILL)BitConverter.ToUInt16(bytes, offset + 0x08);
     PopupFillAttribute = (FILL)BitConverter.ToUInt16(bytes, offset + 0x0A);
     ScreenBufferSizeX = BitConverter.ToInt16(bytes, offset + 0x0C);
     ScreenBufferSizeY = BitConverter.ToInt16(bytes, offset + 0x0E);
     WindowSizeX = BitConverter.ToInt16(bytes, offset + 0x10);
     WindowSizeY = BitConverter.ToInt16(bytes, offset + 0x12);
     WindowOriginX = BitConverter.ToInt16(bytes, offset + 0x14);
     WindowOriginY = BitConverter.ToInt16(bytes, offset + 0x16);
     FontSize = BitConverter.ToUInt32(bytes, offset + 0x20);
     FontFamily = (FONT)BitConverter.ToUInt32(bytes, offset + 0x24);
     FontWeight = BitConverter.ToUInt32(bytes, offset + 0x28);
     FaceName = Encoding.Unicode.GetString(bytes, offset + 0x2C, 0x40);
     CursorSize = BitConverter.ToUInt32(bytes, offset + 0x30);
     FullScreen = BitConverter.ToUInt32(bytes, offset + 0x34) != 0;
     QuickEdit = BitConverter.ToUInt32(bytes, offset + 0x38) != 0;
     InsertMode = BitConverter.ToUInt32(bytes, offset + 0x3C) != 0;
     AutoPosition = BitConverter.ToUInt32(bytes, offset + 0x40) != 0;
     HistoryBufferSize = BitConverter.ToUInt32(bytes, offset + 0x44);
     NumberOfHistroyBuffers = BitConverter.ToUInt32(bytes, offset + 0x48);
     HistoryNoDup = BitConverter.ToUInt32(bytes, offset + 0x4C) != 0;
     // More research needed
     ColorTable = NativeMethods.GetSubArray(bytes, (uint)offset + 0x50, 0x40);
 }