Kadyrov A.F. LabWork05 #6

Closed
NAP wants to merge 3 commits from LabWork05 into LabWork04
8 changed files with 600 additions and 19 deletions

View File

@ -30,6 +30,12 @@ namespace Battleship
return;
}
_startPosX += 10;
_startPosY += 5;
base.DrawTransport(g);
_startPosX -= 10;
_startPosY -= 5;
Pen pen = new(Color.Black);
Brush dopBrush = new SolidBrush(gunBattleship.DopColor);
@ -40,12 +46,6 @@ namespace Battleship
g.DrawRectangle(pen, _startPosX + 85, _startPosY + 10, 15, 20);
}
_startPosX += 10;
_startPosY += 5;
base.DrawTransport(g);
_startPosX -= 10;
_startPosY -= 5;
if (gunBattleship.GunTower)
{
g.FillEllipse(dopBrush, _startPosX + 105, _startPosY + 12, 17, 17);

View File

@ -41,5 +41,10 @@ namespace Battleship
Weight = weight <= 0 ? rnd.Next(40, 70) : weight;
BodyColor = bodyColor;
}
public void ChangeColor(Color color)
{
BodyColor = color;
}
}
}

View File

@ -45,5 +45,10 @@ namespace Battleship
GunTower = gunTower;
SternFence = sternFence;
}
public void ChangeDopColor(Color color)
{
DopColor = color;
}
}
}

View File

@ -0,0 +1,374 @@
namespace Battleship
{
partial class FormBattleshipConfig
{
// <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.GroupBoxConfig = new System.Windows.Forms.GroupBox();
this.LabelGunBattleship = new System.Windows.Forms.Label();
this.LabelBasicBattleship = new System.Windows.Forms.Label();
this.GroupBoxColors = new System.Windows.Forms.GroupBox();
this.PanelSilver = new System.Windows.Forms.Panel();
this.PanelRed = new System.Windows.Forms.Panel();
this.PanelBlue = new System.Windows.Forms.Panel();
this.PanelCyan = new System.Windows.Forms.Panel();
this.PanelLime = new System.Windows.Forms.Panel();
this.PanelFuchsia = new System.Windows.Forms.Panel();
this.PanelYellow = new System.Windows.Forms.Panel();
this.PanelOrange = new System.Windows.Forms.Panel();
this.CheckBoxCompartmentRocket = new System.Windows.Forms.CheckBox();
this.CheckBoxGunTower = new System.Windows.Forms.CheckBox();
this.CheckBoxSternFence = new System.Windows.Forms.CheckBox();
this.NumericUpDownWeight = new System.Windows.Forms.NumericUpDown();
this.NumericUpDownSpeed = new System.Windows.Forms.NumericUpDown();
this.LabelWeight = new System.Windows.Forms.Label();
this.LabelSpeed = new System.Windows.Forms.Label();
this.PictureBoxBattleship = new System.Windows.Forms.PictureBox();
this.PanelBattleship = new System.Windows.Forms.Panel();
this.LabelModifColor = new System.Windows.Forms.Label();
this.LabelBodyColor = new System.Windows.Forms.Label();
this.ButtomAdd = new System.Windows.Forms.Button();
this.ButtonCancel = new System.Windows.Forms.Button();
this.GroupBoxConfig.SuspendLayout();
this.GroupBoxColors.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.NumericUpDownWeight)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.NumericUpDownSpeed)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.PictureBoxBattleship)).BeginInit();
this.PanelBattleship.SuspendLayout();
this.SuspendLayout();
//
// GroupBoxConfig
//
this.GroupBoxConfig.Controls.Add(this.LabelGunBattleship);
this.GroupBoxConfig.Controls.Add(this.LabelBasicBattleship);
this.GroupBoxConfig.Controls.Add(this.GroupBoxColors);
this.GroupBoxConfig.Controls.Add(this.CheckBoxCompartmentRocket);
this.GroupBoxConfig.Controls.Add(this.CheckBoxGunTower);
this.GroupBoxConfig.Controls.Add(this.CheckBoxSternFence);
this.GroupBoxConfig.Controls.Add(this.NumericUpDownWeight);
this.GroupBoxConfig.Controls.Add(this.NumericUpDownSpeed);
this.GroupBoxConfig.Controls.Add(this.LabelWeight);
this.GroupBoxConfig.Controls.Add(this.LabelSpeed);
this.GroupBoxConfig.Location = new System.Drawing.Point(12, 12);
this.GroupBoxConfig.Name = "GroupBoxConfig";
this.GroupBoxConfig.Size = new System.Drawing.Size(596, 241);
this.GroupBoxConfig.TabIndex = 0;
this.GroupBoxConfig.TabStop = false;
this.GroupBoxConfig.Text = "Параметры: ";
//
// LabelGunBattleship
//
this.LabelGunBattleship.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.LabelGunBattleship.Location = new System.Drawing.Point(452, 183);
this.LabelGunBattleship.Name = "LabelGunBattleship";
this.LabelGunBattleship.Size = new System.Drawing.Size(123, 41);
this.LabelGunBattleship.TabIndex = 9;
this.LabelGunBattleship.Text = "Продвинутый корабль";
this.LabelGunBattleship.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.LabelGunBattleship.MouseDown += new System.Windows.Forms.MouseEventHandler(this.LabelBattleship_MouseDown);
//
// LabelBasicBattleship
//
this.LabelBasicBattleship.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.LabelBasicBattleship.Location = new System.Drawing.Point(321, 183);
this.LabelBasicBattleship.Name = "LabelBasicBattleship";
this.LabelBasicBattleship.Size = new System.Drawing.Size(125, 41);
this.LabelBasicBattleship.TabIndex = 8;
this.LabelBasicBattleship.Text = "Обычный корабль";
this.LabelBasicBattleship.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.LabelBasicBattleship.MouseDown += new System.Windows.Forms.MouseEventHandler(this.LabelBattleship_MouseDown);
//
// GroupBoxColors
//
this.GroupBoxColors.Controls.Add(this.PanelSilver);
this.GroupBoxColors.Controls.Add(this.PanelRed);
this.GroupBoxColors.Controls.Add(this.PanelBlue);
this.GroupBoxColors.Controls.Add(this.PanelCyan);
this.GroupBoxColors.Controls.Add(this.PanelLime);
this.GroupBoxColors.Controls.Add(this.PanelFuchsia);
this.GroupBoxColors.Controls.Add(this.PanelYellow);
this.GroupBoxColors.Controls.Add(this.PanelOrange);
this.GroupBoxColors.Location = new System.Drawing.Point(321, 24);
this.GroupBoxColors.Name = "GroupBoxColors";
this.GroupBoxColors.Size = new System.Drawing.Size(254, 144);
this.GroupBoxColors.TabIndex = 7;
this.GroupBoxColors.TabStop = false;
this.GroupBoxColors.Text = "Цвета: ";
//
// PanelSilver
//
this.PanelSilver.BackColor = System.Drawing.Color.Silver;
this.PanelSilver.Location = new System.Drawing.Point(191, 78);
this.PanelSilver.Name = "PanelSilver";
this.PanelSilver.Size = new System.Drawing.Size(44, 45);
this.PanelSilver.TabIndex = 1;
//
// PanelRed
//
this.PanelRed.BackColor = System.Drawing.Color.Red;
this.PanelRed.Location = new System.Drawing.Point(136, 78);
this.PanelRed.Name = "PanelRed";
this.PanelRed.Size = new System.Drawing.Size(46, 45);
this.PanelRed.TabIndex = 1;
//
// PanelBlue
//
this.PanelBlue.BackColor = System.Drawing.Color.Blue;
this.PanelBlue.Location = new System.Drawing.Point(79, 78);
this.PanelBlue.Name = "PanelBlue";
this.PanelBlue.Size = new System.Drawing.Size(46, 45);
this.PanelBlue.TabIndex = 1;
//
// PanelCyan
//
this.PanelCyan.BackColor = System.Drawing.Color.Cyan;
this.PanelCyan.Location = new System.Drawing.Point(20, 78);
this.PanelCyan.Name = "PanelCyan";
this.PanelCyan.Size = new System.Drawing.Size(48, 45);
this.PanelCyan.TabIndex = 1;
//
// PanelLime
//
this.PanelLime.BackColor = System.Drawing.Color.Lime;
this.PanelLime.Location = new System.Drawing.Point(191, 24);
this.PanelLime.Name = "PanelLime";
this.PanelLime.Size = new System.Drawing.Size(44, 45);
this.PanelLime.TabIndex = 1;
//
// PanelFuchsia
//
this.PanelFuchsia.BackColor = System.Drawing.Color.Fuchsia;
this.PanelFuchsia.Location = new System.Drawing.Point(136, 24);
this.PanelFuchsia.Name = "PanelFuchsia";
this.PanelFuchsia.Size = new System.Drawing.Size(46, 45);
this.PanelFuchsia.TabIndex = 1;
//
// PanelYellow
//
this.PanelYellow.BackColor = System.Drawing.Color.Yellow;
this.PanelYellow.Location = new System.Drawing.Point(79, 24);
this.PanelYellow.Name = "PanelYellow";
this.PanelYellow.Size = new System.Drawing.Size(46, 45);
this.PanelYellow.TabIndex = 1;
//
// PanelOrange
//
this.PanelOrange.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(0)))));
this.PanelOrange.Location = new System.Drawing.Point(20, 24);
this.PanelOrange.Name = "PanelOrange";
this.PanelOrange.Size = new System.Drawing.Size(48, 45);
this.PanelOrange.TabIndex = 0;
//
// CheckBoxCompartmentRocket
//
this.CheckBoxCompartmentRocket.AutoSize = true;
this.CheckBoxCompartmentRocket.Location = new System.Drawing.Point(42, 205);
this.CheckBoxCompartmentRocket.Name = "CheckBoxCompartmentRocket";
this.CheckBoxCompartmentRocket.Size = new System.Drawing.Size(217, 19);
this.CheckBoxCompartmentRocket.TabIndex = 6;
this.CheckBoxCompartmentRocket.Text = "Признак наличия отсека для ракет";
this.CheckBoxCompartmentRocket.UseVisualStyleBackColor = true;
//
// CheckBoxGunTower
//
this.CheckBoxGunTower.AutoSize = true;
this.CheckBoxGunTower.Location = new System.Drawing.Point(42, 168);
this.CheckBoxGunTower.Name = "CheckBoxGunTower";
this.CheckBoxGunTower.Size = new System.Drawing.Size(228, 19);
this.CheckBoxGunTower.TabIndex = 5;
this.CheckBoxGunTower.Text = "Признак наличия орудийной башни";
this.CheckBoxGunTower.UseVisualStyleBackColor = true;
//
// CheckBoxSternFence
//
this.CheckBoxSternFence.AutoSize = true;
this.CheckBoxSternFence.Location = new System.Drawing.Point(42, 129);
this.CheckBoxSternFence.Name = "CheckBoxSternFence";
this.CheckBoxSternFence.Size = new System.Drawing.Size(218, 19);
this.CheckBoxSternFence.TabIndex = 4;
this.CheckBoxSternFence.Text = "Признак наличия забора на корме";
this.CheckBoxSternFence.UseVisualStyleBackColor = true;
//
// NumericUpDownWeight
//
this.NumericUpDownWeight.Location = new System.Drawing.Point(113, 78);
this.NumericUpDownWeight.Name = "NumericUpDownWeight";
this.NumericUpDownWeight.Size = new System.Drawing.Size(120, 23);
this.NumericUpDownWeight.TabIndex = 3;
this.NumericUpDownWeight.Value = new decimal(new int[] {
1,
0,
0,
0});
//
// NumericUpDownSpeed
//
this.NumericUpDownSpeed.Location = new System.Drawing.Point(113, 41);
this.NumericUpDownSpeed.Name = "NumericUpDownSpeed";
this.NumericUpDownSpeed.Size = new System.Drawing.Size(120, 23);
this.NumericUpDownSpeed.TabIndex = 2;
this.NumericUpDownSpeed.Value = new decimal(new int[] {
1,
0,
0,
0});
//
// LabelWeight
//
this.LabelWeight.AutoSize = true;
this.LabelWeight.Location = new System.Drawing.Point(42, 80);
this.LabelWeight.Name = "LabelWeight";
this.LabelWeight.Size = new System.Drawing.Size(32, 15);
this.LabelWeight.TabIndex = 1;
this.LabelWeight.Text = "Вес: ";
//
// LabelSpeed
//
this.LabelSpeed.AutoSize = true;
this.LabelSpeed.Location = new System.Drawing.Point(42, 43);
this.LabelSpeed.Name = "LabelSpeed";
this.LabelSpeed.Size = new System.Drawing.Size(65, 15);
this.LabelSpeed.TabIndex = 0;
this.LabelSpeed.Text = "Скорость: ";
//
// PictureBoxBattleship
//
this.PictureBoxBattleship.Location = new System.Drawing.Point(29, 53);
this.PictureBoxBattleship.Name = "PictureBoxBattleship";
this.PictureBoxBattleship.Size = new System.Drawing.Size(240, 136);
this.PictureBoxBattleship.TabIndex = 1;
this.PictureBoxBattleship.TabStop = false;
//
// PanelBattleship
//
this.PanelBattleship.AllowDrop = true;
this.PanelBattleship.Controls.Add(this.LabelModifColor);
this.PanelBattleship.Controls.Add(this.LabelBodyColor);
this.PanelBattleship.Controls.Add(this.PictureBoxBattleship);
this.PanelBattleship.Location = new System.Drawing.Point(621, 20);
this.PanelBattleship.Name = "PanelBattleship";
this.PanelBattleship.Size = new System.Drawing.Size(298, 197);
this.PanelBattleship.TabIndex = 2;
this.PanelBattleship.DragDrop += new System.Windows.Forms.DragEventHandler(this.PanelBattleship_DragDrop);
this.PanelBattleship.DragEnter += new System.Windows.Forms.DragEventHandler(this.PanelBattleship_DragEnter);
//
// LabelModifColor
//
this.LabelModifColor.AllowDrop = true;
this.LabelModifColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.LabelModifColor.Location = new System.Drawing.Point(153, 8);
this.LabelModifColor.Name = "LabelModifColor";
this.LabelModifColor.Size = new System.Drawing.Size(116, 38);
this.LabelModifColor.TabIndex = 3;
this.LabelModifColor.Text = "Цвет модификаций корабля";
this.LabelModifColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.LabelModifColor.DragDrop += new System.Windows.Forms.DragEventHandler(this.LabelModifColor_DragDrop);
this.LabelModifColor.DragEnter += new System.Windows.Forms.DragEventHandler(this.LabelModifColor_DragEnter);
//
// LabelBodyColor
//
this.LabelBodyColor.AllowDrop = true;
this.LabelBodyColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.LabelBodyColor.Location = new System.Drawing.Point(29, 8);
this.LabelBodyColor.Name = "LabelBodyColor";
this.LabelBodyColor.Size = new System.Drawing.Size(118, 38);
this.LabelBodyColor.TabIndex = 2;
this.LabelBodyColor.Text = "Цвет корпуса корабля";
this.LabelBodyColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.LabelBodyColor.DragDrop += new System.Windows.Forms.DragEventHandler(this.LabelBodyColor_DragDrop);
this.LabelBodyColor.DragEnter += new System.Windows.Forms.DragEventHandler(this.LabelBodyColor_DragEnter);
//
// ButtomAdd
//
this.ButtomAdd.Location = new System.Drawing.Point(685, 227);
this.ButtomAdd.Name = "ButtomAdd";
this.ButtomAdd.Size = new System.Drawing.Size(83, 27);
this.ButtomAdd.TabIndex = 3;
this.ButtomAdd.Text = "Добавить";
this.ButtomAdd.UseVisualStyleBackColor = true;
this.ButtomAdd.Click += new System.EventHandler(this.ButtomAdd_Click);
//
// ButtonCancel
//
this.ButtonCancel.Location = new System.Drawing.Point(783, 227);
this.ButtonCancel.Name = "ButtonCancel";
this.ButtonCancel.Size = new System.Drawing.Size(79, 27);
this.ButtonCancel.TabIndex = 4;
this.ButtonCancel.Text = "Отмена";
this.ButtonCancel.UseVisualStyleBackColor = true;
//
// FormBattleshipConfig
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(935, 266);
this.Controls.Add(this.ButtonCancel);
this.Controls.Add(this.ButtomAdd);
this.Controls.Add(this.PanelBattleship);
this.Controls.Add(this.GroupBoxConfig);
this.Name = "FormBattleshipConfig";
this.Text = "Создание корабля";
this.GroupBoxConfig.ResumeLayout(false);
this.GroupBoxConfig.PerformLayout();
this.GroupBoxColors.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.NumericUpDownWeight)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.NumericUpDownSpeed)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.PictureBoxBattleship)).EndInit();
this.PanelBattleship.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private GroupBox GroupBoxConfig;
private Label LabelGunBattleship;
private Label LabelBasicBattleship;
private GroupBox GroupBoxColors;
private Panel PanelSilver;
private Panel PanelRed;
private Panel PanelBlue;
private Panel PanelCyan;
private Panel PanelLime;
private Panel PanelFuchsia;
private Panel PanelYellow;
private Panel PanelOrange;
private CheckBox CheckBoxCompartmentRocket;
private CheckBox CheckBoxGunTower;
private CheckBox CheckBoxSternFence;
private NumericUpDown NumericUpDownWeight;
private NumericUpDown NumericUpDownSpeed;
private Label LabelWeight;
private Label LabelSpeed;
private PictureBox PictureBoxBattleship;
private Panel PanelBattleship;
private Label LabelModifColor;
private Label LabelBodyColor;
private Button ButtomAdd;
private Button ButtonCancel;
}
}

View File

@ -0,0 +1,134 @@
namespace Battleship
{
public partial class FormBattleshipConfig : Form
{
DrawningBattleship _battleship = null;
private event Action<DrawningBattleship> EventAddBattleship;
public FormBattleshipConfig()
{
InitializeComponent();
PanelBlue.MouseDown += PanelColor_MouseDown;
PanelCyan.MouseDown += PanelColor_MouseDown;
PanelFuchsia.MouseDown += PanelColor_MouseDown;
PanelLime.MouseDown += PanelColor_MouseDown;
PanelOrange.MouseDown += PanelColor_MouseDown;
PanelRed.MouseDown += PanelColor_MouseDown;
PanelSilver.MouseDown += PanelColor_MouseDown;
PanelYellow.MouseDown += PanelColor_MouseDown;
ButtonCancel.Click += (sender, e) => Close();
}
private void DrawBattleship()
{
Bitmap bmp = new(PictureBoxBattleship.Width, PictureBoxBattleship.Height);
Graphics gr = Graphics.FromImage(bmp);
_battleship?.SetPosition(5, 5, PictureBoxBattleship.Width, PictureBoxBattleship.Height);
_battleship?.DrawTransport(gr);
PictureBoxBattleship.Image = bmp;
}
public void AddEvent(Action<DrawningBattleship> ev)
{
if (EventAddBattleship == null)
{
EventAddBattleship = ev;
}
else
{
EventAddBattleship += ev;
}
}
private void LabelBattleship_MouseDown(object sender, MouseEventArgs e)
{
(sender as Label).DoDragDrop((sender as Label).Name, DragDropEffects.Move | DragDropEffects.Copy);
}
private void PanelBattleship_DragEnter(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.Text))
{
e.Effect = DragDropEffects.Copy;
}
else
{
e.Effect = DragDropEffects.None;
}
}
private void PanelBattleship_DragDrop(object sender, DragEventArgs e)
{
switch (e.Data.GetData(DataFormats.Text).ToString())
{
case "LabelBasicBattleship":
_battleship = new DrawningBattleship((int)NumericUpDownSpeed.Value, (int)NumericUpDownWeight.Value, Color.White);
break;
case "LabelGunBattleship":
_battleship = new DrawningGunBattleship((int)NumericUpDownSpeed.Value, (int)NumericUpDownWeight.Value, Color.White, Color.Black,
CheckBoxCompartmentRocket.Checked, CheckBoxGunTower.Checked, CheckBoxSternFence.Checked);
break;
}
DrawBattleship();
}
private void PanelColor_MouseDown(object sender, MouseEventArgs e)
{
(sender as Control).DoDragDrop((sender as Control).BackColor, DragDropEffects.Move | DragDropEffects.Copy);
}
private void LabelBodyColor_DragEnter(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(typeof(Color)))
{
e.Effect = DragDropEffects.Copy;
}
else
{
e.Effect = DragDropEffects.None;
}
}
private void LabelModifColor_DragEnter(object sender, DragEventArgs e)
{
if (_battleship is DrawningGunBattleship)
{
if (e.Data.GetDataPresent(typeof(Color)))
{
e.Effect = DragDropEffects.Copy;
}
else
{
e.Effect = DragDropEffects.None;
}
}
}
private void LabelBodyColor_DragDrop(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(typeof(Color)) && _battleship != null)
{
_battleship.Battleship.ChangeColor((Color)e.Data.GetData(typeof(Color)));
DrawBattleship();
}
}
private void LabelModifColor_DragDrop(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(typeof(Color)) && _battleship != null)
{
if (_battleship is DrawningGunBattleship _gunBattleship)
{
if (_gunBattleship.Battleship is EntityGunBattleship _entityGunBattleship)
{
_entityGunBattleship.ChangeDopColor((Color)e.Data.GetData(typeof(Color)));
DrawBattleship();
}
}
}
}
private void ButtomAdd_Click(object sender, EventArgs e)
{
EventAddBattleship?.Invoke(_battleship);
Close();
}
}
}

View 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>

View File

@ -252,7 +252,7 @@
this.Controls.Add(this.pictureBox);
this.Controls.Add(this.groupBoxTools);
this.Name = "FormMapWithSetBattleship";
this.Text = "FormMapWithSetBattleship";
this.Text = "Карта с набором объектов";
this.groupBoxTools.ResumeLayout(false);
this.groupBoxTools.PerformLayout();
this.groupBoxMaps.ResumeLayout(false);

View File

@ -50,24 +50,27 @@ namespace Battleship
}
private void ButtonAddBattleship_Click(object sender, EventArgs e)
{
var formBattleshipConfig = new FormBattleshipConfig();
formBattleshipConfig.AddEvent(AddBattleshipOnMap);
formBattleshipConfig.Show();
}
private void AddBattleshipOnMap(DrawningBattleship battleship)
{
if (listBoxMaps.SelectedIndex == -1)
{
return;
}
FormBattleship form = new();
if (form.ShowDialog() == DialogResult.OK)
DrawningObjectBattleship boat = new(battleship);
if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] + boat >= 0)
{
DrawningObjectBattleship battleship = new(form.SelectedBattleship);
if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] + battleship != -1)
{
MessageBox.Show("Объект добавлен");
pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
}
else
{
MessageBox.Show("Не удалось добавить объект");
}
MessageBox.Show("Объект добавлен");
pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
}
else
{
MessageBox.Show("Не удалось добавить объект");
}
}