Добавление цветового диалога

This commit is contained in:
Володя 2022-10-09 21:48:40 +03:00
parent 5ccb3d550f
commit cceb17014c
2 changed files with 22 additions and 10 deletions

View File

@ -29,10 +29,13 @@ namespace AirPlaneWithRadar
private void ButtonCreate_Click(object sender, EventArgs e) private void ButtonCreate_Click(object sender, EventArgs e)
{ {
Random rnd = new(); Random rnd = new();
_plain = new DrawingPlain(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;
}
_plain = new DrawingPlain(rnd.Next(100, 300), rnd.Next(1000, 2000), color);
SetData(); SetData();
Draw(); Draw();
} }
@ -67,13 +70,22 @@ namespace AirPlaneWithRadar
{ {
Random rnd = new(); Random rnd = new();
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 dopColor = Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256));
ColorDialog dialogDop = new();
if (dialogDop.ShowDialog() == DialogResult.OK)
{
dopColor = dialogDop.Color;
}
_plain = new DrawingRadarPlane(rnd.Next(100, 300), rnd.Next(1000, 2000), _plain = new DrawingRadarPlane(rnd.Next(100, 300), rnd.Next(1000, 2000),
Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)), color,
Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)), dopColor,
Convert.ToBoolean(rnd.Next(0, 2)), Convert.ToBoolean(rnd.Next(0, 2))); Convert.ToBoolean(rnd.Next(0, 2)), Convert.ToBoolean(rnd.Next(0, 2)));
SetData(); SetData();
Draw(); Draw();
} }

View File

@ -63,7 +63,7 @@ namespace AirPlaneWithRadar
public T Remove(int position) public T Remove(int position)
{ {
T mid; T mid;
if (_places[position] != null) if (_places[position] != null && position < _places.Length)
{ {
mid = _places[position]; mid = _places[position];
_places[position] = null; _places[position] = null;