From d01d7cf01282f61bedd8a88ae8bdc89c195c8e96 Mon Sep 17 00:00:00 2001 From: DelphyAlmond Date: Sun, 28 Apr 2024 12:36:36 +0400 Subject: [PATCH] Storage(two_Forms) --- WinF_Lab1_Cruiser - Ярлык.lnk | Bin 1521 -> 0 bytes .../CruiserMech/CruiserMech.csproj | 34 ---- .../WinF_Lab2_Cruiser.sln | 12 +- .../CollectionForm.Designer.cs | 174 ++++++++++++++++++ .../WinF_Lab2_Cruiser/CollectionForm.cs | 151 +++++++++++++++ .../WinF_Lab2_Cruiser/CollectionForm.resx | 0 .../AbstractCompany.cs | 65 +++++++ .../CollectionGenericObjects/ArrayAlg.cs | 101 ++++++++++ .../CollectionGenericObjects/ICGO.cs | 23 +++ .../NewClassCollection.cs | 68 +++++++ .../DrawingCanvas.Designer.cs | 52 +----- .../WinF_Lab2_Cruiser}/DrawingCanvas.cs | 44 +++-- .../WinF_Lab2_Cruiser/DrawingCanvas.resx | 120 ++++++++++++ .../Drawing_tools/DirectionType.cs | 2 +- .../Drawing_tools/DrawingBase.cs | 4 +- .../Drawing_tools/DrawingCruiser.cs | 4 +- .../Entity_Folder/Base_Class_Cruiser.cs | 2 +- .../Entity_Folder/Class_CruiserEntity.cs | 2 +- .../Move_Strategy/AbstractStrategy.cs | 6 +- .../Move_Strategy/Boarder.cs | 10 +- .../Move_Strategy/Center.cs | 2 +- .../WinF_Lab2_Cruiser}/Move_Strategy/IMO.cs | 4 +- .../Move_Strategy/MovableCruiser.cs | 6 +- .../WinF_Lab2_Cruiser}/Move_Strategy/Moves.cs | 2 +- .../Move_Strategy/ObjectParam.cs | 2 +- .../Move_Strategy/Status.cs | 2 +- .../WinF_Lab2_Cruiser}/Program.cs | 5 +- .../Properties/Resources.Designer.cs | 14 +- .../Properties/Resources.resx | 3 - .../Resources/down_arrow_res.png | Bin .../Resources/left_arrow_res.png | Bin .../Resources/right_arrow_res.png | Bin .../Resources/up_arrow_res.png | Bin .../WinF_Lab2_Cruiser.csproj | 11 ++ 34 files changed, 789 insertions(+), 136 deletions(-) delete mode 100644 WinF_Lab1_Cruiser - Ярлык.lnk delete mode 100644 WinF_Lab1_Cruiser/CruiserMech/CruiserMech.csproj rename WinF_Lab1_Cruiser/WinF_Lab1_Cruiser.sln => WinF_Lab2_Cruiser/WinF_Lab2_Cruiser.sln (58%) create mode 100644 WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/CollectionForm.Designer.cs create mode 100644 WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/CollectionForm.cs rename WinF_Lab1_Cruiser/CruiserMech/DrawingCanvas.resx => WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/CollectionForm.resx (100%) create mode 100644 WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/CollectionGenericObjects/AbstractCompany.cs create mode 100644 WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/CollectionGenericObjects/ArrayAlg.cs create mode 100644 WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/CollectionGenericObjects/ICGO.cs create mode 100644 WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/CollectionGenericObjects/NewClassCollection.cs rename {WinF_Lab1_Cruiser/CruiserMech => WinF_Lab2_Cruiser/WinF_Lab2_Cruiser}/DrawingCanvas.Designer.cs (79%) rename {WinF_Lab1_Cruiser/CruiserMech => WinF_Lab2_Cruiser/WinF_Lab2_Cruiser}/DrawingCanvas.cs (85%) create mode 100644 WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/DrawingCanvas.resx rename {WinF_Lab1_Cruiser/CruiserMech => WinF_Lab2_Cruiser/WinF_Lab2_Cruiser}/Drawing_tools/DirectionType.cs (86%) rename {WinF_Lab1_Cruiser/CruiserMech => WinF_Lab2_Cruiser/WinF_Lab2_Cruiser}/Drawing_tools/DrawingBase.cs (98%) rename {WinF_Lab1_Cruiser/CruiserMech => WinF_Lab2_Cruiser/WinF_Lab2_Cruiser}/Drawing_tools/DrawingCruiser.cs (96%) rename {WinF_Lab1_Cruiser/CruiserMech => WinF_Lab2_Cruiser/WinF_Lab2_Cruiser}/Entity_Folder/Base_Class_Cruiser.cs (93%) rename {WinF_Lab1_Cruiser/CruiserMech => WinF_Lab2_Cruiser/WinF_Lab2_Cruiser}/Entity_Folder/Class_CruiserEntity.cs (96%) rename {WinF_Lab1_Cruiser/CruiserMech => WinF_Lab2_Cruiser/WinF_Lab2_Cruiser}/Move_Strategy/AbstractStrategy.cs (94%) rename {WinF_Lab1_Cruiser/CruiserMech => WinF_Lab2_Cruiser/WinF_Lab2_Cruiser}/Move_Strategy/Boarder.cs (80%) rename {WinF_Lab1_Cruiser/CruiserMech => WinF_Lab2_Cruiser/WinF_Lab2_Cruiser}/Move_Strategy/Center.cs (96%) rename {WinF_Lab1_Cruiser/CruiserMech => WinF_Lab2_Cruiser/WinF_Lab2_Cruiser}/Move_Strategy/IMO.cs (78%) rename {WinF_Lab1_Cruiser/CruiserMech => WinF_Lab2_Cruiser/WinF_Lab2_Cruiser}/Move_Strategy/MovableCruiser.cs (89%) rename {WinF_Lab1_Cruiser/CruiserMech => WinF_Lab2_Cruiser/WinF_Lab2_Cruiser}/Move_Strategy/Moves.cs (85%) rename {WinF_Lab1_Cruiser/CruiserMech => WinF_Lab2_Cruiser/WinF_Lab2_Cruiser}/Move_Strategy/ObjectParam.cs (95%) rename {WinF_Lab1_Cruiser/CruiserMech => WinF_Lab2_Cruiser/WinF_Lab2_Cruiser}/Move_Strategy/Status.cs (83%) rename {WinF_Lab1_Cruiser/CruiserMech => WinF_Lab2_Cruiser/WinF_Lab2_Cruiser}/Program.cs (76%) rename {WinF_Lab1_Cruiser/CruiserMech => WinF_Lab2_Cruiser/WinF_Lab2_Cruiser}/Properties/Resources.Designer.cs (89%) rename {WinF_Lab1_Cruiser/CruiserMech => WinF_Lab2_Cruiser/WinF_Lab2_Cruiser}/Properties/Resources.resx (96%) rename {WinF_Lab1_Cruiser/CruiserMech => WinF_Lab2_Cruiser/WinF_Lab2_Cruiser}/Resources/down_arrow_res.png (100%) rename {WinF_Lab1_Cruiser/CruiserMech => WinF_Lab2_Cruiser/WinF_Lab2_Cruiser}/Resources/left_arrow_res.png (100%) rename {WinF_Lab1_Cruiser/CruiserMech => WinF_Lab2_Cruiser/WinF_Lab2_Cruiser}/Resources/right_arrow_res.png (100%) rename {WinF_Lab1_Cruiser/CruiserMech => WinF_Lab2_Cruiser/WinF_Lab2_Cruiser}/Resources/up_arrow_res.png (100%) create mode 100644 WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/WinF_Lab2_Cruiser.csproj diff --git a/WinF_Lab1_Cruiser - Ярлык.lnk b/WinF_Lab1_Cruiser - Ярлык.lnk deleted file mode 100644 index 10b6d7e7fae39396f63438cafd46c0ebb9035c2b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1521 zcma)6ZD>X;z z&pqe7=bU>(0Bj`%T!C?Gh5sO)hMn@Xqb~f{8+l{)BrgXM-@Ikk0`U4E045~luUk=ZczMtB0Bbw2E*jvGON^dD#pOV)X z(AdLuFwut;48$SM8?h}Pb&uBJv%~1@?=w;Tn8&Q;v2aE_3Kr7JbEEXtiGF%Dc~F8_ z-d|kH_Sm7WiG&&&-{-|z@;?3AF=s~0`AmDIMz1b(NcnQpd8k-}2ttU`pNVq%H_(N( zJY9jFe1sNlw%U%i;1+)*BoSWAM`+Rhsh*2aa7{8^_OA%R?kTh(fh7F%QQVYNMoCd` z@%R|t91EO?TzTNEJ-pXn zcy7OMV!G%+&mXg86Sh77cRtD*ETR8T=+GVB7QW;9Zc;_MdF1bl#YfGZt5ej!CBYnG zKs>4Qt2hNJd@O)Nsa0N4Ldr(+O2wr#DplNj72WD+k~5<}Hs$()36%-TQJPE=nmVBQ z&xE|{xA%)befdc5g#2UJkYSs}DFV7OFC+2@^l)oe-*JEAr z@|wY)icVj~_|{)nT-;CnO2W$3N1p3cYyL|z*%A5L{<}B&6MMgyp_k}j@pB2DT;AJs q{7`>jBv4;*wC3&1i`4HHg8*@_=JScJ*oXB)dg7h!?e=}5pQA_MctofG diff --git a/WinF_Lab1_Cruiser/CruiserMech/CruiserMech.csproj b/WinF_Lab1_Cruiser/CruiserMech/CruiserMech.csproj deleted file mode 100644 index f0eacb9..0000000 --- a/WinF_Lab1_Cruiser/CruiserMech/CruiserMech.csproj +++ /dev/null @@ -1,34 +0,0 @@ - - - - WinExe - net8.0-windows - enable - true - enable - true - - - - - - - - - - - - True - True - Resources.resx - - - - - - ResXFileCodeGenerator - Resources.Designer.cs - - - - \ No newline at end of file diff --git a/WinF_Lab1_Cruiser/WinF_Lab1_Cruiser.sln b/WinF_Lab2_Cruiser/WinF_Lab2_Cruiser.sln similarity index 58% rename from WinF_Lab1_Cruiser/WinF_Lab1_Cruiser.sln rename to WinF_Lab2_Cruiser/WinF_Lab2_Cruiser.sln index 6f13627..8ef4c40 100644 --- a/WinF_Lab1_Cruiser/WinF_Lab1_Cruiser.sln +++ b/WinF_Lab2_Cruiser/WinF_Lab2_Cruiser.sln @@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.8.34525.116 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CruiserMech", "CruiserMech\CruiserMech.csproj", "{E4BB26A0-B2DE-4C25-99FA-C84AC5FAD361}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WinF_Lab2_Cruiser", "WinF_Lab2_Cruiser\WinF_Lab2_Cruiser.csproj", "{D13E8CC0-46D6-4CB4-9DE1-E340C99B69FB}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -11,15 +11,15 @@ Global Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {E4BB26A0-B2DE-4C25-99FA-C84AC5FAD361}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {E4BB26A0-B2DE-4C25-99FA-C84AC5FAD361}.Debug|Any CPU.Build.0 = Debug|Any CPU - {E4BB26A0-B2DE-4C25-99FA-C84AC5FAD361}.Release|Any CPU.ActiveCfg = Release|Any CPU - {E4BB26A0-B2DE-4C25-99FA-C84AC5FAD361}.Release|Any CPU.Build.0 = Release|Any CPU + {D13E8CC0-46D6-4CB4-9DE1-E340C99B69FB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D13E8CC0-46D6-4CB4-9DE1-E340C99B69FB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D13E8CC0-46D6-4CB4-9DE1-E340C99B69FB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D13E8CC0-46D6-4CB4-9DE1-E340C99B69FB}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {7A9FCCBC-7DB9-4CE7-AA8B-6C609F3E0FB0} + SolutionGuid = {23A421F3-C54C-4554-B468-133A363BD9CD} EndGlobalSection EndGlobal diff --git a/WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/CollectionForm.Designer.cs b/WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/CollectionForm.Designer.cs new file mode 100644 index 0000000..26e7951 --- /dev/null +++ b/WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/CollectionForm.Designer.cs @@ -0,0 +1,174 @@ +namespace WinF_Lab2_Cruiser +{ + partial class CollectionForm + { + /// + /// 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() + { + ToolBox = new GroupBox(); + Check = new Button(); + RandomGenerator = new Button(); + RemoveButton = new Button(); + maskedTextBox1 = new MaskedTextBox(); + Add2Button = new Button(); + AddButton = new Button(); + comboBox1 = new ComboBox(); + pictureBox1 = new PictureBox(); + ToolBox.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)pictureBox1).BeginInit(); + SuspendLayout(); + // + // ToolBox + // + ToolBox.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Right; + ToolBox.Controls.Add(Check); + ToolBox.Controls.Add(RandomGenerator); + ToolBox.Controls.Add(RemoveButton); + ToolBox.Controls.Add(maskedTextBox1); + ToolBox.Controls.Add(Add2Button); + ToolBox.Controls.Add(AddButton); + ToolBox.Controls.Add(comboBox1); + ToolBox.Location = new Point(1042, 12); + ToolBox.Name = "ToolBox"; + ToolBox.Size = new Size(207, 701); + ToolBox.TabIndex = 0; + ToolBox.TabStop = false; + ToolBox.Text = "Tools"; + // + // Check + // + Check.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + Check.Location = new Point(34, 629); + Check.Name = "Check"; + Check.Size = new Size(150, 46); + Check.TabIndex = 6; + Check.Text = "Check"; + Check.UseVisualStyleBackColor = true; + Check.Click += Check_Click; + // + // RandomGenerator + // + RandomGenerator.Anchor = AnchorStyles.Right; + RandomGenerator.Location = new Point(34, 391); + RandomGenerator.Name = "RandomGenerator"; + RandomGenerator.Size = new Size(150, 140); + RandomGenerator.TabIndex = 5; + RandomGenerator.Text = "Generator Random"; + RandomGenerator.UseVisualStyleBackColor = true; + RandomGenerator.Click += RandomGenerator_Click; + // + // RemoveButton + // + RemoveButton.Location = new Point(34, 275); + RemoveButton.Name = "RemoveButton"; + RemoveButton.Size = new Size(150, 46); + RemoveButton.TabIndex = 4; + RemoveButton.Text = "Delete"; + RemoveButton.UseVisualStyleBackColor = true; + RemoveButton.Click += RemoveButton_Click; + // + // maskedTextBox1 + // + maskedTextBox1.Anchor = AnchorStyles.Right; + maskedTextBox1.Location = new Point(6, 214); + maskedTextBox1.Mask = "00"; + maskedTextBox1.Name = "maskedTextBox1"; + maskedTextBox1.Size = new Size(198, 39); + maskedTextBox1.TabIndex = 3; + maskedTextBox1.ValidatingType = typeof(int); + // + // Add2Button + // + Add2Button.Anchor = AnchorStyles.Right; + Add2Button.Location = new Point(6, 146); + Add2Button.Name = "Add2Button"; + Add2Button.Size = new Size(198, 46); + Add2Button.TabIndex = 2; + Add2Button.Text = "Advanced"; + Add2Button.UseVisualStyleBackColor = true; + Add2Button.Click += Add2Button_Click; + // + // AddButton + // + AddButton.Anchor = AnchorStyles.Right; + AddButton.Location = new Point(6, 94); + AddButton.Name = "AddButton"; + AddButton.Size = new Size(198, 46); + AddButton.TabIndex = 1; + AddButton.Text = "Base"; + AddButton.UseVisualStyleBackColor = true; + AddButton.Click += AddButton_Click; + // + // comboBox1 + // + comboBox1.Anchor = AnchorStyles.Top | AnchorStyles.Right; + comboBox1.DropDownStyle = ComboBoxStyle.DropDownList; + comboBox1.FormattingEnabled = true; + comboBox1.Items.AddRange(new object[] { "Storage" }); + comboBox1.Location = new Point(6, 38); + comboBox1.Name = "comboBox1"; + comboBox1.Size = new Size(198, 40); + comboBox1.TabIndex = 0; + comboBox1.SelectedIndexChanged += comboBox_SelectedIndexChanged; + // + // pictureBox1 + // + pictureBox1.BackgroundImageLayout = ImageLayout.Stretch; + pictureBox1.Dock = DockStyle.Left; + pictureBox1.Location = new Point(0, 0); + pictureBox1.Name = "pictureBox1"; + pictureBox1.Size = new Size(1036, 723); + pictureBox1.TabIndex = 3; + pictureBox1.TabStop = false; + // + // CollectionForm + // + AutoScaleDimensions = new SizeF(13F, 32F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(1259, 723); + Controls.Add(pictureBox1); + Controls.Add(ToolBox); + Name = "CollectionForm"; + Text = "CollectionForm"; + ToolBox.ResumeLayout(false); + ToolBox.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)pictureBox1).EndInit(); + ResumeLayout(false); + } + + #endregion + + private GroupBox ToolBox; + private ComboBox comboBox1; + private Button AddButton; + private Button Add2Button; + private MaskedTextBox maskedTextBox1; + private PictureBox pictureBox1; + private Button RemoveButton; + private Button RandomGenerator; + private Button Check; + } +} \ No newline at end of file diff --git a/WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/CollectionForm.cs b/WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/CollectionForm.cs new file mode 100644 index 0000000..8418766 --- /dev/null +++ b/WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/CollectionForm.cs @@ -0,0 +1,151 @@ +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 WinF_Lab2_Cruiser.CollectionGenericObjects; +using WinF_Lab2_Cruiser.Drawing_tools; +using static System.Windows.Forms.VisualStyles.VisualStyleElement; +using WinF_Lab2_Cruiser.Entity_Folder; + +namespace WinF_Lab2_Cruiser +{ + public partial class CollectionForm : Form + { + private AbstractCompany _Company; + public CollectionForm() + { + InitializeComponent(); + } + + private void comboBox_SelectedIndexChanged(object sender, EventArgs e) + { + switch (comboBox1.Text) + { + case "Storage": + _Company = new NewClassCollection(pictureBox1.Width, pictureBox1.Height, new ArrayAlg()); + break; + } + } + + private static Color GetColor(Random r) + { + Color cl = Color.FromArgb(r.Next(0, 256), r.Next(0, 256), r.Next(0, 256)); + ColorDialog dialog = new(); + + if (dialog.ShowDialog() == DialogResult.OK) + { cl = dialog.Color; } + + return cl; + } + + private void CreateObject(string type) + { + if (_Company == null) + { + return; + } + + Random rn = new Random(); + DrawingBase Transport; + switch (type) + { + case nameof(DrawingBase): + Transport = new DrawingBase(rn.Next(100, 300), rn.Next(1000, 3000), GetColor(rn)); + break; + case nameof(DrawingCruiser): + Class_CruiserEntity Obj = new Class_CruiserEntity(rn.Next(100, 300), rn.Next(1000, 3000), + GetColor(rn), GetColor(rn), Convert.ToBoolean(rn.Next(0, 2)), + Convert.ToBoolean(rn.Next(0, 2)), rn.Next(1, 4), rn.Next(5, 10), rn.Next(1, 3)); + Transport = new DrawingCruiser(Obj); + break; + default: + return; + } + + if (_Company + Transport > 0) + { + MessageBox.Show("> Object was added"); + pictureBox1.Image = _Company.Show(); + } + + else { MessageBox.Show("[!] Failed to add object"); } + } + + private void AddButton_Click(object sender, EventArgs e) => CreateObject(nameof(DrawingBase)); + + private void Add2Button_Click(object sender, EventArgs e) => CreateObject(nameof(DrawingCruiser)); + + private void RemoveButton_Click(object sender, EventArgs e) + { + if (_Company == null) + { + return; + } + + if (string.IsNullOrEmpty(maskedTextBox1?.Text) || _Company == null) { return; } + if (MessageBox.Show("[*] Remove object: Are you sure?", "Remove", + MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes) + { + return; + } + if (_Company - Convert.ToInt32(maskedTextBox1.Text) != null) + { + MessageBox.Show("> Object was removed"); + pictureBox1.Image = _Company.Show(); + } + else { MessageBox.Show("[!] No object to be removed"); } + } + + private void RandomGenerator_Click(object sender, EventArgs e) + { + if (_Company == null) + { + return; + } + + int counter = 100; + DrawingBase? drBase = null; + + while (drBase == null) + { + drBase = _Company.GetRandomObj(); + + counter--; + + if (counter <= 0) + { + break; + } + } + + if (drBase == null) + { + return; + } + + DrawingCanvas Form = new DrawingCanvas(); + + /* + DrawingCanvas Form = new() { SetTransport = drBase }; + */ + + Form.SetTransport = drBase; + Form.ShowDialog(); + // ---------------------------------------------------------- + } + + private void Check_Click(object sender, EventArgs e) + { + if (_Company == null) + { + return; + } + pictureBox1.Image = _Company.Show(); + } + } +} diff --git a/WinF_Lab1_Cruiser/CruiserMech/DrawingCanvas.resx b/WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/CollectionForm.resx similarity index 100% rename from WinF_Lab1_Cruiser/CruiserMech/DrawingCanvas.resx rename to WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/CollectionForm.resx diff --git a/WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/CollectionGenericObjects/AbstractCompany.cs b/WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/CollectionGenericObjects/AbstractCompany.cs new file mode 100644 index 0000000..84f3197 --- /dev/null +++ b/WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/CollectionGenericObjects/AbstractCompany.cs @@ -0,0 +1,65 @@ +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using WinF_Lab2_Cruiser.Drawing_tools; + +namespace WinF_Lab2_Cruiser.CollectionGenericObjects +{ + public abstract class AbstractCompany + { + protected readonly int _placeSizeWidth = 302; + protected readonly int _placeSizeHeight = 46; + + protected readonly int _picW, _picH; + + protected ICGO? _Array = null; + + // max num of vehicles + private int GetMaxCount => _picW * _picH / (_placeSizeWidth * _placeSizeHeight); + + public AbstractCompany(int SizeWidth, int SizeHeight, ICGO? array) + { + _picW = SizeWidth; + _picH = SizeHeight; + _Array = array; + _Array.SetMaxCount = GetMaxCount; + } + + // insted of bool: + public static int operator +(AbstractCompany cmp, + DrawingBase trasport) => (cmp._Array.Insert(trasport)); + + public static DrawingBase operator -(AbstractCompany cmp, + int pos) => (cmp._Array.Remove(pos)); + + public DrawingBase? GetRandomObj() + { + Random r = new(); + return _Array?.GetItem(r.Next(GetMaxCount)); + } + + public Bitmap? Show() + { + Bitmap bitmap = new(_picW, _picH); + Graphics Gr = Graphics.FromImage(bitmap); + + DrawBackgound(Gr); + + SetObjectsPosition(); + + for (int i = 0; i < (_Array?.Count ?? 0); ++i) + { + DrawingBase? obj = _Array?.GetItem(i); + obj?.DrawTransport(Gr); + } + return bitmap; + } + + protected abstract void DrawBackgound(Graphics g); + protected abstract void SetObjectsPosition(); + + } +} diff --git a/WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/CollectionGenericObjects/ArrayAlg.cs b/WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/CollectionGenericObjects/ArrayAlg.cs new file mode 100644 index 0000000..4d93e81 --- /dev/null +++ b/WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/CollectionGenericObjects/ArrayAlg.cs @@ -0,0 +1,101 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace WinF_Lab2_Cruiser.CollectionGenericObjects +{ + public class ArrayAlg : ICGO + where K : class + { + private K?[] _Array; + + public ArrayAlg() + { + _Array = Array.Empty(); + } + + public int Count => _Array.Length; + + public int SetMaxCount { set { if (value > 0) { _Array = new K?[value]; } } } + + public K? GetItem(int index) + { + if (index > Count || index < 0) + { + return null; + } + return _Array[index]; + } + + public int Insert(K item) + { + // any empty place + for (int i = 0; i < Count; i++) + { + if (_Array[i] == null) + { + _Array[i] = item; + return i; + } + } + return -1; + } + + public int Insert(int index, K item) + { + if (_Array[index] == null) + { + _Array[index] = item; + return index; + } + + else + { + int min_diff = 100, min_index = 100; + + for (int i = 0; i < Count; i++) + { + if (_Array[i] == null && min_diff > Math.Abs(index - i)) + { + min_diff = Math.Abs(index - i); + min_index = i; + } + } + + _Array[min_index] = item; + return min_index; + } + + return -1; + } + + public K Remove(int index) + { + K item; + if (index < Count && index >= 0) + { + item = _Array[index]; + _Array[index] = null; + return item; + } + return null; + } + + /* + public bool Remove(int index) + { + K item; + if (index < Count) + { + item = _Array[index]; + _Array[index] = null; + return true; + } + return false; + } + */ + } +} diff --git a/WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/CollectionGenericObjects/ICGO.cs b/WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/CollectionGenericObjects/ICGO.cs new file mode 100644 index 0000000..a2b7902 --- /dev/null +++ b/WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/CollectionGenericObjects/ICGO.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace WinF_Lab2_Cruiser.CollectionGenericObjects +{ + public interface ICGO // U> + where K : class // ссылочный тип + // where U : struct // 2nd dop task + { + int Count { get; } + int SetMaxCount { set; } + + int Insert(K item); + int Insert(int index, K item); + + K? Remove(int index); + //bool Remove(int index); + K? GetItem(int index); + } +} diff --git a/WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/CollectionGenericObjects/NewClassCollection.cs b/WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/CollectionGenericObjects/NewClassCollection.cs new file mode 100644 index 0000000..863b1c6 --- /dev/null +++ b/WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/CollectionGenericObjects/NewClassCollection.cs @@ -0,0 +1,68 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using WinF_Lab2_Cruiser.Drawing_tools; + +namespace WinF_Lab2_Cruiser.CollectionGenericObjects +{ + internal class NewClassCollection : AbstractCompany // service + { + private int startCoordX = 10, startCoordY = 10, between = 30; + + public int maxWkolvo { get; private set; } + public int maxHkolvo { get; private set; } + + public NewClassCollection(int SizeWidth, int SizeHeight, ICGO? array) : base(SizeWidth, SizeHeight, array) + { + maxWkolvo = _picW / (_placeSizeWidth + between); + maxHkolvo = _picH / _placeSizeHeight; + } + + protected override void DrawBackgound(Graphics g) + { + Pen pen = new(Color.Black, 2); + + int currentH = 10, currentW = 10; + + for (int i = 0; i < maxWkolvo; i++) + { + currentH = 10; + for (int j = 0; j < maxHkolvo; j++) + { + g.DrawLine(pen, currentW + 302, currentH - 1, currentW - 1, currentH - 1); + g.DrawLine(pen, currentW - 1, currentH - 1, currentW - 1, currentH + 50); + + currentH += _placeSizeHeight + 1; // + between; + } + currentW += _placeSizeWidth + between; + } + } + + protected override void SetObjectsPosition() + { + int index_collection = 0; + int newX = startCoordX, newY = startCoordY; + + if (_Array != null) + { + for(int i = 0; i < maxHkolvo; ++i) + { + newX = startCoordX; + for (int j = 0; j < maxWkolvo; ++j) + { + if (_Array.GetItem(index_collection) != null) + { + _Array.GetItem(index_collection).SetPicSize(_picW, _picH); + _Array.GetItem(index_collection).SetPos(newX, newY); + newX += _placeSizeWidth + between; + index_collection++; + } + } + newY += _placeSizeHeight + 2; + } + } + } + } +} diff --git a/WinF_Lab1_Cruiser/CruiserMech/DrawingCanvas.Designer.cs b/WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/DrawingCanvas.Designer.cs similarity index 79% rename from WinF_Lab1_Cruiser/CruiserMech/DrawingCanvas.Designer.cs rename to WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/DrawingCanvas.Designer.cs index 8698918..471e3b8 100644 --- a/WinF_Lab1_Cruiser/CruiserMech/DrawingCanvas.Designer.cs +++ b/WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/DrawingCanvas.Designer.cs @@ -1,9 +1,5 @@ -using System.Drawing.Printing; -using System.Windows.Forms; -using static System.Net.Mime.MediaTypeNames; -using System.Xml.Linq; - -namespace CruiserMech + +namespace WinF_Lab2_Cruiser { partial class DrawingCanvas { @@ -34,8 +30,6 @@ namespace CruiserMech private void InitializeComponent() { pictureBox1 = new PictureBox(); - CreateButton = new Button(); - CreateButton2 = new Button(); buttonUp = new Button(); buttonLeft = new Button(); buttonDown = new Button(); @@ -56,29 +50,6 @@ namespace CruiserMech pictureBox1.TabIndex = 0; pictureBox1.TabStop = false; // - // CreateButton - // - CreateButton.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; - CreateButton.Location = new Point(22, 465); - CreateButton.Margin = new Padding(6); - CreateButton.Name = "CreateButton"; - CreateButton.Size = new Size(139, 113); - CreateButton.TabIndex = 1; - CreateButton.Text = "Create object"; - CreateButton.UseVisualStyleBackColor = true; - CreateButton.Click += buttonCr_Click; - // - // CreateButton2 - // - CreateButton2.Location = new Point(22, 26); - CreateButton2.Margin = new Padding(6); - CreateButton2.Name = "CreateButton2"; - CreateButton2.Size = new Size(139, 113); - CreateButton2.TabIndex = 2; - CreateButton2.Text = "Cr Updated Object"; - CreateButton2.UseVisualStyleBackColor = true; - CreateButton2.Click += buttonCr2_Click; - // // buttonUp // buttonUp.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; @@ -131,9 +102,6 @@ namespace CruiserMech buttonRight.UseVisualStyleBackColor = true; buttonRight.Click += ButtonMove_Click; // - // ListComboBox - // - // // ButtonActivate // ButtonActivate.Anchor = AnchorStyles.Right; @@ -145,18 +113,18 @@ namespace CruiserMech ButtonActivate.UseVisualStyleBackColor = true; ButtonActivate.Click += comboBox_Activate; // - // comboBox1 + // comboBox // comboBox.FormattingEnabled = true; comboBox.Items.AddRange(new object[] { "Center", "Boarder" }); - comboBox.Location = new Point(188, 26); - comboBox.Name = "Directions"; + comboBox.Location = new Point(22, 27); + comboBox.Name = "comboBox"; comboBox.Size = new Size(203, 40); comboBox.TabIndex = 9; // // Activate // - Activate.Location = new Point(188, 93); + Activate.Location = new Point(22, 84); Activate.Name = "Activate"; Activate.Size = new Size(203, 46); Activate.TabIndex = 10; @@ -177,8 +145,6 @@ namespace CruiserMech Controls.Add(buttonDown); Controls.Add(buttonLeft); Controls.Add(buttonUp); - Controls.Add(CreateButton); - Controls.Add(CreateButton2); Controls.Add(pictureBox1); Controls.Add(ButtonActivate); Margin = new Padding(4, 2, 4, 2); @@ -190,8 +156,8 @@ namespace CruiserMech } #endregion private PictureBox pictureBox1; - private Button CreateButton; - private Button CreateButton2; + //private Button CreateButton; + //private Button CreateButton2; private Button buttonUp; private Button buttonLeft; private Button buttonDown; @@ -200,4 +166,4 @@ namespace CruiserMech private ComboBox comboBox; private Button Activate; } -} \ No newline at end of file +} diff --git a/WinF_Lab1_Cruiser/CruiserMech/DrawingCanvas.cs b/WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/DrawingCanvas.cs similarity index 85% rename from WinF_Lab1_Cruiser/CruiserMech/DrawingCanvas.cs rename to WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/DrawingCanvas.cs index 980dd8e..a76cfe9 100644 --- a/WinF_Lab1_Cruiser/CruiserMech/DrawingCanvas.cs +++ b/WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/DrawingCanvas.cs @@ -1,23 +1,32 @@ -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using WinF_Lab2_Cruiser.Drawing_tools; +using WinF_Lab2_Cruiser.Entity_Folder; +using WinF_Lab2_Cruiser.Move_Strategy; using System.Windows.Forms; -using CruiserMech.Drawing_tools; -using CruiserMech.Entity_Folder; -using CruiserMech.Move_Strategy; -namespace CruiserMech + +namespace WinF_Lab2_Cruiser { public partial class DrawingCanvas : Form { private DrawingBase? _DrCruiser; - private AbstractStrategy _strategy; + private AbstractStrategy? _strategy; + + public DrawingBase SetTransport + { + set + { + _DrCruiser = value; + _DrCruiser.SetPicSize(pictureBox1.Width, pictureBox1.Height); + comboBox.Enabled = true; + _strategy = null; + Draw(); + } + } + public DrawingCanvas() { InitializeComponent(); _strategy = null; + // DrawBackgound(Gr); } //private DrawingCanvas_Load(object sender, EventArgs e); private void Draw() @@ -29,8 +38,10 @@ namespace CruiserMech Bitmap bmp = new(pictureBox1.Width, pictureBox1.Height); Graphics gr = Graphics.FromImage(bmp); _DrCruiser.DrawTransport(gr); pictureBox1.Image = bmp; + // DrawBackgound(gr); } + /* private void CreateObj(string type) { Random rn = new Random(); @@ -54,6 +65,12 @@ namespace CruiserMech Draw(); } + + + private void buttonCr2_Click(object sender, EventArgs e) => CreateObj(nameof(DrawingCruiser)); + private void buttonCr_Click(object sender, EventArgs e) => CreateObj(nameof(DrawingBase)); + */ + private void comboBox_Activate(object sender, EventArgs e) { if (_DrCruiser == null) return; @@ -83,8 +100,6 @@ namespace CruiserMech } } - private void buttonCr2_Click(object sender, EventArgs e) => CreateObj(nameof(DrawingCruiser)); - private void buttonCr_Click(object sender, EventArgs e) => CreateObj(nameof(DrawingBase)); private void ButtonMove_Click(object sender, EventArgs e) { if (_DrCruiser == null) @@ -92,8 +107,7 @@ namespace CruiserMech return; } string name = ((Button)sender)?.Name ?? string.Empty; - bool result = false; - switch (name) + bool result = false; switch (name) { case "buttonUp": result = _DrCruiser.MoveTransport(DirectionType.Up); diff --git a/WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/DrawingCanvas.resx b/WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/DrawingCanvas.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/DrawingCanvas.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/WinF_Lab1_Cruiser/CruiserMech/Drawing_tools/DirectionType.cs b/WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/Drawing_tools/DirectionType.cs similarity index 86% rename from WinF_Lab1_Cruiser/CruiserMech/Drawing_tools/DirectionType.cs rename to WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/Drawing_tools/DirectionType.cs index 76e3569..6964f2e 100644 --- a/WinF_Lab1_Cruiser/CruiserMech/Drawing_tools/DirectionType.cs +++ b/WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/Drawing_tools/DirectionType.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace CruiserMech.Drawing_tools +namespace WinF_Lab2_Cruiser.Drawing_tools { public enum DirectionType { diff --git a/WinF_Lab1_Cruiser/CruiserMech/Drawing_tools/DrawingBase.cs b/WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/Drawing_tools/DrawingBase.cs similarity index 98% rename from WinF_Lab1_Cruiser/CruiserMech/Drawing_tools/DrawingBase.cs rename to WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/Drawing_tools/DrawingBase.cs index 1d7fc57..6064041 100644 --- a/WinF_Lab1_Cruiser/CruiserMech/Drawing_tools/DrawingBase.cs +++ b/WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/Drawing_tools/DrawingBase.cs @@ -4,9 +4,9 @@ using System.Drawing.Drawing2D; using System.Linq; using System.Text; using System.Threading.Tasks; -using CruiserMech.Entity_Folder; +using WinF_Lab2_Cruiser.Entity_Folder; -namespace CruiserMech.Drawing_tools +namespace WinF_Lab2_Cruiser.Drawing_tools { public class DrawingBase { diff --git a/WinF_Lab1_Cruiser/CruiserMech/Drawing_tools/DrawingCruiser.cs b/WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/Drawing_tools/DrawingCruiser.cs similarity index 96% rename from WinF_Lab1_Cruiser/CruiserMech/Drawing_tools/DrawingCruiser.cs rename to WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/Drawing_tools/DrawingCruiser.cs index 3065d1f..b960c36 100644 --- a/WinF_Lab1_Cruiser/CruiserMech/Drawing_tools/DrawingCruiser.cs +++ b/WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/Drawing_tools/DrawingCruiser.cs @@ -4,9 +4,9 @@ using System.Drawing.Drawing2D; using System.Linq; using System.Text; using System.Threading.Tasks; -using CruiserMech.Entity_Folder; +using WinF_Lab2_Cruiser.Entity_Folder; -namespace CruiserMech.Drawing_tools +namespace WinF_Lab2_Cruiser.Drawing_tools { internal class DrawingCruiser : DrawingBase { diff --git a/WinF_Lab1_Cruiser/CruiserMech/Entity_Folder/Base_Class_Cruiser.cs b/WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/Entity_Folder/Base_Class_Cruiser.cs similarity index 93% rename from WinF_Lab1_Cruiser/CruiserMech/Entity_Folder/Base_Class_Cruiser.cs rename to WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/Entity_Folder/Base_Class_Cruiser.cs index adef8b5..8b1a31b 100644 --- a/WinF_Lab1_Cruiser/CruiserMech/Entity_Folder/Base_Class_Cruiser.cs +++ b/WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/Entity_Folder/Base_Class_Cruiser.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace CruiserMech.Entity_Folder +namespace WinF_Lab2_Cruiser.Entity_Folder { public class Base_Class_Cruiser { diff --git a/WinF_Lab1_Cruiser/CruiserMech/Entity_Folder/Class_CruiserEntity.cs b/WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/Entity_Folder/Class_CruiserEntity.cs similarity index 96% rename from WinF_Lab1_Cruiser/CruiserMech/Entity_Folder/Class_CruiserEntity.cs rename to WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/Entity_Folder/Class_CruiserEntity.cs index 5fd0a2d..d9213fd 100644 --- a/WinF_Lab1_Cruiser/CruiserMech/Entity_Folder/Class_CruiserEntity.cs +++ b/WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/Entity_Folder/Class_CruiserEntity.cs @@ -5,7 +5,7 @@ using System.Text; using System.Threading.Tasks; -namespace CruiserMech.Entity_Folder +namespace WinF_Lab2_Cruiser.Entity_Folder { internal class Class_CruiserEntity : Base_Class_Cruiser { diff --git a/WinF_Lab1_Cruiser/CruiserMech/Move_Strategy/AbstractStrategy.cs b/WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/Move_Strategy/AbstractStrategy.cs similarity index 94% rename from WinF_Lab1_Cruiser/CruiserMech/Move_Strategy/AbstractStrategy.cs rename to WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/Move_Strategy/AbstractStrategy.cs index 55e4d4b..9f61360 100644 --- a/WinF_Lab1_Cruiser/CruiserMech/Move_Strategy/AbstractStrategy.cs +++ b/WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/Move_Strategy/AbstractStrategy.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace CruiserMech.Move_Strategy +namespace WinF_Lab2_Cruiser.Move_Strategy { public abstract class AbstractStrategy { @@ -64,6 +64,8 @@ namespace CruiserMech.Move_Strategy return _movableObj?.GetStep; } + // protected virtual void AdditionalMethod() { } + protected virtual void MoveToTarget() { ObjectParam? objParams = GetObjParam; @@ -93,7 +95,7 @@ namespace CruiserMech.Move_Strategy if (objParams == null) { return false; } return objParams.MiddleHorizontal - GetStep() <= FieldWidth / 2 && - objParams.MiddleHorizontal + GetStep() >= FieldWidth / 2 && + objParams.MiddleHorizontal + GetStep() + 1 >= FieldWidth / 2 && objParams.MiddleVertical - GetStep() <= FieldHeight / 2 && objParams.MiddleVertical + GetStep() >= FieldHeight / 2; } diff --git a/WinF_Lab1_Cruiser/CruiserMech/Move_Strategy/Boarder.cs b/WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/Move_Strategy/Boarder.cs similarity index 80% rename from WinF_Lab1_Cruiser/CruiserMech/Move_Strategy/Boarder.cs rename to WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/Move_Strategy/Boarder.cs index 7ffaa47..b289c8e 100644 --- a/WinF_Lab1_Cruiser/CruiserMech/Move_Strategy/Boarder.cs +++ b/WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/Move_Strategy/Boarder.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace CruiserMech.Move_Strategy; +namespace WinF_Lab2_Cruiser.Move_Strategy; public class Boarder : AbstractStrategy { @@ -16,8 +16,8 @@ public class Boarder : AbstractStrategy return false; } - return FieldWidth - GetStep() < objP.SecondCoordX - && FieldHeight - GetStep() < objP.SecondCoordY; + return FieldWidth < objP.SecondCoordX + && FieldHeight < objP.SecondCoordY; } protected override void MoveToTarget() @@ -31,7 +31,7 @@ public class Boarder : AbstractStrategy int s = (int)GetStep(); int diffx = objP.SecondCoordX - (FieldWidth - s); - if (Math.Abs(diffx) > GetStep()) + if (Math.Abs(diffx) >= GetStep()) { if (diffx > 0) { @@ -43,7 +43,7 @@ public class Boarder : AbstractStrategy } int diffy = objP.SecondCoordY - (FieldHeight - s); - if (Math.Abs(diffy) > GetStep()) + if (Math.Abs(diffy) >= GetStep()) { if (diffy > 0) { diff --git a/WinF_Lab1_Cruiser/CruiserMech/Move_Strategy/Center.cs b/WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/Move_Strategy/Center.cs similarity index 96% rename from WinF_Lab1_Cruiser/CruiserMech/Move_Strategy/Center.cs rename to WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/Move_Strategy/Center.cs index a8dfb5a..9a4776b 100644 --- a/WinF_Lab1_Cruiser/CruiserMech/Move_Strategy/Center.cs +++ b/WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/Move_Strategy/Center.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace CruiserMech.Move_Strategy; +namespace WinF_Lab2_Cruiser.Move_Strategy; public class Center : AbstractStrategy { diff --git a/WinF_Lab1_Cruiser/CruiserMech/Move_Strategy/IMO.cs b/WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/Move_Strategy/IMO.cs similarity index 78% rename from WinF_Lab1_Cruiser/CruiserMech/Move_Strategy/IMO.cs rename to WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/Move_Strategy/IMO.cs index c76a11f..a44f256 100644 --- a/WinF_Lab1_Cruiser/CruiserMech/Move_Strategy/IMO.cs +++ b/WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/Move_Strategy/IMO.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace CruiserMech.Move_Strategy +namespace WinF_Lab2_Cruiser.Move_Strategy { public interface IMO { @@ -14,6 +14,8 @@ namespace CruiserMech.Move_Strategy int GetStep { get; } + int AdditionalMethod { set; } + bool TryMoveObj(Moves direction); } } diff --git a/WinF_Lab1_Cruiser/CruiserMech/Move_Strategy/MovableCruiser.cs b/WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/Move_Strategy/MovableCruiser.cs similarity index 89% rename from WinF_Lab1_Cruiser/CruiserMech/Move_Strategy/MovableCruiser.cs rename to WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/Move_Strategy/MovableCruiser.cs index fbb2f60..543f0ee 100644 --- a/WinF_Lab1_Cruiser/CruiserMech/Move_Strategy/MovableCruiser.cs +++ b/WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/Move_Strategy/MovableCruiser.cs @@ -3,9 +3,9 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -using CruiserMech.Drawing_tools; +using WinF_Lab2_Cruiser.Drawing_tools; -namespace CruiserMech.Move_Strategy +namespace WinF_Lab2_Cruiser.Move_Strategy { public class MovableCruiser : IMO { @@ -31,6 +31,8 @@ namespace CruiserMech.Move_Strategy public int GetStep => (int)(_DrBase?.BaseEntity?.Step ?? 0); + public int AdditionalMethod { set => throw new NotImplementedException(); } + public bool TryMoveObj(Moves direction) { if (_DrBase == null || _DrBase.BaseEntity == null) diff --git a/WinF_Lab1_Cruiser/CruiserMech/Move_Strategy/Moves.cs b/WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/Move_Strategy/Moves.cs similarity index 85% rename from WinF_Lab1_Cruiser/CruiserMech/Move_Strategy/Moves.cs rename to WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/Move_Strategy/Moves.cs index 4ac4dac..1ef88bd 100644 --- a/WinF_Lab1_Cruiser/CruiserMech/Move_Strategy/Moves.cs +++ b/WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/Move_Strategy/Moves.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace CruiserMech.Move_Strategy +namespace WinF_Lab2_Cruiser.Move_Strategy { public enum Moves { diff --git a/WinF_Lab1_Cruiser/CruiserMech/Move_Strategy/ObjectParam.cs b/WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/Move_Strategy/ObjectParam.cs similarity index 95% rename from WinF_Lab1_Cruiser/CruiserMech/Move_Strategy/ObjectParam.cs rename to WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/Move_Strategy/ObjectParam.cs index 3dfb21d..b301820 100644 --- a/WinF_Lab1_Cruiser/CruiserMech/Move_Strategy/ObjectParam.cs +++ b/WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/Move_Strategy/ObjectParam.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace CruiserMech.Move_Strategy +namespace WinF_Lab2_Cruiser.Move_Strategy { public class ObjectParam { diff --git a/WinF_Lab1_Cruiser/CruiserMech/Move_Strategy/Status.cs b/WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/Move_Strategy/Status.cs similarity index 83% rename from WinF_Lab1_Cruiser/CruiserMech/Move_Strategy/Status.cs rename to WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/Move_Strategy/Status.cs index f7b8452..bf9bd57 100644 --- a/WinF_Lab1_Cruiser/CruiserMech/Move_Strategy/Status.cs +++ b/WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/Move_Strategy/Status.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace CruiserMech.Move_Strategy +namespace WinF_Lab2_Cruiser.Move_Strategy { public enum Status { diff --git a/WinF_Lab1_Cruiser/CruiserMech/Program.cs b/WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/Program.cs similarity index 76% rename from WinF_Lab1_Cruiser/CruiserMech/Program.cs rename to WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/Program.cs index d6e5fc1..ed2216d 100644 --- a/WinF_Lab1_Cruiser/CruiserMech/Program.cs +++ b/WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/Program.cs @@ -1,4 +1,4 @@ -namespace CruiserMech +namespace WinF_Lab2_Cruiser { internal static class Program { @@ -11,7 +11,8 @@ namespace CruiserMech // To customize application configuration such as set high DPI settings or default font, // see https://aka.ms/applicationconfiguration. ApplicationConfiguration.Initialize(); - Application.Run(new DrawingCanvas()); + // Application.Run(new DrawingCanvas()); + Application.Run(new CollectionForm()); } } } \ No newline at end of file diff --git a/WinF_Lab1_Cruiser/CruiserMech/Properties/Resources.Designer.cs b/WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/Properties/Resources.Designer.cs similarity index 89% rename from WinF_Lab1_Cruiser/CruiserMech/Properties/Resources.Designer.cs rename to WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/Properties/Resources.Designer.cs index 4cc8276..1a56f62 100644 --- a/WinF_Lab1_Cruiser/CruiserMech/Properties/Resources.Designer.cs +++ b/WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/Properties/Resources.Designer.cs @@ -8,7 +8,7 @@ // //------------------------------------------------------------------------------ -namespace CruiserMech.Properties { +namespace WinF_Lab2_Cruiser.Properties { using System; @@ -39,7 +39,7 @@ namespace CruiserMech.Properties { internal static global::System.Resources.ResourceManager ResourceManager { get { if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("CruiserMech.Properties.Resources", typeof(Resources).Assembly); + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("WinF_Lab2_Cruiser.Properties.Resources", typeof(Resources).Assembly); resourceMan = temp; } return resourceMan; @@ -90,16 +90,6 @@ namespace CruiserMech.Properties { } } - /// - /// Поиск локализованного ресурса типа System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap up_arrow { - get { - object obj = ResourceManager.GetObject("up_arrow", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - /// /// Поиск локализованного ресурса типа System.Drawing.Bitmap. /// diff --git a/WinF_Lab1_Cruiser/CruiserMech/Properties/Resources.resx b/WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/Properties/Resources.resx similarity index 96% rename from WinF_Lab1_Cruiser/CruiserMech/Properties/Resources.resx rename to WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/Properties/Resources.resx index a281732..71e335c 100644 --- a/WinF_Lab1_Cruiser/CruiserMech/Properties/Resources.resx +++ b/WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/Properties/Resources.resx @@ -121,9 +121,6 @@ ..\Resources\right_arrow_res.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\up_arrow.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - ..\Resources\up_arrow_res.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a diff --git a/WinF_Lab1_Cruiser/CruiserMech/Resources/down_arrow_res.png b/WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/Resources/down_arrow_res.png similarity index 100% rename from WinF_Lab1_Cruiser/CruiserMech/Resources/down_arrow_res.png rename to WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/Resources/down_arrow_res.png diff --git a/WinF_Lab1_Cruiser/CruiserMech/Resources/left_arrow_res.png b/WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/Resources/left_arrow_res.png similarity index 100% rename from WinF_Lab1_Cruiser/CruiserMech/Resources/left_arrow_res.png rename to WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/Resources/left_arrow_res.png diff --git a/WinF_Lab1_Cruiser/CruiserMech/Resources/right_arrow_res.png b/WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/Resources/right_arrow_res.png similarity index 100% rename from WinF_Lab1_Cruiser/CruiserMech/Resources/right_arrow_res.png rename to WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/Resources/right_arrow_res.png diff --git a/WinF_Lab1_Cruiser/CruiserMech/Resources/up_arrow_res.png b/WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/Resources/up_arrow_res.png similarity index 100% rename from WinF_Lab1_Cruiser/CruiserMech/Resources/up_arrow_res.png rename to WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/Resources/up_arrow_res.png diff --git a/WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/WinF_Lab2_Cruiser.csproj b/WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/WinF_Lab2_Cruiser.csproj new file mode 100644 index 0000000..663fdb8 --- /dev/null +++ b/WinF_Lab2_Cruiser/WinF_Lab2_Cruiser/WinF_Lab2_Cruiser.csproj @@ -0,0 +1,11 @@ + + + + WinExe + net8.0-windows + enable + true + enable + + + \ No newline at end of file -- 2.25.1