예제 #1
0
 private static string PrintMenuOptions(int index, int x, int y)
 {
     string [] menuText = { "Search For City Press 1:",            "Search by lon and lat Press 2:", "Collect multiple city data Press 3:",
                            "Four Days Weather Forecast Press 4:", "Daily Weather Forecast 5:",      "Close Program Press 6:", ":> " };
     ColorAndStyle.SetTextColor(Colors.Magenta);
     return(ColorAndStyle.SetTextPosition(menuText[index], x, y + index));
 }
예제 #2
0
        private static async Task <bool> MainMenuNavigation(int userInput)
        {
            if (!userInput.Equals(ExitProgram))
            {
                string        url = string.Empty;
                List <string> output;

                Console.Clear();
                output = await InPut.InPutString(userInput);

                if (output.Equals(null))
                {
                    throw new Exception("input cant be empty!!!");
                }
                else
                {
                    Console.Clear();
                    int count = 0;
                    ColorAndStyle.SetTextColor(Colors.Magenta);
                    for (int i = 0; i < output.Count(); i++)
                    {
                        Console.WriteLine(ColorAndStyle.SetTextPosition(output[i], 42, 9 + i));
                        Console.Write(ColorAndStyle.SetTextPosition("*", 74, 9 + i));
                    }
                    willContinue = true;
                }
            }
            else
            {
                willContinue = false;
            }
            return(willContinue);
        }
예제 #3
0
        public static async Task <List <string> > InPutString(int i)
        {
            string        input       = string.Empty;
            List <string> apiResponse = new List <string>();

            if (i.Equals(_SearchForOneCity))
            {
                OutPut.PrintTitleFrame();
                OutPut.PrintMenuFrame();
                ColorAndStyle.SetTextColor(Colors.Magenta);
                input = EnterStringValue(ColorAndStyle.SetTextPosition("Enter city name: ", menuX, menuY));
                if (input.Equals(string.Empty))
                {
                    return(null);
                }

                apiResponse = OutPut.PrintWeatherCondition(await data.GetAPIResponse(input, i)).ToList();
            }
            else if (i.Equals(_SearchBylongLat))
            {
                OutPut.PrintTitleFrame();
                OutPut.PrintMenuFrame();
                ColorAndStyle.SetTextColor(Colors.Magenta);
                int lon = int.Parse(EnterStringValue(ColorAndStyle.SetTextPosition("Enter lat value: ", menuX, menuY)));
                int lat = int.Parse(EnterStringValue(ColorAndStyle.SetTextPosition("Enter lon value: ", menuX, menuY)));
                Console.Clear();
                apiResponse = OutPut.PrintWeatherCondition(await data.GetAPIResponse(lat, lon)).ToList();
            }
            else if (i.Equals(_SearchForMultipleCities))
            {
                OutPut.PrintTitleFrame();
                OutPut.PrintMenuFrame();
                ColorAndStyle.SetTextColor(Colors.Magenta);
                List <string> apiData = new List <string>();
                foreach (var s in await AddCityNames(i))
                {
                    apiData = OutPut.PrintWeatherCondition(s).ToList();
                    if (!apiData.Contains("404"))
                    {
                        apiResponse.AddRange(apiData);
                    }
                }
            }
            else if (i.Equals(_FourDaysForeCast))
            {
                OutPut.PrintTitleFrame();
                OutPut.PrintMenuFrame();
                ColorAndStyle.SetTextColor(Colors.Magenta);
                apiResponse = OutPut.PrintFourDaysForecast(await data.GetAPIResponse(EnterStringValue(ColorAndStyle.SetTextPosition("Enter City Name: ", menuX, menuY)), i));
            }
            else if (i.Equals(_DailyForCast))
            {
                OutPut.PrintTitleFrame();
                OutPut.PrintMenuFrame();
                ColorAndStyle.SetTextColor(Colors.Magenta);
                apiResponse = OutPut.PrintDailyForecast(await data.GetAPIResponse(EnterStringValue(ColorAndStyle.SetTextPosition("Enter city name: ", menuX, menuY)), i)).ToList();
            }

            return(apiResponse);
        }
예제 #4
0
        public static string PrintErrorMessages(string message, int userX, int userY)
        {
            Console.Clear();
            Threads.StartThreadWithJoin(new Thread(new ThreadStart(PrintTitleFrame)));
            Threads.StartThread(new Thread(new ThreadStart(PrintMenuFrame)));

            ColorAndStyle.SetTextColor(Colors.red, string.Empty);
            return(ColorAndStyle.SetTextPosition(message, menuX + userX, menuY + userY));
        }
예제 #5
0
        private static async Task <List <WeatherData> > AddCityNames(int value)
        {
            List <WeatherData> listOfWeatherData = new List <WeatherData>();
            bool   continueLoop = true;
            string input        = string.Empty;

            while (continueLoop.Equals(true))
            {
                #region menu prompts
                if (listOfWeatherData.Count < 1)
                {
                    ColorAndStyle.SetTextColor(Colors.red);
                    Console.Write(ColorAndStyle.SetTextPosition("Press enter to exit or enter city", menuX - 7, menuY));
                    ColorAndStyle.SetTextColor(Colors.Magenta);
                    Console.WriteLine(ColorAndStyle.SetTextPosition("Enter city  name:", menuX - 7, menuY + 1));
                    ColorAndStyle.SetTextPosition(string.Empty, menuX + 11, menuY + 1);
                    input = Console.ReadLine();
                }
                else
                {
                    Console.Clear();
                    Threads.StartThreadWithJoin(new Thread(new ThreadStart(OutPut.PrintTitleFrame)));
                    Threads.StartThreadWithJoin(new Thread(new ThreadStart(OutPut.PrintMenuFrame)));
                    ColorAndStyle.SetTextColor(Colors.red);
                    Console.Write(ColorAndStyle.SetTextPosition("Press enter to exit or enter city", menuX - 7, menuY));
                    ColorAndStyle.SetTextColor(Colors.Magenta);
                    Console.WriteLine(ColorAndStyle.SetTextPosition("Enter another city: ", menuX - 7, menuY + 1));
                    ColorAndStyle.SetTextPosition(string.Empty, menuX + 13, menuY + 1);
                    input = Console.ReadLine();
                }
                #endregion

                #region handle user input
                if (!input.Equals(string.Empty))
                {
                    weathers = await data.GetAPIResponse(input, 1);

                    listOfWeatherData.Add(weathers);
                }
                else if (listOfWeatherData.Count < 1 && input.Equals(string.Empty))
                {
                    throw new Exception("first input cant be empty!!");
                }
                else
                {
                    continueLoop = false;
                }
                #endregion
            }

            return(listOfWeatherData);
        }
예제 #6
0
        public static void PrintTitleFrame()
        {
            ColorAndStyle.SetTextColor(Colors.white);
            Console.WriteLine(ColorAndStyle.SetTextPosition("***********************************", menuX, menuY - 5));
            ColorAndStyle.SetTextColor(Colors.green);
            Console.WriteLine(ColorAndStyle.SetTextPosition("WeatherApp", menuX + 12, menuY - 4));
            ColorAndStyle.SetTextColor(Colors.white);

            for (int i = 0; i < MenuSize - 5; i++)
            {
                Console.WriteLine(ColorAndStyle.SetTextPosition("*", menuX, menuY + i - 4));
                Console.WriteLine(ColorAndStyle.SetTextPosition("*", menuX + 34, menuY + i - 4));
            }
        }
예제 #7
0
        public static void PrintMenuFrame()//TODO work in progress, just temporary. Want to avoid void
        {
            ColorAndStyle.SetTextColor(Colors.white);
            Console.WriteLine(ColorAndStyle.SetTextPosition("**************************************************", menuX - 8, menuY - 2));
            Console.WriteLine(ColorAndStyle.SetTextPosition("*", menuX + 41, menuY - 1));
            Console.WriteLine(ColorAndStyle.SetTextPosition("*", menuX + -8, menuY - 1));

            for (int i = 0; i < 15; i++)
            {
                Console.WriteLine(ColorAndStyle.SetTextPosition("*", menuX - 8, menuY + i));
                Console.WriteLine(ColorAndStyle.SetTextPosition("*", menuX + 41, menuY + i));
            }


            Console.WriteLine(ColorAndStyle.SetTextPosition("*", menuX - 8, menuY + MenuSize));
            Console.WriteLine(ColorAndStyle.SetTextPosition("*", menuX + 41, menuY + MenuSize));
            Console.WriteLine(ColorAndStyle.SetTextPosition("**************************************************", menuX - 8, menuY + 13 + 1));
        }