using System;
namespace Task01
{
internal class Program
{
static void Main(string[] args)
{
bool quit = false;
DateTime now;
while (!quit)
{
string choice;
Console.WriteLine(
"1.\tRun example.\n" +
"2.\tChange text color.\n" +
"3.\tChange background color.\n" +
"4.\tChange title.\n" +
"5.\tChange console size.\n" +
"6.\tMake beep sound.\n" +
"7.\tShow current time.\n" +
"8.\tShow count of days until ...\n" +
"9.\tQuit the program.\n"
);
choice = Console.ReadLine();
Console.Clear();
now = DateTime.Now;
bool innerQuit;
switch (choice)
{
case "1":
Console.WriteLine("Input your name: ");
string name = Console.ReadLine();
Console.WriteLine("Hello, {0}", name);
Console.WriteLine("Today is {0}, {1:D2}.{2:D2}.{3:D2}\n", now.DayOfWeek, now.Day, now.Month, now.Year);
break;
case "2":
do
{
innerQuit = true;
Console.WriteLine(
"1.\tChange text color to Green.\n" +
"2.\tChange text color to Yellow.\n" +
"3.\tChange text color to Red.\n" +
"4.\tChange text color to Blue.\n" +
"5.\tChange text color to Gray.\n" +
"6.\tChange text color to White.\n" +
"7.\tChange text color to Black.\n" +
"8.\tRun to default.\n" +
"9.\tQuit text color settings.\n"
);
choice = Console.ReadLine();
switch (choice)
{
case "1":
Console.ForegroundColor = ConsoleColor.Green;
break;
case "2":
Console.ForegroundColor = ConsoleColor.Yellow;
break;
case "3":
Console.ForegroundColor = ConsoleColor.Red;
break;
case "4":
Console.ForegroundColor = ConsoleColor.Blue;
break;
case "5":
Console.ForegroundColor = ConsoleColor.Gray;
break;
case "6":
Console.ForegroundColor = ConsoleColor.White;
break;
case "7":
Console.ForegroundColor = ConsoleColor.Black;
break;
case "8":
Console.ResetColor();
break;
case "9":
break;
default:
innerQuit = false;
break;
}
} while (!innerQuit);
break;
case "3":
do
{
innerQuit = true;
Console.WriteLine(
"1.\tChange background color to Green.\n" +
"2.\tChange background color to Yellow.\n" +
"3.\tChange background color to Red.\n" +
"4.\tChange background color to Blue.\n" +
"5.\tChange background color to Gray.\n" +
"6.\tChange background color to White.\n" +
"7.\tChange background color to Black.\n" +
"8.\tRun to default.\n" +
"9.\tQuit background color settings.\n"
);
choice = Console.ReadLine();
switch (choice)
{
case "1":
Console.BackgroundColor = ConsoleColor.Green;
break;
case "2":
Console.BackgroundColor = ConsoleColor.Yellow;
break;
case "3":
Console.BackgroundColor = ConsoleColor.Red;
break;
case "4":
Console.BackgroundColor = ConsoleColor.Blue;
break;
case "5":
Console.BackgroundColor = ConsoleColor.Gray;
break;
case "6":
Console.BackgroundColor = ConsoleColor.White;
break;
case "7":
Console.BackgroundColor = ConsoleColor.Black;
break;
case "8":
Console.ResetColor();
break;
case "9":
break;
default:
innerQuit = false;
break;
}
} while (!innerQuit);
break;
case "4":
while (true)
{
Console.WriteLine("Enter text to change title: ");
string str = Console.ReadLine();
if (!string.IsNullOrEmpty(str))
{
Console.Title = str;
break;
}
else
{
Console.WriteLine("String must not be empty. Repeat please.");
}
}
break;
case "5":
while (true)
{
int borderX = -1, borderY = -1;
Console.Write("Enter width (1 - {0}): ", Console.LargestWindowWidth);
if (int.TryParse(Console.ReadLine(), out borderX) && borderX >= 1 && borderX <= Console.LargestWindowWidth)
{
Console.Write("Enter height (1 - {0}): ", Console.LargestWindowHeight);
if (int.TryParse(Console.ReadLine(), out borderY) && borderY >= 1 && borderY <= Console.LargestWindowHeight)
{
Console.SetWindowSize(borderX, borderY);
break;
}
}
Console.WriteLine("Width and height must be valid integers within the specified range.");
}
break;
case "6":
Console.Beep();
break;
case "7":
Console.WriteLine("Date: " + now.ToShortDateString());
Console.WriteLine("Time: " + now.ToShortTimeString() + "\n");
break;
case "8":
DateTime newYear = new DateTime(now.Year + 1, 1, 1);
TimeSpan daysLeft = newYear - now;
string newYearMessage = daysLeft.Days == 1 ? "day" : "days";
Console.WriteLine("{0} {1} until new year", daysLeft.Days, newYearMessage);
DateTime birthday = new DateTime(now.Year + 1, 1, 6);
daysLeft = birthday - now;
string birthdayMessage = daysLeft.Days == 1 ? "day" : "days";
Console.WriteLine("{0} {1} until my birthday", daysLeft.Days, birthdayMessage);
DateTime kaiDay = new DateTime(now.Year + 1, 5, 27);
daysLeft = kaiDay - now;
string kaiDayMessage = daysLeft.Days == 1 ? "day" : "days";
Console.WriteLine("{0} {1} until KAI day", daysLeft.Days, kaiDayMessage);
Console.WriteLine("Days until victory: not long left\n");
break;
case "9":
Console.WriteLine("Closure -_-");
quit = true;
break;
}
}
}
}
}