Exemplo n.º 1
0
        /// <summary> Handle the KeyPress event. </summary>
        /// <param name="e"> The event data. <see cref="XrwKeyEvent"/> </param>
        /// <remarks> Set XrwKeyEvent. Set result to nonzero to stop further event processing. </remarks>
        public virtual void OnKeyPress(XrwKeyEvent e)
        {
            KeyPressDelegate keyPress = KeyPress;

            if (keyPress != null)
            {
                keyPress(this, e);
            }
        }
Exemplo n.º 2
0
        static void ExecuteCommand(KeyPressDelegate keyPressHandler, HintDelegate hintHandler)
        {
            try
            {
                hintHandler();
            }
            catch { }

            keyPressHandler(Console.ReadKey());
        }
Exemplo n.º 3
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();
        }
Exemplo n.º 4
0
        static void MainOption(ConsoleKeyInfo key)
        {
            switch (key.Key)
            {
            case ConsoleKey.D1:
                Console.Clear();
                if (DataHelper.RetrieveData())
                {
                    PrintData();
                }
                break;

            case ConsoleKey.D2:
                HintHandler      = Hint.Modify;
                KeyPressHandler -= MainOption;
                KeyPressHandler += ModifyData;
                break;

            case ConsoleKey.D:
                DoCamouflage();
                //PrintData();
                break;

            case ConsoleKey.Escape:
            case ConsoleKey.Backspace:
            case ConsoleKey.Delete:
                Environment.Exit(0);
                break;

            default:
                Console.CursorTop--;
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("\nIllegal Input, please check your input again");
                Console.ForegroundColor = ConsoleColor.Black;
                break;
            }
        }
Exemplo n.º 5
0
        static bool initialization(string[] args)
        {
            try
            {
                //ReadSubscriptionConfigurationFile();
                Console.BackgroundColor = ConsoleColor.White;
                Console.ForegroundColor = ConsoleColor.Black;

                // Create a connection
                connection = new OleDbConnection(connectionString);

                // Create a command and set its connection
                command            = connection.CreateCommand();
                command.Connection = connection;

                // Open connecton
                connection.Open();

                Console.ForegroundColor = ConsoleColor.DarkGreen;
                Console.WriteLine("Connection Susseccfully Opened");
                Console.WriteLine(connectionString);

                KeyPressHandler += MainOption;
                HintHandler      = Hint.MainOption;

                if (DataHelper.RetrieveData())
                {
                    FormatRawData();

                    SetUpCost_MonthMapping();

                    if (args.Length != 0)
                    {
                        ExternalInvocationHandler(args);
                    }

                    Console.ForegroundColor = ConsoleColor.DarkGreen;
                    Console.WriteLine("--Initialization SUCCESSFUL--\n");
                }
                else
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("--Initialization FAILED--");

                    return(false);
                }

                Console.ForegroundColor = ConsoleColor.Black;

                return(true);
            }
            catch (Exception exception)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("--Initialization FAILED--");

                Console.WriteLine(exception.Message + "\n");
                Console.ForegroundColor = ConsoleColor.Black;

                Console.WriteLine("Do you wish to continue?\nThe program may malfunction");
                Console.WriteLine("Press \"1\" to continue\n      \"2\" to exit");

                return(false);
            }
        }
Exemplo n.º 6
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();
        }