Сделал лаб01
This commit is contained in:
parent
7b7ccfde47
commit
0aae5667ec
@ -8,7 +8,7 @@ public class DrawingSeaplane
|
|||||||
/// Класс-сущность
|
/// Класс-сущность
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public EntitySeaplane? EntitySeaplane { get; private set; }
|
public EntitySeaplane? EntitySeaplane { get; private set; }
|
||||||
|
public DrawingWindows Windows;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Ширина окна
|
/// Ширина окна
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -32,7 +32,7 @@ public class DrawingSeaplane
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Ширина прорисовки автомобиля
|
/// Ширина прорисовки автомобиля
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private readonly int _drawningSeaplaneWidth = 155;
|
private readonly int _drawningSeaplaneWidth = 160;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Высота прорисовки автомобиля
|
/// Высота прорисовки автомобиля
|
||||||
@ -56,6 +56,8 @@ public class DrawingSeaplane
|
|||||||
_pictureHeight = null;
|
_pictureHeight = null;
|
||||||
_startPosX = null;
|
_startPosX = null;
|
||||||
_startPosY = null;
|
_startPosY = null;
|
||||||
|
Windows = new DrawingWindows();
|
||||||
|
Windows.WinNum = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -137,7 +139,7 @@ public class DrawingSeaplane
|
|||||||
{
|
{
|
||||||
//влево
|
//влево
|
||||||
case DirectionType.Left:
|
case DirectionType.Left:
|
||||||
if (_startPosX.Value - EntitySeaplane.Step > 0)
|
if (_startPosX.Value - EntitySeaplane.Step > 1)
|
||||||
{
|
{
|
||||||
_startPosX -= (int)EntitySeaplane.Step;
|
_startPosX -= (int)EntitySeaplane.Step;
|
||||||
}
|
}
|
||||||
@ -149,7 +151,7 @@ public class DrawingSeaplane
|
|||||||
_startPosY -= (int)EntitySeaplane.Step;
|
_startPosY -= (int)EntitySeaplane.Step;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
// вправо
|
//вправо
|
||||||
case DirectionType.Right:
|
case DirectionType.Right:
|
||||||
|
|
||||||
if (_startPosX + (int)EntitySeaplane.Step < _pictureWidth - _drawningSeaplaneWidth)
|
if (_startPosX + (int)EntitySeaplane.Step < _pictureWidth - _drawningSeaplaneWidth)
|
||||||
@ -177,11 +179,12 @@ public class DrawingSeaplane
|
|||||||
{
|
{
|
||||||
if (EntitySeaplane == null || !_startPosX.HasValue || !_startPosY.HasValue)
|
if (EntitySeaplane == null || !_startPosX.HasValue || !_startPosY.HasValue)
|
||||||
{
|
{
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Pen pen = new(Color.Black);
|
|
||||||
Pen penKraya = new(Color.Black, 2);
|
Pen penKraya = new(Color.Black, 2);
|
||||||
Brush additionalBrush = new SolidBrush(EntitySeaplane.AdditionalColor);
|
Brush additionalBrush = new SolidBrush(EntitySeaplane.AdditionalColor);
|
||||||
|
Pen pen = new(Color.Black);
|
||||||
//Начинаем рисовать
|
//Начинаем рисовать
|
||||||
//Полигон для хвоста
|
//Полигон для хвоста
|
||||||
Point point1 = new Point(_startPosX.Value, _startPosY.Value);
|
Point point1 = new Point(_startPosX.Value, _startPosY.Value);
|
||||||
@ -215,17 +218,6 @@ public class DrawingSeaplane
|
|||||||
|
|
||||||
//Крыло
|
//Крыло
|
||||||
g.FillEllipse(brAdditional, _startPosX.Value + 45, _startPosY.Value + 43, 50, 7);
|
g.FillEllipse(brAdditional, _startPosX.Value + 45, _startPosY.Value + 43, 50, 7);
|
||||||
|
|
||||||
//Иллюминаторы
|
|
||||||
|
|
||||||
for (int i = 0; i < 80; i += 10)
|
|
||||||
{
|
|
||||||
|
|
||||||
g.FillEllipse(brWhity, _startPosX.Value + 30 + i, _startPosY.Value + 34, 6, 6);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
//Поплавки
|
//Поплавки
|
||||||
|
|
||||||
if (EntitySeaplane.LandingGear)
|
if (EntitySeaplane.LandingGear)
|
||||||
@ -253,7 +245,7 @@ public class DrawingSeaplane
|
|||||||
}
|
}
|
||||||
//Пилоты
|
//Пилоты
|
||||||
g.FillEllipse(brWhity, _startPosX.Value + 115, _startPosY.Value + 34, 20, 8);
|
g.FillEllipse(brWhity, _startPosX.Value + 115, _startPosY.Value + 34, 20, 8);
|
||||||
|
Windows.DrawWindows(g, _startPosX.Value + 5, _startPosY.Value + 5);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
77
ProjectSeaplane/ProjectSeaplane/DrawingWindows.cs
Normal file
77
ProjectSeaplane/ProjectSeaplane/DrawingWindows.cs
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ProjectSeaplane;
|
||||||
|
|
||||||
|
public class DrawingWindows
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Класс-сущность
|
||||||
|
/// </summary>
|
||||||
|
public EntitySeaplane? EntitySeaplane { get; private set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Количество иллюминаторов
|
||||||
|
/// </summary>
|
||||||
|
private NumberOfWindows numberOfWindows;
|
||||||
|
public int WinNum
|
||||||
|
{
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (value == 10 || value < 15)
|
||||||
|
{
|
||||||
|
numberOfWindows = NumberOfWindows.TenWindows;
|
||||||
|
}
|
||||||
|
else if (value == 20 || (value >= 15 && value < 25))
|
||||||
|
{
|
||||||
|
numberOfWindows = NumberOfWindows.TwentyWindows;
|
||||||
|
}
|
||||||
|
else if (value == 30 || (value >= 25 && value < 31))
|
||||||
|
{
|
||||||
|
numberOfWindows = NumberOfWindows.ThirtyWindows;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Прорисовка доп класса
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="g"></param>
|
||||||
|
public void DrawWindows(Graphics g, int _startPosX, int _startPosY)
|
||||||
|
{
|
||||||
|
|
||||||
|
Brush brWhity = new SolidBrush(Color.GhostWhite);
|
||||||
|
|
||||||
|
|
||||||
|
switch (numberOfWindows)
|
||||||
|
{
|
||||||
|
case NumberOfWindows.TenWindows:
|
||||||
|
for (int i = 0; i < 60; i += 6)
|
||||||
|
{
|
||||||
|
g.FillEllipse(brWhity, _startPosX + 30 + i, _startPosY + 26, 4, 4);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case NumberOfWindows.TwentyWindows:
|
||||||
|
for (int j = 0; j < 5; j += 4)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < 60; i += 6)
|
||||||
|
{
|
||||||
|
g.FillEllipse(brWhity, _startPosX + 30 + i, _startPosY + 26 + j, 4, 4);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case NumberOfWindows.ThirtyWindows:
|
||||||
|
for (int j = 0; j < 9; j += 4)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < 60; i += 6)
|
||||||
|
{
|
||||||
|
g.FillEllipse(brWhity, _startPosX + 30 + i, _startPosY + 26 + j, 4, 4);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,6 @@
|
|||||||
namespace ProjectSeaplane;
|
using static System.Windows.Forms.LinkLabel;
|
||||||
|
|
||||||
|
namespace ProjectSeaplane;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Класс-сущность Гидросамолета
|
/// Класс-сущность Гидросамолета
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -49,6 +51,5 @@ public class EntitySeaplane
|
|||||||
AdditionalColor = additionalColor;
|
AdditionalColor = additionalColor;
|
||||||
LandingGear = landingGear;
|
LandingGear = landingGear;
|
||||||
Radar = radar;
|
Radar = radar;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -34,7 +34,9 @@
|
|||||||
buttonDown = new Button();
|
buttonDown = new Button();
|
||||||
buttonUp = new Button();
|
buttonUp = new Button();
|
||||||
buttonRight = new Button();
|
buttonRight = new Button();
|
||||||
|
numericUpDownNumberOfWindows = new NumericUpDown();
|
||||||
((System.ComponentModel.ISupportInitialize)pictureBoxSeaplane).BeginInit();
|
((System.ComponentModel.ISupportInitialize)pictureBoxSeaplane).BeginInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)numericUpDownNumberOfWindows).BeginInit();
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
//
|
//
|
||||||
// pictureBoxSeaplane
|
// pictureBoxSeaplane
|
||||||
@ -109,11 +111,23 @@
|
|||||||
buttonRight.UseVisualStyleBackColor = false;
|
buttonRight.UseVisualStyleBackColor = false;
|
||||||
buttonRight.Click += ButtonMove_Click;
|
buttonRight.Click += ButtonMove_Click;
|
||||||
//
|
//
|
||||||
|
// numericUpDownNumberOfWindows
|
||||||
|
//
|
||||||
|
numericUpDownNumberOfWindows.Increment = new decimal(new int[] { 10, 0, 0, 0 });
|
||||||
|
numericUpDownNumberOfWindows.Location = new Point(93, 349);
|
||||||
|
numericUpDownNumberOfWindows.Maximum = new decimal(new int[] { 30, 0, 0, 0 });
|
||||||
|
numericUpDownNumberOfWindows.Minimum = new decimal(new int[] { 10, 0, 0, 0 });
|
||||||
|
numericUpDownNumberOfWindows.Name = "numericUpDownNumberOfWindows";
|
||||||
|
numericUpDownNumberOfWindows.Size = new Size(47, 23);
|
||||||
|
numericUpDownNumberOfWindows.TabIndex = 8;
|
||||||
|
numericUpDownNumberOfWindows.Value = new decimal(new int[] { 10, 0, 0, 0 });
|
||||||
|
//
|
||||||
// FormSeaplane
|
// FormSeaplane
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
ClientSize = new Size(590, 379);
|
ClientSize = new Size(590, 379);
|
||||||
|
Controls.Add(numericUpDownNumberOfWindows);
|
||||||
Controls.Add(buttonRight);
|
Controls.Add(buttonRight);
|
||||||
Controls.Add(buttonUp);
|
Controls.Add(buttonUp);
|
||||||
Controls.Add(buttonDown);
|
Controls.Add(buttonDown);
|
||||||
@ -123,6 +137,7 @@
|
|||||||
Name = "FormSeaplane";
|
Name = "FormSeaplane";
|
||||||
Text = "Гидросамолет";
|
Text = "Гидросамолет";
|
||||||
((System.ComponentModel.ISupportInitialize)pictureBoxSeaplane).EndInit();
|
((System.ComponentModel.ISupportInitialize)pictureBoxSeaplane).EndInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)numericUpDownNumberOfWindows).EndInit();
|
||||||
ResumeLayout(false);
|
ResumeLayout(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -134,5 +149,6 @@
|
|||||||
private Button buttonDown;
|
private Button buttonDown;
|
||||||
private Button buttonUp;
|
private Button buttonUp;
|
||||||
private Button buttonRight;
|
private Button buttonRight;
|
||||||
|
private NumericUpDown numericUpDownNumberOfWindows;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -46,7 +46,7 @@
|
|||||||
Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)));
|
Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)));
|
||||||
_drawingSeaplane.SetPictureSize(pictureBoxSeaplane.Width, pictureBoxSeaplane.Height);
|
_drawingSeaplane.SetPictureSize(pictureBoxSeaplane.Width, pictureBoxSeaplane.Height);
|
||||||
_drawingSeaplane.SetPosition(random.Next(10, 100), random.Next(10, 100));
|
_drawingSeaplane.SetPosition(random.Next(10, 100), random.Next(10, 100));
|
||||||
|
_drawingSeaplane.Windows.WinNum = (int)numericUpDownNumberOfWindows.Value;
|
||||||
Draw();
|
Draw();
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -84,7 +84,5 @@
|
|||||||
Draw();
|
Draw();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
25
ProjectSeaplane/ProjectSeaplane/NumberOfWindows.cs
Normal file
25
ProjectSeaplane/ProjectSeaplane/NumberOfWindows.cs
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ProjectSeaplane;
|
||||||
|
/// <summary>
|
||||||
|
/// Количество иллюминаторов
|
||||||
|
/// </summary>
|
||||||
|
public enum NumberOfWindows
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 10 иллюминаторов
|
||||||
|
/// </summary>
|
||||||
|
TenWindows,
|
||||||
|
/// <summary>
|
||||||
|
/// 20 иллюминаторов
|
||||||
|
/// </summary>
|
||||||
|
TwentyWindows,
|
||||||
|
/// <summary>
|
||||||
|
/// 30 иллюминаторов
|
||||||
|
/// </summary>
|
||||||
|
ThirtyWindows
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user