E.E. Eliseev Lab Work 03 #4

Merged
eegov merged 5 commits from LabWork03 into LabWork02 2022-10-14 08:56:47 +04:00
4 changed files with 38 additions and 30 deletions
Showing only changes of commit 1e66082200 - Show all commits

View File

@ -102,16 +102,17 @@ namespace Airbus
}
Pen pen = new(Color.Black);
Brush darkBrush = new SolidBrush(Color.DarkKhaki);
Brush selectedBrush = new SolidBrush(Airbus.CorpusColor);
Brush darcBlue = new SolidBrush(Color.DarkSlateBlue);
Brush darkBrush = new SolidBrush(Color.Black);
//корпус
g.FillRectangle(darkBrush, _startPosX, _startPosY + 10, 40, 10);
g.FillRectangle(selectedBrush, _startPosX, _startPosY + 10, 40, 10);
g.DrawRectangle(pen, _startPosX, _startPosY + 10, 40, 10);
//крыло
g.FillRectangle(darkBrush, _startPosX + 10, _startPosY + 13, 20, 2);
g.FillRectangle(darkBrush, _startPosX + 12, _startPosY + 15, 16, 2);
g.FillRectangle(selectedBrush, _startPosX + 10, _startPosY + 13, 20, 2);
g.FillRectangle(selectedBrush, _startPosX + 12, _startPosY + 15, 16, 2);
g.DrawRectangle(pen, _startPosX + 10, _startPosY + 13, 20, 2);
g.DrawRectangle(pen, _startPosX + 12, _startPosY + 15, 16, 2);
@ -124,12 +125,12 @@ namespace Airbus
new Point((int)_startPosX, (int)_startPosY + 10)
};
g.FillPolygon(darkBrush, point_tailWing);
g.FillPolygon(selectedBrush, point_tailWing);
g.DrawLine(pen, _startPosX, _startPosY + 10, _startPosX, _startPosY);
g.DrawLine(pen, _startPosX, _startPosY, _startPosX + 10, _startPosY + 10);
//заднее поперечное крыло
g.FillEllipse(darkBrush, _startPosX - 3, _startPosY + 7, 10, 5);
g.FillEllipse(selectedBrush, _startPosX - 3, _startPosY + 7, 10, 5);
g.DrawEllipse(pen, _startPosX - 3, _startPosY + 7, 10, 5);
//нос самолёта
@ -152,7 +153,7 @@ namespace Airbus
};
g.FillPolygon(darcBlue, point_upperBow);
g.FillPolygon(darkBrush, point_lowerBow);
g.FillPolygon(selectedBrush, point_lowerBow);
g.DrawLine(pen, _startPosX + 40, _startPosY + 15, _startPosX + 50, _startPosY + 16);
g.DrawLine(pen, _startPosX + 40, _startPosY + 10, _startPosX + 47, _startPosY + 15);
g.DrawLine(pen, _startPosX + 40, _startPosY + 20, _startPosX + 50, _startPosY + 15);

View File

@ -45,8 +45,15 @@ namespace Airbus
private void ButtonCreate_Click(object sender, EventArgs e)
{
Random rnd = new();
_airbus = new DrawningAirbus(rnd.Next(100, 300), rnd.Next(1000, 2000),
Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
Color color = Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256));
ColorDialog dialog = new();
if (dialog.ShowDialog() == DialogResult.OK)
{
color = dialog.Color;
}
_airbus = new DrawningAirbus(rnd.Next(100, 300), rnd.Next(1000, 2000), color);
SetData();
Draw();
}
@ -84,9 +91,23 @@ namespace Airbus
private void ButtonCreateModif_Click(object sender, EventArgs e)
{
Random rnd = new();
_airbus = new DrawningSuperAirbus(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)),
Color color = Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256));
ColorDialog dialog = new();
if(dialog.ShowDialog() == DialogResult.OK)
{
color = dialog.Color;
}
Color addColor = Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256));
ColorDialog dialogAdd = new();
if(dialogAdd.ShowDialog() == DialogResult.OK)
{
addColor = dialogAdd.Color;
}
_airbus = new DrawningSuperAirbus(rnd.Next(100, 300), rnd.Next(1000, 2000), color, addColor,
Convert.ToBoolean(rnd.Next(0, 2)), Convert.ToBoolean(rnd.Next(0, 2)));
SetData();
Draw();

View File

@ -45,30 +45,12 @@ namespace Airbus
//пеергрузка оператора сложения
public static int operator +(MapWithSetPlanesGeneric<T, U> map, T plane)
{
/*if (map._setPlanes.Insert(plane) != -1)
{
return true;
}
else
{
return false;
}*/
return map._setPlanes.Insert(plane);
}
//перегрузка оператора вычитания
public static T operator -(MapWithSetPlanesGeneric<T, U> map, int position)
{
/*if (map._setPlanes.Remove(position) != null)
{
return true;
}
else
{
return false;
}*/
return map._setPlanes.Remove(position);
}

View File

@ -92,6 +92,10 @@ namespace Airbus
public T Get(int position)
{
if (position >= _places.Length || position < 0)
{
return null;
}
else if (_places[position] == null)
{
return null;
}