LabWork02 #3

Closed
Inohara wants to merge 9 commits from LabWork02 into LabWork1
4 changed files with 62 additions and 16 deletions
Showing only changes of commit 01cffb5f90 - Show all commits

View File

@ -26,6 +26,15 @@ namespace AircraftCarrier
public override void DrawTransport(Graphics g)
{
if(Warship is not EntityAircraftCarrier aircraftCarrier)
{
return;
}
Pen pen = new(Color.Black);
Brush dopBrush = new SolidBrush(aircraftCarrier.DopColor);
base.DrawTransport(g);
}
}

View File

@ -34,7 +34,7 @@ namespace AircraftCarrier
/// <summary>
/// Ширина отрисовки военного корабля
/// </summary>
private readonly int _warshipWidth = 94;
private readonly int _warshipWidth = 114;
/// <summary>
/// Высота отрисовки военного корабля
/// </summary>
@ -152,11 +152,11 @@ namespace AircraftCarrier
Pen pen = new(Color.Black);
//границы военного корабля
PointF point1 = new PointF(_startPosX, _startPosY);
PointF point2 = new PointF(_startPosX + 74, _startPosY);
PointF point3 = new PointF(_startPosX + 94, _startPosY + 20);
PointF point4 = new PointF(_startPosX + 74, _startPosY + 40);
PointF point5 = new PointF(_startPosX, _startPosY + 40);
PointF point1 = new PointF(_startPosX + 4, _startPosY);
PointF point2 = new PointF(_startPosX + 94, _startPosY);
PointF point3 = new PointF(_startPosX + 114, _startPosY + 20);
PointF point4 = new PointF(_startPosX + 94, _startPosY + 40);
PointF point5 = new PointF(_startPosX + 4, _startPosY + 40);
PointF[] curvePoints =
{
@ -170,18 +170,18 @@ namespace AircraftCarrier
//мачта
Brush brWhite = new SolidBrush(Color.White);
g.FillEllipse(brWhite, _startPosX + 59, _startPosY + 13, 15, 15);
g.FillEllipse(brWhite, _startPosX + 79, _startPosY + 13, 15, 15);
//границы мачты
g.DrawEllipse(pen, _startPosX + 59, _startPosY + 13, 15, 15);
g.DrawEllipse(pen, _startPosX + 79, _startPosY + 13, 15, 15);
//палуба
g.FillRectangle(brWhite, _startPosX + 44, _startPosY + 10, 10, 20);
g.FillRectangle(brWhite, _startPosX + 24, _startPosY + 15, 20, 10);
g.FillRectangle(brWhite, _startPosX + 64, _startPosY + 10, 10, 20);
g.FillRectangle(brWhite, _startPosX + 44, _startPosY + 15, 20, 10);
//границы палуба
g.DrawRectangle(pen, _startPosX + 44, _startPosY + 10, 10, 20);
g.DrawRectangle(pen, _startPosX + 24, _startPosY + 15, 20, 10);
g.DrawRectangle(pen, _startPosX + 64, _startPosY + 10, 10, 20);
g.DrawRectangle(pen, _startPosX + 44, _startPosY + 15, 20, 10);
//двигатели
Brush brBlack = new SolidBrush(Color.Black);

View File

@ -38,6 +38,7 @@
this.buttonUp = new System.Windows.Forms.Button();
this.buttonLeft = new System.Windows.Forms.Button();
this.buttonRight = new System.Windows.Forms.Button();
this.buttonCreateModif = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxWarship)).BeginInit();
this.statusStrip.SuspendLayout();
this.SuspendLayout();
@ -145,11 +146,22 @@
this.buttonRight.UseVisualStyleBackColor = true;
this.buttonRight.Click += new System.EventHandler(this.ButtonMove_Click);
//
// buttonCreateModif
//
this.buttonCreateModif.Location = new System.Drawing.Point(93, 393);
this.buttonCreateModif.Name = "buttonCreateModif";
this.buttonCreateModif.Size = new System.Drawing.Size(92, 23);
this.buttonCreateModif.TabIndex = 7;
this.buttonCreateModif.Text = "Modification";
this.buttonCreateModif.UseVisualStyleBackColor = true;
this.buttonCreateModif.Click += new System.EventHandler(this.ButtonCreateModif_Click);
//
// FormWarship
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(768, 448);
this.Controls.Add(this.buttonCreateModif);
this.Controls.Add(this.buttonRight);
this.Controls.Add(this.buttonLeft);
this.Controls.Add(this.buttonUp);
@ -179,5 +191,6 @@
private Button buttonUp;
private Button buttonLeft;
private Button buttonRight;
private Button buttonCreateModif;
}
}

View File

@ -18,6 +18,17 @@ namespace AircraftCarrier
pictureBoxWarship.Image = bmp;
}
/// <summary>
/// Ìåòîä óñòàíîâêè äàííûõ
/// </summary>
private void SetData()
{
Random rnd = new();
_warship.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100), pictureBoxWarship.Width, pictureBoxWarship.Height);
toolStripStatusLabelSpeed.Text = $"Ñêîðîñòü: {_warship.Warship.Speed}";
toolStripStatusLabelWeight.Text = $"Âåñ: {_warship.Warship.Weight}";
toolStripStatusLabelBodyColor.Text = $"Öâåò: {_warship.Warship.BodyColor.Name}";
}
/// <summary>
/// Îáðàáîòêà íàæàòèÿ êíîïêè "Create"
/// </summary>
/// <param name="sender"></param>
@ -26,10 +37,7 @@ namespace AircraftCarrier
{
Random rnd = new();
_warship = new DrawingWarship(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
_warship.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100), pictureBoxWarship.Width, pictureBoxWarship.Height);
toolStripStatusLabelSpeed.Text = $"Ñêîðîñòü: {_warship.Warship.Speed}";
toolStripStatusLabelWeight.Text = $"Âåñ: {_warship.Warship.Weight}";
toolStripStatusLabelBodyColor.Text = $"Öâåò: {_warship.Warship.BodyColor.Name}";
SetData();
Draw();
}
@ -63,5 +71,21 @@ namespace AircraftCarrier
_warship?.ChangeBorders(pictureBoxWarship.Width,pictureBoxWarship.Height);
Draw();
}
/// <summary>
/// Îáðàáîòêà íàæàòèÿ êíîïêè "Modification"
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ButtonCreateModif_Click(object sender, EventArgs e)
{
Random rnd = new();
_warship = new DrawingAircraftCarrier(rnd.Next(100, 300), rnd.Next(1000, 2000),
Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)),
Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)),
Convert.ToBoolean(rnd.Next(0, 2)), Convert.ToBoolean(rnd.Next(0, 2)), Convert.ToBoolean(rnd.Next(0, 2)));
SetData();
Draw();
}
}
}