part lab1

This commit is contained in:
PIbd-13_Valiullin 2024-02-13 11:21:02 +04:00
parent f6b09f5478
commit 802379a969
7 changed files with 199 additions and 45 deletions

View File

@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WarmlyShip
{
internal enum DirectionType
{
Up = 1,
Down = 2,
Left = 3,
Right = 4
}
}

View File

@ -0,0 +1,87 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WarmlyShip
{
internal class DrawningWarmlyShip
{
public EntityWarmlyShip? EntityWarmlyShip { get; private set; }
private int? _pictureWidth;
private int? _pictureHeight;
private int? _startPosX;
private int? _startPosY;
private readonly int _drawningCarWidth = 110;
private readonly int _drawningCarHeight = 60;
public void Init(int speed, double weight, Color bodyColor, Color seckondColor, bool fuelHole, bool pipes)
{
EntityWarmlyShip = new EntityWarmlyShip();
EntityWarmlyShip.Init(speed, weight, bodyColor, seckondColor, fuelHole, pipes);
_pictureHeight = null;
_pictureWidth = null;
_startPosX = null;
_startPosY = null;
}
public bool SetPictureSize(int width, int height)
{
// проверить влазит или не влазит
_pictureHeight = width;
_pictureWidth = height;
return true;
}
public void SetPosition(int x, int y)
{
if (!_pictureHeight.HasValue || !_pictureWidth.HasValue) {
return;
}
// корректировка координат ессли не влазит
_startPosX = x;
_startPosY = y;
}
public bool MoveTransport(DirectionType direction)
{
if (EntityWarmlyShip == null || !_startPosX.HasValue || !_startPosY.HasValue)
{
return false;
}
switch (direction)
{
case DirectionType.Left:
if (_startPosY.Value - EntityWarmlyShip.Step > 0)
{
_startPosX -= (int)EntityWarmlyShip.Step;
}
return true;
case DirectionType.Up:
if (_startPosY.Value - EntityWarmlyShip.Step > 0)
{
_startPosY -= (int)EntityWarmlyShip.Step;
}
return true;
//дописать право и низ
default : return false;
}
}
public void DrawTransport(Graphics g)
{
if (EntityWarmlyShip == null || !_startPosX.HasValue || !_startPosY.HasValue)
{
return;
}
Pen pen = new(Color.Black);
// нарисовать корабль
}
}
}

View File

@ -1,10 +0,0 @@
namespace WarmlyShip
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
}
}

View File

@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WarmlyShip
{
class EntityWarmlyShip
{
public int Speed { get; set; }
public double Weight { get; set; }
public Color BodyColor { get; set; }
public Color SeckondColor { get; set; }
public bool FuelHole { get; set; }
public bool Pipes { get; set; }
public void Init(int speed, double weight, Color bodyColor, Color seckondColor, bool fuelHole, bool pipes)
{
Speed = speed;
Weight = weight;
BodyColor = bodyColor;
SeckondColor = seckondColor;
FuelHole = fuelHole;
Pipes = pipes;
}
public double Step => Speed * 100 / Weight;
}
}

View File

@ -1,6 +1,6 @@
namespace WarmlyShip namespace WarmlyShip
{ {
partial class Form1 partial class pictureBoxShips
{ {
/// <summary> /// <summary>
/// Required designer variable. /// Required designer variable.
@ -19,7 +19,7 @@
} }
base.Dispose(disposing); base.Dispose(disposing);
} }
//123
#region Windows Form Designer generated code #region Windows Form Designer generated code
/// <summary> /// <summary>
@ -28,10 +28,16 @@
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
this.components = new System.ComponentModel.Container(); SuspendLayout();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; //
this.ClientSize = new System.Drawing.Size(800, 450); // pictureBoxShips
this.Text = "Form1"; //
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(900, 500);
Name = "pictureBoxShips";
Text = "pictureBoxShips";
ResumeLayout(false);
} }
#endregion #endregion

View File

@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WarmlyShip
{
public partial class pictureBoxShips : Form
{
public pictureBoxShips()
{
InitializeComponent();
}
}
}