diff --git a/Airbus/Airbus/DrawningAirbus.cs b/Airbus/Airbus/DrawningAirbus.cs index 06df580..aa08d78 100644 --- a/Airbus/Airbus/DrawningAirbus.cs +++ b/Airbus/Airbus/DrawningAirbus.cs @@ -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); diff --git a/Airbus/Airbus/FormAirbus.cs b/Airbus/Airbus/FormAirbus.cs index ff30d83..8dde536 100644 --- a/Airbus/Airbus/FormAirbus.cs +++ b/Airbus/Airbus/FormAirbus.cs @@ -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(); diff --git a/Airbus/Airbus/MapWithSetPlanesGeneric.cs b/Airbus/Airbus/MapWithSetPlanesGeneric.cs index b1e12fe..9b3ea1f 100644 --- a/Airbus/Airbus/MapWithSetPlanesGeneric.cs +++ b/Airbus/Airbus/MapWithSetPlanesGeneric.cs @@ -45,30 +45,12 @@ namespace Airbus //пеергрузка оператора сложения public static int operator +(MapWithSetPlanesGeneric map, T plane) { - /*if (map._setPlanes.Insert(plane) != -1) - { - return true; - } - else - { - return false; - }*/ - return map._setPlanes.Insert(plane); } //перегрузка оператора вычитания public static T operator -(MapWithSetPlanesGeneric map, int position) { - /*if (map._setPlanes.Remove(position) != null) - { - return true; - } - else - { - return false; - }*/ - return map._setPlanes.Remove(position); } diff --git a/Airbus/Airbus/SetPlanesGeneric.cs b/Airbus/Airbus/SetPlanesGeneric.cs index 59935f1..9c9a974 100644 --- a/Airbus/Airbus/SetPlanesGeneric.cs +++ b/Airbus/Airbus/SetPlanesGeneric.cs @@ -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; }