PIbd-13 Valiullin R.A.LabWork01 Simple #1
@ -6,7 +6,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace WarmlyShip
|
||||
{
|
||||
internal enum DirectionType
|
||||
public enum DirectionType
|
||||
{
|
||||
Up = 1,
|
||||
Down = 2,
|
||||
|
@ -6,7 +6,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace WarmlyShip
|
||||
{
|
||||
internal class DrawningWarmlyShip
|
||||
public class DrawningWarmlyShip
|
||||
{
|
||||
public EntityWarmlyShip? EntityWarmlyShip { get; private set; }
|
||||
|
||||
@ -17,9 +17,9 @@ namespace WarmlyShip
|
||||
private int? _startPosX;
|
||||
|
||||
private int? _startPosY;
|
||||
private readonly int _drawningCarWidth = 110;
|
||||
private readonly int _drawningWarmlyShipWidth = 150;
|
||||
|
||||
private readonly int _drawningCarHeight = 60;
|
||||
private readonly int _drawningWarmlyShipHeight = 80;
|
||||
|
||||
public void Init(int speed, double weight, Color bodyColor, Color seckondColor, bool fuelHole, bool pipes)
|
||||
{
|
||||
@ -32,9 +32,12 @@ namespace WarmlyShip
|
||||
}
|
||||
public bool SetPictureSize(int width, int height)
|
||||
{
|
||||
// проверить влазит или не влазит
|
||||
_pictureHeight = width;
|
||||
_pictureWidth = height;
|
||||
|
||||
|
||||
_pictureHeight = height;
|
||||
_pictureWidth = width;
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
public void SetPosition(int x, int y)
|
||||
@ -46,6 +49,21 @@ namespace WarmlyShip
|
||||
// корректировка координат ессли не влазит
|
||||
_startPosX = x;
|
||||
_startPosY = y;
|
||||
|
||||
if (_pictureHeight < _drawningWarmlyShipHeight || _pictureWidth < _drawningWarmlyShipWidth)
|
||||
{
|
||||
EntityWarmlyShip = null;
|
||||
}
|
||||
else if (_pictureHeight < _drawningWarmlyShipHeight + _startPosY.Value || _pictureWidth < _drawningWarmlyShipWidth + _startPosX.Value)
|
||||
{
|
||||
_startPosX = 0;
|
||||
_startPosY = 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
public bool MoveTransport(DirectionType direction)
|
||||
{
|
||||
@ -53,6 +71,7 @@ namespace WarmlyShip
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (direction)
|
||||
{
|
||||
case DirectionType.Left:
|
||||
@ -68,8 +87,21 @@ namespace WarmlyShip
|
||||
_startPosY -= (int)EntityWarmlyShip.Step;
|
||||
}
|
||||
return true;
|
||||
//дописать право и низ
|
||||
|
||||
case DirectionType.Right:
|
||||
if (_startPosX.Value + _drawningWarmlyShipWidth + EntityWarmlyShip.Step < _pictureWidth)
|
||||
{
|
||||
_startPosX += (int)EntityWarmlyShip.Step;
|
||||
}
|
||||
return true;
|
||||
|
||||
case DirectionType.Down:
|
||||
if (_startPosY.Value + _drawningWarmlyShipHeight + EntityWarmlyShip.Step < _pictureHeight)
|
||||
{
|
||||
_startPosY += (int)EntityWarmlyShip.Step;
|
||||
}
|
||||
return true;
|
||||
|
||||
default : return false;
|
||||
}
|
||||
}
|
||||
@ -80,8 +112,51 @@ namespace WarmlyShip
|
||||
{
|
||||
return;
|
||||
}
|
||||
Pen pen = new(Color.Black);
|
||||
|
||||
|
||||
// нарисовать корабль
|
||||
Pen pen = new(Color.Black, 2);
|
||||
Brush brMain = new SolidBrush(EntityWarmlyShip.BodyColor);
|
||||
Brush brSecond = new SolidBrush(EntityWarmlyShip.SeckondColor);
|
||||
// трапеция
|
||||
Point[] points = new Point[]
|
||||
{
|
||||
|
||||
new Point(_startPosX.Value, _startPosY.Value+50),
|
||||
new Point(_startPosX.Value + 150, _startPosY.Value+ 50),
|
||||
new Point(_startPosX.Value + 120, _startPosY.Value + 80),
|
||||
new Point(_startPosX.Value + 30, _startPosY.Value + 80)
|
||||
|
||||
};
|
||||
g.FillPolygon(brMain, points);
|
||||
g.DrawPolygon(pen, points);
|
||||
|
||||
//палуба
|
||||
g.FillRectangle(brMain, _startPosX.Value + 25, _startPosY.Value + 30, 100, 20);
|
||||
g.DrawRectangle(pen, _startPosX.Value + 25, _startPosY.Value + 30, 100, 20);
|
||||
|
||||
//якорь
|
||||
g.DrawLine(pen, _startPosX.Value + 30, _startPosY.Value + 53, _startPosX.Value + 30, _startPosY.Value + 70);
|
||||
g.DrawLine(pen, _startPosX.Value + 23, _startPosY.Value + 70, _startPosX.Value + 37, _startPosY.Value + 70);
|
||||
g.DrawLine(pen, _startPosX.Value + 23, _startPosY.Value + 60, _startPosX.Value + 37, _startPosY.Value + 60);
|
||||
|
||||
Brush blackBr = new SolidBrush(Color.Black);
|
||||
|
||||
//трубы
|
||||
if (EntityWarmlyShip.Pipes)
|
||||
{
|
||||
|
||||
g.FillRectangle(brSecond, _startPosX.Value + 35, _startPosY.Value, 20, 30);
|
||||
g.FillRectangle(brSecond, _startPosX.Value + 64, _startPosY.Value, 20, 30);
|
||||
g.FillRectangle(brSecond, _startPosX.Value + 93, _startPosY.Value, 20, 30);
|
||||
}
|
||||
|
||||
//топливный отсек
|
||||
if (EntityWarmlyShip.FuelHole)
|
||||
{
|
||||
g.FillEllipse(brSecond, _startPosX.Value + 100, _startPosY.Value + 55, 15, 15);
|
||||
g.DrawEllipse(pen, _startPosX.Value + 100, _startPosY.Value + 55, 15, 15);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
62
WarmlyShip/WarmlyShip/EntityWarmlyShip.cs
Normal file
62
WarmlyShip/WarmlyShip/EntityWarmlyShip.cs
Normal file
@ -0,0 +1,62 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WarmlyShip
|
||||
{
|
||||
public class EntityWarmlyShip
|
||||
{
|
||||
/// <summary>
|
||||
/// Скорость
|
||||
/// </summary>
|
||||
public int Speed { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Вес
|
||||
/// </summary>
|
||||
public double Weight { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Основной цвет
|
||||
/// </summary>
|
||||
public Color BodyColor { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// доп. цвет
|
||||
/// </summary>
|
||||
public Color SeckondColor { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// признак наличия отсека для топлива
|
||||
/// </summary>
|
||||
public bool FuelHole { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Признак наличия трубы
|
||||
/// </summary>
|
||||
public bool Pipes { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="speed"> скорость </param>
|
||||
/// <param name="weight">вес</param>
|
||||
/// <param name="bodyColor">основной цвет</param>
|
||||
/// <param name="seckondColor">доп. цвет</param>
|
||||
/// <param name="fuelHole">признак наличия отсека для топлива</param>
|
||||
/// <param name="pipes">признак наличия трубы</param>
|
||||
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;
|
||||
}
|
||||
}
|
@ -11,7 +11,7 @@ namespace WarmlyShip
|
||||
// To customize application configuration such as set high DPI settings or default font,
|
||||
// see https://aka.ms/applicationconfiguration.
|
||||
ApplicationConfiguration.Initialize();
|
||||
Application.Run(new Form1());
|
||||
Application.Run(new pictureBoxShips());
|
||||
}
|
||||
}
|
||||
}
|
103
WarmlyShip/WarmlyShip/Properties/Resources.Designer.cs
generated
Normal file
103
WarmlyShip/WarmlyShip/Properties/Resources.Designer.cs
generated
Normal file
@ -0,0 +1,103 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace WarmlyShip.Properties {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// </summary>
|
||||
// This class was auto-generated by the StronglyTypedResourceBuilder
|
||||
// class via a tool like ResGen or Visual Studio.
|
||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
// with the /str option, or rebuild your VS project.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class Resources {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal Resources() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("WarmlyShip.Properties.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the current thread's CurrentUICulture property for all
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap arrowDown {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("arrowDown", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap arrowLeft {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("arrowLeft", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap arrowRight {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("arrowRight", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap arrowUp {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("arrowUp", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
133
WarmlyShip/WarmlyShip/Properties/Resources.resx
Normal file
133
WarmlyShip/WarmlyShip/Properties/Resources.resx
Normal file
@ -0,0 +1,133 @@
|
||||
<?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
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<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
|
||||
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
|
||||
mimetype set.
|
||||
|
||||
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
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
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
|
||||
: 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
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
<data name="arrowDown" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\arrowDown.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="arrowLeft" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\arrowLeft.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="arrowRight" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\arrowRight.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="arrowUp" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\arrowUp.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
</root>
|
BIN
WarmlyShip/WarmlyShip/Resources/arrowDown.jpg
Normal file
BIN
WarmlyShip/WarmlyShip/Resources/arrowDown.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 61 KiB |
BIN
WarmlyShip/WarmlyShip/Resources/arrowLeft.jpg
Normal file
BIN
WarmlyShip/WarmlyShip/Resources/arrowLeft.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 60 KiB |
BIN
WarmlyShip/WarmlyShip/Resources/arrowRight.jpg
Normal file
BIN
WarmlyShip/WarmlyShip/Resources/arrowRight.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 60 KiB |
BIN
WarmlyShip/WarmlyShip/Resources/arrowUp.jpg
Normal file
BIN
WarmlyShip/WarmlyShip/Resources/arrowUp.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 61 KiB |
@ -1,35 +0,0 @@
|
||||
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;
|
||||
}
|
||||
}
|
@ -8,4 +8,19 @@
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Update="Properties\Resources.Designer.cs">
|
||||
<DesignTime>True</DesignTime>
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Update="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
92
WarmlyShip/WarmlyShip/pictureBoxShips.Designer.cs
generated
92
WarmlyShip/WarmlyShip/pictureBoxShips.Designer.cs
generated
@ -28,18 +28,108 @@
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
pictureBox1 = new PictureBox();
|
||||
buttonDown = new Button();
|
||||
buttonUp = new Button();
|
||||
buttonRight = new Button();
|
||||
buttonLeft = new Button();
|
||||
buttonCreate = new Button();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBox1).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// pictureBox1
|
||||
//
|
||||
pictureBox1.Dock = DockStyle.Fill;
|
||||
pictureBox1.Location = new Point(0, 0);
|
||||
pictureBox1.Name = "pictureBox1";
|
||||
pictureBox1.Size = new Size(854, 493);
|
||||
pictureBox1.TabIndex = 0;
|
||||
pictureBox1.TabStop = false;
|
||||
//
|
||||
// buttonDown
|
||||
//
|
||||
buttonDown.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
buttonDown.BackgroundImage = Properties.Resources.arrowDown;
|
||||
buttonDown.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
buttonDown.Location = new Point(766, 446);
|
||||
buttonDown.Name = "buttonDown";
|
||||
buttonDown.Size = new Size(35, 35);
|
||||
buttonDown.TabIndex = 10;
|
||||
buttonDown.UseVisualStyleBackColor = true;
|
||||
buttonDown.Click += ButtonMove_Click;
|
||||
//
|
||||
// buttonUp
|
||||
//
|
||||
buttonUp.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
buttonUp.BackgroundImage = Properties.Resources.arrowUp;
|
||||
buttonUp.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
buttonUp.Location = new Point(766, 405);
|
||||
buttonUp.Name = "buttonUp";
|
||||
buttonUp.Size = new Size(35, 35);
|
||||
buttonUp.TabIndex = 9;
|
||||
buttonUp.UseVisualStyleBackColor = true;
|
||||
buttonUp.Click += ButtonMove_Click;
|
||||
//
|
||||
// buttonRight
|
||||
//
|
||||
buttonRight.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
buttonRight.BackgroundImage = Properties.Resources.arrowRight;
|
||||
buttonRight.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
buttonRight.Location = new Point(807, 446);
|
||||
buttonRight.Name = "buttonRight";
|
||||
buttonRight.Size = new Size(35, 35);
|
||||
buttonRight.TabIndex = 8;
|
||||
buttonRight.UseVisualStyleBackColor = true;
|
||||
buttonRight.Click += ButtonMove_Click;
|
||||
//
|
||||
// buttonLeft
|
||||
//
|
||||
buttonLeft.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
buttonLeft.BackgroundImage = Properties.Resources.arrowLeft;
|
||||
buttonLeft.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
buttonLeft.Location = new Point(725, 446);
|
||||
buttonLeft.Name = "buttonLeft";
|
||||
buttonLeft.Size = new Size(35, 35);
|
||||
buttonLeft.TabIndex = 7;
|
||||
buttonLeft.UseVisualStyleBackColor = true;
|
||||
buttonLeft.Click += ButtonMove_Click;
|
||||
//
|
||||
// buttonCreate
|
||||
//
|
||||
buttonCreate.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
||||
buttonCreate.Location = new Point(17, 458);
|
||||
buttonCreate.Name = "buttonCreate";
|
||||
buttonCreate.Size = new Size(75, 23);
|
||||
buttonCreate.TabIndex = 6;
|
||||
buttonCreate.Text = "создать";
|
||||
buttonCreate.UseVisualStyleBackColor = true;
|
||||
buttonCreate.Click += ButtonCreate_Click;
|
||||
//
|
||||
// pictureBoxShips
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(900, 500);
|
||||
ClientSize = new Size(854, 493);
|
||||
Controls.Add(buttonDown);
|
||||
Controls.Add(buttonUp);
|
||||
Controls.Add(buttonRight);
|
||||
Controls.Add(buttonLeft);
|
||||
Controls.Add(buttonCreate);
|
||||
Controls.Add(pictureBox1);
|
||||
Name = "pictureBoxShips";
|
||||
StartPosition = FormStartPosition.CenterScreen;
|
||||
Text = "pictureBoxShips";
|
||||
((System.ComponentModel.ISupportInitialize)pictureBox1).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private PictureBox pictureBox1;
|
||||
|
||||
private Button buttonDown;
|
||||
private Button buttonUp;
|
||||
private Button buttonRight;
|
||||
private Button buttonLeft;
|
||||
private Button buttonCreate;
|
||||
}
|
||||
}
|
@ -12,9 +12,69 @@ namespace WarmlyShip
|
||||
{
|
||||
public partial class pictureBoxShips : Form
|
||||
eegov
commented
В названии класса должен присутствовать префикс или суффикс Form В названии класса должен присутствовать префикс или суффикс Form
|
||||
{
|
||||
private DrawningWarmlyShip? _drawningWarmlyShip;
|
||||
public pictureBoxShips()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void Draw()
|
||||
{
|
||||
|
||||
if (_drawningWarmlyShip == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Bitmap bmp = new(pictureBox1.Width, pictureBox1.Height);
|
||||
Graphics gr = Graphics.FromImage(bmp);
|
||||
_drawningWarmlyShip.DrawTransport(gr);
|
||||
pictureBox1.Image = bmp;
|
||||
}
|
||||
|
||||
private void ButtonCreate_Click(object sender, EventArgs e)
|
||||
{
|
||||
Random random = new();
|
||||
_drawningWarmlyShip = new DrawningWarmlyShip();
|
||||
_drawningWarmlyShip.Init(random.Next(100, 300), random.Next(1000, 3000),
|
||||
Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)),
|
||||
Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)),
|
||||
Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)));
|
||||
_drawningWarmlyShip.SetPictureSize(pictureBox1.Width, pictureBox1.Height);
|
||||
_drawningWarmlyShip.SetPosition(random.Next(10, 100), random.Next(10, 100));
|
||||
|
||||
Draw();
|
||||
}
|
||||
|
||||
private void ButtonMove_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_drawningWarmlyShip == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
string name = ((Button)sender)?.Name ?? string.Empty;
|
||||
bool result = false;
|
||||
switch (name)
|
||||
{
|
||||
case "buttonUp":
|
||||
result = _drawningWarmlyShip.MoveTransport(DirectionType.Up);
|
||||
break;
|
||||
case "buttonDown":
|
||||
result = _drawningWarmlyShip.MoveTransport(DirectionType.Down);
|
||||
break;
|
||||
case "buttonLeft":
|
||||
result = _drawningWarmlyShip.MoveTransport(DirectionType.Left);
|
||||
break;
|
||||
case "buttonRight":
|
||||
result = _drawningWarmlyShip.MoveTransport(DirectionType.Right);
|
||||
break;
|
||||
}
|
||||
|
||||
if (result)
|
||||
{
|
||||
Draw();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user
У элементов форм, с которыми работаем в логике должны быть логичные имена