Пример #1
0
        static ScreenManager()
        {
            uint zz = 0;

            Windows.GetConsoleMode(Windows.GetStdHandle((int)StdHandles.STD_INPUT_HANDLE), ref zz);
            Windows.SetConsoleMode(Windows.GetStdHandle((int)StdHandles.STD_INPUT_HANDLE), zz | 0x0010);
        }
Пример #2
0
        public static uint SysTVGetScrMode(ref SysPoint Size)
        {
            uint result = 0;

            Windows.GetConsoleScreenBufferInfo(Windows.GetStdHandle((int)StdHandles.STD_OUTPUT_HANDLE), out SysBufInfo);
            switch (SysBufInfo.dwSize.Y)
            {
            case 25: result = 0x0003;
                break;

            case 43:
            case 50: result = 0x0103;
                break;

            default: result = 0x00ff;
                break;
            }

            Size.X = SysBufInfo.dwSize.X;
            Size.Y = SysBufInfo.dwSize.Y;
            if (Size.Y > 234)
            {
                Size.Y = 234;
            }
            return(result);
        }
Пример #3
0
        public static void SetCursorType(CursorType CursorType)
        {
            int[] CursorTypes = new int[3] {
                1, 100, 15
            };
            bool[] CursorVisible = new bool[3] {
                false, true, true
            };
            CONSOLE_CURSOR_INFO Info;

            Info.Size    = CursorTypes[(int)CursorType];
            Info.Visible = CursorVisible[(int)CursorType];
            SetConsoleCursorInfo(Windows.GetStdHandle((int)StdHandles.STD_OUTPUT_HANDLE), Info);
        }
Пример #4
0
        public void SysTVSetCurType(int Y1, int Y2, bool Show)
        {
            CONSOLE_CURSOR_INFO Info;

            Info.Visible = Show;
            if (Math.Abs(Y1 - Y2) <= 1)
            {
                Info.Size = 15;
            }
            else
            {
                Info.Size = 99;
            }
            SetConsoleCursorInfo(Windows.GetStdHandle((int)StdHandles.STD_OUTPUT_HANDLE), Info);
        }
Пример #5
0
        public static void SysTVGetCurType(ref int Y1, ref int Y2, ref bool Visible)
        {
            CONSOLE_CURSOR_INFO Info;

            Windows.GetConsoleCursorInfo(Windows.GetStdHandle((int)StdHandles.STD_OUTPUT_HANDLE), out Info);
            Visible = Info.Visible;
            if (Info.Size <= 25)
            {
                Y1 = 6;
                Y2 = 7;
            }
            else
            {
                Y1 = 1;
                Y2 = 7;
            }
        }
Пример #6
0
        public static bool ReadConsoleOutput(
            ref CHAR_INFO[] lpBuffer, COORD BufferSize, COORD BufferCoord, ref SMALL_RECT ReadRegion)
        {
            return(Windows.ReadConsoleOutput((IntPtr)Windows.GetStdHandle((int)StdHandles.STD_OUTPUT_HANDLE), lpBuffer, BufferSize, BufferCoord, ref ReadRegion));

            //unsafe
            //{
            //    fixed (char* ciRef = &lpBuffer[0].WideChar)
            //    {
            //        return Windows.ReadConsoleOutput(
            //            Windows.GetStdHandle((int)StdHandles.STD_OUTPUT_HANDLE),
            //            ciRef,
            //            BufferSize,
            //            BufferCoord,
            //            ref ReadRegion);
            //    }
            //}
        }
Пример #7
0
 public static void SetConsoleCursorPosition(long X, long Y)
 {
     Windows.SetConsoleCursorPosition(
         Windows.GetStdHandle((int)StdHandles.STD_OUTPUT_HANDLE), new COORD((short)X, (short)Y));
 }
Пример #8
0
 public static bool WriteConsoleOutput(
     CHAR_INFO[] char_info, COORD dwBufferSize, COORD dwBufferCoord, ref SMALL_RECT lpWriteRegion)
 {
     return(Windows.WriteConsoleOutput((IntPtr)Windows.GetStdHandle((int)StdHandles.STD_OUTPUT_HANDLE), char_info, dwBufferSize, dwBufferCoord, ref lpWriteRegion));
 }
Пример #9
0
        public static void KbdUpdateEventQueues()
        {
            AltNumericKey[] AltNumericKeys =
            {
                new AltNumericKey(0x9B00, 4),
                new AltNumericKey(0x9D00, 6),
                new AltNumericKey(0x9F00, 1),
                new AltNumericKey(0xA100, 3),
                new AltNumericKey(0x9700, 7),
                new AltNumericKey(0x9900, 9),
                new AltNumericKey(0x9800, 8),
                new AltNumericKey(0xA000, 2),
                new AltNumericKey(0xA200, 0),
                new AltNumericKey(0x4c00, 5)
            };

            System.UInt32  EventCount;
            INPUT_RECORD[] InRec = new INPUT_RECORD[1];
            bool           FoundAlt;
            byte           AltNumeric = 0;

            if (SysKeyCount > SysKeyQue.GetUpperBound(0))
            {
                return;
            }
            do
            {
                EventCount = 0;
                bool x = Windows.GetNumberOfConsoleInputEvents(Windows.GetStdHandle((int)StdHandles.STD_INPUT_HANDLE),
                                                               ref EventCount);
                if (EventCount == 0)
                {
                    return;
                }
                //Windows.ReadConsoleInput(Windows.GetStdHandle((int)StdHandles.STD_INPUT_HANDLE), ref InRec, out EventCount);
                Windows.ReadConsoleInput(new IntPtr(Windows.GetStdHandle((int)StdHandles.STD_INPUT_HANDLE)), InRec, 1, out EventCount);
                if (EventCount == 0)
                {
                    return;
                }
                switch ((EventTypes)InRec[0].EventType)
                {
                case EventTypes.KEY_EVENT:
                    if (SysKeyCount <= SysKeyQue.GetUpperBound(0))
                    {
                        if (InRec[0].KeyEvent.bKeyDown)
                        {
                            SysKeyQue[SysKeyCount].wKeyEvent = InRec[0].KeyEvent;
                            SysShiftState = SysKeyQue[SysKeyCount].skeShiftState;
                            switch ((int)InRec[0].KeyEvent.wVirtualKeyCode)
                            {
                            case VK_SHIFT:
                            case VK_CONTROL:
                            case VK_MENU:
                                break;

                            default:
                                System.Text.Encoding enc = System.Text.Encoding.GetEncoding(866);
                                byte[] bb = enc.GetBytes(new char[] { InRec[0].KeyEvent.UnicodeChar });
                                SysKeyQue[SysKeyCount].skeKeyCode = TranslateKeyCode((byte)InRec[0].KeyEvent.wVirtualKeyCode, (byte)InRec[0].KeyEvent.wVirtualScanCode, /*InRec.KeyEvent.AsciiChar*/ bb[0], InRec[0].KeyEvent.dwControlKeyState);
                                SysKeyQue[SysKeyCount].wKeyEvent  = InRec[0].KeyEvent;
                                if (SysKeyQue[SysKeyCount].skeKeyCode == 0)
                                {
                                    return;
                                }
                                FoundAlt = false;
                                if (((SysKeyQue[SysKeyCount].skeShiftState & 0x08) == 0x08) &&
                                    ((InRec[0].KeyEvent.dwControlKeyState & 0x100) == 0))
                                {
                                    if (SysPlatform == 1)
                                    {
                                        for (int i = 0; i < 10; i++)
                                        {
                                            if (SysKeyQue[SysKeyCount].skeKeyCode == AltNumericKeys[i].VK)
                                            {
                                                AltNumeric = (byte)((AltNumeric * 10) + AltNumericKeys[i].Value);
                                                FoundAlt   = true;
                                            }
                                        }
                                    }
                                    else
                                    if (((int)InRec[0].KeyEvent.wVirtualKeyCode >= VK_NUMPAD0) && ((int)InRec[0].KeyEvent.wVirtualKeyCode <= VK_NUMPAD9))
                                    {
                                        AltNumeric = (byte)((AltNumeric * 10) + InRec[0].KeyEvent.wVirtualKeyCode - VK_NUMPAD0);
                                        FoundAlt   = true;
                                    }
                                }
                                if (!FoundAlt)
                                {
                                    SysKeyCount++;
                                    AltNumeric = 0;
                                }
                                break;
                            }
                        }
                        else
                        {
                            if ((int)InRec[0].KeyEvent.wVirtualKeyCode == VK_MENU)
                            {
                                if (AltNumeric != 0)
                                {
                                    SysKeyQue[SysKeyCount].skeKeyCode = AltNumeric;
                                    AltNumeric = 0;
                                    SysKeyCount++;
                                }
                            }
                        }
                    }
                    break;

                case EventTypes.MOUSE_EVENT:
                    if (SysMouCount <= SysMouQue.GetUpperBound(0))
                    {
                        SysMouQue[SysMouCount].smePos.X   = InRec[0].MouseEvent.dwMousePosition.X;
                        SysMouQue[SysMouCount].smePos.Y   = InRec[0].MouseEvent.dwMousePosition.Y;
                        SysMouQue[SysMouCount].smeButtons = (byte)InRec[0].MouseEvent.dwButtonState;
                        SysMouQue[SysMouCount].smeTime    = (int)SysSysMouseCount();
                        SysMouCount++;
                    }
                    break;
                }
            } while (true && (SysKeyCount <= SysKeyQue.GetUpperBound(0)));
        }