laba3 -100%

This commit is contained in:
Robert 2023-12-14 20:24:57 +04:00
parent e573f439b5
commit 729ce56642
6 changed files with 46 additions and 20 deletions

View File

@ -95,6 +95,10 @@ namespace DumpTruck.DrawningObjects
protected DrawningTruck(int speed, double weight, Color bodyColor, Color additionalColor, int width, int height, int truckWidth, int truckHeight) protected DrawningTruck(int speed, double weight, Color bodyColor, Color additionalColor, int width, int height, int truckWidth, int truckHeight)
{ {
// TODO: Продумать проверки // TODO: Продумать проверки
if (width < _truckWidth || height < _truckHeight)
{
return;
}
_pictureWidth = width; _pictureWidth = width;
_pictureHeight = height; _pictureHeight = height;
_truckWidth = truckWidth; _truckWidth = truckWidth;

View File

@ -152,6 +152,7 @@
buttonSelectTruck.TabIndex = 10; buttonSelectTruck.TabIndex = 10;
buttonSelectTruck.Text = "SelectTruck"; buttonSelectTruck.Text = "SelectTruck";
buttonSelectTruck.UseVisualStyleBackColor = true; buttonSelectTruck.UseVisualStyleBackColor = true;
buttonSelectTruck.Click += buttonSelectTruck_Click_1;
// //
// FormDumpTruck // FormDumpTruck
// //

View File

@ -55,8 +55,9 @@ namespace DumpTruck
{ {
color = dialog.Color; color = dialog.Color;
} }
_drawningTruck = new DrawningTruck(random.Next(100, 300), random.Next(1000, 3000), _drawningTruck = new DrawningTruck(random.Next(100, 300), random.Next(1000, 3000),
color,color, color, color,
pictureBoxDumpTruck.Width, pictureBoxDumpTruck.Height); pictureBoxDumpTruck.Width, pictureBoxDumpTruck.Height);
_drawningTruck.SetPosition(random.Next(10, 100), random.Next(10, 100)); _drawningTruck.SetPosition(random.Next(10, 100), random.Next(10, 100));
Draw(); Draw();
@ -70,8 +71,14 @@ namespace DumpTruck
{ {
color = dialog.Color; color = dialog.Color;
} }
Color color2 = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256));
ColorDialog dialog2 = new();
if (dialog.ShowDialog() == DialogResult.OK)
{
color2 = dialog2.Color;
}
_drawningTruck = new DrawningDumpTruck(random.Next(100, 300), random.Next(1000, 3000), _drawningTruck = new DrawningDumpTruck(random.Next(100, 300), random.Next(1000, 3000),
color,color, color, color2,
Convert.ToBoolean(1), pictureBoxDumpTruck.Width, pictureBoxDumpTruck.Height); Convert.ToBoolean(1), pictureBoxDumpTruck.Width, pictureBoxDumpTruck.Height);
_drawningTruck.SetPosition(random.Next(10, 100), random.Next(10, 100)); _drawningTruck.SetPosition(random.Next(10, 100), random.Next(10, 100));
Draw(); Draw();
@ -142,7 +149,8 @@ namespace DumpTruck
_abstractStrategy = null; _abstractStrategy = null;
} }
} }
private void buttonSelectTruck_Click(object sender, EventArgs e)
private void buttonSelectTruck_Click_1(object sender, EventArgs e)
{ {
selectedTruck = _drawningTruck; selectedTruck = _drawningTruck;
DialogResult = DialogResult.OK; DialogResult = DialogResult.OK;

View File

@ -44,25 +44,29 @@
groupBox1.Controls.Add(buttonRefreshCollection); groupBox1.Controls.Add(buttonRefreshCollection);
groupBox1.Controls.Add(buttonRemoveTruck); groupBox1.Controls.Add(buttonRemoveTruck);
groupBox1.Controls.Add(buttonAddTruck); groupBox1.Controls.Add(buttonAddTruck);
groupBox1.Location = new Point(588, 12); groupBox1.Location = new Point(689, 16);
groupBox1.Margin = new Padding(3, 4, 3, 4);
groupBox1.Name = "groupBox1"; groupBox1.Name = "groupBox1";
groupBox1.Size = new Size(200, 426); groupBox1.Padding = new Padding(3, 4, 3, 4);
groupBox1.Size = new Size(229, 568);
groupBox1.TabIndex = 0; groupBox1.TabIndex = 0;
groupBox1.TabStop = false; groupBox1.TabStop = false;
groupBox1.Text = "Инструменты"; groupBox1.Text = "Инструменты";
// //
// maskedTextBoxNumber // maskedTextBoxNumber
// //
maskedTextBoxNumber.Location = new Point(52, 101); maskedTextBoxNumber.Location = new Point(59, 135);
maskedTextBoxNumber.Margin = new Padding(3, 4, 3, 4);
maskedTextBoxNumber.Name = "maskedTextBoxNumber"; maskedTextBoxNumber.Name = "maskedTextBoxNumber";
maskedTextBoxNumber.Size = new Size(100, 23); maskedTextBoxNumber.Size = new Size(114, 27);
maskedTextBoxNumber.TabIndex = 4; maskedTextBoxNumber.TabIndex = 4;
// //
// buttonRefreshCollection // buttonRefreshCollection
// //
buttonRefreshCollection.Location = new Point(6, 224); buttonRefreshCollection.Location = new Point(7, 299);
buttonRefreshCollection.Margin = new Padding(3, 4, 3, 4);
buttonRefreshCollection.Name = "buttonRefreshCollection"; buttonRefreshCollection.Name = "buttonRefreshCollection";
buttonRefreshCollection.Size = new Size(188, 33); buttonRefreshCollection.Size = new Size(215, 44);
buttonRefreshCollection.TabIndex = 3; buttonRefreshCollection.TabIndex = 3;
buttonRefreshCollection.Text = "Обновить коллекцию"; buttonRefreshCollection.Text = "Обновить коллекцию";
buttonRefreshCollection.UseVisualStyleBackColor = true; buttonRefreshCollection.UseVisualStyleBackColor = true;
@ -70,9 +74,10 @@
// //
// buttonRemoveTruck // buttonRemoveTruck
// //
buttonRemoveTruck.Location = new Point(6, 130); buttonRemoveTruck.Location = new Point(7, 173);
buttonRemoveTruck.Margin = new Padding(3, 4, 3, 4);
buttonRemoveTruck.Name = "buttonRemoveTruck"; buttonRemoveTruck.Name = "buttonRemoveTruck";
buttonRemoveTruck.Size = new Size(188, 34); buttonRemoveTruck.Size = new Size(215, 45);
buttonRemoveTruck.TabIndex = 2; buttonRemoveTruck.TabIndex = 2;
buttonRemoveTruck.Text = "Удалить грузовик"; buttonRemoveTruck.Text = "Удалить грузовик";
buttonRemoveTruck.UseVisualStyleBackColor = true; buttonRemoveTruck.UseVisualStyleBackColor = true;
@ -80,9 +85,10 @@
// //
// buttonAddTruck // buttonAddTruck
// //
buttonAddTruck.Location = new Point(6, 22); buttonAddTruck.Location = new Point(7, 29);
buttonAddTruck.Margin = new Padding(3, 4, 3, 4);
buttonAddTruck.Name = "buttonAddTruck"; buttonAddTruck.Name = "buttonAddTruck";
buttonAddTruck.Size = new Size(188, 31); buttonAddTruck.Size = new Size(215, 41);
buttonAddTruck.TabIndex = 1; buttonAddTruck.TabIndex = 1;
buttonAddTruck.Text = "Добавить грузовик"; buttonAddTruck.Text = "Добавить грузовик";
buttonAddTruck.UseVisualStyleBackColor = true; buttonAddTruck.UseVisualStyleBackColor = true;
@ -90,19 +96,21 @@
// //
// pictureBoxCollection // pictureBoxCollection
// //
pictureBoxCollection.Location = new Point(12, 12); pictureBoxCollection.Location = new Point(12, 16);
pictureBoxCollection.Margin = new Padding(3, 4, 3, 4);
pictureBoxCollection.Name = "pictureBoxCollection"; pictureBoxCollection.Name = "pictureBoxCollection";
pictureBoxCollection.Size = new Size(570, 426); pictureBoxCollection.Size = new Size(651, 568);
pictureBoxCollection.TabIndex = 1; pictureBoxCollection.TabIndex = 1;
pictureBoxCollection.TabStop = false; pictureBoxCollection.TabStop = false;
// //
// FormTruckCollection // FormTruckCollection
// //
AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font; AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 450); ClientSize = new Size(935, 593);
Controls.Add(pictureBoxCollection); Controls.Add(pictureBoxCollection);
Controls.Add(groupBox1); Controls.Add(groupBox1);
Margin = new Padding(3, 4, 3, 4);
Name = "FormTruckCollection"; Name = "FormTruckCollection";
Text = "Набор грузовиков"; Text = "Набор грузовиков";
groupBox1.ResumeLayout(false); groupBox1.ResumeLayout(false);

View File

@ -7,6 +7,7 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
using System.Xml;
using DumpTruck.DrawningObjects; using DumpTruck.DrawningObjects;
using DumpTruck.Generics; using DumpTruck.Generics;
using DumpTruck.MovementStrategy; using DumpTruck.MovementStrategy;
@ -47,16 +48,20 @@ namespace DumpTruck
private void buttonRemoveTruck_Click(object sender, EventArgs e) private void buttonRemoveTruck_Click(object sender, EventArgs e)
{ {
if (MessageBox.Show("Удалить объект?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) if (MessageBox.Show("Удалить объект?", "Удаление",
MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
{ {
return; return;
} }
int pos = Convert.ToInt32(maskedTextBoxNumber.Text); int pos = Convert.ToInt32(maskedTextBoxNumber.Text);
if (_trucks - pos) if (_trucks - pos)
{ {
MessageBox.Show("Объект удален"); MessageBox.Show("Объект удален");
pictureBoxCollection.Image = _trucks.ShowTrucks(); pictureBoxCollection.Image = _trucks.ShowTrucks();
} }
else else
{ {
MessageBox.Show("Не удалось удалить объект"); MessageBox.Show("Не удалось удалить объект");

View File

@ -23,11 +23,11 @@ namespace DumpTruck.Generics
/// <summary> /// <summary>
/// Размер занимаемого объектом места (ширина) /// Размер занимаемого объектом места (ширина)
/// </summary> /// </summary>
private readonly int _placeSizeWidth = 110; private readonly int _placeSizeWidth = 140;
/// <summary> /// <summary>
/// Размер занимаемого объектом места (высота) /// Размер занимаемого объектом места (высота)
/// </summary> /// </summary>
private readonly int _placeSizeHeight = 70; private readonly int _placeSizeHeight = 100;
/// <summary> /// <summary>
/// Набор объектов /// Набор объектов
/// </summary> /// </summary>