Полностью готовая Lab_6

This commit is contained in:
Максим Егоров 2024-07-30 16:22:44 +03:00
parent daddb88352
commit 62a2bf7716
3 changed files with 162 additions and 150 deletions

View File

@ -37,8 +37,10 @@ namespace Sailboat.Generics
/// Набор объектов /// Набор объектов
/// </summary> /// </summary>
private readonly SetGeneric<T> _collection; private readonly SetGeneric<T> _collection;
internal IEnumerable<DrawingBoat> GetBoats; /// <summary>
/// Получение объектов коллекции
/// </summary>
public IEnumerable<T?> GetBoats => _collection.GetBoats();
/// <summary> /// <summary>
/// Конструктор /// Конструктор
/// </summary> /// </summary>
@ -49,7 +51,7 @@ namespace Sailboat.Generics
int width = picWidth / _placeSizeWidth; int width = picWidth / _placeSizeWidth;
int height = picHeight / _placeSizeHeight; int height = picHeight / _placeSizeHeight;
_pictureWidth = picWidth; _pictureWidth = picWidth;
_pictureHeight = picHeight - 0; _pictureHeight = picHeight;
_collection = new SetGeneric<T>(width * height); _collection = new SetGeneric<T>(width * height);
} }
/// <summary> /// <summary>
@ -135,6 +137,8 @@ namespace Sailboat.Generics
if (boat != null) if (boat != null)
{ {
int width = _pictureWidth / _placeSizeWidth; int width = _pictureWidth / _placeSizeWidth;
boat._pictureWidth = _pictureWidth;
boat._pictureHeight = _pictureHeight;
boat.SetPosition(i % width * _placeSizeWidth, i / width * _placeSizeHeight); boat.SetPosition(i % width * _placeSizeWidth, i / width * _placeSizeHeight);
boat.DrawTransport(g); boat.DrawTransport(g);
} }
@ -142,4 +146,4 @@ namespace Sailboat.Generics
} }
} }
} }
} }

View File

@ -12,8 +12,8 @@ namespace Sailboat.DrawingObjects
public class DrawingBoat public class DrawingBoat
{ {
public EntityBoat? EntityBoat { get; protected set; } public EntityBoat? EntityBoat { get; protected set; }
private int _pictureWidth; public int _pictureWidth;
private int _pictureHeight; public int _pictureHeight;
protected int _startPosX; protected int _startPosX;
protected int _startPosY; protected int _startPosY;
private readonly int _boatWidth = 160; private readonly int _boatWidth = 160;

View File

@ -28,207 +28,215 @@
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
this.pictureBoxCollection = new System.Windows.Forms.PictureBox(); pictureBoxCollection = new PictureBox();
this.panelTools = new System.Windows.Forms.Panel(); panelTools = new Panel();
this.panelCollection = new System.Windows.Forms.Panel(); panelCollection = new Panel();
this.buttonDelObject = new System.Windows.Forms.Button(); buttonDelObject = new Button();
this.listBoxStorages = new System.Windows.Forms.ListBox(); listBoxStorages = new ListBox();
this.buttonAddObject = new System.Windows.Forms.Button(); buttonAddObject = new Button();
this.textBoxStorageName = new System.Windows.Forms.TextBox(); textBoxStorageName = new TextBox();
this.maskedTextBoxNumber = new System.Windows.Forms.MaskedTextBox(); maskedTextBoxNumber = new MaskedTextBox();
this.buttonRefreshCollection = new System.Windows.Forms.Button(); buttonRefreshCollection = new Button();
this.buttonRemoveBoat = new System.Windows.Forms.Button(); buttonRemoveBoat = new Button();
this.buttonAddBoat = new System.Windows.Forms.Button(); buttonAddBoat = new Button();
this.menuStrip = new System.Windows.Forms.MenuStrip(); menuStrip = new MenuStrip();
this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); toolStripMenuItem1 = new ToolStripMenuItem();
this.ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); ToolStripMenuItem = new ToolStripMenuItem();
this.SaveToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); SaveToolStripMenuItem = new ToolStripMenuItem();
this.LoadToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); LoadToolStripMenuItem = new ToolStripMenuItem();
this.openFileDialog = new System.Windows.Forms.OpenFileDialog(); openFileDialog = new OpenFileDialog();
this.saveFileDialog = new System.Windows.Forms.SaveFileDialog(); saveFileDialog = new SaveFileDialog();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxCollection)).BeginInit(); ((System.ComponentModel.ISupportInitialize)pictureBoxCollection).BeginInit();
this.panelTools.SuspendLayout(); panelTools.SuspendLayout();
this.panelCollection.SuspendLayout(); panelCollection.SuspendLayout();
this.menuStrip.SuspendLayout(); menuStrip.SuspendLayout();
this.SuspendLayout(); SuspendLayout();
// //
// pictureBoxCollection // pictureBoxCollection
// //
this.pictureBoxCollection.Location = new System.Drawing.Point(0, 0); pictureBoxCollection.Location = new Point(0, 0);
this.pictureBoxCollection.Name = "pictureBoxCollection"; pictureBoxCollection.Margin = new Padding(3, 2, 3, 2);
this.pictureBoxCollection.Size = new System.Drawing.Size(750, 600); pictureBoxCollection.Name = "pictureBoxCollection";
this.pictureBoxCollection.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize; pictureBoxCollection.Size = new Size(750, 600);
this.pictureBoxCollection.TabIndex = 0; pictureBoxCollection.SizeMode = PictureBoxSizeMode.AutoSize;
this.pictureBoxCollection.TabStop = false; pictureBoxCollection.TabIndex = 0;
pictureBoxCollection.TabStop = false;
// //
// panelTools // panelTools
// //
this.panelTools.BackColor = System.Drawing.SystemColors.ScrollBar; panelTools.BackColor = SystemColors.ScrollBar;
this.panelTools.Controls.Add(this.panelCollection); panelTools.Controls.Add(panelCollection);
this.panelTools.Controls.Add(this.maskedTextBoxNumber); panelTools.Controls.Add(maskedTextBoxNumber);
this.panelTools.Controls.Add(this.buttonRefreshCollection); panelTools.Controls.Add(buttonRefreshCollection);
this.panelTools.Controls.Add(this.buttonRemoveBoat); panelTools.Controls.Add(buttonRemoveBoat);
this.panelTools.Controls.Add(this.buttonAddBoat); panelTools.Controls.Add(buttonAddBoat);
this.panelTools.Controls.Add(this.menuStrip); panelTools.Controls.Add(menuStrip);
this.panelTools.Location = new System.Drawing.Point(756, 0); panelTools.Location = new Point(689, 0);
this.panelTools.Name = "panelTools"; panelTools.Margin = new Padding(3, 2, 3, 2);
this.panelTools.Size = new System.Drawing.Size(209, 722); panelTools.Name = "panelTools";
this.panelTools.TabIndex = 1; panelTools.Size = new Size(183, 542);
panelTools.TabIndex = 1;
// //
// panelCollection // panelCollection
// //
this.panelCollection.BackColor = System.Drawing.SystemColors.AppWorkspace; panelCollection.BackColor = SystemColors.AppWorkspace;
this.panelCollection.Controls.Add(this.buttonDelObject); panelCollection.Controls.Add(buttonDelObject);
this.panelCollection.Controls.Add(this.listBoxStorages); panelCollection.Controls.Add(listBoxStorages);
this.panelCollection.Controls.Add(this.buttonAddObject); panelCollection.Controls.Add(buttonAddObject);
this.panelCollection.Controls.Add(this.textBoxStorageName); panelCollection.Controls.Add(textBoxStorageName);
this.panelCollection.Location = new System.Drawing.Point(20, 166); panelCollection.Location = new Point(18, 124);
this.panelCollection.Name = "panelCollection"; panelCollection.Margin = new Padding(3, 2, 3, 2);
this.panelCollection.Size = new System.Drawing.Size(181, 287); panelCollection.Name = "panelCollection";
this.panelCollection.TabIndex = 4; panelCollection.Size = new Size(158, 215);
panelCollection.TabIndex = 4;
// //
// buttonDelObject // buttonDelObject
// //
this.buttonDelObject.Location = new System.Drawing.Point(12, 230); buttonDelObject.Location = new Point(10, 172);
this.buttonDelObject.Name = "buttonDelObject"; buttonDelObject.Margin = new Padding(3, 2, 3, 2);
this.buttonDelObject.Size = new System.Drawing.Size(154, 34); buttonDelObject.Name = "buttonDelObject";
this.buttonDelObject.TabIndex = 5; buttonDelObject.Size = new Size(135, 26);
this.buttonDelObject.Text = "Удалить набор"; buttonDelObject.TabIndex = 5;
this.buttonDelObject.UseVisualStyleBackColor = true; buttonDelObject.Text = "Удалить набор";
this.buttonDelObject.Click += new System.EventHandler(this.buttonDelObject_Click); buttonDelObject.UseVisualStyleBackColor = true;
buttonDelObject.Click += buttonDelObject_Click;
// //
// listBoxStorages // listBoxStorages
// //
this.listBoxStorages.FormattingEnabled = true; listBoxStorages.FormattingEnabled = true;
this.listBoxStorages.ItemHeight = 20; listBoxStorages.ItemHeight = 15;
this.listBoxStorages.Location = new System.Drawing.Point(12, 102); listBoxStorages.Location = new Point(10, 76);
this.listBoxStorages.Name = "listBoxStorages"; listBoxStorages.Margin = new Padding(3, 2, 3, 2);
this.listBoxStorages.Size = new System.Drawing.Size(154, 104); listBoxStorages.Name = "listBoxStorages";
this.listBoxStorages.TabIndex = 6; listBoxStorages.Size = new Size(135, 79);
this.listBoxStorages.SelectedIndexChanged += new System.EventHandler(this.ListBoxObjects_SelectedIndexChanged); listBoxStorages.TabIndex = 6;
listBoxStorages.SelectedIndexChanged += ListBoxObjects_SelectedIndexChanged;
// //
// buttonAddObject // buttonAddObject
// //
this.buttonAddObject.Location = new System.Drawing.Point(12, 62); buttonAddObject.Location = new Point(10, 46);
this.buttonAddObject.Name = "buttonAddObject"; buttonAddObject.Margin = new Padding(3, 2, 3, 2);
this.buttonAddObject.Size = new System.Drawing.Size(154, 34); buttonAddObject.Name = "buttonAddObject";
this.buttonAddObject.TabIndex = 5; buttonAddObject.Size = new Size(135, 26);
this.buttonAddObject.Text = "Добавить набор"; buttonAddObject.TabIndex = 5;
this.buttonAddObject.UseVisualStyleBackColor = true; buttonAddObject.Text = "Добавить набор";
this.buttonAddObject.Click += new System.EventHandler(this.buttonAddObject_Click); buttonAddObject.UseVisualStyleBackColor = true;
buttonAddObject.Click += buttonAddObject_Click;
// //
// textBoxStorageName // textBoxStorageName
// //
this.textBoxStorageName.Location = new System.Drawing.Point(29, 29); textBoxStorageName.Location = new Point(25, 22);
this.textBoxStorageName.Name = "textBoxStorageName"; textBoxStorageName.Margin = new Padding(3, 2, 3, 2);
this.textBoxStorageName.Size = new System.Drawing.Size(125, 27); textBoxStorageName.Name = "textBoxStorageName";
this.textBoxStorageName.TabIndex = 0; textBoxStorageName.Size = new Size(110, 23);
textBoxStorageName.TabIndex = 0;
// //
// maskedTextBoxNumber // maskedTextBoxNumber
// //
this.maskedTextBoxNumber.Location = new System.Drawing.Point(49, 567); maskedTextBoxNumber.Location = new Point(43, 425);
this.maskedTextBoxNumber.Name = "maskedTextBoxNumber"; maskedTextBoxNumber.Margin = new Padding(3, 2, 3, 2);
this.maskedTextBoxNumber.Size = new System.Drawing.Size(125, 27); maskedTextBoxNumber.Name = "maskedTextBoxNumber";
this.maskedTextBoxNumber.TabIndex = 3; maskedTextBoxNumber.Size = new Size(110, 23);
maskedTextBoxNumber.TabIndex = 3;
// //
// buttonRefreshCollection // buttonRefreshCollection
// //
this.buttonRefreshCollection.Location = new System.Drawing.Point(20, 682); buttonRefreshCollection.Location = new Point(18, 512);
this.buttonRefreshCollection.Name = "buttonRefreshCollection"; buttonRefreshCollection.Margin = new Padding(3, 2, 3, 2);
this.buttonRefreshCollection.Size = new System.Drawing.Size(180, 34); buttonRefreshCollection.Name = "buttonRefreshCollection";
this.buttonRefreshCollection.TabIndex = 2; buttonRefreshCollection.Size = new Size(158, 26);
this.buttonRefreshCollection.Text = "Обновить коллекцию"; buttonRefreshCollection.TabIndex = 2;
this.buttonRefreshCollection.UseVisualStyleBackColor = true; buttonRefreshCollection.Text = "Обновить коллекцию";
this.buttonRefreshCollection.Click += new System.EventHandler(this.buttonRefreshCollection_Click); buttonRefreshCollection.UseVisualStyleBackColor = true;
buttonRefreshCollection.Click += buttonRefreshCollection_Click;
// //
// buttonRemoveBoat // buttonRemoveBoat
// //
this.buttonRemoveBoat.Location = new System.Drawing.Point(21, 620); buttonRemoveBoat.Location = new Point(18, 465);
this.buttonRemoveBoat.Name = "buttonRemoveBoat"; buttonRemoveBoat.Margin = new Padding(3, 2, 3, 2);
this.buttonRemoveBoat.Size = new System.Drawing.Size(180, 34); buttonRemoveBoat.Name = "buttonRemoveBoat";
this.buttonRemoveBoat.TabIndex = 1; buttonRemoveBoat.Size = new Size(158, 26);
this.buttonRemoveBoat.Text = "Удалить лодку"; buttonRemoveBoat.TabIndex = 1;
this.buttonRemoveBoat.UseVisualStyleBackColor = true; buttonRemoveBoat.Text = "Удалить лодку";
this.buttonRemoveBoat.Click += new System.EventHandler(this.buttonRemoveBoat_Click); buttonRemoveBoat.UseVisualStyleBackColor = true;
buttonRemoveBoat.Click += buttonRemoveBoat_Click;
// //
// buttonAddBoat // buttonAddBoat
// //
this.buttonAddBoat.Location = new System.Drawing.Point(20, 490); buttonAddBoat.Location = new Point(18, 368);
this.buttonAddBoat.Name = "buttonAddBoat"; buttonAddBoat.Margin = new Padding(3, 2, 3, 2);
this.buttonAddBoat.Size = new System.Drawing.Size(180, 34); buttonAddBoat.Name = "buttonAddBoat";
this.buttonAddBoat.TabIndex = 0; buttonAddBoat.Size = new Size(158, 26);
this.buttonAddBoat.Text = "Добавить лодку"; buttonAddBoat.TabIndex = 0;
this.buttonAddBoat.UseVisualStyleBackColor = true; buttonAddBoat.Text = "Добавить лодку";
this.buttonAddBoat.Click += new System.EventHandler(this.buttonAddBoat_Click); buttonAddBoat.UseVisualStyleBackColor = true;
buttonAddBoat.Click += buttonAddBoat_Click;
// //
// menuStrip // menuStrip
// //
this.menuStrip.ImageScalingSize = new System.Drawing.Size(20, 20); menuStrip.ImageScalingSize = new Size(20, 20);
this.menuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { menuStrip.Items.AddRange(new ToolStripItem[] { toolStripMenuItem1, ToolStripMenuItem });
this.toolStripMenuItem1, menuStrip.Location = new Point(0, 0);
this.ToolStripMenuItem}); menuStrip.Name = "menuStrip";
this.menuStrip.Location = new System.Drawing.Point(0, 0); menuStrip.Padding = new Padding(5, 2, 0, 2);
this.menuStrip.Name = "menuStrip"; menuStrip.Size = new Size(183, 24);
this.menuStrip.Size = new System.Drawing.Size(209, 28); menuStrip.TabIndex = 5;
this.menuStrip.TabIndex = 5;
// //
// toolStripMenuItem1 // toolStripMenuItem1
// //
this.toolStripMenuItem1.Name = "toolStripMenuItem1"; toolStripMenuItem1.Name = "toolStripMenuItem1";
this.toolStripMenuItem1.Size = new System.Drawing.Size(14, 24); toolStripMenuItem1.Size = new Size(12, 20);
// //
// ToolStripMenuItem // ToolStripMenuItem
// //
this.ToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { ToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { SaveToolStripMenuItem, LoadToolStripMenuItem });
this.SaveToolStripMenuItem, ToolStripMenuItem.Name = "ToolStripMenuItem";
this.LoadToolStripMenuItem}); ToolStripMenuItem.Size = new Size(48, 20);
this.ToolStripMenuItem.Name = "ToolStripMenuItem"; ToolStripMenuItem.Text = "Файл";
this.ToolStripMenuItem.Size = new System.Drawing.Size(59, 24);
this.ToolStripMenuItem.Text = "Файл";
// //
// SaveToolStripMenuItem // SaveToolStripMenuItem
// //
this.SaveToolStripMenuItem.Name = "SaveToolStripMenuItem"; SaveToolStripMenuItem.Name = "SaveToolStripMenuItem";
this.SaveToolStripMenuItem.Size = new System.Drawing.Size(224, 26); SaveToolStripMenuItem.Size = new Size(141, 22);
this.SaveToolStripMenuItem.Text = "Сохранение"; SaveToolStripMenuItem.Text = "Сохранение";
this.SaveToolStripMenuItem.Click += new System.EventHandler(this.SaveToolStripMenuItem_Click); SaveToolStripMenuItem.Click += SaveToolStripMenuItem_Click;
// //
// LoadToolStripMenuItem // LoadToolStripMenuItem
// //
this.LoadToolStripMenuItem.Name = "LoadToolStripMenuItem"; LoadToolStripMenuItem.Name = "LoadToolStripMenuItem";
this.LoadToolStripMenuItem.Size = new System.Drawing.Size(224, 26); LoadToolStripMenuItem.Size = new Size(141, 22);
this.LoadToolStripMenuItem.Text = "Загрузка"; LoadToolStripMenuItem.Text = "Загрузка";
this.LoadToolStripMenuItem.Click += new System.EventHandler(this.LoadToolStripMenuItem_Click); LoadToolStripMenuItem.Click += LoadToolStripMenuItem_Click;
// //
// openFileDialog // openFileDialog
// //
this.openFileDialog.FileName = "openFileDialog"; openFileDialog.FileName = "openFileDialog";
this.openFileDialog.Filter = "txt file | *.txt"; openFileDialog.Filter = "txt file | *.txt";
// //
// saveFileDialog // saveFileDialog
// //
this.saveFileDialog.Filter = "txt file | *.txt"; saveFileDialog.Filter = "txt file | *.txt";
// //
// FormBoatCollection // FormBoatCollection
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); AutoScaleDimensions = new SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; AutoScaleMode = AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(969, 728); ClientSize = new Size(884, 546);
this.Controls.Add(this.panelTools); Controls.Add(panelTools);
this.Controls.Add(this.pictureBoxCollection); Controls.Add(pictureBoxCollection);
this.MainMenuStrip = this.menuStrip; MainMenuStrip = menuStrip;
this.Name = "FormBoatCollection"; Margin = new Padding(3, 2, 3, 2);
this.Text = "FormBoatCollection"; Name = "FormBoatCollection";
((System.ComponentModel.ISupportInitialize)(this.pictureBoxCollection)).EndInit(); Text = "FormBoatCollection";
this.panelTools.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)pictureBoxCollection).EndInit();
this.panelTools.PerformLayout(); panelTools.ResumeLayout(false);
this.panelCollection.ResumeLayout(false); panelTools.PerformLayout();
this.panelCollection.PerformLayout(); panelCollection.ResumeLayout(false);
this.menuStrip.ResumeLayout(false); panelCollection.PerformLayout();
this.menuStrip.PerformLayout(); menuStrip.ResumeLayout(false);
this.ResumeLayout(false); menuStrip.PerformLayout();
this.PerformLayout(); ResumeLayout(false);
PerformLayout();
} }
#endregion #endregion