コード例 #1
0
        /// <summary>
        /// The constructor for this form. Allows you to open this form from multiple places and jump to different functionality depending on the enum passed in
        /// </summary>
        /// <param name="actionChoice"></param>
        public FormFreshAPIPull(AppEnum.ManagerAction actionChoice)
        {
            switch (actionChoice)
            {
            case AppEnum.ManagerAction.None:
            case AppEnum.ManagerAction.WelcomePage:
                break;

            case AppEnum.ManagerAction.GetWeather:
                FreshApiPullGetWeather();
                break;

            case AppEnum.ManagerAction.CustomizePlantingDay:
                break;

            case AppEnum.ManagerAction.AutoFillPlantingDays:
                FreshApiPullAutoFill();
                break;

            case AppEnum.ManagerAction.TogglePlantingDay:
            case AppEnum.ManagerAction.CalendarOnly:
            case AppEnum.ManagerAction.Print:
            case AppEnum.ManagerAction.Exit:
            default:
                break;
            }
        }
コード例 #2
0
        /// <summary>
        /// method to display the manager menu and get the user's choice
        /// </summary>
        /// <returns></returns>
        public static AppEnum.ManagerAction GetUserActionChoice()
        {
            AppEnum.ManagerAction userActionChoice = AppEnum.ManagerAction.None;
            //
            // set a string variable with a length equal to the horizontal margin and filled with spaces
            //
            string leftTab = ConsoleUtil.FillStringWithSpaces(DISPLAY_HORIZONTAL_MARGIN);

            //
            // set up display area
            //
            DisplayReset();

            //
            // display the menu
            //
            DisplayMessage("Ski Manager Menu");
            DisplayMessage("");
            Console.WriteLine(
                leftTab + "1. Display All Ski Runs Information" + Environment.NewLine +
                leftTab + "2. Delete the Ski Run with ID = 1" + Environment.NewLine +
                leftTab + "E. Exit" + Environment.NewLine);

            DisplayMessage("");
            DisplayPromptMessage("Enter the number/letter for the menu choice.");
            ConsoleKeyInfo userResponse = Console.ReadKey(true);

            switch (userResponse.KeyChar)
            {
            case '1':
                userActionChoice = AppEnum.ManagerAction.ListAllSkiRuns;
                break;

            case '2':
                userActionChoice = AppEnum.ManagerAction.DeleteSkiRun;
                break;

            case 'E':
            case 'e':
                userActionChoice = AppEnum.ManagerAction.Quit;
                break;

            default:
                Console.WriteLine(
                    "It appears you have selected an incorrect choice." + Environment.NewLine +
                    "Press any key to try again or the ESC key to exit.");

                userResponse = Console.ReadKey(true);
                if (userResponse.Key == ConsoleKey.Escape)
                {
                    userActionChoice = AppEnum.ManagerAction.Quit;
                }
                break;
            }

            return(userActionChoice);
        }
コード例 #3
0
        /// <summary>
        /// A method that iterates through the table layout panel for the calendar, and depending on the enum that gets sent to it, will either fill in only the names of the days of the week, the days plus the weather icons, or all of the above with the planting days too
        /// </summary>
        /// <param name="response"></param>
        /// <param name="actionChoice"></param>
        private void FillWeatherDays(Response response, AppEnum.ManagerAction actionChoice)
        {
            int indexR = 0;

            for (int r = 0; r < tblFreshAPI.RowCount; r++)
            {
                for (int c = 0; c < tblFreshAPI.ColumnCount; c++)
                {
                    Control control = tblFreshAPI.GetControlFromPosition(c, r);
                    //
                    // apply names to the labels
                    //
                    if (control is Label)
                    {
                        //
                        // cast the control as a Label
                        //
                        Label iconLabel = control as Label;
                        if (iconLabel != null)
                        {
                            //
                            // get the weekday from the response object
                            //
                            string date = response.Forecast.Simpleforecast.Forecastdays.Forecastday[indexR].Date.Weekday;
                            iconLabel.Text = date;
                            indexR        += 1;
                        }
                        //
                        // reset the response index, because the row after a label row will be the same set of days, whereas after a row of picture boxes, you want it to keep incrementing to the next set of five days in the forecast
                        //
                        //
                        // the end of the row is actually column = 4, because they start their numbering at 0,0 instead of 1,1 to be more programmer-ish
                        //
                        if (c == 4)
                        {
                            if (r == 0)
                            {
                                indexR = 0;
                            }
                            else if (r == 2)
                            {
                                indexR = 5;
                            }
                        }
                    }
                    else //apply images to picture boxes
                    {
                        PictureBox  picture = control as PictureBox;
                        Forecastday fd      = response.Forecast.Simpleforecast.Forecastdays.Forecastday[indexR];

                        switch (actionChoice)
                        {
                        case AppEnum.ManagerAction.None:
                            break;

                        case AppEnum.ManagerAction.WelcomePage:
                            break;

                        case AppEnum.ManagerAction.GetWeather:
                            if (fd.IsRainyDay)
                            {
                                picture.Image = Resources.raindrop;
                            }
                            break;

                        case AppEnum.ManagerAction.CustomizePlantingDay:
                            break;

                        case AppEnum.ManagerAction.AutoFillPlantingDays:
                            if (fd.IsPlantingDay)
                            {
                                picture.Image = Resources.seedling;
                            }
                            else if (fd.IsRainyDay)
                            {
                                picture.Image = Resources.raindrop;
                            }
                            break;

                        case AppEnum.ManagerAction.TogglePlantingDay:
                            if (fd.IsPlantingDay)
                            {
                                picture.Image = Resources.seedling;
                            }
                            else if (fd.IsRainyDay)
                            {
                                picture.Image = Resources.raindrop;
                            }
                            else
                            {
                                picture.Image = Resources.blankscreen;
                            }
                            break;

                        case AppEnum.ManagerAction.Print:
                            break;

                        case AppEnum.ManagerAction.Exit:
                            break;

                        case AppEnum.ManagerAction.CalendarOnly:
                            picture.Image = Resources.blankscreen;
                            break;

                        default:
                            break;
                        }

                        indexR += 1;
                    }
                }
            }
        }
コード例 #4
0
            /// <summary>
            /// method to display the manager menu and get the user's choice
            /// </summary>
            /// <returns></returns>
            public static AppEnum.ManagerAction GetUserActionChoice()
            {
                AppEnum.ManagerAction userActionChoice = AppEnum.ManagerAction.None;
                //
                // set a string variable with a length equal to the horizontal margin and filled with spaces
                //
                string leftTab = ConsoleUtil.FillStringWithSpaces(DISPLAY_HORIZONTAL_MARGIN);

                //
                // set up display area
                //
                DisplayReset();

                //
                // display the menu
                //
                DisplayMessage("Hotel Menu");
                DisplayMessage("");
                Console.WriteLine(
                    leftTab + "1. List All Hotels" + Environment.NewLine +
                    leftTab + "2. Quit" + Environment.NewLine +
                    leftTab + "3. Delete a Hotel" + Environment.NewLine +
                    leftTab + "4. Add a Hotel" + Environment.NewLine +
                    leftTab + "5. Display a Hotel Detail" + Environment.NewLine +
                    leftTab + "6. Update Hotel Information" + Environment.NewLine +
                    leftTab + "7. Query Hotel By Rooms Available" + Environment.NewLine +
                    leftTab + "E. Exit" + Environment.NewLine);

                DisplayMessage("");
                DisplayPromptMessage("Enter the number/letter for the menu choice.");
                ConsoleKeyInfo userResponse = Console.ReadKey(true);

                switch (userResponse.KeyChar)
                {
                    case '1':
                        userActionChoice = AppEnum.ManagerAction.ListAllHotels;
                        break;
                    case '2':
                        userActionChoice = AppEnum.ManagerAction.Quit;
                        break;
                    case '3':
                        userActionChoice = AppEnum.ManagerAction.DeleteHotel;
                        break;
                    case '4':
                        userActionChoice = AppEnum.ManagerAction.AddHotel;
                        break;
                    case '5':
                        userActionChoice = AppEnum.ManagerAction.DisplayHotelDetail;
                        break;
                    case '6':
                        userActionChoice = AppEnum.ManagerAction.UpdateHotel;
                        break;
                    case '7':
                        userActionChoice = AppEnum.ManagerAction.QueryHotelsByRoomsAvilable;
                        break;
                    case 'E':
                    case 'e':
                        userActionChoice = AppEnum.ManagerAction.Quit;
                        break;
                    default:
                        Console.WriteLine(
                            "You have selected an incorrect answer." + Environment.NewLine +
                            "Press any key to try again or the ESC key to exit.");

                        userResponse = Console.ReadKey(true);
                        if (userResponse.Key == ConsoleKey.Escape)
                        {
                            userActionChoice = AppEnum.ManagerAction.Quit;
                        }
                        break;
                }

                return userActionChoice;
            }