private static void CreateTicketMenu()
        {
            Console.BackgroundColor = ConsoleColor.DarkBlue;
            Console.Clear();
            TransportTicket ticket = new TransportTicket();

            bool[] checkForVariables = new bool[7] {
                false, false, false, false, false, false, false
            };
            DrawAddTicketMenu(ticket);

            #region Prepare Variables For Mouse
            var handle = NativeMethods.GetStdHandle(NativeMethods.STD_INPUT_HANDLE);

            int mode = 0;
            if (!(NativeMethods.GetConsoleMode(handle, ref mode)))
            {
                throw new Win32Exception();
            }

            mode |= NativeMethods.ENABLE_MOUSE_INPUT;
            mode &= ~NativeMethods.ENABLE_QUICK_EDIT_MODE;
            mode |= NativeMethods.ENABLE_EXTENDED_FLAGS;

            if (!(NativeMethods.SetConsoleMode(handle, mode)))
            {
                throw new Win32Exception();
            }

            var  record    = new NativeMethods.INPUT_RECORD();
            uint recordLen = 0;
            #endregion
            while (true)
            {
                if (!(NativeMethods.ReadConsoleInput(handle, ref record, 1, ref recordLen)))
                {
                    throw new Win32Exception();
                }
                Console.SetCursorPosition(0, 0);  // siline biler
                switch (record.EventType)
                {
                case NativeMethods.MOUSE_EVENT:
                {
                    Console.WriteLine("x: " + record.MouseEvent.dwMousePosition.X);
                    Console.WriteLine("y: " + record.MouseEvent.dwMousePosition.Y);
                    Console.WriteLine("y: " + record.MouseEvent.dwEventFlags);

                    if (record.MouseEvent.dwButtonState != 1 || record.MouseEvent.dwEventFlags != 0)
                    {
                        continue;
                    }
                    if (record.MouseEvent.dwMousePosition.Y == 5 &&
                        record.MouseEvent.dwMousePosition.X > 51 && record.MouseEvent.dwMousePosition.X <= 67)             // Back
                    {
                        SetType(ticket);
                        checkForVariables[0] = true;
                    }
                    else if (record.MouseEvent.dwMousePosition.Y == 9 &&
                             record.MouseEvent.dwMousePosition.X > 35 && record.MouseEvent.dwMousePosition.X <= 59)        // Back
                    {
                        SetLocation(ticket, true);
                        checkForVariables[1] = true;
                    }
                    else if (record.MouseEvent.dwMousePosition.Y == 9 &&
                             record.MouseEvent.dwMousePosition.X > 60 && record.MouseEvent.dwMousePosition.X <= 84)        // Back
                    {
                        SetLocation(ticket, false);
                        checkForVariables[2] = true;
                    }
                    else if (record.MouseEvent.dwMousePosition.Y == 15 &&
                             record.MouseEvent.dwMousePosition.X > 35 && record.MouseEvent.dwMousePosition.X <= 59)        // Back
                    {
                        SetTime(ticket, true);
                        checkForVariables[3] = true;
                    }
                    else if (record.MouseEvent.dwMousePosition.Y == 15 &&
                             record.MouseEvent.dwMousePosition.X > 60 && record.MouseEvent.dwMousePosition.X <= 84)        // Back
                    {
                        SetTime(ticket, false);
                        checkForVariables[4] = true;
                    }
                    else if (record.MouseEvent.dwMousePosition.Y == 20 &&
                             record.MouseEvent.dwMousePosition.X > 35 && record.MouseEvent.dwMousePosition.X <= 59)        // Back
                    {
                        SetStatus(ticket);
                        checkForVariables[5] = true;
                    }
                    else if (record.MouseEvent.dwMousePosition.Y == 20 &&
                             record.MouseEvent.dwMousePosition.X > 60 && record.MouseEvent.dwMousePosition.X <= 84)        // Back
                    {
                        SetPrice(ticket);
                        checkForVariables[6] = true;
                    }
                    else if (record.MouseEvent.dwMousePosition.Y == 26 &&
                             record.MouseEvent.dwMousePosition.X > 43 && record.MouseEvent.dwMousePosition.X <= 56)        // Back
                    {
                        Console.Clear();
                        return;
                    }
                    else if (record.MouseEvent.dwMousePosition.Y == 26 &&
                             record.MouseEvent.dwMousePosition.X > 62 && record.MouseEvent.dwMousePosition.X <= 75)        // Back
                    {
                        bool falseExist = false;
                        foreach (var item in checkForVariables)
                        {
                            if (item == false)
                            {
                                falseExist = true;
                                break;
                            }
                        }
                        if (falseExist == true)
                        {
                            SaveTicket(ticket, false);
                        }
                        else
                        {
                            SaveTicket(ticket, true);
                            return;
                        }
                    }

                    break;
                }
                }
            }
        }
        private static void DeleteTicketMenu()
        {
            Console.BackgroundColor = ConsoleColor.DarkYellow;
            Console.Clear();
            DrawDeleteTicketMenu();

            List <TransportTicket> tickets = TransportTicket.LoadAllTickets();
            int index = 0;

            ShowTicket(tickets[0]);
            DrawNextBackButton(true, false);

            #region Prepare Variables For Mouse
            var handle = NativeMethods.GetStdHandle(NativeMethods.STD_INPUT_HANDLE);

            int mode = 0;
            if (!(NativeMethods.GetConsoleMode(handle, ref mode)))
            {
                throw new Win32Exception();
            }

            mode |= NativeMethods.ENABLE_MOUSE_INPUT;
            mode &= ~NativeMethods.ENABLE_QUICK_EDIT_MODE;
            mode |= NativeMethods.ENABLE_EXTENDED_FLAGS;

            if (!(NativeMethods.SetConsoleMode(handle, mode)))
            {
                throw new Win32Exception();
            }

            var  record    = new NativeMethods.INPUT_RECORD();
            uint recordLen = 0;
            #endregion

            while (true)
            {
                if (!(NativeMethods.ReadConsoleInput(handle, ref record, 1, ref recordLen)))
                {
                    throw new Win32Exception();
                }
                Console.SetCursorPosition(0, 0);  // siline biler
                switch (record.EventType)
                {
                case NativeMethods.MOUSE_EVENT:
                {
                    Console.WriteLine("x: " + record.MouseEvent.dwMousePosition.X);
                    Console.WriteLine("y: " + record.MouseEvent.dwMousePosition.Y);
                    Console.WriteLine("y: " + record.MouseEvent.dwEventFlags);

                    if (record.MouseEvent.dwButtonState != 1 || record.MouseEvent.dwEventFlags != 0)
                    {
                        continue;
                    }
                    if (record.MouseEvent.dwMousePosition.Y > 8 && record.MouseEvent.dwMousePosition.Y <= 11 &&
                        record.MouseEvent.dwMousePosition.X > 50 && record.MouseEvent.dwMousePosition.X < 74)             // Delete
                    {
                    }
                    if (record.MouseEvent.dwMousePosition.Y > 8 && record.MouseEvent.dwMousePosition.Y <= 11 &&
                        record.MouseEvent.dwMousePosition.X > 12 && record.MouseEvent.dwMousePosition.X < 27)            // Back to Menu
                    {
                        return;
                    }
                    if (record.MouseEvent.dwMousePosition.X >= 38 && record.MouseEvent.dwMousePosition.X <= 45 &&
                        record.MouseEvent.dwMousePosition.Y >= 19 && record.MouseEvent.dwMousePosition.Y <= 20)          // Back
                    {
                        if (index != 0)
                        {
                            index--;
                        }
                        else
                        {
                            continue;
                        }
                    }
                    if (record.MouseEvent.dwMousePosition.X >= 107 && record.MouseEvent.dwMousePosition.X <= 116 &&
                        record.MouseEvent.dwMousePosition.Y >= 19 && record.MouseEvent.dwMousePosition.Y <= 20)      // Next
                    {
                        if (index != tickets.Count - 1)
                        {
                            index++;
                        }
                        else
                        {
                            continue;
                        }
                    }

                    break;
                }
                }
            }
        }
Beispiel #3
0
        public static void Menu(NativeMethods.INPUT_RECORD record, NativeMethods.ConsoleHandle handle, uint recordLen)
        {
            bool login_sign = true;

            Console.BackgroundColor = ConsoleColor.Red;
            Console.Clear();
            DrawMenu(login_sign);

            while (true)
            {
                if (!(NativeMethods.ReadConsoleInput(handle, ref record, 1, ref recordLen)))
                {
                    throw new Win32Exception();
                }
                Console.SetCursorPosition(0, 0);  // siline biler
                switch (record.EventType)
                {
                case NativeMethods.MOUSE_EVENT:
                {
                    Console.WriteLine("x: " + record.MouseEvent.dwMousePosition.X);
                    Console.WriteLine("y: " + record.MouseEvent.dwMousePosition.Y);
                    Console.WriteLine("y: " + record.MouseEvent.dwEventFlags);

                    if (record.MouseEvent.dwButtonState != 1 || record.MouseEvent.dwEventFlags != 0)
                    {
                        continue;
                    }
                    if (record.MouseEvent.dwMousePosition.Y >= 5 && record.MouseEvent.dwMousePosition.Y <= 9 &&
                        record.MouseEvent.dwMousePosition.X >= 41 && record.MouseEvent.dwMousePosition.X <= 66)         // Login
                    {
                        if (login_sign == false)
                        {
                            login_sign = true;
                            DrawMenu(login_sign);
                        }
                    }
                    else if (record.MouseEvent.dwMousePosition.Y >= 5 && record.MouseEvent.dwMousePosition.Y <= 9 &&
                             record.MouseEvent.dwMousePosition.X > 68 && record.MouseEvent.dwMousePosition.X <= 93)       // Sign in
                    {
                        if (login_sign == true)
                        {
                            login_sign = false;
                            DrawMenu(login_sign);
                        }
                    }
                    else if (record.MouseEvent.dwMousePosition.Y >= 8 && record.MouseEvent.dwMousePosition.Y <= 10 &&
                             record.MouseEvent.dwMousePosition.X > 13 && record.MouseEvent.dwMousePosition.X <= 30)        // Back
                    {
                        return;
                    }

                    break;
                }

                case NativeMethods.KEY_EVENT:
                {
                    if (record.KeyEvent.bKeyDown == true && record.KeyEvent.wVirtualKeyCode == 13) // Enter pressed
                    {
                        if (login_sign == true)                                                    // Login
                        {
                            var user = new User();
                            if (LoginMenu(user) == true)
                            {
                                IboTicketsUserMenu.Menu(user);
                                Console.BackgroundColor = ConsoleColor.Red;
                                Console.Clear();
                                DrawMenu(true);
                            }
                            else
                            {
                                DrawMenu(true);
                            }
                        }
                        else             // Sign in
                        {
                            SignMenu();
                        }
                    }
                    break;
                }
                }
            }
        }
        public static void Menu()
        {
            Console.BackgroundColor = ConsoleColor.DarkBlue;
            Console.Clear();
            DrawMenu();

            #region Prepare Variables For Mouse
            var handle = NativeMethods.GetStdHandle(NativeMethods.STD_INPUT_HANDLE);

            int mode = 0;
            if (!(NativeMethods.GetConsoleMode(handle, ref mode)))
            {
                throw new Win32Exception();
            }

            mode |= NativeMethods.ENABLE_MOUSE_INPUT;
            mode &= ~NativeMethods.ENABLE_QUICK_EDIT_MODE;
            mode |= NativeMethods.ENABLE_EXTENDED_FLAGS;

            if (!(NativeMethods.SetConsoleMode(handle, mode)))
            {
                throw new Win32Exception();
            }

            var  record    = new NativeMethods.INPUT_RECORD();
            uint recordLen = 0;
            #endregion

            while (true)
            {
                if (!(NativeMethods.ReadConsoleInput(handle, ref record, 1, ref recordLen)))
                {
                    throw new Win32Exception();
                }
                Console.SetCursorPosition(0, 0);  // siline biler
                switch (record.EventType)
                {
                case NativeMethods.MOUSE_EVENT:
                {
                    Console.WriteLine("x: " + record.MouseEvent.dwMousePosition.X);
                    Console.WriteLine("y: " + record.MouseEvent.dwMousePosition.Y);
                    Console.WriteLine("y: " + record.MouseEvent.dwEventFlags);

                    if (record.MouseEvent.dwButtonState != 1 || record.MouseEvent.dwEventFlags != 0)
                    {
                        continue;
                    }
                    if (record.MouseEvent.dwMousePosition.Y > 8 && record.MouseEvent.dwMousePosition.Y <= 11 &&
                        record.MouseEvent.dwMousePosition.X > 50 && record.MouseEvent.dwMousePosition.X < 74)             // Create Tiket
                    {
                        CreateTicketMenu();
                        Console.BackgroundColor = ConsoleColor.DarkBlue;
                        Console.Clear();
                        DrawMenu();
                    }
                    if (record.MouseEvent.dwMousePosition.Y > 14 && record.MouseEvent.dwMousePosition.Y <= 17 &&
                        record.MouseEvent.dwMousePosition.X > 50 && record.MouseEvent.dwMousePosition.X < 74)             // Delete Tiket
                    {
                        DeleteTicketMenu();
                        Console.BackgroundColor = ConsoleColor.DarkBlue;
                        Console.Clear();
                        DrawMenu();
                    }
                    if (record.MouseEvent.dwMousePosition.Y > 8 && record.MouseEvent.dwMousePosition.Y <= 11 &&
                        record.MouseEvent.dwMousePosition.X > 12 && record.MouseEvent.dwMousePosition.X < 27)            //Back
                    {
                        return;
                    }

                    break;
                }
                }
            }
        }
Beispiel #5
0
        public static void Menu()
        {
            SetMenu();
            #region Prepare Variables For Mouse
            var handle = NativeMethods.GetStdHandle(NativeMethods.STD_INPUT_HANDLE);

            int mode = 0;
            if (!(NativeMethods.GetConsoleMode(handle, ref mode)))
            {
                throw new Win32Exception();
            }

            mode |= NativeMethods.ENABLE_MOUSE_INPUT;
            mode &= ~NativeMethods.ENABLE_QUICK_EDIT_MODE;
            mode |= NativeMethods.ENABLE_EXTENDED_FLAGS;

            if (!(NativeMethods.SetConsoleMode(handle, mode)))
            {
                throw new Win32Exception();
            }

            var  record    = new NativeMethods.INPUT_RECORD();
            uint recordLen = 0;
            #endregion

            while (true)
            {
                if (!(NativeMethods.ReadConsoleInput(handle, ref record, 1, ref recordLen)))
                {
                    throw new Win32Exception();
                }
                Console.SetCursorPosition(0, 0);  // siline biler
                switch (record.EventType)
                {
                case NativeMethods.MOUSE_EVENT:
                {
                    Console.WriteLine("x: " + record.MouseEvent.dwMousePosition.X);
                    Console.WriteLine("y: " + record.MouseEvent.dwMousePosition.Y);
                    Console.WriteLine("y: " + record.MouseEvent.dwEventFlags);

                    if (record.MouseEvent.dwButtonState != 1 || record.MouseEvent.dwEventFlags != 0)
                    {
                        continue;
                    }
                    if (record.MouseEvent.dwMousePosition.X >= 26 && record.MouseEvent.dwMousePosition.X <= 53 &&
                        record.MouseEvent.dwMousePosition.Y >= 13 && record.MouseEvent.dwMousePosition.Y <= 25)
                    {
                        Autorisation.Menu(record, handle, recordLen);
                        Console.BackgroundColor = ConsoleColor.Cyan;
                        Console.Clear();
                        SetMenu();
                    }
                    if (record.MouseEvent.dwMousePosition.X >= 76 && record.MouseEvent.dwMousePosition.X <= 103 &&
                        record.MouseEvent.dwMousePosition.Y >= 13 && record.MouseEvent.dwMousePosition.Y <= 25)
                    {
                        LoginForAdmin.Menu();
                    }
                }
                break;
                }
            }
        }