ProgLab1_winforms/Core/Program.cs

89 lines
2.9 KiB
C#
Raw Normal View History

using laba3.Core;
using laba3.Subprograms;
2024-12-14 10:20:38 +04:00
using ProgLab1.GUI;
using System;
2024-12-14 10:20:38 +04:00
using System.Windows.Forms;
using static System.Windows.Forms.DataFormats;
class Program
{
2024-12-14 10:20:38 +04:00
[STAThread] // Требуется для Windows Forms
static void Main()
{
2024-12-14 10:20:38 +04:00
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Menu mainForm = new Menu();
laba3.Core.Menu mainMenu = new laba3.Core.Menu("Select option");
mainMenu.AddOption("Guess answer math game", () => GuessAnswerMath.RunGame());
mainMenu.AddOption("About me", () => PrintAboutMe());
mainMenu.AddOption("Array sort", () => new ArraySortDemo().Run());
mainMenu.AddOption("Snake game", () => {
int sizex = 0;
int sizey = 0;
SnakeGame.Level difficulty = 0;
2024-12-14 10:20:38 +04:00
laba3.Core.Menu sizeMenu = new laba3.Core.Menu("Select world size");
sizeMenu.AddOption("Small size (10x10)", () => { sizex = 10; sizey = 10; });
sizeMenu.AddOption("Medium size (20x20)", () => { sizex = 20; sizey = 20; });
sizeMenu.AddOption("Big size (40x20)", () => { sizex = 40; sizey = 20; });
sizeMenu.RunMenu();
2024-12-14 10:20:38 +04:00
laba3.Core.Menu difficultyMenu = new laba3.Core.Menu("Select difficulty");
difficultyMenu.AddOption("Easy", () => { difficulty = SnakeGame.Level.Low; });
difficultyMenu.AddOption("Medium", () => { difficulty = SnakeGame.Level.Medium; });
difficultyMenu.AddOption("Hard", () => { difficulty = SnakeGame.Level.High; });
difficultyMenu.RunMenu();
SnakeGame game = new SnakeGame(difficulty, sizex, sizey);
game.start();
});
mainMenu.AddOption("Exit", () => Exit());
Utils.Arrays withoutParams = new Utils.Arrays();
Utils.Arrays withOneParam = new Utils.Arrays(10);
Utils.Arrays withTwoParams = new Utils.Arrays(10, 100);
2024-12-14 10:20:38 +04:00
laba3.Core.Menu test = new laba3.Core.Menu("test");
test.AddOption("a", () => { });
mainForm.AddMenu(mainMenu);
mainForm.AddMenu(mainMenu);
mainForm.AddMenu(mainMenu);
Application.Run(mainForm);
}
private static void PrintAboutMe()
{
const string aboutme = @"Морозов Иван Сергеевич 6106 aka DIvan2000
Website: divan2000.su";
Console.WriteLine(aboutme);
}
private static void Exit()
{
if(ExitMenu())
Environment.Exit(0);
}
private static bool ExitMenu()
{
while (true)
{
Console.WriteLine("Really exit? [y/n]");
switch (Console.ReadKey(true).KeyChar)
{
case 'y':
return true;
case 'n':
return false;
default:
Console.Clear();
Console.WriteLine("Wrong key!");
break;
}
}
}
}