Создала вторую формочку
This commit is contained in:
parent
38b8cbf1fc
commit
1f59d32cf7
122
WarmlyShip/WarmlyShip/FormShipCollection.Designer.cs
generated
Normal file
122
WarmlyShip/WarmlyShip/FormShipCollection.Designer.cs
generated
Normal file
@ -0,0 +1,122 @@
|
||||
namespace WarmlyShip
|
||||
{
|
||||
partial class FormShipCollection
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.pictureBoxCollection = new System.Windows.Forms.PictureBox();
|
||||
this.panelCollection = new System.Windows.Forms.Panel();
|
||||
this.buttonRefreshCollection = new System.Windows.Forms.Button();
|
||||
this.buttonRemoveShip = new System.Windows.Forms.Button();
|
||||
this.maskedTextBoxNumber = new System.Windows.Forms.TextBox();
|
||||
this.buttonAddShip = new System.Windows.Forms.Button();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxCollection)).BeginInit();
|
||||
this.panelCollection.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// pictureBoxCollection
|
||||
//
|
||||
this.pictureBoxCollection.Location = new System.Drawing.Point(0, 0);
|
||||
this.pictureBoxCollection.Name = "pictureBoxCollection";
|
||||
this.pictureBoxCollection.Size = new System.Drawing.Size(700, 453);
|
||||
this.pictureBoxCollection.TabIndex = 0;
|
||||
this.pictureBoxCollection.TabStop = false;
|
||||
//
|
||||
// panelCollection
|
||||
//
|
||||
this.panelCollection.Controls.Add(this.buttonRefreshCollection);
|
||||
this.panelCollection.Controls.Add(this.buttonRemoveShip);
|
||||
this.panelCollection.Controls.Add(this.maskedTextBoxNumber);
|
||||
this.panelCollection.Controls.Add(this.buttonAddShip);
|
||||
this.panelCollection.Location = new System.Drawing.Point(699, 0);
|
||||
this.panelCollection.Name = "panelCollection";
|
||||
this.panelCollection.Size = new System.Drawing.Size(218, 453);
|
||||
this.panelCollection.TabIndex = 1;
|
||||
//
|
||||
// buttonRefreshCollection
|
||||
//
|
||||
this.buttonRefreshCollection.Location = new System.Drawing.Point(16, 239);
|
||||
this.buttonRefreshCollection.Name = "buttonRefreshCollection";
|
||||
this.buttonRefreshCollection.Size = new System.Drawing.Size(171, 40);
|
||||
this.buttonRefreshCollection.TabIndex = 5;
|
||||
this.buttonRefreshCollection.Text = "Обновить коллекцию";
|
||||
this.buttonRefreshCollection.UseVisualStyleBackColor = true;
|
||||
this.buttonRefreshCollection.Click += new System.EventHandler(this.ButtonRefreshCollection_Click);
|
||||
//
|
||||
// buttonRemoveShip
|
||||
//
|
||||
this.buttonRemoveShip.Location = new System.Drawing.Point(16, 166);
|
||||
this.buttonRemoveShip.Name = "buttonRemoveShip";
|
||||
this.buttonRemoveShip.Size = new System.Drawing.Size(171, 40);
|
||||
this.buttonRemoveShip.TabIndex = 4;
|
||||
this.buttonRemoveShip.Text = "Удалить теплоход";
|
||||
this.buttonRemoveShip.UseVisualStyleBackColor = true;
|
||||
this.buttonRemoveShip.Click += new System.EventHandler(this.ButtonRemoveShip_Click);
|
||||
//
|
||||
// maskedTextBoxNumber
|
||||
//
|
||||
this.maskedTextBoxNumber.Location = new System.Drawing.Point(16, 124);
|
||||
this.maskedTextBoxNumber.Name = "maskedTextBoxNumber";
|
||||
this.maskedTextBoxNumber.Size = new System.Drawing.Size(171, 27);
|
||||
this.maskedTextBoxNumber.TabIndex = 3;
|
||||
//
|
||||
// buttonAddShip
|
||||
//
|
||||
this.buttonAddShip.Location = new System.Drawing.Point(16, 38);
|
||||
this.buttonAddShip.Name = "buttonAddShip";
|
||||
this.buttonAddShip.Size = new System.Drawing.Size(171, 40);
|
||||
this.buttonAddShip.TabIndex = 2;
|
||||
this.buttonAddShip.Text = "Добавить теплоход";
|
||||
this.buttonAddShip.UseVisualStyleBackColor = true;
|
||||
this.buttonAddShip.Click += new System.EventHandler(this.ButtonAddShip_Click);
|
||||
//
|
||||
// FormShipCollection
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(918, 453);
|
||||
this.Controls.Add(this.panelCollection);
|
||||
this.Controls.Add(this.pictureBoxCollection);
|
||||
this.Name = "FormShipCollection";
|
||||
this.Text = "Набор теплоходов";
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxCollection)).EndInit();
|
||||
this.panelCollection.ResumeLayout(false);
|
||||
this.panelCollection.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private PictureBox pictureBoxCollection;
|
||||
private Panel panelCollection;
|
||||
private Button buttonAddShip;
|
||||
private TextBox maskedTextBoxNumber;
|
||||
private Button buttonRemoveShip;
|
||||
private Button buttonRefreshCollection;
|
||||
}
|
||||
}
|
93
WarmlyShip/WarmlyShip/FormShipCollection.cs
Normal file
93
WarmlyShip/WarmlyShip/FormShipCollection.cs
Normal file
@ -0,0 +1,93 @@
|
||||
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;
|
||||
|
||||
using WarmlyShip.DrawingObjects;
|
||||
using WarmlyShip.Generics;
|
||||
using WarmlyShip.MovementStrategy;
|
||||
|
||||
|
||||
namespace WarmlyShip
|
||||
{
|
||||
/// <summary>
|
||||
/// Форма для работы с набором объектов класса DrawningCar
|
||||
/// </summary>
|
||||
public partial class FormShipCollection : Form
|
||||
{
|
||||
/// <summary>
|
||||
/// Набор объектов
|
||||
/// </summary>
|
||||
private readonly ShipsGenericCollection<DrawingWarmlyShip,
|
||||
DrawingObjectShip> _ships;
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
public FormShipCollection()
|
||||
{
|
||||
InitializeComponent();
|
||||
_ships = new ShipsGenericCollection<DrawingWarmlyShip, DrawingObjectShip>
|
||||
(pictureBoxCollection.Width, pictureBoxCollection.Height);
|
||||
}
|
||||
/// <summary>
|
||||
/// Добавление объекта в набор
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonAddShip_Click(object sender, EventArgs e)
|
||||
{
|
||||
FormWarmlyShip form = new();
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
if (_ships + form.SelectedShip != -1)
|
||||
{
|
||||
MessageBox.Show("Объект добавлен");
|
||||
pictureBoxCollection.Image = _ships.ShowShips();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Не удалось добавить объект");
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Удаление объекта из набора
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonRemoveShip_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (MessageBox.Show("Удалить объект?", "Удаление",
|
||||
MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
|
||||
{
|
||||
return;
|
||||
}
|
||||
int pos = Convert.ToInt32(maskedTextBoxNumber.Text);
|
||||
if (_ships - pos != null)
|
||||
{
|
||||
MessageBox.Show("Объект удален");
|
||||
pictureBoxCollection.Image = _ships.ShowShips();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Не удалось удалить объект");
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Обновление рисунка по набору
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonRefreshCollection_Click(object sender, EventArgs
|
||||
e)
|
||||
{
|
||||
pictureBoxCollection.Image = _ships.ShowShips();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
60
WarmlyShip/WarmlyShip/FormShipCollection.resx
Normal file
60
WarmlyShip/WarmlyShip/FormShipCollection.resx
Normal file
@ -0,0 +1,60 @@
|
||||
<root>
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
17
WarmlyShip/WarmlyShip/FormWarmlyShip.Designer.cs
generated
17
WarmlyShip/WarmlyShip/FormWarmlyShip.Designer.cs
generated
@ -37,6 +37,7 @@
|
||||
this.buttonRight = new System.Windows.Forms.Button();
|
||||
this.comboBoxStrategy = new System.Windows.Forms.ComboBox();
|
||||
this.buttonStep = new System.Windows.Forms.Button();
|
||||
this.buttonSelectShip = new System.Windows.Forms.Button();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxWarmlyShip)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
@ -134,17 +135,28 @@
|
||||
//
|
||||
// buttonStep
|
||||
//
|
||||
this.buttonStep.Location = new System.Drawing.Point(756, 56);
|
||||
this.buttonStep.Location = new System.Drawing.Point(720, 56);
|
||||
this.buttonStep.Name = "buttonStep";
|
||||
this.buttonStep.Size = new System.Drawing.Size(94, 29);
|
||||
this.buttonStep.Size = new System.Drawing.Size(150, 29);
|
||||
this.buttonStep.TabIndex = 8;
|
||||
this.buttonStep.Text = "Шаг";
|
||||
this.buttonStep.UseVisualStyleBackColor = true;
|
||||
this.buttonStep.Click += new System.EventHandler(this.buttonStep_Click);
|
||||
//
|
||||
// buttonSelectShip
|
||||
//
|
||||
this.buttonSelectShip.Location = new System.Drawing.Point(720, 107);
|
||||
this.buttonSelectShip.Name = "buttonSelectShip";
|
||||
this.buttonSelectShip.Size = new System.Drawing.Size(150, 29);
|
||||
this.buttonSelectShip.TabIndex = 9;
|
||||
this.buttonSelectShip.Text = "Выбрать теплоход";
|
||||
this.buttonSelectShip.UseVisualStyleBackColor = true;
|
||||
this.buttonSelectShip.Click += new System.EventHandler(this.ButtonSelectShip_Click);
|
||||
//
|
||||
// FormWarmlyShip
|
||||
//
|
||||
this.ClientSize = new System.Drawing.Size(882, 453);
|
||||
this.Controls.Add(this.buttonSelectShip);
|
||||
this.Controls.Add(this.buttonStep);
|
||||
this.Controls.Add(this.comboBoxStrategy);
|
||||
this.Controls.Add(this.buttonRight);
|
||||
@ -173,5 +185,6 @@
|
||||
private Button buttonRight;
|
||||
private ComboBox comboBoxStrategy;
|
||||
private Button buttonStep;
|
||||
private Button buttonSelectShip;
|
||||
}
|
||||
}
|
@ -131,5 +131,16 @@ namespace WarmlyShip
|
||||
_strategy = null;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Âûáîð òåïëîõîäà
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonSelectShip_Click(object sender, EventArgs e)
|
||||
{
|
||||
SelectedShip = _drawingWarmlyShip;
|
||||
DialogResult = DialogResult.OK;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -11,7 +11,7 @@ namespace WarmlyShip
|
||||
// To customize application configuration such as set high DPI settings or default font,
|
||||
// see https://aka.ms/applicationconfiguration.
|
||||
ApplicationConfiguration.Initialize();
|
||||
Application.Run(new FormWarmlyShip());
|
||||
Application.Run(new FormShipCollection());
|
||||
}
|
||||
}
|
||||
}
|
@ -24,11 +24,11 @@ namespace WarmlyShip.Generics
|
||||
/// <summary>
|
||||
/// Размер занимаемого объектом места (ширина)
|
||||
/// </summary>
|
||||
private readonly int _placeSizeWidth = 185;
|
||||
private readonly int _placeSizeWidth = 190;
|
||||
/// <summary>
|
||||
/// Размер занимаемого объектом места (высота)
|
||||
/// </summary>
|
||||
private readonly int _placeSizeHeight = 180;
|
||||
private readonly int _placeSizeHeight = 200;
|
||||
/// <summary>
|
||||
/// Набор объектов
|
||||
/// </summary>
|
||||
@ -90,7 +90,7 @@ namespace WarmlyShip.Generics
|
||||
/// Вывод всего набора объектов
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Bitmap ShowCars()
|
||||
public Bitmap ShowShips()
|
||||
{
|
||||
Bitmap bmp = new(_pictureWidth, _pictureHeight);
|
||||
Graphics gr = Graphics.FromImage(bmp);
|
||||
|
Loading…
Reference in New Issue
Block a user