Revert "Неудачный коммит"
This reverts commit 565d0f15cc25f2fb7a1d133e1c5c2c1767f7da34.
This commit is contained in:
		
							parent
							
								
									565d0f15cc
								
							
						
					
					
						commit
						2d28599940
					
				
							
								
								
									
										29
									
								
								Core/Menu.cs
									
									
									
									
									
								
							
							
						
						
									
										29
									
								
								Core/Menu.cs
									
									
									
									
									
								
							| @ -10,9 +10,9 @@ namespace laba3.Core | |||||||
|     /// <summary> |     /// <summary> | ||||||
|     /// TUI menu; |     /// TUI menu; | ||||||
|     /// </summary> |     /// </summary> | ||||||
|     public class Menu |     internal class Menu | ||||||
|     { |     { | ||||||
|         private List<MenuOption> options; |         private List<Option> options; | ||||||
|         private int selected; |         private int selected; | ||||||
|         private string title; |         private string title; | ||||||
|          |          | ||||||
| @ -23,21 +23,9 @@ namespace laba3.Core | |||||||
|         public Menu(string title) |         public Menu(string title) | ||||||
|         { |         { | ||||||
|             this.title = title; |             this.title = title; | ||||||
|             this.options = new List<MenuOption> { }; |             this.options = new List<Option> { }; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         /// <summary> |  | ||||||
|         /// Get options list |  | ||||||
|         /// </summary> |  | ||||||
|         /// <returns></returns> |  | ||||||
|         public List<MenuOption> GetOptions() { return this.options; } |  | ||||||
|          |  | ||||||
|         /// <summary> |  | ||||||
|         /// Get title string |  | ||||||
|         /// </summary> |  | ||||||
|         /// <returns></returns> |  | ||||||
|         public string GetTitle() { return this.title; } |  | ||||||
| 
 |  | ||||||
|         /// <summary> |         /// <summary> | ||||||
|         /// Add option to menu; |         /// Add option to menu; | ||||||
|         /// </summary> |         /// </summary> | ||||||
| @ -45,7 +33,7 @@ namespace laba3.Core | |||||||
|         /// <param name="action">Action, runs if option selected</param> |         /// <param name="action">Action, runs if option selected</param> | ||||||
|         public void AddOption(string name, Action action) |         public void AddOption(string name, Action action) | ||||||
|         { |         { | ||||||
|             this.options.Add(new MenuOption(name, action)); |             this.options.Add(new Option(name, action)); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         /// <summary> |         /// <summary> | ||||||
| @ -89,7 +77,7 @@ namespace laba3.Core | |||||||
|             Console.Clear(); |             Console.Clear(); | ||||||
|             Console.WriteLine(title); |             Console.WriteLine(title); | ||||||
|             int optionIndex = 0; |             int optionIndex = 0; | ||||||
|             foreach (MenuOption option in options) |             foreach (Option option in options) | ||||||
|             { |             { | ||||||
|                 string pointer = optionIndex == selected ? " ->" : "   "; |                 string pointer = optionIndex == selected ? " ->" : "   "; | ||||||
|                 Console.WriteLine($"{pointer}{option.Name}"); |                 Console.WriteLine($"{pointer}{option.Name}"); | ||||||
| @ -97,15 +85,12 @@ namespace laba3.Core | |||||||
|             } |             } | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         /// <summary> |         private struct Option | ||||||
|         /// Menu option struct; |  | ||||||
|         /// </summary> |  | ||||||
|         public struct MenuOption |  | ||||||
|         { |         { | ||||||
|             public string Name { get; } |             public string Name { get; } | ||||||
|             public Action Action { get; } |             public Action Action { get; } | ||||||
| 
 | 
 | ||||||
|             public MenuOption(string name, Action action) |             public Option(string name, Action action) | ||||||
|             { |             { | ||||||
|                 Name = name; |                 Name = name; | ||||||
|                 Action = action; |                 Action = action; | ||||||
|  | |||||||
| @ -1,20 +1,12 @@ | |||||||
| using laba3.Core; | using laba3.Core; | ||||||
| using laba3.Subprograms; | using laba3.Subprograms; | ||||||
| using ProgLab1.GUI; |  | ||||||
| using System; | using System; | ||||||
| using System.Windows.Forms; |  | ||||||
| using static System.Windows.Forms.DataFormats; |  | ||||||
| 
 | 
 | ||||||
| class Program | class Program | ||||||
| { | { | ||||||
|     [STAThread] // Требуется для Windows Forms |  | ||||||
|     static void Main() |     static void Main() | ||||||
|     { |     { | ||||||
|         Application.EnableVisualStyles(); |         Menu mainMenu = new Menu("Select option"); | ||||||
|         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("Guess answer math game", () => GuessAnswerMath.RunGame()); | ||||||
|         mainMenu.AddOption("About me", () => PrintAboutMe()); |         mainMenu.AddOption("About me", () => PrintAboutMe()); | ||||||
|         mainMenu.AddOption("Array sort", () => new ArraySortDemo().Run()); |         mainMenu.AddOption("Array sort", () => new ArraySortDemo().Run()); | ||||||
| @ -22,13 +14,13 @@ class Program | |||||||
|             int sizex = 0; |             int sizex = 0; | ||||||
|             int sizey = 0; |             int sizey = 0; | ||||||
|             SnakeGame.Level difficulty = 0; |             SnakeGame.Level difficulty = 0; | ||||||
|             laba3.Core.Menu sizeMenu = new laba3.Core.Menu("Select world size"); |             Menu sizeMenu = new Menu("Select world size"); | ||||||
|             sizeMenu.AddOption("Small size (10x10)", () => { sizex = 10; sizey = 10; }); |             sizeMenu.AddOption("Small size (10x10)", () => { sizex = 10; sizey = 10; }); | ||||||
|             sizeMenu.AddOption("Medium size (20x20)", () => { sizex = 20; sizey = 20; }); |             sizeMenu.AddOption("Medium size (20x20)", () => { sizex = 20; sizey = 20; }); | ||||||
|             sizeMenu.AddOption("Big size (40x20)", () => { sizex = 40; sizey = 20; }); |             sizeMenu.AddOption("Big size (40x20)", () => { sizex = 40; sizey = 20; }); | ||||||
|             sizeMenu.RunMenu(); |             sizeMenu.RunMenu(); | ||||||
| 
 | 
 | ||||||
|             laba3.Core.Menu difficultyMenu = new laba3.Core.Menu("Select difficulty"); |             Menu difficultyMenu = new Menu("Select difficulty"); | ||||||
|             difficultyMenu.AddOption("Easy", () => { difficulty = SnakeGame.Level.Low; }); |             difficultyMenu.AddOption("Easy", () => { difficulty = SnakeGame.Level.Low; }); | ||||||
|             difficultyMenu.AddOption("Medium", () => { difficulty = SnakeGame.Level.Medium; }); |             difficultyMenu.AddOption("Medium", () => { difficulty = SnakeGame.Level.Medium; }); | ||||||
|             difficultyMenu.AddOption("Hard", () => { difficulty = SnakeGame.Level.High; }); |             difficultyMenu.AddOption("Hard", () => { difficulty = SnakeGame.Level.High; }); | ||||||
| @ -45,16 +37,13 @@ class Program | |||||||
|         Utils.Arrays withOneParam = new Utils.Arrays(10); |         Utils.Arrays withOneParam = new Utils.Arrays(10); | ||||||
|         Utils.Arrays withTwoParams = new Utils.Arrays(10, 100); |         Utils.Arrays withTwoParams = new Utils.Arrays(10, 100); | ||||||
| 
 | 
 | ||||||
|         laba3.Core.Menu test = new laba3.Core.Menu("test"); |         while (true) | ||||||
|         test.AddOption("a", () => { }); |         { | ||||||
|         mainForm.AddMenu(mainMenu); |             mainMenu.RunMenu(); | ||||||
|         mainForm.AddMenu(mainMenu); |             Console.WriteLine("Press Enter to continue"); | ||||||
|         mainForm.AddMenu(mainMenu); |             while (Console.ReadKey().Key != ConsoleKey.Enter) { } | ||||||
| 
 |             Console.Clear(); | ||||||
| 
 |         } | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
|         Application.Run(mainForm); |  | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     private static void PrintAboutMe() |     private static void PrintAboutMe() | ||||||
|  | |||||||
							
								
								
									
										39
									
								
								GUI/MenuForm.Designer.cs
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										39
									
								
								GUI/MenuForm.Designer.cs
									
									
									
										generated
									
									
									
								
							| @ -1,39 +0,0 @@ | |||||||
| namespace ProgLab1.GUI |  | ||||||
| { |  | ||||||
|     partial class Menu |  | ||||||
|     { |  | ||||||
|         /// <summary> |  | ||||||
|         /// Required designer variable. |  | ||||||
|         /// </summary> |  | ||||||
|         private System.ComponentModel.IContainer components = null; |  | ||||||
| 
 |  | ||||||
|         /// <summary> |  | ||||||
|         /// Clean up any resources being used. |  | ||||||
|         /// </summary> |  | ||||||
|         /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> |  | ||||||
|         protected override void Dispose(bool disposing) |  | ||||||
|         { |  | ||||||
|             if (disposing && (components != null)) |  | ||||||
|             { |  | ||||||
|                 components.Dispose(); |  | ||||||
|             } |  | ||||||
|             base.Dispose(disposing); |  | ||||||
|         } |  | ||||||
| 
 |  | ||||||
|         #region Windows Form Designer generated code |  | ||||||
| 
 |  | ||||||
|         /// <summary> |  | ||||||
|         /// Required method for Designer support - do not modify |  | ||||||
|         /// the contents of this method with the code editor. |  | ||||||
|         /// </summary> |  | ||||||
|         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 = "Main"; |  | ||||||
|         } |  | ||||||
| 
 |  | ||||||
|         #endregion |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| @ -1,63 +0,0 @@ | |||||||
| 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 MenuForm : Form |  | ||||||
|     { |  | ||||||
|         public MenuForm() |  | ||||||
|         { |  | ||||||
|             InitializeComponent(); |  | ||||||
|         } |  | ||||||
| 
 |  | ||||||
|         /// <summary> |  | ||||||
|         /// Adds menu to GUI |  | ||||||
|         /// </summary> |  | ||||||
|         /// <param name="consoleMenu">TUI menu</param> |  | ||||||
|         public void AddMenu(Menu consoleMenu) |  | ||||||
|         { |  | ||||||
| 
 |  | ||||||
|             FlowLayoutPanel buttonPanel = new FlowLayoutPanel |  | ||||||
|             { |  | ||||||
|                 Dock = DockStyle.Fill, // Растягиваем на всю форму |  | ||||||
|                 FlowDirection = FlowDirection.TopDown, // Кнопки располагаются сверху вниз |  | ||||||
|                 WrapContents = false // Запрет переноса |  | ||||||
|             }; |  | ||||||
| 
 |  | ||||||
|             Label menuLabel = new Label |  | ||||||
|             { |  | ||||||
|                 Text = consoleMenu.GetTitle(), // Текст заголовка |  | ||||||
|                 Font = new System.Drawing.Font("Arial", 16, System.Drawing.FontStyle.Bold), // Стиль шрифта |  | ||||||
|                 TextAlign = System.Drawing.ContentAlignment.MiddleCenter, // Выравнивание текста по центру |  | ||||||
|                 Dock = DockStyle.Top, // Заголовок сверху |  | ||||||
|                 Height = 40 // Высота заголовка |  | ||||||
|             }; |  | ||||||
| 
 |  | ||||||
|             buttonPanel.Controls.Add(menuLabel); |  | ||||||
| 
 |  | ||||||
|             foreach (MenuOption option in consoleMenu.GetOptions()) |  | ||||||
|             { |  | ||||||
|                 Button button = new Button |  | ||||||
|                 { |  | ||||||
|                     Text = option.Name, |  | ||||||
|                     Width = buttonPanel.Width-10, |  | ||||||
|                     Height = 40, |  | ||||||
|                     Margin = new Padding(5), |  | ||||||
|                 }; |  | ||||||
| 
 |  | ||||||
|                 // Связываем обработчик с OnSelect из консольного меню |  | ||||||
|                 button.Click += (sender, e) => option.Action(); |  | ||||||
| 
 |  | ||||||
|                 buttonPanel.Controls.Add(button); |  | ||||||
|             } |  | ||||||
|         } |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| @ -1,120 +0,0 @@ | |||||||
| <?xml version="1.0" encoding="utf-8"?> |  | ||||||
| <root> |  | ||||||
|   <!--  |  | ||||||
|     Microsoft ResX Schema  |  | ||||||
|      |  | ||||||
|     Version 2.0 |  | ||||||
|      |  | ||||||
|     The primary goals of this format is to allow a simple XML format  |  | ||||||
|     that is mostly human readable. The generation and parsing of the  |  | ||||||
|     various data types are done through the TypeConverter classes  |  | ||||||
|     associated with the data types. |  | ||||||
|      |  | ||||||
|     Example: |  | ||||||
|      |  | ||||||
|     ... ado.net/XML headers & schema ... |  | ||||||
|     <resheader name="resmimetype">text/microsoft-resx</resheader> |  | ||||||
|     <resheader name="version">2.0</resheader> |  | ||||||
|     <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> |  | ||||||
|     <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> |  | ||||||
|     <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> |  | ||||||
|     <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> |  | ||||||
|     <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> |  | ||||||
|         <value>[base64 mime encoded serialized .NET Framework object]</value> |  | ||||||
|     </data> |  | ||||||
|     <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> |  | ||||||
|         <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> |  | ||||||
|         <comment>This is a comment</comment> |  | ||||||
|     </data> |  | ||||||
|                  |  | ||||||
|     There are any number of "resheader" rows that contain simple  |  | ||||||
|     name/value pairs. |  | ||||||
|      |  | ||||||
|     Each data row contains a name, and value. The row also contains a  |  | ||||||
|     type or mimetype. Type corresponds to a .NET class that support  |  | ||||||
|     text/value conversion through the TypeConverter architecture.  |  | ||||||
|     Classes that don't support this are serialized and stored with the  |  | ||||||
|     mimetype set. |  | ||||||
|      |  | ||||||
|     The mimetype is used for serialized objects, and tells the  |  | ||||||
|     ResXResourceReader how to depersist the object. This is currently not  |  | ||||||
|     extensible. For a given mimetype the value must be set accordingly: |  | ||||||
|      |  | ||||||
|     Note - application/x-microsoft.net.object.binary.base64 is the format  |  | ||||||
|     that the ResXResourceWriter will generate, however the reader can  |  | ||||||
|     read any of the formats listed below. |  | ||||||
|      |  | ||||||
|     mimetype: application/x-microsoft.net.object.binary.base64 |  | ||||||
|     value   : The object must be serialized with  |  | ||||||
|             : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter |  | ||||||
|             : and then encoded with base64 encoding. |  | ||||||
|      |  | ||||||
|     mimetype: application/x-microsoft.net.object.soap.base64 |  | ||||||
|     value   : The object must be serialized with  |  | ||||||
|             : System.Runtime.Serialization.Formatters.Soap.SoapFormatter |  | ||||||
|             : and then encoded with base64 encoding. |  | ||||||
| 
 |  | ||||||
|     mimetype: application/x-microsoft.net.object.bytearray.base64 |  | ||||||
|     value   : The object must be serialized into a byte array  |  | ||||||
|             : using a System.ComponentModel.TypeConverter |  | ||||||
|             : and then encoded with base64 encoding. |  | ||||||
|     --> |  | ||||||
|   <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> |  | ||||||
|     <xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> |  | ||||||
|     <xsd:element name="root" msdata:IsDataSet="true"> |  | ||||||
|       <xsd:complexType> |  | ||||||
|         <xsd:choice maxOccurs="unbounded"> |  | ||||||
|           <xsd:element name="metadata"> |  | ||||||
|             <xsd:complexType> |  | ||||||
|               <xsd:sequence> |  | ||||||
|                 <xsd:element name="value" type="xsd:string" minOccurs="0" /> |  | ||||||
|               </xsd:sequence> |  | ||||||
|               <xsd:attribute name="name" use="required" type="xsd:string" /> |  | ||||||
|               <xsd:attribute name="type" type="xsd:string" /> |  | ||||||
|               <xsd:attribute name="mimetype" type="xsd:string" /> |  | ||||||
|               <xsd:attribute ref="xml:space" /> |  | ||||||
|             </xsd:complexType> |  | ||||||
|           </xsd:element> |  | ||||||
|           <xsd:element name="assembly"> |  | ||||||
|             <xsd:complexType> |  | ||||||
|               <xsd:attribute name="alias" type="xsd:string" /> |  | ||||||
|               <xsd:attribute name="name" type="xsd:string" /> |  | ||||||
|             </xsd:complexType> |  | ||||||
|           </xsd:element> |  | ||||||
|           <xsd:element name="data"> |  | ||||||
|             <xsd:complexType> |  | ||||||
|               <xsd:sequence> |  | ||||||
|                 <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> |  | ||||||
|                 <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> |  | ||||||
|               </xsd:sequence> |  | ||||||
|               <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" /> |  | ||||||
|               <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> |  | ||||||
|               <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> |  | ||||||
|               <xsd:attribute ref="xml:space" /> |  | ||||||
|             </xsd:complexType> |  | ||||||
|           </xsd:element> |  | ||||||
|           <xsd:element name="resheader"> |  | ||||||
|             <xsd:complexType> |  | ||||||
|               <xsd:sequence> |  | ||||||
|                 <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> |  | ||||||
|               </xsd:sequence> |  | ||||||
|               <xsd:attribute name="name" type="xsd:string" use="required" /> |  | ||||||
|             </xsd:complexType> |  | ||||||
|           </xsd:element> |  | ||||||
|         </xsd:choice> |  | ||||||
|       </xsd:complexType> |  | ||||||
|     </xsd:element> |  | ||||||
|   </xsd:schema> |  | ||||||
|   <resheader name="resmimetype"> |  | ||||||
|     <value>text/microsoft-resx</value> |  | ||||||
|   </resheader> |  | ||||||
|   <resheader name="version"> |  | ||||||
|     <value>2.0</value> |  | ||||||
|   </resheader> |  | ||||||
|   <resheader name="reader"> |  | ||||||
|     <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> |  | ||||||
|   </resheader> |  | ||||||
|   <resheader name="writer"> |  | ||||||
|     <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> |  | ||||||
|   </resheader> |  | ||||||
| </root> |  | ||||||
| @ -2,10 +2,9 @@ | |||||||
| 
 | 
 | ||||||
|   <PropertyGroup> |   <PropertyGroup> | ||||||
|     <OutputType>Exe</OutputType> |     <OutputType>Exe</OutputType> | ||||||
|     <TargetFramework>net8.0-windows10.0.17763.0</TargetFramework> |     <TargetFramework>net8.0</TargetFramework> | ||||||
|     <ImplicitUsings>enable</ImplicitUsings> |     <ImplicitUsings>enable</ImplicitUsings> | ||||||
|     <Nullable>enable</Nullable> |     <Nullable>enable</Nullable> | ||||||
|     <UseWindowsForms>True</UseWindowsForms> |  | ||||||
|   </PropertyGroup> |   </PropertyGroup> | ||||||
| 
 | 
 | ||||||
| </Project> | </Project> | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user