diff --git a/Core/Program.cs b/Core/Program.cs
index 5d89c56..61cbcf0 100644
--- a/Core/Program.cs
+++ b/Core/Program.cs
@@ -8,6 +8,7 @@ class Program
static MenuForm mainMenuForm;
static MenuForm snakeDiffMenuForm;
static MenuForm snakeSizeMenuForm;
+ static AboutMeForm aboutMeForm;
[STAThread] // Требуется для Windows Forms
static void Main()
@@ -31,7 +32,7 @@ class Program
Menu mainMenu = new Menu("Select option");
mainMenu.AddOption("Guess answer math game", () => GuessAnswerMath.RunGame());
- mainMenu.AddOption("About me", () => PrintAboutMe());
+ mainMenu.AddOption("About me", () => mainMenuForm.SwitchToForm(aboutMeForm));
mainMenu.AddOption("Array sort", () => new ArraySortDemo().Run());
mainMenu.AddOption("Snake game", () => {
mainMenuForm.Hide();
@@ -47,11 +48,14 @@ class Program
snakeDiffMenuForm = new MenuForm(difficultyMenu, () => { snakeDiffMenuForm.SwitchToForm(snakeSizeMenuForm); });
snakeSizeMenuForm = new MenuForm(sizeMenu, () =>
{
+ snakeSizeMenuForm.Hide();
SnakeGame game = new SnakeGame(difficulty, sizex, sizey);
game.start();
snakeSizeMenuForm.SwitchToForm(mainMenuForm);
});
+ aboutMeForm = new AboutMeForm(mainMenuForm);
+
Application.Run(mainMenuForm);
@@ -65,8 +69,7 @@ Website: divan2000.su";
}
private static void Exit()
{
- if(ExitMenu())
- Environment.Exit(0);
+ ExitDialog.Exit();
}
private static bool ExitMenu()
{
diff --git a/Core/Utils.cs b/Core/Utils.cs
index 9e1c87a..80720d4 100644
--- a/Core/Utils.cs
+++ b/Core/Utils.cs
@@ -216,5 +216,21 @@ namespace laba3.Core
}
}
}
+
+ public static void OpenInWeb(string url)
+ {
+ try
+ {
+ System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo
+ {
+ FileName = url, // Замените на свой сайт
+ UseShellExecute = true // Это указывает, что нужно использовать ассоциации с оболочкой (браузер)
+ });
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show("Ошибка при открытии браузера: " + ex.Message);
+ }
+ }
}
}
diff --git a/GUI/AboutMeForm.Designer.cs b/GUI/AboutMeForm.Designer.cs
new file mode 100644
index 0000000..030c367
--- /dev/null
+++ b/GUI/AboutMeForm.Designer.cs
@@ -0,0 +1,39 @@
+namespace ProgLab1.GUI
+{
+ partial class AboutMeForm
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ this.components = new System.ComponentModel.Container();
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(800, 450);
+ this.Text = "AboutMeForm";
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
diff --git a/GUI/AboutMeForm.cs b/GUI/AboutMeForm.cs
new file mode 100644
index 0000000..bc2a03d
--- /dev/null
+++ b/GUI/AboutMeForm.cs
@@ -0,0 +1,41 @@
+using laba3.Core;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace ProgLab1.GUI
+{
+ public partial class AboutMeForm : Form
+ {
+ private Label nameLabel;
+ private LinkLabel websiteLinkLabel;
+ public AboutMeForm(Form onCloseForm)
+ {
+ InitializeComponent();
+ this.Text = "Обо мне";
+
+ nameLabel = new Label();
+ nameLabel.Text = "Морозов Иван Сергеевич 6106 aka DIvan2000";
+ nameLabel.AutoSize = true;
+ nameLabel.Top = 50;
+ nameLabel.Left = 50;
+
+ websiteLinkLabel = new LinkLabel();
+ websiteLinkLabel.Text = "Мой сайт: divan2000.su";
+ websiteLinkLabel.AutoSize = true;
+ websiteLinkLabel.Top = 100;
+ websiteLinkLabel.Left = 50;
+ websiteLinkLabel.LinkClicked += new LinkLabelLinkClickedEventHandler( (object sender, LinkLabelLinkClickedEventArgs e) => { Utils.OpenInWeb("https://divan2000.su"); });
+
+ this.Controls.Add(nameLabel);
+ this.Controls.Add(websiteLinkLabel);
+ this.FormClosing += new FormClosingEventHandler((object sender, FormClosingEventArgs e) => { e.Cancel = true; this.Hide(); onCloseForm.Show(); });
+ }
+ }
+}
diff --git a/GUI/AboutMeForm.resx b/GUI/AboutMeForm.resx
new file mode 100644
index 0000000..1af7de1
--- /dev/null
+++ b/GUI/AboutMeForm.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/GUI/ExitDialog.cs b/GUI/ExitDialog.cs
new file mode 100644
index 0000000..61d1b94
--- /dev/null
+++ b/GUI/ExitDialog.cs
@@ -0,0 +1,22 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ProgLab1.GUI
+{
+ public static class ExitDialog
+ {
+ public static bool Exit()
+ {
+ DialogResult result = MessageBox.Show("Вы уверены, что хотите закрыть программу?", "Подтверждение", MessageBoxButtons.YesNo);
+ if (result == DialogResult.Yes)
+ {
+ Environment.Exit(0);
+ return true;
+ }
+ return false;
+ }
+ }
+}
diff --git a/GUI/MathGameForm.Designer.cs b/GUI/MathGameForm.Designer.cs
new file mode 100644
index 0000000..ebd73c5
--- /dev/null
+++ b/GUI/MathGameForm.Designer.cs
@@ -0,0 +1,39 @@
+namespace ProgLab1.GUI
+{
+ partial class MathGameForm
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ this.components = new System.ComponentModel.Container();
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(800, 450);
+ this.Text = "MathGameForm";
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
diff --git a/GUI/MathGameForm.cs b/GUI/MathGameForm.cs
new file mode 100644
index 0000000..0300194
--- /dev/null
+++ b/GUI/MathGameForm.cs
@@ -0,0 +1,31 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+using System.Xml;
+
+namespace ProgLab1.GUI
+{
+ public partial class MathGameForm : Form
+ {
+ private Label formula;
+ public MathGameForm()
+ {
+ InitializeComponent();
+ this.Text = "Угадайка";
+
+ formula = new Label();
+ formula.Text = "Math.Sin((Math.Pow(a, 3) + Math.Pow(b, 5)) / (2 * PI)) + Math.Pow(Math.Cos(a + b), (1.0 / 3.0))";
+ formula.AutoSize = true;
+ formula.Top = 50;
+ formula.Left = 50;
+
+ this.Controls.Add(formula);
+ }
+ }
+}
diff --git a/GUI/MathGameForm.resx b/GUI/MathGameForm.resx
new file mode 100644
index 0000000..1af7de1
--- /dev/null
+++ b/GUI/MathGameForm.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/GUI/MenuForm.cs b/GUI/MenuForm.cs
index 0f4f035..7f88a38 100644
--- a/GUI/MenuForm.cs
+++ b/GUI/MenuForm.cs
@@ -18,19 +18,21 @@ namespace ProgLab1.GUI
public MenuForm(Menu consoleMenu)
{
InitializeComponent();
+ this.Text = "Меню";
this.Width = 800;
this.Height = 600;
AddMenu(consoleMenu);
- this.FormClosing += new FormClosingEventHandler((object sender, FormClosingEventArgs e) => { e.Cancel = true; });
+ this.FormClosing += new FormClosingEventHandler((object sender, FormClosingEventArgs e) => { e.Cancel = !ExitDialog.Exit(); });
}
public MenuForm(Menu consoleMenu, Action onAny)
{
InitializeComponent();
+ this.Text = "Меню";
this.Width = 800;
this.Height = 600;
AddMenu(consoleMenu, onAny);
- this.FormClosing += new FormClosingEventHandler((object sender, FormClosingEventArgs e) => { e.Cancel = true; });
+ this.FormClosing += new FormClosingEventHandler((object sender, FormClosingEventArgs e) => { e.Cancel = !ExitDialog.Exit(); });
}
public void SwitchToForm(Form form)