コード例 #1
0
        static void ModifyData(ConsoleKeyInfo key)
        {
            switch (key.Key)
            {
            case ConsoleKey.D1:
                // Add Data
                Hint.AddData();
                DataHelper.Add();
                break;

            case ConsoleKey.D2:
                // Update Data
                Hint.UpdateData();
                HintHandler            = null;
                ReferedFunctionHandler = DataHelper.Update;
                Console.CursorTop     -= FormattedData.GetLength(1);
                KeyPressHandler       -= ModifyData;
                KeyPressHandler       += MoveCursor;
                break;

            case ConsoleKey.D3:
                // Delete Data
                Hint.DeleteData();
                HintHandler            = null;
                ReferedFunctionHandler = DataHelper.Delete;
                Console.CursorTop     -= FormattedData.GetLength(1) - 6;
                KeyPressHandler       -= ModifyData;
                KeyPressHandler       += MoveCursor;
                break;

            case ConsoleKey.Escape:
            case ConsoleKey.Backspace:
            case ConsoleKey.Delete:
                // Go Back
                HintHandler      = Hint.MainOption;
                KeyPressHandler -= ModifyData;
                KeyPressHandler += MainOption;
                return;

            default:
                return;
            }

            PrintData();
        }
コード例 #2
0
        static void MoveCursor(ConsoleKeyInfo key)
        {
            FormattedData[SystemCursor.XCoord, SystemCursor.YCoord].ContentColor    = ConsoleColor.Black;
            FormattedData[SystemCursor.XCoord, SystemCursor.YCoord].BackgroundColor = ConsoleColor.White;

            if (ReferedFunctionHandler == DataHelper.Delete)
            {
                for (int i = 0; i < Columnnumber; i++)
                {
                    FormattedData[i, SystemCursor.YCoord].ContentColor    = ConsoleColor.Black;
                    FormattedData[i, SystemCursor.YCoord].BackgroundColor = ConsoleColor.White;
                }
            }

            switch (key.Key)
            {
            case ConsoleKey.UpArrow:
            case ConsoleKey.W:
            case ConsoleKey.J:
                SystemCursor.YCoord--;
                break;

            case ConsoleKey.DownArrow:
            case ConsoleKey.S:
            case ConsoleKey.K:
                SystemCursor.YCoord++;
                break;

            case ConsoleKey.LeftArrow:
            case ConsoleKey.A:
            case ConsoleKey.H:

                if (ReferedFunctionHandler != DataHelper.Delete)
                {
                    SystemCursor.XCoord--;
                }
                break;

            case ConsoleKey.RightArrow:
            case ConsoleKey.D:
            case ConsoleKey.L:

                if (ReferedFunctionHandler != DataHelper.Delete)
                {
                    SystemCursor.XCoord++;
                }
                break;

            case ConsoleKey.Enter:
            case ConsoleKey.Spacebar:
                ReferedFunctionHandler(SystemCursor.XCoord, SystemCursor.YCoord);
                break;

            case ConsoleKey.Escape:
            case ConsoleKey.Backspace:
            case ConsoleKey.Delete:
                ReferedFunctionHandler = null;
                HintHandler            = Hint.Modify;
                KeyPressHandler       -= MoveCursor;
                KeyPressHandler       += ModifyData;
                return;

            default:
                return;
            }

            FormattedData[SystemCursor.XCoord, SystemCursor.YCoord].ContentColor    = ConsoleColor.White;
            FormattedData[SystemCursor.XCoord, SystemCursor.YCoord].BackgroundColor = ConsoleColor.DarkBlue;

            if (ReferedFunctionHandler == DataHelper.Delete)
            {
                for (int i = 0; i < Columnnumber; i++)
                {
                    FormattedData[i, SystemCursor.YCoord].ContentColor    = ConsoleColor.White;
                    FormattedData[i, SystemCursor.YCoord].BackgroundColor = ConsoleColor.DarkBlue;
                }
            }
            Console.CursorLeft = 0;
            Console.CursorTop -= FormattedData.GetLength(1);
            PrintData();
        }