From 74ae24d23ba68d30c3e2f0f8b51428cf92e45b41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9A=D0=B0=D1=88=D0=B8=D0=BD=20=D0=9C=D0=B0=D0=BA=D1=81?= =?UTF-8?q?=D0=B8=D0=BC?= Date: Wed, 19 Oct 2022 09:03:11 +0400 Subject: [PATCH] =?UTF-8?q?=D0=98=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D1=8F=20=D0=BE=D1=82=D0=BE=D0=B1=D1=80=D0=B0=D0=B6=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../FormMapWithSetGasolineTanker.Designer.cs | 93 ++++++++++++------- .../FormMapWithSetGasolineTanker.cs | 28 +++++- .../MapWithSetGasolienTankerGeneric.cs | 15 ++- 3 files changed, 90 insertions(+), 46 deletions(-) diff --git a/GasolineTanker/GasolineTanker/FormMapWithSetGasolineTanker.Designer.cs b/GasolineTanker/GasolineTanker/FormMapWithSetGasolineTanker.Designer.cs index 9e65eb2..ac96937 100644 --- a/GasolineTanker/GasolineTanker/FormMapWithSetGasolineTanker.Designer.cs +++ b/GasolineTanker/GasolineTanker/FormMapWithSetGasolineTanker.Designer.cs @@ -63,9 +63,11 @@ this.groupBoxTools.Controls.Add(this.buttonRemoveGasolineTanker); this.groupBoxTools.Controls.Add(this.buttonAddGasolineTanker); this.groupBoxTools.Dock = System.Windows.Forms.DockStyle.Right; - this.groupBoxTools.Location = new System.Drawing.Point(694, 0); + this.groupBoxTools.Location = new System.Drawing.Point(793, 0); + this.groupBoxTools.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.groupBoxTools.Name = "groupBoxTools"; - this.groupBoxTools.Size = new System.Drawing.Size(200, 629); + this.groupBoxTools.Padding = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.groupBoxTools.Size = new System.Drawing.Size(229, 839); this.groupBoxTools.TabIndex = 0; this.groupBoxTools.TabStop = false; this.groupBoxTools.Text = "Tools"; @@ -77,18 +79,21 @@ this.groupBoxMaps.Controls.Add(this.buttonAddMap); this.groupBoxMaps.Controls.Add(this.textBoxNewMapName); this.groupBoxMaps.Controls.Add(this.comboBoxSelectorMap); - this.groupBoxMaps.Location = new System.Drawing.Point(6, 22); + this.groupBoxMaps.Location = new System.Drawing.Point(7, 29); + this.groupBoxMaps.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.groupBoxMaps.Name = "groupBoxMaps"; - this.groupBoxMaps.Size = new System.Drawing.Size(190, 305); + this.groupBoxMaps.Padding = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.groupBoxMaps.Size = new System.Drawing.Size(217, 407); this.groupBoxMaps.TabIndex = 13; this.groupBoxMaps.TabStop = false; this.groupBoxMaps.Text = "Maps"; // // buttonDeleteMap // - this.buttonDeleteMap.Location = new System.Drawing.Point(6, 241); + this.buttonDeleteMap.Location = new System.Drawing.Point(7, 321); + this.buttonDeleteMap.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.buttonDeleteMap.Name = "buttonDeleteMap"; - this.buttonDeleteMap.Size = new System.Drawing.Size(175, 49); + this.buttonDeleteMap.Size = new System.Drawing.Size(200, 65); this.buttonDeleteMap.TabIndex = 16; this.buttonDeleteMap.Text = "Delete Map"; this.buttonDeleteMap.UseVisualStyleBackColor = true; @@ -97,18 +102,20 @@ // listBoxMaps // this.listBoxMaps.FormattingEnabled = true; - this.listBoxMaps.ItemHeight = 15; - this.listBoxMaps.Location = new System.Drawing.Point(6, 141); + this.listBoxMaps.ItemHeight = 20; + this.listBoxMaps.Location = new System.Drawing.Point(7, 188); + this.listBoxMaps.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.listBoxMaps.Name = "listBoxMaps"; - this.listBoxMaps.Size = new System.Drawing.Size(176, 94); + this.listBoxMaps.Size = new System.Drawing.Size(201, 124); this.listBoxMaps.TabIndex = 15; this.listBoxMaps.SelectedIndexChanged += new System.EventHandler(this.listBoxMaps_SelectedIndexChanged); // // buttonAddMap // - this.buttonAddMap.Location = new System.Drawing.Point(6, 84); + this.buttonAddMap.Location = new System.Drawing.Point(7, 112); + this.buttonAddMap.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.buttonAddMap.Name = "buttonAddMap"; - this.buttonAddMap.Size = new System.Drawing.Size(176, 51); + this.buttonAddMap.Size = new System.Drawing.Size(201, 68); this.buttonAddMap.TabIndex = 14; this.buttonAddMap.Text = "Add Map"; this.buttonAddMap.UseVisualStyleBackColor = true; @@ -116,9 +123,10 @@ // // textBoxNewMapName // - this.textBoxNewMapName.Location = new System.Drawing.Point(6, 24); + this.textBoxNewMapName.Location = new System.Drawing.Point(7, 32); + this.textBoxNewMapName.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.textBoxNewMapName.Name = "textBoxNewMapName"; - this.textBoxNewMapName.Size = new System.Drawing.Size(178, 23); + this.textBoxNewMapName.Size = new System.Drawing.Size(203, 27); this.textBoxNewMapName.TabIndex = 13; // // comboBoxSelectorMap @@ -128,18 +136,20 @@ this.comboBoxSelectorMap.Items.AddRange(new object[] { "Simple map", "Long map"}); - this.comboBoxSelectorMap.Location = new System.Drawing.Point(6, 53); + this.comboBoxSelectorMap.Location = new System.Drawing.Point(7, 71); + this.comboBoxSelectorMap.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.comboBoxSelectorMap.Name = "comboBoxSelectorMap"; - this.comboBoxSelectorMap.Size = new System.Drawing.Size(178, 23); + this.comboBoxSelectorMap.Size = new System.Drawing.Size(203, 28); this.comboBoxSelectorMap.TabIndex = 12; this.comboBoxSelectorMap.SelectedIndexChanged += new System.EventHandler(this.ComboBoxSelectorMap_SelectedIndexChanged); // // maskedTextBoxPosition // - this.maskedTextBoxPosition.Location = new System.Drawing.Point(10, 391); + this.maskedTextBoxPosition.Location = new System.Drawing.Point(11, 521); + this.maskedTextBoxPosition.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.maskedTextBoxPosition.Mask = "00"; this.maskedTextBoxPosition.Name = "maskedTextBoxPosition"; - this.maskedTextBoxPosition.Size = new System.Drawing.Size(184, 23); + this.maskedTextBoxPosition.Size = new System.Drawing.Size(210, 27); this.maskedTextBoxPosition.TabIndex = 11; // // keyRight @@ -147,9 +157,10 @@ this.keyRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.keyRight.BackgroundImage = global::GasolineTanker.Properties.Resources.KeyRight; this.keyRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; - this.keyRight.Location = new System.Drawing.Point(122, 587); + this.keyRight.Location = new System.Drawing.Point(139, 783); + this.keyRight.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.keyRight.Name = "keyRight"; - this.keyRight.Size = new System.Drawing.Size(30, 30); + this.keyRight.Size = new System.Drawing.Size(34, 40); this.keyRight.TabIndex = 10; this.keyRight.UseVisualStyleBackColor = true; this.keyRight.Click += new System.EventHandler(this.ButtonMove_Click); @@ -159,9 +170,10 @@ this.keyLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.keyLeft.BackgroundImage = global::GasolineTanker.Properties.Resources.KeyLeft; this.keyLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; - this.keyLeft.Location = new System.Drawing.Point(50, 587); + this.keyLeft.Location = new System.Drawing.Point(57, 783); + this.keyLeft.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.keyLeft.Name = "keyLeft"; - this.keyLeft.Size = new System.Drawing.Size(30, 30); + this.keyLeft.Size = new System.Drawing.Size(34, 40); this.keyLeft.TabIndex = 9; this.keyLeft.UseVisualStyleBackColor = true; this.keyLeft.Click += new System.EventHandler(this.ButtonMove_Click); @@ -171,9 +183,10 @@ this.keyUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.keyUp.BackgroundImage = global::GasolineTanker.Properties.Resources.KeyUp; this.keyUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; - this.keyUp.Location = new System.Drawing.Point(86, 551); + this.keyUp.Location = new System.Drawing.Point(98, 735); + this.keyUp.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.keyUp.Name = "keyUp"; - this.keyUp.Size = new System.Drawing.Size(30, 30); + this.keyUp.Size = new System.Drawing.Size(34, 40); this.keyUp.TabIndex = 8; this.keyUp.UseVisualStyleBackColor = true; this.keyUp.Click += new System.EventHandler(this.ButtonMove_Click); @@ -183,18 +196,20 @@ this.keyDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.keyDown.BackgroundImage = global::GasolineTanker.Properties.Resources.KeyDown; this.keyDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; - this.keyDown.Location = new System.Drawing.Point(86, 587); + this.keyDown.Location = new System.Drawing.Point(98, 783); + this.keyDown.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.keyDown.Name = "keyDown"; - this.keyDown.Size = new System.Drawing.Size(30, 30); + this.keyDown.Size = new System.Drawing.Size(34, 40); this.keyDown.TabIndex = 7; this.keyDown.UseVisualStyleBackColor = true; this.keyDown.Click += new System.EventHandler(this.ButtonMove_Click); // // buttonShowOnMap // - this.buttonShowOnMap.Location = new System.Drawing.Point(8, 500); + this.buttonShowOnMap.Location = new System.Drawing.Point(9, 667); + this.buttonShowOnMap.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.buttonShowOnMap.Name = "buttonShowOnMap"; - this.buttonShowOnMap.Size = new System.Drawing.Size(186, 34); + this.buttonShowOnMap.Size = new System.Drawing.Size(213, 45); this.buttonShowOnMap.TabIndex = 4; this.buttonShowOnMap.Text = "Show on map"; this.buttonShowOnMap.UseVisualStyleBackColor = true; @@ -202,9 +217,10 @@ // // buttonShowStorage // - this.buttonShowStorage.Location = new System.Drawing.Point(8, 460); + this.buttonShowStorage.Location = new System.Drawing.Point(9, 613); + this.buttonShowStorage.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.buttonShowStorage.Name = "buttonShowStorage"; - this.buttonShowStorage.Size = new System.Drawing.Size(186, 34); + this.buttonShowStorage.Size = new System.Drawing.Size(213, 45); this.buttonShowStorage.TabIndex = 3; this.buttonShowStorage.Text = "Show storage"; this.buttonShowStorage.UseVisualStyleBackColor = true; @@ -212,18 +228,21 @@ // // buttonRemoveGasolineTanker // - this.buttonRemoveGasolineTanker.Location = new System.Drawing.Point(8, 420); + this.buttonRemoveGasolineTanker.Location = new System.Drawing.Point(9, 560); + this.buttonRemoveGasolineTanker.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.buttonRemoveGasolineTanker.Name = "buttonRemoveGasolineTanker"; - this.buttonRemoveGasolineTanker.Size = new System.Drawing.Size(186, 34); + this.buttonRemoveGasolineTanker.Size = new System.Drawing.Size(213, 45); this.buttonRemoveGasolineTanker.TabIndex = 2; this.buttonRemoveGasolineTanker.Text = "Remove gasoline tanker"; this.buttonRemoveGasolineTanker.UseVisualStyleBackColor = true; + this.buttonRemoveGasolineTanker.Click += new System.EventHandler(this.buttonRemoveGasolineTanker_Click); // // buttonAddGasolineTanker // - this.buttonAddGasolineTanker.Location = new System.Drawing.Point(10, 351); + this.buttonAddGasolineTanker.Location = new System.Drawing.Point(11, 468); + this.buttonAddGasolineTanker.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.buttonAddGasolineTanker.Name = "buttonAddGasolineTanker"; - this.buttonAddGasolineTanker.Size = new System.Drawing.Size(186, 34); + this.buttonAddGasolineTanker.Size = new System.Drawing.Size(213, 45); this.buttonAddGasolineTanker.TabIndex = 1; this.buttonAddGasolineTanker.Text = "Add gasoline tanker"; this.buttonAddGasolineTanker.UseVisualStyleBackColor = true; @@ -233,18 +252,20 @@ // this.pictureBox.Dock = System.Windows.Forms.DockStyle.Fill; this.pictureBox.Location = new System.Drawing.Point(0, 0); + this.pictureBox.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.pictureBox.Name = "pictureBox"; - this.pictureBox.Size = new System.Drawing.Size(694, 629); + this.pictureBox.Size = new System.Drawing.Size(793, 839); this.pictureBox.TabIndex = 1; this.pictureBox.TabStop = false; // // FormMapWithSetGasolineTanker // - this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(894, 629); + this.ClientSize = new System.Drawing.Size(1022, 839); this.Controls.Add(this.pictureBox); this.Controls.Add(this.groupBoxTools); + this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.Name = "FormMapWithSetGasolineTanker"; this.Text = "FormMapWithSetGasolineTanker"; this.groupBoxTools.ResumeLayout(false); diff --git a/GasolineTanker/GasolineTanker/FormMapWithSetGasolineTanker.cs b/GasolineTanker/GasolineTanker/FormMapWithSetGasolineTanker.cs index 9fa2688..8ecaafc 100644 --- a/GasolineTanker/GasolineTanker/FormMapWithSetGasolineTanker.cs +++ b/GasolineTanker/GasolineTanker/FormMapWithSetGasolineTanker.cs @@ -96,7 +96,7 @@ namespace GasolineTanker { return; } - pictureBox.Image = _mapGasolineTankerCollectionGeneric.ShowOnMap(); + pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowOnMap(); } private void ButtonMove_Click(object sender, EventArgs e) { @@ -181,5 +181,31 @@ namespace GasolineTanker { pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet(); } + + private void buttonRemoveGasolineTanker_Click(object sender, EventArgs e) + { + if (listBoxMaps.SelectedIndex == -1) + { + return; + } + if (string.IsNullOrEmpty(maskedTextBoxPosition.Text)) + { + return; + } + if (MessageBox.Show("Delete object?", "Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) + { + return; + } + int pos = Convert.ToInt32(maskedTextBoxPosition.Text); + if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] - pos != null) + { + MessageBox.Show("Object delete"); + pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet(); + } + else + { + MessageBox.Show("Errore delete object"); + } + } } } diff --git a/GasolineTanker/GasolineTanker/MapWithSetGasolienTankerGeneric.cs b/GasolineTanker/GasolineTanker/MapWithSetGasolienTankerGeneric.cs index fe0cb2f..4a437cc 100644 --- a/GasolineTanker/GasolineTanker/MapWithSetGasolienTankerGeneric.cs +++ b/GasolineTanker/GasolineTanker/MapWithSetGasolienTankerGeneric.cs @@ -110,16 +110,13 @@ namespace GasolineTanker { int width = _pictureWidth / _placeSizeWidth; int height = _pictureHeight / _placeSizeHeight; - foreach (var gasolineTanker in _setGasolineTanker.GetGasolineTanker()) + int i = 0; + + foreach (var warship in _setGasolineTanker.GetGasolineTanker()) { - gasolineTanker.SetObject(width, height, _pictureWidth, _pictureHeight); - gasolineTanker.DrawningObject(g); - width += _placeSizeWidth; - if (width > _pictureWidth - _placeSizeWidth) - { - width = _pictureWidth / _placeSizeWidth; - height -= _placeSizeHeight; - } + warship.SetObject(i % width * _placeSizeWidth+10, (height - 1 - i / width) * _placeSizeHeight + 10, _pictureWidth, _pictureHeight); + warship.DrawningObject(g); + i++; } } }