Фикс2 Лабораторная работа 1

This commit is contained in:
ivans 2024-02-14 15:03:05 +04:00
parent dcb0b44290
commit 4fbee86189
4 changed files with 62 additions and 68 deletions

View File

@ -69,15 +69,34 @@ public class DrawingSeaplane
// TODO проверка, что объект "влезает" в размеры поля // TODO проверка, что объект "влезает" в размеры поля
// если влезает, сохраняем границы и корректируем позицию объекта, если она была уже установлена // если влезает, сохраняем границы и корректируем позицию объекта, если она была уже установлена
if (_drawningSeaplaneWidth < width && _drawningSeaplaneHeight < height)
{
_pictureWidth = width; _pictureWidth = width;
_pictureHeight = height; _pictureHeight = height;
if (_startPosX != null && _startPosY != null)
{
if (_startPosX + _drawningSeaplaneWidth > width)
{
_startPosX = width - (_drawningSeaplaneWidth + 1);
if (_drawningSeaplaneWidth < width && _drawningSeaplaneHeight < height) {
return true;
} }
else { return false; } if (_startPosY + _drawningSeaplaneWidth > height)
{
_startPosY = height - (_drawningSeaplaneHeight + 1);
}
}
return true;
}
return false;
} }
@ -98,13 +117,21 @@ public class DrawingSeaplane
_startPosX = x; _startPosX = x;
_startPosY = y; _startPosY = y;
if (_drawningSeaplaneWidth - _startPosX < 0) if (_startPosX < 0)
{ {
_startPosX += _drawningSeaplaneWidth; _startPosX = 0;
} }
if (_drawningSeaplaneHeight - _startPosY < 0) if (_startPosY < 0)
{ {
_startPosY += _drawningSeaplaneHeight; _startPosY = 0;
}
if (_startPosX + _drawningSeaplaneWidth > _pictureWidth)
{
_startPosX = _pictureWidth - _drawningSeaplaneWidth;
}
if (_startPosY - _drawningSeaplaneHeight > _pictureHeight)
{
_startPosY = _pictureHeight - _drawningSeaplaneHeight;
} }
} }
@ -251,48 +278,14 @@ public class DrawingSeaplane
g.FillEllipse(brAdditional, _startPosX.Value + 30, _startPosY.Value + 12, 40, 15); g.FillEllipse(brAdditional, _startPosX.Value + 30, _startPosY.Value + 12, 40, 15);
g.FillPolygon(brAdditional, Radar); g.FillPolygon(brAdditional, Radar);
} }
else { else
{
} }
//Пилоты //Пилоты
g.FillEllipse(brWhity, _startPosX.Value + 115, _startPosY.Value + 34, 20, 8); g.FillEllipse(brWhity, _startPosX.Value + 115, _startPosY.Value + 34, 20, 8);
//границы автомобиля
//g.DrawEllipse(pen, _startPosX.Value + 10, _startPosY.Value + 5, 20, 20);
//g.DrawEllipse(pen, _startPosX.Value + 10, _startPosY.Value + 35, 20, 20);
//g.DrawEllipse(pen, _startPosX.Value + 80, _startPosY.Value + 5, 20, 20);
//g.DrawEllipse(pen, _startPosX.Value + 80, _startPosY.Value + 35, 20, 20);
//g.DrawRectangle(pen, _startPosX.Value + 9, _startPosY.Value + 15, 10, 30);
//g.DrawRectangle(pen, _startPosX.Value + 90, _startPosY.Value + 15, 10, 30);
//g.DrawRectangle(pen, _startPosX.Value + 20, _startPosY.Value + 4, 70, 52);
////задние фары
//Brush brRed = new SolidBrush(Color.Red);
//g.FillEllipse(brRed, _startPosX.Value + 10, _startPosY.Value + 5, 20, 20);
//g.FillEllipse(brRed, _startPosX.Value + 10, _startPosY.Value + 35, 20, 20);
////передние фары
//Brush brYellow = new SolidBrush(Color.Yellow);
//g.FillEllipse(brYellow, _startPosX.Value + 80, _startPosY.Value + 5, 20, 20);
//g.FillEllipse(brYellow, _startPosX.Value + 80, _startPosY.Value + 35, 20, 20);
////кузов
//Brush br = new SolidBrush(EntitySeaplane.BodyColor);
//g.FillRectangle(br, _startPosX.Value + 10, _startPosY.Value + 15, 10, 30);
//g.FillRectangle(br, _startPosX.Value + 90, _startPosY.Value + 15, 10, 30);
//g.FillRectangle(br, _startPosX.Value + 20, _startPosY.Value + 5, 70, 50);
////стекла
//Brush brBlue = new SolidBrush(Color.LightBlue);
//g.FillRectangle(brBlue, _startPosX.Value + 70, _startPosY.Value + 10, 5, 40);
//g.FillRectangle(brBlue, _startPosX.Value + 30, _startPosY.Value + 10, 5, 40);
//g.FillRectangle(brBlue, _startPosX.Value + 35, _startPosY.Value + 8, 35, 2);
//g.FillRectangle(brBlue, _startPosX.Value + 35, _startPosY.Value + 51, 35, 2);
////выделяем рамкой крышу
//g.DrawRectangle(pen, _startPosX.Value + 35, _startPosY.Value + 10, 35, 40);
//g.DrawRectangle(pen, _startPosX.Value + 75, _startPosY.Value + 15, 25, 30);
//g.DrawRectangle(pen, _startPosX.Value + 10, _startPosY.Value + 15, 15, 30);

View File

@ -40,7 +40,7 @@ public class EntitySeaplane
/// <param name="bodyColor">Основной цвет</param> /// <param name="bodyColor">Основной цвет</param>
/// <param name="additionalColor">Дополнительный цвет</param> /// <param name="additionalColor">Дополнительный цвет</param>
/// <param name="landingGear">Тип "шасси"</param> /// <param name="landingGear">Тип "шасси"</param>
/// <param name="radar">Тип двигателя</param> /// <param name="radar">При</param>
public void Init(int speed, double weight, Color bodyColor, Color additionalColor, bool landingGear, bool radar) public void Init(int speed, double weight, Color bodyColor, Color additionalColor, bool landingGear, bool radar)
{ {
Speed = speed; Speed = speed;

View File

@ -42,15 +42,14 @@
pictureBoxSeaplane.Dock = DockStyle.Fill; pictureBoxSeaplane.Dock = DockStyle.Fill;
pictureBoxSeaplane.Location = new Point(0, 0); pictureBoxSeaplane.Location = new Point(0, 0);
pictureBoxSeaplane.Name = "pictureBoxSeaplane"; pictureBoxSeaplane.Name = "pictureBoxSeaplane";
pictureBoxSeaplane.Size = new Size(776, 531); pictureBoxSeaplane.Size = new Size(590, 379);
pictureBoxSeaplane.TabIndex = 0; pictureBoxSeaplane.TabIndex = 0;
pictureBoxSeaplane.TabStop = false; pictureBoxSeaplane.TabStop = false;
// //
// buttonCreate // buttonCreate
// //
buttonCreate.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; buttonCreate.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
buttonCreate.Location = new Point(12, 501); buttonCreate.Location = new Point(12, 349);
buttonCreate.Name = "buttonCreate"; buttonCreate.Name = "buttonCreate";
buttonCreate.Size = new Size(75, 23); buttonCreate.Size = new Size(75, 23);
buttonCreate.TabIndex = 1; buttonCreate.TabIndex = 1;
@ -64,7 +63,7 @@
buttonLeft.BackColor = Color.Snow; buttonLeft.BackColor = Color.Snow;
buttonLeft.BackgroundImage = Properties.Resources.arrow11; buttonLeft.BackgroundImage = Properties.Resources.arrow11;
buttonLeft.BackgroundImageLayout = ImageLayout.Stretch; buttonLeft.BackgroundImageLayout = ImageLayout.Stretch;
buttonLeft.Location = new Point(651, 489); buttonLeft.Location = new Point(465, 337);
buttonLeft.Name = "buttonLeft"; buttonLeft.Name = "buttonLeft";
buttonLeft.Size = new Size(35, 35); buttonLeft.Size = new Size(35, 35);
buttonLeft.TabIndex = 2; buttonLeft.TabIndex = 2;
@ -77,7 +76,7 @@
buttonDown.BackColor = Color.Snow; buttonDown.BackColor = Color.Snow;
buttonDown.BackgroundImage = Properties.Resources.arrow4; buttonDown.BackgroundImage = Properties.Resources.arrow4;
buttonDown.BackgroundImageLayout = ImageLayout.Stretch; buttonDown.BackgroundImageLayout = ImageLayout.Stretch;
buttonDown.Location = new Point(692, 489); buttonDown.Location = new Point(506, 337);
buttonDown.Name = "buttonDown"; buttonDown.Name = "buttonDown";
buttonDown.Size = new Size(35, 35); buttonDown.Size = new Size(35, 35);
buttonDown.TabIndex = 4; buttonDown.TabIndex = 4;
@ -90,7 +89,7 @@
buttonUp.BackColor = Color.Snow; buttonUp.BackColor = Color.Snow;
buttonUp.BackgroundImage = Properties.Resources.arrow2; buttonUp.BackgroundImage = Properties.Resources.arrow2;
buttonUp.BackgroundImageLayout = ImageLayout.Stretch; buttonUp.BackgroundImageLayout = ImageLayout.Stretch;
buttonUp.Location = new Point(692, 449); buttonUp.Location = new Point(506, 297);
buttonUp.Name = "buttonUp"; buttonUp.Name = "buttonUp";
buttonUp.Size = new Size(35, 35); buttonUp.Size = new Size(35, 35);
buttonUp.TabIndex = 5; buttonUp.TabIndex = 5;
@ -103,7 +102,7 @@
buttonRight.BackColor = Color.Snow; buttonRight.BackColor = Color.Snow;
buttonRight.BackgroundImage = Properties.Resources.arrow3; buttonRight.BackgroundImage = Properties.Resources.arrow3;
buttonRight.BackgroundImageLayout = ImageLayout.Stretch; buttonRight.BackgroundImageLayout = ImageLayout.Stretch;
buttonRight.Location = new Point(733, 489); buttonRight.Location = new Point(547, 337);
buttonRight.Name = "buttonRight"; buttonRight.Name = "buttonRight";
buttonRight.Size = new Size(35, 35); buttonRight.Size = new Size(35, 35);
buttonRight.TabIndex = 7; buttonRight.TabIndex = 7;
@ -114,7 +113,7 @@
// //
AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font; AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(776, 531); ClientSize = new Size(590, 379);
Controls.Add(buttonRight); Controls.Add(buttonRight);
Controls.Add(buttonUp); Controls.Add(buttonUp);
Controls.Add(buttonDown); Controls.Add(buttonDown);

View File

@ -84,5 +84,7 @@
Draw(); Draw();
} }
} }
} }
} }