diff --git a/Sailboat/Sailboat/FormBoatCollection.Designer.cs b/Sailboat/Sailboat/FormBoatCollection.Designer.cs new file mode 100644 index 0000000..ce5a7c0 --- /dev/null +++ b/Sailboat/Sailboat/FormBoatCollection.Designer.cs @@ -0,0 +1,124 @@ +namespace Sailboat +{ + partial class FormBoatCollection + { + /// + /// 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() + { + pictureBoxCollection = new PictureBox(); + buttonAddBoat = new Button(); + buttonRemoveBoat = new Button(); + buttonRefreshCollection = new Button(); + maskedTextBoxNumber = new MaskedTextBox(); + groupBoxTools = new GroupBox(); + ((System.ComponentModel.ISupportInitialize)pictureBoxCollection).BeginInit(); + groupBoxTools.SuspendLayout(); + SuspendLayout(); + // + // pictureBoxCollection + // + pictureBoxCollection.Dock = DockStyle.Fill; + pictureBoxCollection.Location = new Point(0, 0); + pictureBoxCollection.Name = "pictureBoxCollection"; + pictureBoxCollection.Size = new Size(800, 450); + pictureBoxCollection.TabIndex = 0; + pictureBoxCollection.TabStop = false; + // + // buttonAddBoat + // + buttonAddBoat.Location = new Point(6, 26); + buttonAddBoat.Name = "buttonAddBoat"; + buttonAddBoat.Size = new Size(238, 45); + buttonAddBoat.TabIndex = 1; + buttonAddBoat.Text = "Добавить лодку"; + buttonAddBoat.UseVisualStyleBackColor = true; + buttonAddBoat.Click += buttonAddBoat_Click; + // + // buttonRemoveBoat + // + buttonRemoveBoat.Location = new Point(6, 145); + buttonRemoveBoat.Name = "buttonRemoveBoat"; + buttonRemoveBoat.Size = new Size(238, 45); + buttonRemoveBoat.TabIndex = 2; + buttonRemoveBoat.Text = "Удалить лодку"; + buttonRemoveBoat.UseVisualStyleBackColor = true; + buttonRemoveBoat.Click += buttonRemoveBoat_Click; + // + // buttonRefreshCollection + // + buttonRefreshCollection.Location = new Point(6, 227); + buttonRefreshCollection.Name = "buttonRefreshCollection"; + buttonRefreshCollection.Size = new Size(238, 45); + buttonRefreshCollection.TabIndex = 3; + buttonRefreshCollection.Text = "Обновить коллекцию"; + buttonRefreshCollection.UseVisualStyleBackColor = true; + buttonRefreshCollection.Click += buttonRefreshCollection_Click; + // + // maskedTextBoxNumber + // + maskedTextBoxNumber.Location = new Point(69, 112); + maskedTextBoxNumber.Name = "maskedTextBoxNumber"; + maskedTextBoxNumber.Size = new Size(125, 27); + maskedTextBoxNumber.TabIndex = 4; + // + // groupBoxTools + // + groupBoxTools.Controls.Add(buttonAddBoat); + groupBoxTools.Controls.Add(buttonRefreshCollection); + groupBoxTools.Controls.Add(maskedTextBoxNumber); + groupBoxTools.Controls.Add(buttonRemoveBoat); + groupBoxTools.Location = new Point(538, 12); + groupBoxTools.Name = "groupBoxTools"; + groupBoxTools.Size = new Size(250, 426); + groupBoxTools.TabIndex = 2; + groupBoxTools.TabStop = false; + groupBoxTools.Text = "Инструменты"; + // + // FormBoatCollection + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(800, 450); + Controls.Add(groupBoxTools); + Controls.Add(pictureBoxCollection); + Name = "FormBoatCollection"; + Text = "FormBoatCollection"; + ((System.ComponentModel.ISupportInitialize)pictureBoxCollection).EndInit(); + groupBoxTools.ResumeLayout(false); + groupBoxTools.PerformLayout(); + ResumeLayout(false); + } + + #endregion + + private PictureBox pictureBoxCollection; + private Button buttonAddBoat; + private Button buttonRemoveBoat; + private Button buttonRefreshCollection; + private MaskedTextBox maskedTextBoxNumber; + private GroupBox groupBoxTools; + } +} \ No newline at end of file diff --git a/Sailboat/Sailboat/FormBoatCollection.cs b/Sailboat/Sailboat/FormBoatCollection.cs new file mode 100644 index 0000000..fffacea --- /dev/null +++ b/Sailboat/Sailboat/FormBoatCollection.cs @@ -0,0 +1,66 @@ +using Sailboat.DrawingObjects; +using Sailboat.Generics; +using Sailboat.MovementStrategy; +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; + +namespace Sailboat +{ + public partial class FormBoatCollection : Form + { + private readonly BoatsGenericCollection _boats; + public FormBoatCollection() + { + InitializeComponent(); + _boats = new BoatsGenericCollection(pictureBoxCollection.Width, pictureBoxCollection.Height); + } + + private void buttonAddBoat_Click(object sender, EventArgs e) + { + FormSailboat form = new(); + if (form.ShowDialog() == DialogResult.OK) + { + if (_boats + form.SelectedBoat != -1) + { + MessageBox.Show("Объект добавлен"); + pictureBoxCollection.Image = _boats.ShowBoats(); + } + else + { + MessageBox.Show("Не удалось добавить объект"); + } + } + } + + private void buttonRemoveBoat_Click(object sender, EventArgs e) + { + if (MessageBox.Show("Удалить объект?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) + { + return; + } + int pos = Convert.ToInt32(maskedTextBoxNumber.Text); + if (_boats - pos != null) + { + MessageBox.Show("Объект удален"); + pictureBoxCollection.Image = _boats.ShowBoats(); + } + else + { + MessageBox.Show("Не удалось удалить объект"); + } + + } + + private void buttonRefreshCollection_Click(object sender, EventArgs e) + { + pictureBoxCollection.Image = _boats.ShowBoats(); + } + } +} diff --git a/Sailboat/Sailboat/FormBoatCollection.resx b/Sailboat/Sailboat/FormBoatCollection.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/Sailboat/Sailboat/FormBoatCollection.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