示例#1
0
        public void ClearArea()
        {
            object asyncLockObj = XingKongScreen.AsyncLockObj;

            lock (asyncLockObj)
            {
                XingKongScreen.SetColor(XingKongScreen.XColor.White);
                XingKongScreen.FillSquare(new Point(Left, Top), new Point(Left + width, Top + height));
                XingKongScreen.SetColor();
            }
        }
示例#2
0
        public void ClearArea()
        {
            object asyncLockObj = XingKongScreen.AsyncLockObj;

            lock (asyncLockObj)
            {
                XingKongScreen.SetColor(XingKongScreen.XColor.White);
                XingKongScreen.FillSquare(lastP1, lastP2);
                XingKongScreen.SetColor();
            }
        }
示例#3
0
        public void ClearArea()
        {
            object asyncLockObj = XingKongScreen.AsyncLockObj;

            lock (asyncLockObj)
            {
                if (IsDebugEnabled)
                {
                    XingKongScreen.SetColor(XingKongScreen.XColor.Black);
                }
                else
                {
                    XingKongScreen.SetColor(XingKongScreen.XColor.White);
                }
                XingKongScreen.FillSquare(new Point(left, top), new Point(left + width, top + height));
                XingKongScreen.SetColor();
            }
        }
示例#4
0
        public void Draw()
        {
            //先生成文本
            int fontHeight = 32;

            switch (FontSize)
            {
            case XingKongScreen.XFontSize.Normal:
                fontHeight = 32;
                break;

            case XingKongScreen.XFontSize.Large:
                fontHeight = 48;
                break;

            case XingKongScreen.XFontSize.ExtraLarge:
                fontHeight = 64;
                break;

            default:
                break;
            }
            int fontWidth = XingKongScreen.MeasureStringWidth(Text, FontSize);
            int fontLeft  = 10;

            switch (TextAlign)
            {
            case XingKongScreen.TextAlign.Left:
                fontLeft = 10 + left;
                break;

            case XingKongScreen.TextAlign.Center:
                fontLeft = (Width - fontWidth) / 2 + Left + TextXoffset;
                break;

            case XingKongScreen.TextAlign.Right:
                fontLeft = Width - fontWidth - 10;
                break;

            default:
                break;
            }
            int fontTop = (Height - fontHeight) / 2 + Top + TextYoffset;

            XingKongLabel ltemp = new XingKongLabel();

            ltemp.Text     = Text;
            ltemp.Left     = (short)fontLeft;
            ltemp.Top      = (short)fontTop;
            ltemp.FontSize = FontSize;

            //计算矩形位置
            Point p1 = new Point(Left, Top);
            Point p2 = new Point(Left + Width, Top + Height);

            object asyncLockObj = XingKongScreen.AsyncLockObj;

            lock (asyncLockObj)
            {
                if (isChecked)
                {
                    XingKongScreen.SetColor(XingKongScreen.XColor.Gray);
                    XingKongScreen.FillSquare(p1, p2);

                    //设置文字为白色,背景为黑色
                    XingKongScreen.SetColor(XingKongScreen.XColor.White, XingKongScreen.XColor.Gray);
                    ltemp.Draw();

                    //恢复默认调色板
                    XingKongScreen.SetColor();
                }
                else
                {
                    XingKongScreen.SetColor(XingKongScreen.XColor.White);
                    XingKongScreen.FillSquare(p1, p2);
                    XingKongScreen.SetColor();
                    //先画文本
                    ltemp.Draw();
                    //再画矩形
                    XingKongScreen.DrawSquare(p1, p2);
                }
            }

            NeedDraw = false;
        }
        public DialogResult Show()
        {
            canExit = false;

            int[] widths = new int[3];
            widths[0] = XingKongScreen.MeasureStringWidth(Caption, lbCaption.FontSize);
            widths[1] = XingKongScreen.MeasureStringWidth(Title, lbTitle.FontSize);
            widths[2] = 128 * 2 + 40;

            int maxWidth = widths[0];

            foreach (int w in widths)
            {
                if (w > maxWidth)
                {
                    maxWidth = w;
                }
            }

            int actWidth  = maxWidth + 150;
            int actHeight = actWidth * 3 / 4;
            int left      = (800 - actWidth) / 2;
            int top       = (600 - actHeight) / 2;

            lbCaption.Left = (short)(20 + left);
            lbCaption.Top  = (short)(20 + top);

            Point pLeftTopOfBox     = new Point(left, top);
            Point pRightButtomOfBox = new Point(left + actWidth, top + actHeight);

            XingKongScreen.SetColor(XingKongScreen.XColor.White);
            XingKongScreen.FillSquare(pLeftTopOfBox, pRightButtomOfBox);
            XingKongScreen.SetColor();
            XingKongScreen.DrawSquare(pLeftTopOfBox, pRightButtomOfBox);

            int lbCaptionFontHeight = getFontHeightPixel(lbCaption.FontSize);
            int lbTitleFontHeight   = getFontHeightPixel(lbTitle.FontSize);

            XingKongScreen.DrawLine(new Point(left, 40 + top + lbCaptionFontHeight), new Point(left + actWidth, 40 + top + lbTitleFontHeight));

            lbTitle.Top  = (short)((actHeight / 5) + 40 + top + lbCaptionFontHeight);
            lbTitle.Left = (short)(((actWidth - XingKongScreen.MeasureStringWidth(lbTitle.Text, lbTitle.FontSize)) / 2) + left);

            int btOkFontHeight     = getFontHeightPixel(btOk.FontSize);
            int btCancelFontHeight = getFontHeightPixel(btCancel.FontSize);

            if (DialogStyle == Style.OkCancel)
            {
                btOk.Left = (actWidth - widths[2]) / 2 + left;
                btOk.Top  = (short)((actHeight * 3 / 5) + top + btCancelFontHeight);

                btCancel.Left = btOk.Left + btOk.Width + 40;
                btCancel.Top  = btOk.Top;

                btOk.Draw();
                btCancel.Draw();
            }
            else
            {
                btOk.Left = (actWidth - btOk.Width) / 2 + left;
                btOk.Top  = (short)((actHeight * 3 / 5) + top + btCancelFontHeight);
                btOk.Draw();
            }


            lbCaption.Draw();
            lbTitle.Draw();
            XingKongScreen.FreshScreen();

            if (btOk.IsChecked)
            {
                result = DialogResult.OK;
            }
            else
            {
                result = DialogResult.Cancel;
            }

            keyboard             = XingKongScreen.GetKeyboard();
            keyboard.KeyPressed += Keyboard_KeyPressed;
            while (!canExit)
            {
                Thread.Sleep(10);
            }
            keyboard.KeyPressed -= Keyboard_KeyPressed;
            return(result);
        }
示例#6
0
        public void Draw()
        {
            if (bitmap == null)
            {
                return;
            }

            setLastPoint();

            if (!SkipPreProceed)
            {
                try
                {
                    getGrayBitmap();
                }
                catch (Exception)
                {
                    bitmap = bitmap.Clone(new Rectangle(0, 0, bitmap.Width, bitmap.Height), PixelFormat.Format24bppRgb);
                    getGrayBitmap();
                }
            }

            object asyncLockObj = XingKongScreen.AsyncLockObj;

            lock (asyncLockObj)
            {
                //初始化判断颜色是否相同的临时变量
                colorCount = 0;
                lastColor  = 0x03;
                for (int x = 0; x < bitmap.Width; x++)
                {
                    for (int y = 0; y < bitmap.Height; y++)
                    {
                        byte color = GetPixelColor(bitmap.GetPixel(x, y).R, !SkipPreProceed);

                        if (lastColor != color)
                        {
                            colorCount++;
                            if (colorCount % 2 == 1)
                            {
                                //线的开始,记录点
                                lastPoint = new Point(x, y);
                                lastColor = color;
                                XingKongScreen.SetColor((XingKongScreen.XColor)color);
                            }
                            else if (colorCount != 0 && lastColor != 0x03)
                            {
                                //线的结束,画线
                                XingKongScreen.DrawLine(getOffsetPoint(lastPoint), getOffsetPoint(new Point(x, y)));
                            }
                        }
                    }
                    if (colorCount % 2 != 0 && lastColor != 0x03)
                    {
                        XingKongScreen.DrawLine(getOffsetPoint(lastPoint), getOffsetPoint(new Point(x, bitmap.Height)));
                        colorCount = 0;
                        lastColor  = 0x03;
                    }
                }
                XingKongScreen.SetColor();//恢复初始调色板
                NeedDraw = false;
            }
        }