diff --git a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/FormTractorCollection.Designer.cs b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/FormTractorCollection.Designer.cs deleted file mode 100644 index baa946f..0000000 --- a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/FormTractorCollection.Designer.cs +++ /dev/null @@ -1,146 +0,0 @@ -namespace ProjectTractor -{ - partial class FormTractorCollection - { - /// - /// 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() - { - this.splitContainer1 = new System.Windows.Forms.SplitContainer(); - this.pictureBox1 = new System.Windows.Forms.PictureBox(); - this.labelPanelInstuments = new System.Windows.Forms.Label(); - this.maskedTextBoxNumber = new System.Windows.Forms.MaskedTextBox(); - this.button1 = new System.Windows.Forms.Button(); - this.button2 = new System.Windows.Forms.Button(); - this.button3 = new System.Windows.Forms.Button(); - ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); - this.splitContainer1.Panel1.SuspendLayout(); - this.splitContainer1.Panel2.SuspendLayout(); - this.splitContainer1.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); - this.SuspendLayout(); - // - // splitContainer1 - // - this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill; - this.splitContainer1.Location = new System.Drawing.Point(0, 0); - this.splitContainer1.Name = "splitContainer1"; - // - // splitContainer1.Panel1 - // - this.splitContainer1.Panel1.Controls.Add(this.pictureBox1); - // - // splitContainer1.Panel2 - // - this.splitContainer1.Panel2.Controls.Add(this.button3); - this.splitContainer1.Panel2.Controls.Add(this.button2); - this.splitContainer1.Panel2.Controls.Add(this.button1); - this.splitContainer1.Panel2.Controls.Add(this.maskedTextBoxNumber); - this.splitContainer1.Panel2.Controls.Add(this.labelPanelInstuments); - this.splitContainer1.Size = new System.Drawing.Size(800, 450); - this.splitContainer1.SplitterDistance = 591; - this.splitContainer1.TabIndex = 0; - // - // pictureBox1 - // - this.pictureBox1.Dock = System.Windows.Forms.DockStyle.Fill; - this.pictureBox1.Location = new System.Drawing.Point(0, 0); - this.pictureBox1.Name = "pictureBox1"; - this.pictureBox1.Size = new System.Drawing.Size(591, 450); - this.pictureBox1.TabIndex = 0; - this.pictureBox1.TabStop = false; - // - // labelPanelInstuments - // - this.labelPanelInstuments.AutoSize = true; - this.labelPanelInstuments.Location = new System.Drawing.Point(8, 9); - this.labelPanelInstuments.Name = "labelPanelInstuments"; - this.labelPanelInstuments.Size = new System.Drawing.Size(103, 20); - this.labelPanelInstuments.TabIndex = 0; - this.labelPanelInstuments.Text = "Инструменты"; - // - // maskedTextBoxNumber - // - this.maskedTextBoxNumber.Location = new System.Drawing.Point(8, 146); - this.maskedTextBoxNumber.Name = "maskedTextBoxNumber"; - this.maskedTextBoxNumber.Size = new System.Drawing.Size(185, 27); - this.maskedTextBoxNumber.TabIndex = 1; - // - // button1 - // - this.button1.Location = new System.Drawing.Point(8, 54); - this.button1.Name = "button1"; - this.button1.Size = new System.Drawing.Size(185, 40); - this.button1.TabIndex = 2; - this.button1.Text = "Добавить трактор"; - this.button1.UseVisualStyleBackColor = true; - // - // button2 - // - this.button2.Location = new System.Drawing.Point(8, 179); - this.button2.Name = "button2"; - this.button2.Size = new System.Drawing.Size(185, 36); - this.button2.TabIndex = 3; - this.button2.Text = "Удалить трактор"; - this.button2.UseVisualStyleBackColor = true; - // - // button3 - // - this.button3.Location = new System.Drawing.Point(8, 376); - this.button3.Name = "button3"; - this.button3.Size = new System.Drawing.Size(185, 42); - this.button3.TabIndex = 4; - this.button3.Text = "Обновить коллекцию"; - this.button3.UseVisualStyleBackColor = true; - // - // FormTractorCollection - // - this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(800, 450); - this.Controls.Add(this.splitContainer1); - this.Name = "FormTractorCollection"; - this.Text = "FormTractorCollection"; - this.splitContainer1.Panel1.ResumeLayout(false); - this.splitContainer1.Panel2.ResumeLayout(false); - this.splitContainer1.Panel2.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit(); - this.splitContainer1.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); - this.ResumeLayout(false); - - } - - #endregion - - private SplitContainer splitContainer1; - private PictureBox pictureBox1; - private Button button3; - private Button button2; - private Button button1; - private MaskedTextBox maskedTextBoxNumber; - private Label labelPanelInstuments; - } -} \ 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 6ed2112..74c04d8 100644 --- a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/FormTractorCollection.cs +++ b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/FormTractorCollection.cs @@ -7,14 +7,181 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; +using ProjectTractor.DrawningObjects; +using ProjectTractor.Generics; +using ProjectTractor.MovementStrategy; namespace ProjectTractor { public partial class FormTractorCollection : Form - { + { + + /// + /// Набор объектов + /// + private readonly TractorsGenericCollection _cars; + /// + /// Конструктор + /// public FormTractorCollection() { InitializeComponent(); + _cars = new TractorsGenericCollection(pictureBoxCollection.Width, pictureBoxCollection.Height); } + /// + /// Добавление объекта в набор + /// + /// + /// + private void ButtonAddTractor_Click(object sender, EventArgs e) + { + FormTractor form = new(); + if (form.ShowDialog() == DialogResult.OK) + { + if (_cars + form.SelectedTractor) + { + MessageBox.Show("Объект добавлен"); + pictureBoxCollection.Image = _cars.ShowCars(); + } + else + { + MessageBox.Show("Не удалось добавить объект"); + } + } + } + /// + /// Удаление объекта из набора + /// + /// + /// + private void ButtonRemoveTractor_Click(object sender, EventArgs e) + { + if (MessageBox.Show("Удалить объект?", "Удаление", + MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) + { + return; + } + int pos = Convert.ToInt32(maskedTextBoxNumber.Text); + if (_cars - pos != null) + { + MessageBox.Show("Объект удален"); + pictureBoxCollection.Image = _cars.ShowCars(); + } + else + { + MessageBox.Show("Не удалось удалить объект"); + } + } + /// + /// Обновление рисунка по набору + /// + /// + /// + private void ButtonRefreshCollection_Click(object sender, EventArgs + e) + { + pictureBoxCollection.Image = _cars.ShowCars(); + } + + private void InitializeComponent() + { + this.panelInstruments = new System.Windows.Forms.Panel(); + 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.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.TabIndex = 1; + this.pictureBoxCollection.TabStop = false; + // + // FormTractorCollection + // + this.ClientSize = new System.Drawing.Size(893, 437); + 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.ResumeLayout(false); + + } + + private Panel panelInstruments; + 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/Program.cs b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/Program.cs index 61dbba1..56558ed 100644 --- a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/Program.cs +++ b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/Program.cs @@ -11,7 +11,7 @@ namespace ProjectTractor // To customize application configuration such as set high DPI settings or default font, // see https://aka.ms/applicationconfiguration. ApplicationConfiguration.Initialize(); - Application.Run(new FormTractor()); + Application.Run(new FormTractorCollection()); } } } \ No newline at end of file diff --git a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/SetGeneric.cs b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/SetGeneric.cs index ee4787f..4ce7be5 100644 --- a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/SetGeneric.cs +++ b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/SetGeneric.cs @@ -40,7 +40,6 @@ namespace ProjectTractor.Generics { Insert(tractor, 0); } - // TODO вставка в начало набора return true; } /// @@ -80,8 +79,6 @@ namespace ProjectTractor.Generics } _places[position] = null; return true; - // TODO проверка позиции - // TODO удаление объекта из массива, присвоив элементу массива значение null } /// /// Получение объекта из набора по позиции @@ -94,7 +91,6 @@ namespace ProjectTractor.Generics { return null; } - // TODO проверка позиции return _places[position]; } }