From 6cb1d0eeea5c0aa97b5a38fb81b325f90c784bf5 Mon Sep 17 00:00:00 2001
From: KirillFirsof <117719052+KirillFirsof@users.noreply.github.com>
Date: Thu, 9 Nov 2023 16:30:36 +0400
Subject: [PATCH] =?UTF-8?q?=D0=92=D1=80=D0=BE=D0=B4=D0=B5=20=D0=B2=D1=81?=
=?UTF-8?q?=D0=B5?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../RPP_FirstLaba_Tractor/FormTractor.cs | 22 ++-
.../FormTractorCollection.cs | 134 ++++++++----------
.../TractorsGenericCollection.cs | 11 +-
3 files changed, 82 insertions(+), 85 deletions(-)
diff --git a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/FormTractor.cs b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/FormTractor.cs
index 7bd9091..f0055aa 100644
--- a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/FormTractor.cs
+++ b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/FormTractor.cs
@@ -24,6 +24,8 @@ namespace ProjectTractor
/// -
///
private DrawningTractor? _drawningTractor;
+ private Button ButtonSelectTractor;
+
///
///
///
@@ -175,7 +177,7 @@ namespace ProjectTractor
///
///
///
- private void ButtonSelectCar_Click(object sender, EventArgs e)
+ private void ButtonSelectTractor_Click(object sender, EventArgs e)
{
SelectedTractor = _drawningTractor;
DialogResult = DialogResult.OK;
@@ -192,6 +194,7 @@ namespace ProjectTractor
this.buttonCreateBulldoserTractor = new System.Windows.Forms.Button();
this.buttonStep = new System.Windows.Forms.Button();
this.comboBoxStrategy = new System.Windows.Forms.ComboBox();
+ this.ButtonSelectTractor = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxTractor)).BeginInit();
this.SuspendLayout();
//
@@ -299,9 +302,21 @@ namespace ProjectTractor
this.comboBoxStrategy.Size = new System.Drawing.Size(151, 28);
this.comboBoxStrategy.TabIndex = 8;
//
+ // ButtonSelectTractor
+ //
+ this.ButtonSelectTractor.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
+ this.ButtonSelectTractor.Location = new System.Drawing.Point(469, 403);
+ this.ButtonSelectTractor.Name = "ButtonSelectTractor";
+ this.ButtonSelectTractor.Size = new System.Drawing.Size(199, 29);
+ this.ButtonSelectTractor.TabIndex = 9;
+ this.ButtonSelectTractor.Text = " ";
+ this.ButtonSelectTractor.UseVisualStyleBackColor = true;
+ this.ButtonSelectTractor.Click += new System.EventHandler(this.ButtonSelectTractor_Click);
+ //
// FormTractor
//
this.ClientSize = new System.Drawing.Size(882, 453);
+ this.Controls.Add(this.ButtonSelectTractor);
this.Controls.Add(this.comboBoxStrategy);
this.Controls.Add(this.buttonStep);
this.Controls.Add(this.buttonCreateBulldoserTractor);
@@ -312,7 +327,6 @@ namespace ProjectTractor
this.Controls.Add(this.buttonCreateTractor);
this.Controls.Add(this.pictureBoxTractor);
this.Name = "FormTractor";
- this.Load += new System.EventHandler(this.FormTractor_Load);
((System.ComponentModel.ISupportInitialize)(this.pictureBoxTractor)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
@@ -374,9 +388,5 @@ namespace ProjectTractor
}
}
- private void FormTractor_Load(object sender, EventArgs e)
- {
-
- }
}
}
\ No newline at end of file
diff --git a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/FormTractorCollection.cs b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/FormTractorCollection.cs
index 74c04d8..6b3e486 100644
--- a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/FormTractorCollection.cs
+++ b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/FormTractorCollection.cs
@@ -30,11 +30,7 @@ namespace ProjectTractor
_cars = new TractorsGenericCollection(pictureBoxCollection.Width, pictureBoxCollection.Height);
}
- ///
- /// Добавление объекта в набор
- ///
- ///
- ///
+
private void ButtonAddTractor_Click(object sender, EventArgs e)
{
FormTractor form = new();
@@ -51,6 +47,7 @@ namespace ProjectTractor
}
}
}
+
///
/// Удаление объекта из набора
///
@@ -64,7 +61,7 @@ namespace ProjectTractor
return;
}
int pos = Convert.ToInt32(maskedTextBoxNumber.Text);
- if (_cars - pos != null)
+ if (_cars - pos)
{
MessageBox.Show("Объект удален");
pictureBoxCollection.Image = _cars.ShowCars();
@@ -87,101 +84,94 @@ namespace ProjectTractor
private void InitializeComponent()
{
- this.panelInstruments = new System.Windows.Forms.Panel();
+ this.pictureBoxCollection = new System.Windows.Forms.PictureBox();
+ this.groupBox = new System.Windows.Forms.GroupBox();
this.ButtonRefreshCollection = new System.Windows.Forms.Button();
this.ButtonRemoveTractor = new System.Windows.Forms.Button();
this.ButtonAddTractor = new System.Windows.Forms.Button();
this.maskedTextBoxNumber = new System.Windows.Forms.MaskedTextBox();
- this.labelPanelInstrumets = new System.Windows.Forms.Label();
- this.pictureBoxCollection = new System.Windows.Forms.PictureBox();
- this.panelInstruments.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxCollection)).BeginInit();
+ this.groupBox.SuspendLayout();
this.SuspendLayout();
//
- // panelInstruments
- //
- this.panelInstruments.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
- this.panelInstruments.Controls.Add(this.ButtonRefreshCollection);
- this.panelInstruments.Controls.Add(this.ButtonRemoveTractor);
- this.panelInstruments.Controls.Add(this.ButtonAddTractor);
- this.panelInstruments.Controls.Add(this.maskedTextBoxNumber);
- this.panelInstruments.Controls.Add(this.labelPanelInstrumets);
- this.panelInstruments.Location = new System.Drawing.Point(657, 7);
- this.panelInstruments.Name = "panelInstruments";
- this.panelInstruments.Size = new System.Drawing.Size(228, 422);
- this.panelInstruments.TabIndex = 0;
- //
- // ButtonRefreshCollection
- //
- this.ButtonRefreshCollection.Location = new System.Drawing.Point(8, 334);
- this.ButtonRefreshCollection.Name = "ButtonRefreshCollection";
- this.ButtonRefreshCollection.Size = new System.Drawing.Size(211, 35);
- this.ButtonRefreshCollection.TabIndex = 4;
- this.ButtonRefreshCollection.Text = "Обновить коллекцию";
- this.ButtonRefreshCollection.UseVisualStyleBackColor = true;
- //
- // ButtonRemoveTractor
- //
- this.ButtonRemoveTractor.Location = new System.Drawing.Point(16, 159);
- this.ButtonRemoveTractor.Name = "ButtonRemoveTractor";
- this.ButtonRemoveTractor.Size = new System.Drawing.Size(203, 33);
- this.ButtonRemoveTractor.TabIndex = 3;
- this.ButtonRemoveTractor.Text = "Удалить трактор";
- this.ButtonRemoveTractor.UseVisualStyleBackColor = true;
- //
- // ButtonAddTractor
- //
- this.ButtonAddTractor.Location = new System.Drawing.Point(16, 49);
- this.ButtonAddTractor.Name = "ButtonAddTractor";
- this.ButtonAddTractor.Size = new System.Drawing.Size(203, 34);
- this.ButtonAddTractor.TabIndex = 2;
- this.ButtonAddTractor.Text = "Добавить трактор";
- this.ButtonAddTractor.UseVisualStyleBackColor = true;
- //
- // maskedTextBoxNumber
- //
- this.maskedTextBoxNumber.Location = new System.Drawing.Point(16, 116);
- this.maskedTextBoxNumber.Name = "maskedTextBoxNumber";
- this.maskedTextBoxNumber.Size = new System.Drawing.Size(203, 27);
- this.maskedTextBoxNumber.TabIndex = 1;
- //
- // labelPanelInstrumets
- //
- this.labelPanelInstrumets.AutoSize = true;
- this.labelPanelInstrumets.Location = new System.Drawing.Point(8, 13);
- this.labelPanelInstrumets.Name = "labelPanelInstrumets";
- this.labelPanelInstrumets.Size = new System.Drawing.Size(103, 20);
- this.labelPanelInstrumets.TabIndex = 0;
- this.labelPanelInstrumets.Text = "Инструменты";
- //
// pictureBoxCollection
//
this.pictureBoxCollection.Dock = System.Windows.Forms.DockStyle.Left;
this.pictureBoxCollection.Location = new System.Drawing.Point(0, 0);
this.pictureBoxCollection.Name = "pictureBoxCollection";
- this.pictureBoxCollection.Size = new System.Drawing.Size(651, 437);
+ this.pictureBoxCollection.Size = new System.Drawing.Size(620, 437);
this.pictureBoxCollection.TabIndex = 1;
this.pictureBoxCollection.TabStop = false;
//
+ // groupBox
+ //
+ this.groupBox.Controls.Add(this.ButtonRefreshCollection);
+ this.groupBox.Controls.Add(this.ButtonRemoveTractor);
+ this.groupBox.Controls.Add(this.ButtonAddTractor);
+ this.groupBox.Controls.Add(this.maskedTextBoxNumber);
+ this.groupBox.Location = new System.Drawing.Point(626, 12);
+ this.groupBox.Name = "groupBox";
+ this.groupBox.Size = new System.Drawing.Size(255, 413);
+ this.groupBox.TabIndex = 2;
+ this.groupBox.TabStop = false;
+ this.groupBox.Text = "Инструменты";
+ //
+ // ButtonRefreshCollection
+ //
+ this.ButtonRefreshCollection.Location = new System.Drawing.Point(20, 331);
+ this.ButtonRefreshCollection.Name = "ButtonRefreshCollection";
+ this.ButtonRefreshCollection.Size = new System.Drawing.Size(211, 35);
+ this.ButtonRefreshCollection.TabIndex = 8;
+ this.ButtonRefreshCollection.Text = "Обновить коллекцию";
+ this.ButtonRefreshCollection.UseVisualStyleBackColor = true;
+ this.ButtonRefreshCollection.Click += new System.EventHandler(this.ButtonRefreshCollection_Click);
+ //
+ // ButtonRemoveTractor
+ //
+ this.ButtonRemoveTractor.Location = new System.Drawing.Point(28, 156);
+ this.ButtonRemoveTractor.Name = "ButtonRemoveTractor";
+ this.ButtonRemoveTractor.Size = new System.Drawing.Size(203, 33);
+ this.ButtonRemoveTractor.TabIndex = 7;
+ this.ButtonRemoveTractor.Text = "Удалить трактор";
+ this.ButtonRemoveTractor.UseVisualStyleBackColor = true;
+ this.ButtonRemoveTractor.Click += new System.EventHandler(this.ButtonRemoveTractor_Click);
+ //
+ // ButtonAddTractor
+ //
+ this.ButtonAddTractor.Location = new System.Drawing.Point(28, 46);
+ this.ButtonAddTractor.Name = "ButtonAddTractor";
+ this.ButtonAddTractor.Size = new System.Drawing.Size(203, 34);
+ this.ButtonAddTractor.TabIndex = 6;
+ this.ButtonAddTractor.Text = "Добавить трактор";
+ this.ButtonAddTractor.UseVisualStyleBackColor = true;
+ this.ButtonAddTractor.Click += new System.EventHandler(this.ButtonAddTractor_Click);
+ //
+ // maskedTextBoxNumber
+ //
+ this.maskedTextBoxNumber.Location = new System.Drawing.Point(28, 113);
+ this.maskedTextBoxNumber.Name = "maskedTextBoxNumber";
+ this.maskedTextBoxNumber.Size = new System.Drawing.Size(203, 27);
+ this.maskedTextBoxNumber.TabIndex = 5;
+ //
// FormTractorCollection
//
this.ClientSize = new System.Drawing.Size(893, 437);
+ this.Controls.Add(this.groupBox);
this.Controls.Add(this.pictureBoxCollection);
- this.Controls.Add(this.panelInstruments);
this.Name = "FormTractorCollection";
- this.panelInstruments.ResumeLayout(false);
- this.panelInstruments.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxCollection)).EndInit();
+ this.groupBox.ResumeLayout(false);
+ this.groupBox.PerformLayout();
this.ResumeLayout(false);
}
- private Panel panelInstruments;
+ private GroupBox groupBox;
private Button ButtonRefreshCollection;
private Button ButtonRemoveTractor;
private Button ButtonAddTractor;
private MaskedTextBox maskedTextBoxNumber;
- private Label labelPanelInstrumets;
private PictureBox pictureBoxCollection;
+
}
}
diff --git a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/TractorsGenericCollection.cs b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/TractorsGenericCollection.cs
index 46f2036..2bec09d 100644
--- a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/TractorsGenericCollection.cs
+++ b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/TractorsGenericCollection.cs
@@ -71,14 +71,14 @@ namespace ProjectTractor.Generics
///
///
///
- public static T? operator -(TractorsGenericCollection collect, int pos)
+ public static bool operator -(TractorsGenericCollection collect, int pos)
{
T? obj = collect._collection.Get(pos);
if (obj != null)
{
collect._collection.Remove(pos);
}
- return obj;
+ return true;
}
///
/// Получение объекта IMoveableObject
@@ -132,13 +132,10 @@ namespace ProjectTractor.Generics
DrawningTractor? tractor = _collection.Get(i);
if (tractor != null)
{
- int inRow = _pictureWidth / _placeSizeWidth;
- tractor.SetPosition(_pictureWidth - _placeSizeWidth - (i % inRow * _placeSizeWidth) - _placeSizeHeight / 2 - 8, i / inRow * _placeSizeHeight + 20);
+ int countRows = _pictureWidth / _placeSizeWidth;
+ tractor.SetPosition(_pictureWidth - _placeSizeWidth*2 - (i % countRows * _placeSizeWidth) + 20, _pictureHeight - i / countRows * _placeSizeHeight - 150);
tractor.DrawTransport(g);
}
- // TODO получение объекта
- // TODO установка позиции
- // TODO прорисовка объекта
}
}
}