public XingKongMessageBox()
        {
            lbCaption = new XingKongLabel();
            lbTitle   = new XingKongLabel();
            btOk      = new XingKongButton();
            btCancel  = new XingKongButton();
            if (XingKongScreen.IsRunningOnMono())
            {
                btOk.TextXoffset     = -9;
                btCancel.TextXoffset = -9;
            }
            else
            {
                btOk.TextXoffset     = -2;
                btCancel.TextXoffset = -2;
            }
            btOk.Text       = "确定";
            btCancel.Text   = "取消";
            btOk.Width      = 128;
            btOk.Height     = 60;
            btCancel.Width  = 128;
            btCancel.Height = 60;

            btOk.IsChecked     = true;;
            btCancel.IsChecked = false;

            DialogStyle = Style.OkCancel;
        }
示例#2
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();
            }
        }
示例#3
0
        public void ClearArea()
        {
            object asyncLockObj = XingKongScreen.AsyncLockObj;

            lock (asyncLockObj)
            {
                XingKongScreen.SetColor(XingKongScreen.XColor.White);
                XingKongScreen.FillSquare(lastP1, lastP2);
                XingKongScreen.SetColor();
            }
        }
示例#4
0
 public void Draw()
 {
     XingKongScreen.DrawSquare(new Point(Left, Top), new Point(Left + width, Top + height));
     for (int i = 0; i < scope && i < items.Count; i++)
     {
         int itemIndex = i + firstVisibleItemIndex;
         btItems[i].Text = items[itemIndex];
         if (itemIndex == selectedIndex)
         {
             btItems[i].IsChecked = true;
         }
         btItems[i].Draw();
         btItems[i].IsChecked = false;
     }
 }
        private void Keyboard_KeyPressed(System.Windows.Forms.Keys pressedKey)
        {
            switch (pressedKey)
            {
            case System.Windows.Forms.Keys.Left:
            case System.Windows.Forms.Keys.Right:
                if (DialogStyle == Style.OkCancel)
                {
                    if (btOk.IsChecked)
                    {
                        btOk.IsChecked     = false;
                        btCancel.IsChecked = true;
                    }
                    else
                    {
                        btOk.IsChecked     = true;
                        btCancel.IsChecked = false;
                    }
                    btOk.Draw();
                    btCancel.Draw();
                    XingKongScreen.FreshScreen();
                }
                break;

            case System.Windows.Forms.Keys.Enter:
                canExit = true;
                if (btOk.IsChecked)
                {
                    result = DialogResult.OK;
                }
                else
                {
                    result = DialogResult.Cancel;
                }
                break;

            case System.Windows.Forms.Keys.Escape:
                canExit = true;
                result  = DialogResult.Cancel;
                break;

            default:
                break;
            }
        }
示例#6
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();
            }
        }
示例#7
0
        public void Draw()
        {
            List <byte> byteList = new List <byte>();

            //设置字体大小
            XingKongScreen.SetFontSize((int)FontSize);

            //生成坐标数据
            IEnumerable <byte> left = BitConverter.GetBytes(Left).Reverse();
            IEnumerable <byte> top  = BitConverter.GetBytes(Top).Reverse();

            //生成字符串数据
            byte[] str = Encoding.GetEncoding("GBK").GetBytes(Text);

            IEnumerable <byte> length = BitConverter.GetBytes((short)(9 + str.Length + 1 + 4)).Reverse();

            byteList.Add(0xA5);
            byteList.AddRange(length);
            byteList.Add(0x30);
            byteList.AddRange(left);
            byteList.AddRange(top);
            byteList.AddRange(str);
            byteList.Add(0x00);
            byteList.AddRange(new byte[] { 0xCC, 0x33, 0xC3, 0x3C });

            byte checkByte = XingKongScreen.getCheckByte(byteList);

            byteList.Add(checkByte);

            object asyncLockObj = XingKongScreen.AsyncLockObj;

            lock (asyncLockObj)
            {
                XingKongScreen.Write(byteList);
            }
            NeedDraw = false;
        }
示例#8
0
        public static void DrawLine(Point from, Point to)
        {
            byte[]             command = new byte[] { 0xA5, 0x00, 0x11, 0x22, 0x00, 0x0A, 0x00, 0x0A, 0x00, 0xFF, 0x00, 0xFF, 0xCC, 0x33, 0xC3, 0x3C, 0x96 };
            IEnumerable <byte> fx      = BitConverter.GetBytes((short)(from.X));
            IEnumerable <byte> fy      = BitConverter.GetBytes((short)(from.Y));
            IEnumerable <byte> tx      = BitConverter.GetBytes((short)(to.X));
            IEnumerable <byte> ty      = BitConverter.GetBytes((short)(to.Y));

            command[4] = fx.ElementAt(1);
            command[5] = fx.ElementAt(0);
            command[6] = fy.ElementAt(1);
            command[7] = fy.ElementAt(0);

            command[8]  = tx.ElementAt(1);
            command[9]  = tx.ElementAt(0);
            command[10] = ty.ElementAt(1);
            command[11] = ty.ElementAt(0);

            byte checkbyte = XingKongScreen.getCheckByte(command, true);

            command[16] = checkbyte;

            XingKongScreen.Write(command);
        }
示例#9
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;
        }
示例#10
0
        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);
        }
示例#11
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;
            }
        }