From 02559b8c724065effd6277db15d7171589d2e7d3 Mon Sep 17 00:00:00 2001 From: "nikbel2004@outlook.com" Date: Mon, 13 Nov 2023 02:24:41 +0400 Subject: [PATCH 1/7] =?UTF-8?q?=D0=9B=D0=B0=D0=B1=D0=BE=D1=80=D0=B0=D1=82?= =?UTF-8?q?=D0=BE=D1=80=D0=BD=D0=B0=D1=8F=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82?= =?UTF-8?q?=D0=B0=205?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Tank/Tank.sln | 12 +- ...signer.cs => CollectionsFrame.Designer.cs} | 2 +- ...anksCollections.cs => CollectionsFrame.cs} | 42 +- ...Collections.resx => CollectionsFrame.resx} | 0 Tank/Tank/DrawArmoVehicle.cs | 6 +- Tank/Tank/DrawTank.cs | 2 +- Tank/Tank/EntityArmoVehicle.cs | 5 +- Tank/Tank/EntityTank.cs | 1 + Tank/Tank/FormTank.Designer.cs | 1 + Tank/Tank/FormTank.cs | 5 + Tank/Tank/FormTankConfig.Designer.cs | 405 ++++++++++++++++++ Tank/Tank/FormTankConfig.cs | 148 +++++++ Tank/Tank/FormTankConfig.resx | 120 ++++++ Tank/Tank/Program.cs | 2 +- Tank/Tank/SetGeneric.cs | 24 +- Tank/Tank/TanksGenericCollection.cs | 9 +- Tank/Tank/TanksGenericStorage.cs | 11 +- 17 files changed, 739 insertions(+), 56 deletions(-) rename Tank/Tank/{FormTanksCollections.Designer.cs => CollectionsFrame.Designer.cs} (99%) rename Tank/Tank/{FormTanksCollections.cs => CollectionsFrame.cs} (82%) rename Tank/Tank/{FormTanksCollections.resx => CollectionsFrame.resx} (100%) create mode 100644 Tank/Tank/FormTankConfig.Designer.cs create mode 100644 Tank/Tank/FormTankConfig.cs create mode 100644 Tank/Tank/FormTankConfig.resx diff --git a/Tank/Tank.sln b/Tank/Tank.sln index 736023a..9f7a1ff 100644 --- a/Tank/Tank.sln +++ b/Tank/Tank.sln @@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.7.34031.279 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tank", "Tank\Tank.csproj", "{5C602C58-ECEC-4FAB-BA10-FB671582D227}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tank", "Tank\Tank.csproj", "{4C238BAE-E8EA-4DEF-ABB8-DA9CC49797C0}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -11,15 +11,15 @@ Global Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {5C602C58-ECEC-4FAB-BA10-FB671582D227}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {5C602C58-ECEC-4FAB-BA10-FB671582D227}.Debug|Any CPU.Build.0 = Debug|Any CPU - {5C602C58-ECEC-4FAB-BA10-FB671582D227}.Release|Any CPU.ActiveCfg = Release|Any CPU - {5C602C58-ECEC-4FAB-BA10-FB671582D227}.Release|Any CPU.Build.0 = Release|Any CPU + {4C238BAE-E8EA-4DEF-ABB8-DA9CC49797C0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4C238BAE-E8EA-4DEF-ABB8-DA9CC49797C0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4C238BAE-E8EA-4DEF-ABB8-DA9CC49797C0}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4C238BAE-E8EA-4DEF-ABB8-DA9CC49797C0}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {73BF3262-E499-401F-BDBD-BD2BC7D3C324} + SolutionGuid = {73628EAF-BF42-4CF6-87BF-26523028F0DD} EndGlobalSection EndGlobal diff --git a/Tank/Tank/FormTanksCollections.Designer.cs b/Tank/Tank/CollectionsFrame.Designer.cs similarity index 99% rename from Tank/Tank/FormTanksCollections.Designer.cs rename to Tank/Tank/CollectionsFrame.Designer.cs index 3b605e4..b8cf9d3 100644 --- a/Tank/Tank/FormTanksCollections.Designer.cs +++ b/Tank/Tank/CollectionsFrame.Designer.cs @@ -1,6 +1,6 @@ namespace Tank { - partial class FormTanksCollections + partial class CollectionsFrame { /// /// Required designer variable. diff --git a/Tank/Tank/FormTanksCollections.cs b/Tank/Tank/CollectionsFrame.cs similarity index 82% rename from Tank/Tank/FormTanksCollections.cs rename to Tank/Tank/CollectionsFrame.cs index e310e23..0979e6f 100644 --- a/Tank/Tank/FormTanksCollections.cs +++ b/Tank/Tank/CollectionsFrame.cs @@ -13,12 +13,12 @@ using System.Windows.Forms; namespace Tank { - public partial class FormTanksCollections : Form + public partial class CollectionsFrame : Form { private readonly TanksGenericStorage _storage; // Конструктор - public FormTanksCollections() + public CollectionsFrame() { InitializeComponent(); _storage = new TanksGenericStorage(DrawTank.Width, DrawTank.Height); @@ -77,7 +77,7 @@ namespace Tank } } - private void ButtonAddTank_Click(object sender, EventArgs e) + private void AddTank(DrawArmoVehicle tank) { if (CollectionListBox.SelectedIndex == -1) { @@ -88,20 +88,34 @@ namespace Tank { return; } - FormTank form = new(); - if (form.ShowDialog() == DialogResult.OK) + if ((obj + tank) != false) { - if (obj + form.SelectedTank) - { - MessageBox.Show("Объект добавлен"); - DrawTank.Image = obj.ShowTanks(); - } - else - { - MessageBox.Show("Не удалось добавить объект"); - } + MessageBox.Show("Объект добавлен"); + DrawTank.Image = obj.ShowTanks(); + } + else + { + MessageBox.Show("Не удалось добавить объект"); } } + + private void ButtonAddTank_Click(object sender, EventArgs e) + { + // Проверка на вызов формочки + if (CollectionListBox.SelectedIndex == -1) + { + return; + } + var obj = _storage[CollectionListBox.SelectedItem.ToString() ?? string.Empty]; + if (obj == null) + { + return; + } + FormTankConfig form = new FormTankConfig(); + form.Show(); + form.AddEvent(AddTank); + } + private void ButtonRemoveTank_Click(object sender, EventArgs e) { if (CollectionListBox.SelectedIndex == -1) diff --git a/Tank/Tank/FormTanksCollections.resx b/Tank/Tank/CollectionsFrame.resx similarity index 100% rename from Tank/Tank/FormTanksCollections.resx rename to Tank/Tank/CollectionsFrame.resx diff --git a/Tank/Tank/DrawArmoVehicle.cs b/Tank/Tank/DrawArmoVehicle.cs index cfdf93e..fa84dd5 100644 --- a/Tank/Tank/DrawArmoVehicle.cs +++ b/Tank/Tank/DrawArmoVehicle.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Security.Cryptography.Pkcs; using System.Text; using System.Threading.Tasks; +using System.Drawing; using Tank.Entities; using Tank.MovementStrategy; @@ -12,8 +13,8 @@ namespace Tank public class DrawArmoVehicle { public EntityArmoVehicle? Tank { get; protected set; } - protected int _pictureWidth; - protected int _pictureHeight; + public int _pictureWidth; + public int _pictureHeight; protected int _startPosX; protected int _startPosY; protected readonly int _Width = 160; @@ -55,6 +56,7 @@ namespace Tank Direction.Right => _startPosX + _Width + Tank.Step < _pictureWidth, Direction.Down => _startPosY + _Height + Tank.Step < _pictureHeight, _ => false + }; } diff --git a/Tank/Tank/DrawTank.cs b/Tank/Tank/DrawTank.cs index e270a72..d8b5247 100644 --- a/Tank/Tank/DrawTank.cs +++ b/Tank/Tank/DrawTank.cs @@ -38,7 +38,7 @@ namespace Tank.DrawningObjects if (ArmoVehicle.Caterpillar) { // Гусеница. Отрисовка танковых катков - Brush BrushRandom = new SolidBrush(Tank?.BodyColor ?? Color.Black); + Brush BrushRandom = new SolidBrush(ArmoVehicle?.AdditionalColor ?? Color.Black); g.FillRectangle(BrushRandom, 28 + _startPosX, 50 + _startPosY, 10, 3); g.FillRectangle(BrushRandom, 53 + _startPosX, 50 + _startPosY, 10, 3); g.FillRectangle(BrushRandom, 78 + _startPosX, 50 + _startPosY, 10, 3); diff --git a/Tank/Tank/EntityArmoVehicle.cs b/Tank/Tank/EntityArmoVehicle.cs index 8263ed4..13b7bd2 100644 --- a/Tank/Tank/EntityArmoVehicle.cs +++ b/Tank/Tank/EntityArmoVehicle.cs @@ -4,13 +4,14 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace Tank.Entities +namespace Tank { public class EntityArmoVehicle { public int Speed { get; private set; } public double Weight { get; private set; } - public Color BodyColor { get; private set; } + public Color BodyColor { get; set; } + public void setBodyColor(Color color) { BodyColor = color; } public double Step => (double)Speed * 100 / Weight; public EntityArmoVehicle(int speed, double weight, Color bodyColor) { diff --git a/Tank/Tank/EntityTank.cs b/Tank/Tank/EntityTank.cs index 04d5f7f..39491e1 100644 --- a/Tank/Tank/EntityTank.cs +++ b/Tank/Tank/EntityTank.cs @@ -9,6 +9,7 @@ namespace Tank.Entities public class EntityTank : EntityArmoVehicle { public Color AdditionalColor { get; private set; } + public void setAdditionalColor(Color color) { AdditionalColor = color; } public bool BodyKit { get; private set; } public bool Caterpillar { get; private set; } public bool Tower { get; private set; } diff --git a/Tank/Tank/FormTank.Designer.cs b/Tank/Tank/FormTank.Designer.cs index 4a148c0..0f9e611 100644 --- a/Tank/Tank/FormTank.Designer.cs +++ b/Tank/Tank/FormTank.Designer.cs @@ -173,6 +173,7 @@ Margin = new Padding(3, 4, 3, 4); Name = "FormTank"; Text = "FormTank"; + Load += FormTank_Load; ((System.ComponentModel.ISupportInitialize)pictureBoxTank).EndInit(); ResumeLayout(false); } diff --git a/Tank/Tank/FormTank.cs b/Tank/Tank/FormTank.cs index aae6222..8d1fe16 100644 --- a/Tank/Tank/FormTank.cs +++ b/Tank/Tank/FormTank.cs @@ -128,5 +128,10 @@ namespace Tank SelectedTank = _Tank; DialogResult = DialogResult.OK; } + + private void FormTank_Load(object sender, EventArgs e) + { + + } } } \ No newline at end of file diff --git a/Tank/Tank/FormTankConfig.Designer.cs b/Tank/Tank/FormTankConfig.Designer.cs new file mode 100644 index 0000000..e6a334b --- /dev/null +++ b/Tank/Tank/FormTankConfig.Designer.cs @@ -0,0 +1,405 @@ +namespace Tank +{ + partial class FormTankConfig + { + /// + /// 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() + { + ParamsGroup = new GroupBox(); + labelTank = new Label(); + labelArmoVehicle = new Label(); + groupBoxColors = new GroupBox(); + panelPink = new Panel(); + panelYellow = new Panel(); + panelCyan = new Panel(); + panelRed = new Panel(); + panelBlue = new Panel(); + panelOrange = new Panel(); + panelGreen = new Panel(); + panelSilver = new Panel(); + checkBoxCaterpillar = new CheckBox(); + checkBoxBodyKit = new CheckBox(); + checkBoxTower = new CheckBox(); + numericWeight = new NumericUpDown(); + numericSpeed = new NumericUpDown(); + weightLabel = new Label(); + speedLabel = new Label(); + panelPictureTank = new Panel(); + pictureBox = new PictureBox(); + buttonAdd = new Button(); + buttonCancel = new Button(); + labelColor = new Label(); + labelAdditionalColor = new Label(); + ParamsGroup.SuspendLayout(); + groupBoxColors.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)numericWeight).BeginInit(); + ((System.ComponentModel.ISupportInitialize)numericSpeed).BeginInit(); + panelPictureTank.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)pictureBox).BeginInit(); + SuspendLayout(); + // + // ParamsGroup + // + ParamsGroup.Controls.Add(labelTank); + ParamsGroup.Controls.Add(labelArmoVehicle); + ParamsGroup.Controls.Add(groupBoxColors); + ParamsGroup.Controls.Add(checkBoxCaterpillar); + ParamsGroup.Controls.Add(checkBoxBodyKit); + ParamsGroup.Controls.Add(checkBoxTower); + ParamsGroup.Controls.Add(numericWeight); + ParamsGroup.Controls.Add(numericSpeed); + ParamsGroup.Controls.Add(weightLabel); + ParamsGroup.Controls.Add(speedLabel); + ParamsGroup.Location = new Point(5, 3); + ParamsGroup.Margin = new Padding(5, 4, 5, 4); + ParamsGroup.Name = "ParamsGroup"; + ParamsGroup.Padding = new Padding(5, 4, 5, 4); + ParamsGroup.Size = new Size(240, 740); + ParamsGroup.TabIndex = 0; + ParamsGroup.TabStop = false; + ParamsGroup.Text = "Params Group Box"; + // + // labelTank + // + labelTank.BorderStyle = BorderStyle.FixedSingle; + labelTank.Location = new Point(120, 644); + labelTank.Margin = new Padding(5, 0, 5, 0); + labelTank.Name = "labelTank"; + labelTank.Size = new Size(87, 55); + labelTank.TabIndex = 10; + labelTank.Text = "Tank"; + labelTank.TextAlign = ContentAlignment.MiddleCenter; + labelTank.MouseDown += LabelObject_MouseDown; + // + // labelArmoVehicle + // + labelArmoVehicle.BorderStyle = BorderStyle.FixedSingle; + labelArmoVehicle.Location = new Point(9, 644); + labelArmoVehicle.Margin = new Padding(5, 0, 5, 0); + labelArmoVehicle.Name = "labelArmoVehicle"; + labelArmoVehicle.Size = new Size(96, 55); + labelArmoVehicle.TabIndex = 9; + labelArmoVehicle.Text = "ArmoVehicle"; + labelArmoVehicle.TextAlign = ContentAlignment.MiddleCenter; + labelArmoVehicle.MouseDown += LabelObject_MouseDown; + // + // groupBoxColors + // + groupBoxColors.Controls.Add(panelPink); + groupBoxColors.Controls.Add(panelYellow); + groupBoxColors.Controls.Add(panelCyan); + groupBoxColors.Controls.Add(panelRed); + groupBoxColors.Controls.Add(panelBlue); + groupBoxColors.Controls.Add(panelOrange); + groupBoxColors.Controls.Add(panelGreen); + groupBoxColors.Controls.Add(panelSilver); + groupBoxColors.Location = new Point(16, 268); + groupBoxColors.Margin = new Padding(5, 4, 5, 4); + groupBoxColors.Name = "groupBoxColors"; + groupBoxColors.Padding = new Padding(5, 4, 5, 4); + groupBoxColors.Size = new Size(210, 348); + groupBoxColors.TabIndex = 8; + groupBoxColors.TabStop = false; + groupBoxColors.Text = "Colors"; + // + // panelPink + // + panelPink.BackColor = Color.Fuchsia; + panelPink.Location = new Point(107, 276); + panelPink.Margin = new Padding(5, 4, 5, 4); + panelPink.Name = "panelPink"; + panelPink.Size = new Size(56, 61); + panelPink.TabIndex = 3; + panelPink.MouseDown += panelColor_MouseDown; + // + // panelYellow + // + panelYellow.BackColor = Color.Yellow; + panelYellow.Location = new Point(107, 108); + panelYellow.Margin = new Padding(5, 4, 5, 4); + panelYellow.Name = "panelYellow"; + panelYellow.Size = new Size(56, 61); + panelYellow.TabIndex = 1; + panelYellow.MouseDown += panelColor_MouseDown; + // + // panelCyan + // + panelCyan.BackColor = Color.Cyan; + panelCyan.Location = new Point(107, 192); + panelCyan.Margin = new Padding(5, 4, 5, 4); + panelCyan.Name = "panelCyan"; + panelCyan.Size = new Size(56, 61); + panelCyan.TabIndex = 4; + panelCyan.MouseDown += panelColor_MouseDown; + // + // panelRed + // + panelRed.BackColor = Color.Red; + panelRed.Location = new Point(107, 24); + panelRed.Margin = new Padding(5, 4, 5, 4); + panelRed.Name = "panelRed"; + panelRed.Size = new Size(56, 61); + panelRed.TabIndex = 1; + panelRed.MouseDown += panelColor_MouseDown; + // + // panelBlue + // + panelBlue.BackColor = Color.Blue; + panelBlue.Location = new Point(33, 276); + panelBlue.Margin = new Padding(5, 4, 5, 4); + panelBlue.Name = "panelBlue"; + panelBlue.Size = new Size(56, 61); + panelBlue.TabIndex = 5; + panelBlue.MouseDown += panelColor_MouseDown; + // + // panelOrange + // + panelOrange.BackColor = Color.FromArgb(255, 128, 0); + panelOrange.Location = new Point(33, 108); + panelOrange.Margin = new Padding(5, 4, 5, 4); + panelOrange.Name = "panelOrange"; + panelOrange.Size = new Size(56, 61); + panelOrange.TabIndex = 1; + panelOrange.MouseDown += panelColor_MouseDown; + // + // panelGreen + // + panelGreen.BackColor = Color.Lime; + panelGreen.Location = new Point(33, 192); + panelGreen.Margin = new Padding(5, 4, 5, 4); + panelGreen.Name = "panelGreen"; + panelGreen.Size = new Size(56, 61); + panelGreen.TabIndex = 2; + panelGreen.MouseDown += panelColor_MouseDown; + // + // panelSilver + // + panelSilver.BackColor = Color.Silver; + panelSilver.Location = new Point(33, 24); + panelSilver.Margin = new Padding(5, 4, 5, 4); + panelSilver.Name = "panelSilver"; + panelSilver.Size = new Size(56, 61); + panelSilver.TabIndex = 0; + panelSilver.MouseDown += panelColor_MouseDown; + // + // checkBoxCaterpillarTank + // + checkBoxCaterpillar.AutoSize = true; + checkBoxCaterpillar.Location = new Point(18, 180); + checkBoxCaterpillar.Margin = new Padding(5, 4, 5, 4); + checkBoxCaterpillar.Name = "checkBoxCaterpillarTank"; + checkBoxCaterpillar.Size = new Size(100, 24); + checkBoxCaterpillar.TabIndex = 7; + checkBoxCaterpillar.Text = "Caterpillar"; + checkBoxCaterpillar.UseVisualStyleBackColor = true; + // + // checkBoxBodyKit + // + checkBoxBodyKit.AutoSize = true; + checkBoxBodyKit.Location = new Point(18, 149); + checkBoxBodyKit.Margin = new Padding(5, 4, 5, 4); + checkBoxBodyKit.Name = "checkBoxBodyKit"; + checkBoxBodyKit.Size = new Size(83, 24); + checkBoxBodyKit.TabIndex = 6; + checkBoxBodyKit.Text = "BodyKit"; + checkBoxBodyKit.UseVisualStyleBackColor = true; + // + // checkBoxTower + // + checkBoxTower.AutoSize = true; + checkBoxTower.Location = new Point(18, 216); + checkBoxTower.Margin = new Padding(5, 4, 5, 4); + checkBoxTower.Name = "checkBoxTower"; + checkBoxTower.Size = new Size(71, 24); + checkBoxTower.TabIndex = 5; + checkBoxTower.Text = "Tower"; + checkBoxTower.UseVisualStyleBackColor = true; + // + // numericWeight + // + numericWeight.Location = new Point(66, 79); + numericWeight.Margin = new Padding(5, 4, 5, 4); + numericWeight.Maximum = new decimal(new int[] { 1000, 0, 0, 0 }); + numericWeight.Minimum = new decimal(new int[] { 100, 0, 0, 0 }); + numericWeight.Name = "numericWeight"; + numericWeight.Size = new Size(160, 27); + numericWeight.TabIndex = 4; + numericWeight.Value = new decimal(new int[] { 100, 0, 0, 0 }); + // + // numericSpeed + // + numericSpeed.Location = new Point(66, 36); + numericSpeed.Margin = new Padding(5, 4, 5, 4); + numericSpeed.Maximum = new decimal(new int[] { 1000, 0, 0, 0 }); + numericSpeed.Minimum = new decimal(new int[] { 100, 0, 0, 0 }); + numericSpeed.Name = "numericSpeed"; + numericSpeed.Size = new Size(160, 27); + numericSpeed.TabIndex = 3; + numericSpeed.Value = new decimal(new int[] { 100, 0, 0, 0 }); + // + // weightLabel + // + weightLabel.AutoSize = true; + weightLabel.Location = new Point(11, 79); + weightLabel.Margin = new Padding(5, 0, 5, 0); + weightLabel.Name = "weightLabel"; + weightLabel.Size = new Size(49, 20); + weightLabel.TabIndex = 2; + weightLabel.Text = "weigh"; + // + // speedLabel + // + speedLabel.AutoSize = true; + speedLabel.Location = new Point(11, 39); + speedLabel.Margin = new Padding(5, 0, 5, 0); + speedLabel.Name = "speedLabel"; + speedLabel.Size = new Size(49, 20); + speedLabel.TabIndex = 1; + speedLabel.Text = "speed"; + // + // panel9 + // + panelPictureTank.AllowDrop = true; + panelPictureTank.Controls.Add(pictureBox); + panelPictureTank.Location = new Point(266, 116); + panelPictureTank.Margin = new Padding(5, 4, 5, 4); + panelPictureTank.Name = "panel9"; + panelPictureTank.Size = new Size(784, 520); + panelPictureTank.TabIndex = 11; + panelPictureTank.DragDrop += PanelObject_DragDrop; + panelPictureTank.DragEnter += PanelObject_DragEnter; + // + // pictureBox + // + pictureBox.Location = new Point(18, 8); + pictureBox.Margin = new Padding(5, 4, 5, 4); + pictureBox.Name = "pictureBox"; + pictureBox.Size = new Size(741, 508); + pictureBox.TabIndex = 0; + pictureBox.TabStop = false; + // + // buttonAdd + // + buttonAdd.Location = new Point(306, 660); + buttonAdd.Margin = new Padding(5, 4, 5, 4); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(200, 62); + buttonAdd.TabIndex = 12; + buttonAdd.Text = "Add"; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += ButtonOk_Click; + // + // buttonCancel + // + buttonCancel.Location = new Point(793, 662); + buttonCancel.Margin = new Padding(5, 4, 5, 4); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(210, 60); + buttonCancel.TabIndex = 13; + buttonCancel.Text = "Cancel"; + buttonCancel.UseVisualStyleBackColor = true; + // + // labelColor + // + labelColor.AllowDrop = true; + labelColor.BorderStyle = BorderStyle.FixedSingle; + labelColor.Location = new Point(349, 37); + labelColor.Margin = new Padding(5, 0, 5, 0); + labelColor.Name = "labelColor"; + labelColor.Size = new Size(139, 42); + labelColor.TabIndex = 14; + labelColor.Text = "Color"; + labelColor.TextAlign = ContentAlignment.MiddleCenter; + labelColor.DragDrop += labelColor_DragDrop; + labelColor.DragEnter += labelColor_DragEnter; + // + // labelAdditionalColor + // + labelAdditionalColor.AllowDrop = true; + labelAdditionalColor.BorderStyle = BorderStyle.FixedSingle; + labelAdditionalColor.Location = new Point(815, 32); + labelAdditionalColor.Margin = new Padding(5, 0, 5, 0); + labelAdditionalColor.Name = "labelAdditionalColor"; + labelAdditionalColor.Size = new Size(136, 39); + labelAdditionalColor.TabIndex = 15; + labelAdditionalColor.Text = "Additional color"; + labelAdditionalColor.TextAlign = ContentAlignment.MiddleCenter; + labelAdditionalColor.DragDrop += labelColor_DragDrop; + labelAdditionalColor.DragEnter += labelColor_DragEnter; + // + // FormTankConfig + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(1066, 744); + Controls.Add(labelAdditionalColor); + Controls.Add(labelColor); + Controls.Add(buttonCancel); + Controls.Add(buttonAdd); + Controls.Add(panelPictureTank); + Controls.Add(ParamsGroup); + Margin = new Padding(5, 4, 5, 4); + Name = "FormTankConfig"; + Text = "FormTankConfig"; + ParamsGroup.ResumeLayout(false); + ParamsGroup.PerformLayout(); + groupBoxColors.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)numericWeight).EndInit(); + ((System.ComponentModel.ISupportInitialize)numericSpeed).EndInit(); + panelPictureTank.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)pictureBox).EndInit(); + ResumeLayout(false); + } + + #endregion + + private GroupBox ParamsGroup; + private CheckBox checkBoxCaterpillar; + private CheckBox checkBoxBodyKit; + private CheckBox checkBoxTower; + private NumericUpDown numericWeight; + private NumericUpDown numericSpeed; + private Label weightLabel; + private Label speedLabel; + private GroupBox groupBoxColors; + private Panel panelPink; + private Panel panelYellow; + private Panel panelCyan; + private Panel panelRed; + private Panel panelBlue; + private Panel panelOrange; + private Panel panelGreen; + private Panel panelSilver; + private Label labelTank; + private Label labelArmoVehicle; + private Panel panelPictureTank; + private PictureBox pictureBox; + private Button buttonAdd; + private Button buttonCancel; + private Label labelColor; + private Label labelAdditionalColor; + } +} \ No newline at end of file diff --git a/Tank/Tank/FormTankConfig.cs b/Tank/Tank/FormTankConfig.cs new file mode 100644 index 0000000..b3d82e3 --- /dev/null +++ b/Tank/Tank/FormTankConfig.cs @@ -0,0 +1,148 @@ +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 Tank.DrawningObjects; +using Tank.Entities; + +namespace Tank +{ + public partial class FormTankConfig : Form + { + Color defaultColor; + + // Переменная-выбранный танк + DrawArmoVehicle _tank = null; + + // Событие + private event Action EventAddTank; + + // Конструктор + public FormTankConfig() + { + InitializeComponent(); + + panelSilver.MouseDown += panelColor_MouseDown; + panelRed.MouseDown += panelColor_MouseDown; + panelOrange.MouseDown += panelColor_MouseDown; + panelYellow.MouseDown += panelColor_MouseDown; + panelGreen.MouseDown += panelColor_MouseDown; + panelCyan.MouseDown += panelColor_MouseDown; + panelBlue.MouseDown += panelColor_MouseDown; + panelPink.MouseDown += panelColor_MouseDown; + + defaultColor = labelColor.BackColor; + buttonCancel.Click += (s, e) => Close(); + } + + // Отрисовать танк + private void DrawingTank() + { + Bitmap bmp = new Bitmap(pictureBox.Width, pictureBox.Height); + Graphics gr = Graphics.FromImage(bmp); + _tank?.SetPosition(5, 5); + if (_tank is DrawTank) + (_tank as DrawTank).DrawTransport(gr); + else + _tank?.DrawTransport(gr); + pictureBox.Image = bmp; + } + + // Добавление события + internal void AddEvent(Action ev) + { + if (EventAddTank == null) + { + EventAddTank = ev; + } + else + { + EventAddTank += ev; + } + } + + // Передаем информацию при нажатии на Label + private void LabelObject_MouseDown(object sender, MouseEventArgs e) + { + (sender as Label)?.DoDragDrop((sender as Label)?.Name, DragDropEffects.Move | DragDropEffects.Copy); + } + + // Проверка получаемой информации (ее типа на соответствие требуемому) + private void PanelObject_DragEnter(object sender, DragEventArgs e) + { + if (e.Data?.GetDataPresent(DataFormats.Text) ?? false) + { + e.Effect = DragDropEffects.Copy; + } + else + { + e.Effect = DragDropEffects.None; + } + } + + // Действия при приеме перетаскиваемой информации + private void PanelObject_DragDrop(object sender, DragEventArgs e) + { + switch (e.Data?.GetData(DataFormats.Text).ToString()) + { + case "labelArmoVehicle": + _tank = new DrawArmoVehicle((int)numericSpeed.Value, (int)numericWeight.Value, Color.White, pictureBox.Width, pictureBox.Height); + break; + case "labelTank": + _tank = new DrawTank((int)numericSpeed.Value, (int)numericWeight.Value, Color.White, Color.Black, checkBoxBodyKit.Checked, checkBoxCaterpillar.Checked, checkBoxTower.Checked, pictureBox.Width, pictureBox.Height); + break; + } + labelColor.BackColor = defaultColor; + labelAdditionalColor.BackColor = defaultColor; + DrawingTank(); + } + + // Добавление танка + private void ButtonOk_Click(object sender, EventArgs e) + { + EventAddTank?.Invoke(_tank); + Close(); + } + + private void panelColor_MouseDown(object sender, MouseEventArgs e) + { + (sender as Panel)?.DoDragDrop((sender as Panel)?.BackColor, DragDropEffects.Move | DragDropEffects.Copy); + } + + private void labelColor_DragEnter(object sender, DragEventArgs e) + { + if (e.Data?.GetDataPresent(typeof(Color)) ?? false) + { + e.Effect = DragDropEffects.Copy; + } + else + { + e.Effect = DragDropEffects.None; + } + } + + private void labelColor_DragDrop(object sender, DragEventArgs e) + { + if (_tank == null) + return; + ((Label)sender).BackColor = (Color)e.Data.GetData(typeof(Color)); + switch (((Label)sender).Name) + { + case "labelColor": + _tank.Tank.setBodyColor((Color)e.Data.GetData(typeof(Color))); + break; + case "labelAdditionalColor": + if (!(_tank is DrawTank)) + return; + (_tank.Tank as EntityTank).setAdditionalColor((Color)e.Data.GetData(typeof(Color))); + break; + } + DrawingTank(); + } + } +} \ No newline at end of file diff --git a/Tank/Tank/FormTankConfig.resx b/Tank/Tank/FormTankConfig.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/Tank/Tank/FormTankConfig.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/Tank/Tank/Program.cs b/Tank/Tank/Program.cs index afa7dde..be056fe 100644 --- a/Tank/Tank/Program.cs +++ b/Tank/Tank/Program.cs @@ -11,7 +11,7 @@ namespace Tank // To customize application configuration such as set high DPI settings or default font, // see https://aka.ms/applicationconfiguration. ApplicationConfiguration.Initialize(); - Application.Run(new FormTanksCollections()); + Application.Run(new CollectionsFrame()); } } } \ No newline at end of file diff --git a/Tank/Tank/SetGeneric.cs b/Tank/Tank/SetGeneric.cs index 234613f..4488f34 100644 --- a/Tank/Tank/SetGeneric.cs +++ b/Tank/Tank/SetGeneric.cs @@ -9,39 +9,32 @@ namespace Tank { internal class SetGeneric where T : class { - // Список объектов, которые храним и их количество private readonly List _places; public int Count => _places.Count; - // Максимальное количество объектов private readonly int _maxCount; - // Конструктор public SetGeneric(int count) { _maxCount = count; _places = new List(_maxCount); } - // Добавление объекта в набор - public bool Insert(T tank) + public bool Insert(T car) { - return Insert(tank, 0); + return Insert(car, 0); } - - // Добавление на конкретную позицию - public bool Insert(T tank, int position) + public bool Insert(T car, int position) { if (position < 0 || position >= _maxCount) return false; if (Count >= _maxCount) return false; - _places.Insert(0, tank); + _places.Insert(0, car); return true; } - // Удаление объекта из набора с конкретной позиции public bool Remove(int position) { if (position < 0 || position > _maxCount) @@ -51,8 +44,6 @@ namespace Tank _places.RemoveAt(position); return true; } - - // Получение объекта из набора по позиции public T? this[int position] { get @@ -69,17 +60,18 @@ namespace Tank } } - // Проход по списку - public IEnumerable GetTanks(int? maxTanks = null) + + public IEnumerable GetCars(int? maxCars = null) { for (int i = 0; i < _places.Count; ++i) { yield return _places[i]; - if (maxTanks.HasValue && i == maxTanks.Value) + if (maxCars.HasValue && i == maxCars.Value) { yield break; } } } + } } \ No newline at end of file diff --git a/Tank/Tank/TanksGenericCollection.cs b/Tank/Tank/TanksGenericCollection.cs index 5251443..27ac758 100644 --- a/Tank/Tank/TanksGenericCollection.cs +++ b/Tank/Tank/TanksGenericCollection.cs @@ -95,15 +95,18 @@ namespace Tank.Generics int width = _pictureWidth / _placeSizeWidth; int height = _pictureHeight / _placeSizeHeight; int i = 0; - foreach(var tank in _collection.GetTanks()) + foreach(var tank in _collection.GetCars()) { if (tank != null) { - tank.SetPosition((i % (_pictureWidth / _placeSizeWidth)) * _placeSizeWidth, (i / (_pictureWidth / _placeSizeWidth)) * _placeSizeHeight); + tank._pictureWidth = _pictureWidth; + tank._pictureHeight = _pictureHeight; + tank.SetPosition(i % width * _placeSizeWidth, (i / (_pictureWidth / _placeSizeWidth)) * _placeSizeHeight); tank.DrawTransport(g); } i++; } } } -} \ No newline at end of file +} + diff --git a/Tank/Tank/TanksGenericStorage.cs b/Tank/Tank/TanksGenericStorage.cs index f3e4320..a5fac2f 100644 --- a/Tank/Tank/TanksGenericStorage.cs +++ b/Tank/Tank/TanksGenericStorage.cs @@ -11,37 +11,28 @@ namespace Tank { internal class TanksGenericStorage { - // Словарь readonly Dictionary> _tankStorages; - - // Возвращение списка названий наборов public List Keys => _tankStorages.Keys.ToList(); private readonly int _pictureWidth; private readonly int _pictureHeight; - - // Конструктор public TanksGenericStorage(int pictureWidth, int pictureHeight) { _tankStorages = new Dictionary>(); _pictureWidth = pictureWidth; _pictureHeight = pictureHeight; } - - // Добавление набора public void AddSet(string name) { if (_tankStorages.ContainsKey(name)) return; _tankStorages[name] = new TanksGenericCollection(_pictureWidth, _pictureHeight); } - // Удаление набора public void DelSet(string name) { if (!_tankStorages.ContainsKey(name)) return; _tankStorages.Remove(name); } - // Доступ к набору public TanksGenericCollection? this[string ind] { @@ -52,4 +43,4 @@ namespace Tank } } } -} \ No newline at end of file +} -- 2.25.1 From 525a6a7d7cb7bcfbcd4a4d48be4ac962b247d7b5 Mon Sep 17 00:00:00 2001 From: "nikbel2004@outlook.com" Date: Mon, 13 Nov 2023 02:26:30 +0400 Subject: [PATCH 2/7] =?UTF-8?q?=D0=9B=D0=B0=D0=B1=D0=BE=D1=80=D0=B0=D1=82?= =?UTF-8?q?=D0=BE=D1=80=D0=BD=D0=B0=D1=8F=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82?= =?UTF-8?q?=D0=B0=205?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ionsFrame.Designer.cs => FormTanksCollections.Designer.cs} | 2 +- Tank/Tank/{CollectionsFrame.cs => FormTanksCollections.cs} | 4 ++-- .../Tank/{CollectionsFrame.resx => FormTanksCollections.resx} | 0 Tank/Tank/Program.cs | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) rename Tank/Tank/{CollectionsFrame.Designer.cs => FormTanksCollections.Designer.cs} (99%) rename Tank/Tank/{CollectionsFrame.cs => FormTanksCollections.cs} (98%) rename Tank/Tank/{CollectionsFrame.resx => FormTanksCollections.resx} (100%) diff --git a/Tank/Tank/CollectionsFrame.Designer.cs b/Tank/Tank/FormTanksCollections.Designer.cs similarity index 99% rename from Tank/Tank/CollectionsFrame.Designer.cs rename to Tank/Tank/FormTanksCollections.Designer.cs index b8cf9d3..3b605e4 100644 --- a/Tank/Tank/CollectionsFrame.Designer.cs +++ b/Tank/Tank/FormTanksCollections.Designer.cs @@ -1,6 +1,6 @@ namespace Tank { - partial class CollectionsFrame + partial class FormTanksCollections { /// /// Required designer variable. diff --git a/Tank/Tank/CollectionsFrame.cs b/Tank/Tank/FormTanksCollections.cs similarity index 98% rename from Tank/Tank/CollectionsFrame.cs rename to Tank/Tank/FormTanksCollections.cs index 0979e6f..f35d91d 100644 --- a/Tank/Tank/CollectionsFrame.cs +++ b/Tank/Tank/FormTanksCollections.cs @@ -13,12 +13,12 @@ using System.Windows.Forms; namespace Tank { - public partial class CollectionsFrame : Form + public partial class FormTanksCollections : Form { private readonly TanksGenericStorage _storage; // Конструктор - public CollectionsFrame() + public FormTanksCollections() { InitializeComponent(); _storage = new TanksGenericStorage(DrawTank.Width, DrawTank.Height); diff --git a/Tank/Tank/CollectionsFrame.resx b/Tank/Tank/FormTanksCollections.resx similarity index 100% rename from Tank/Tank/CollectionsFrame.resx rename to Tank/Tank/FormTanksCollections.resx diff --git a/Tank/Tank/Program.cs b/Tank/Tank/Program.cs index be056fe..afa7dde 100644 --- a/Tank/Tank/Program.cs +++ b/Tank/Tank/Program.cs @@ -11,7 +11,7 @@ namespace Tank // To customize application configuration such as set high DPI settings or default font, // see https://aka.ms/applicationconfiguration. ApplicationConfiguration.Initialize(); - Application.Run(new CollectionsFrame()); + Application.Run(new FormTanksCollections()); } } } \ No newline at end of file -- 2.25.1 From 7668db2e11d3449ac73b896ad61cf65efec88877 Mon Sep 17 00:00:00 2001 From: "nikbel2004@outlook.com" Date: Mon, 13 Nov 2023 02:28:53 +0400 Subject: [PATCH 3/7] =?UTF-8?q?=D0=93=D0=BE=D1=82=D0=BE=D0=B2=D0=B0=D1=8F?= =?UTF-8?q?=20=D0=BB=D0=B0=D0=B1=D0=BE=D1=80=D0=B0=D1=82=D0=BE=D1=80=D0=BD?= =?UTF-8?q?=D0=B0=D1=8F=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=B0=205?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Tank/Tank/DrawArmoVehicle.cs | 1 - Tank/Tank/EntityArmoVehicle.cs | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/Tank/Tank/DrawArmoVehicle.cs b/Tank/Tank/DrawArmoVehicle.cs index fa84dd5..8c7a09f 100644 --- a/Tank/Tank/DrawArmoVehicle.cs +++ b/Tank/Tank/DrawArmoVehicle.cs @@ -56,7 +56,6 @@ namespace Tank Direction.Right => _startPosX + _Width + Tank.Step < _pictureWidth, Direction.Down => _startPosY + _Height + Tank.Step < _pictureHeight, _ => false - }; } diff --git a/Tank/Tank/EntityArmoVehicle.cs b/Tank/Tank/EntityArmoVehicle.cs index 13b7bd2..f8c2a31 100644 --- a/Tank/Tank/EntityArmoVehicle.cs +++ b/Tank/Tank/EntityArmoVehicle.cs @@ -10,7 +10,7 @@ namespace Tank { public int Speed { get; private set; } public double Weight { get; private set; } - public Color BodyColor { get; set; } + public Color BodyColor { get; private set; } public void setBodyColor(Color color) { BodyColor = color; } public double Step => (double)Speed * 100 / Weight; public EntityArmoVehicle(int speed, double weight, Color bodyColor) -- 2.25.1 From 156075455206991a0bf91c6218de0092533b058a Mon Sep 17 00:00:00 2001 From: "nikbel2004@outlook.com" Date: Mon, 13 Nov 2023 02:33:10 +0400 Subject: [PATCH 4/7] =?UTF-8?q?=D0=93=D0=BE=D1=82=D0=BE=D0=B2=D0=B0=D1=8F?= =?UTF-8?q?=20=D0=BB=D0=B0=D0=B1=D0=BE=D1=80=D0=B0=D1=82=D0=BE=D1=80=D0=BD?= =?UTF-8?q?=D0=B0=D1=8F=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=B0=205?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Tank/Tank/FormTank.Designer.cs | 1 - Tank/Tank/FormTank.cs | 5 ----- Tank/Tank/SetGeneric.cs | 16 ++++++++++++---- Tank/Tank/TanksGenericCollection.cs | 7 +++---- 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/Tank/Tank/FormTank.Designer.cs b/Tank/Tank/FormTank.Designer.cs index 0f9e611..4a148c0 100644 --- a/Tank/Tank/FormTank.Designer.cs +++ b/Tank/Tank/FormTank.Designer.cs @@ -173,7 +173,6 @@ Margin = new Padding(3, 4, 3, 4); Name = "FormTank"; Text = "FormTank"; - Load += FormTank_Load; ((System.ComponentModel.ISupportInitialize)pictureBoxTank).EndInit(); ResumeLayout(false); } diff --git a/Tank/Tank/FormTank.cs b/Tank/Tank/FormTank.cs index 8d1fe16..aae6222 100644 --- a/Tank/Tank/FormTank.cs +++ b/Tank/Tank/FormTank.cs @@ -128,10 +128,5 @@ namespace Tank SelectedTank = _Tank; DialogResult = DialogResult.OK; } - - private void FormTank_Load(object sender, EventArgs e) - { - - } } } \ No newline at end of file diff --git a/Tank/Tank/SetGeneric.cs b/Tank/Tank/SetGeneric.cs index 4488f34..b8c369d 100644 --- a/Tank/Tank/SetGeneric.cs +++ b/Tank/Tank/SetGeneric.cs @@ -9,21 +9,27 @@ namespace Tank { internal class SetGeneric where T : class { + // Список объектов, которые храним и их количество private readonly List _places; public int Count => _places.Count; + // Максимальное количество объектов private readonly int _maxCount; + // Конструктор public SetGeneric(int count) { _maxCount = count; _places = new List(_maxCount); } + // Добавление объекта в набор public bool Insert(T car) { return Insert(car, 0); } + + // Добавление на конкретную позицию public bool Insert(T car, int position) { if (position < 0 || position >= _maxCount) @@ -35,6 +41,7 @@ namespace Tank return true; } + // Удаление объекта из набора с конкретной позиции public bool Remove(int position) { if (position < 0 || position > _maxCount) @@ -44,6 +51,8 @@ namespace Tank _places.RemoveAt(position); return true; } + + // Получение объекта из набора по позиции public T? this[int position] { get @@ -60,18 +69,17 @@ namespace Tank } } - - public IEnumerable GetCars(int? maxCars = null) + // Проход по списку + public IEnumerable GetTanks(int? maxTanks = null) { for (int i = 0; i < _places.Count; ++i) { yield return _places[i]; - if (maxCars.HasValue && i == maxCars.Value) + if (maxTanks.HasValue && i == maxTanks.Value) { yield break; } } } - } } \ No newline at end of file diff --git a/Tank/Tank/TanksGenericCollection.cs b/Tank/Tank/TanksGenericCollection.cs index 27ac758..70c5411 100644 --- a/Tank/Tank/TanksGenericCollection.cs +++ b/Tank/Tank/TanksGenericCollection.cs @@ -95,18 +95,17 @@ namespace Tank.Generics int width = _pictureWidth / _placeSizeWidth; int height = _pictureHeight / _placeSizeHeight; int i = 0; - foreach(var tank in _collection.GetCars()) + foreach(var tank in _collection.GetTanks()) { if (tank != null) { tank._pictureWidth = _pictureWidth; tank._pictureHeight = _pictureHeight; - tank.SetPosition(i % width * _placeSizeWidth, (i / (_pictureWidth / _placeSizeWidth)) * _placeSizeHeight); + tank.SetPosition((i % (_pictureWidth / _placeSizeWidth)) * _placeSizeWidth, (i / (_pictureWidth / _placeSizeWidth)) * _placeSizeHeight); tank.DrawTransport(g); } i++; } } } -} - +} \ No newline at end of file -- 2.25.1 From 1ccff34c27a3aeaec394fe16e416e3533c102130 Mon Sep 17 00:00:00 2001 From: "nikbel2004@outlook.com" Date: Mon, 13 Nov 2023 02:35:19 +0400 Subject: [PATCH 5/7] =?UTF-8?q?=D0=93=D0=BE=D1=82=D0=BE=D0=B2=D0=B0=D1=8F?= =?UTF-8?q?=20=D0=BB=D0=B0=D0=B1=D0=BE=D1=80=D0=B0=D1=82=D0=BE=D1=80=D0=BD?= =?UTF-8?q?=D0=B0=D1=8F=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=B0=205?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Tank/Tank/SetGeneric.cs | 8 ++++---- Tank/Tank/TanksGenericStorage.cs | 9 +++++++++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/Tank/Tank/SetGeneric.cs b/Tank/Tank/SetGeneric.cs index b8c369d..5f5442f 100644 --- a/Tank/Tank/SetGeneric.cs +++ b/Tank/Tank/SetGeneric.cs @@ -24,20 +24,20 @@ namespace Tank } // Добавление объекта в набор - public bool Insert(T car) + public bool Insert(T tank) { - return Insert(car, 0); + return Insert(tank, 0); } // Добавление на конкретную позицию - public bool Insert(T car, int position) + public bool Insert(T tank, int position) { if (position < 0 || position >= _maxCount) return false; if (Count >= _maxCount) return false; - _places.Insert(0, car); + _places.Insert(0, tank); return true; } diff --git a/Tank/Tank/TanksGenericStorage.cs b/Tank/Tank/TanksGenericStorage.cs index a5fac2f..e328aef 100644 --- a/Tank/Tank/TanksGenericStorage.cs +++ b/Tank/Tank/TanksGenericStorage.cs @@ -11,28 +11,37 @@ namespace Tank { internal class TanksGenericStorage { + // Словарь readonly Dictionary> _tankStorages; + + // Возвращение списка названий наборов public List Keys => _tankStorages.Keys.ToList(); private readonly int _pictureWidth; private readonly int _pictureHeight; + + // Конструктор public TanksGenericStorage(int pictureWidth, int pictureHeight) { _tankStorages = new Dictionary>(); _pictureWidth = pictureWidth; _pictureHeight = pictureHeight; } + + // Добавление набора public void AddSet(string name) { if (_tankStorages.ContainsKey(name)) return; _tankStorages[name] = new TanksGenericCollection(_pictureWidth, _pictureHeight); } + // Удаление набора public void DelSet(string name) { if (!_tankStorages.ContainsKey(name)) return; _tankStorages.Remove(name); } + // Доступ к набору public TanksGenericCollection? this[string ind] { -- 2.25.1 From c565f92d0c9c5a6b48d40d55685d661d89760c95 Mon Sep 17 00:00:00 2001 From: "nikbel2004@outlook.com" Date: Mon, 13 Nov 2023 02:36:16 +0400 Subject: [PATCH 6/7] =?UTF-8?q?=D0=93=D0=BE=D1=82=D0=BE=D0=B2=D0=B0=D1=8F?= =?UTF-8?q?=20=D0=BB=D0=B0=D0=B1=D0=BE=D1=80=D0=B0=D1=82=D0=BE=D1=80=D0=BD?= =?UTF-8?q?=D0=B0=D1=8F=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=B0=205?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Tank/Tank/TanksGenericStorage.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tank/Tank/TanksGenericStorage.cs b/Tank/Tank/TanksGenericStorage.cs index e328aef..f3e4320 100644 --- a/Tank/Tank/TanksGenericStorage.cs +++ b/Tank/Tank/TanksGenericStorage.cs @@ -52,4 +52,4 @@ namespace Tank } } } -} +} \ No newline at end of file -- 2.25.1 From 9f84d8ff33dad827db2bb888d3879aa54baa3be4 Mon Sep 17 00:00:00 2001 From: "nikbel2004@outlook.com" Date: Mon, 13 Nov 2023 02:37:58 +0400 Subject: [PATCH 7/7] =?UTF-8?q?=D0=93=D0=BE=D1=82=D0=BE=D0=B2=D0=B0=D1=8F?= =?UTF-8?q?=20=D0=BB=D0=B0=D0=B1=D0=BE=D1=80=D0=B0=D1=82=D0=BE=D1=80=D0=BD?= =?UTF-8?q?=D0=B0=D1=8F=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=B0=205?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Tank/Tank/SetGeneric.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tank/Tank/SetGeneric.cs b/Tank/Tank/SetGeneric.cs index 5f5442f..234613f 100644 --- a/Tank/Tank/SetGeneric.cs +++ b/Tank/Tank/SetGeneric.cs @@ -16,7 +16,7 @@ namespace Tank // Максимальное количество объектов private readonly int _maxCount; - // Конструктор + // Конструктор public SetGeneric(int count) { _maxCount = count; -- 2.25.1