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,14 +1,14 @@
namespace WarmlyShip
{
partial class Form1
partial class pictureBoxShips
{
/// <summary>
/// Required designer variable.
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
@ -19,19 +19,25 @@
}
base.Dispose(disposing);
}
//123
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Text = "Form1";
SuspendLayout();
//
// pictureBoxShips
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(900, 500);
Name = "pictureBoxShips";
Text = "pictureBoxShips";
ResumeLayout(false);
}
#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();
}
}
}

View File

@ -1,17 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
@ -26,36 +26,36 @@
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->