DozorovaA.A_SecondLabWork #2

Merged
eegov merged 8 commits from SecondLabWork into FirstLabWork 2022-09-30 11:05:38 +04:00
14 changed files with 906 additions and 11 deletions
Showing only changes of commit 9120c6ecf9 - Show all commits

View File

@ -0,0 +1,209 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ArmoredVehicle
{
internal abstract class AbstractMap
{
private IDrawningObject _drawningObject = null;
protected int[,] _map = null;
protected int _width;
protected int _height;
protected float _size_x;
protected float _size_y;
protected readonly Random _random = new();
protected readonly int _freeRoad = 0;
protected readonly int _barrier = 1;
public Bitmap CreateMap(int width, int height, IDrawningObject drawningObject)
{
_width = width;
_height = height;
_drawningObject = drawningObject;
GenerateMap();
while (!SetObjectOnMap())
{
GenerateMap();
}
return DrawMapWithObject();
}
public Bitmap MoveObject(Direction direction)
{
bool possibility = true;
(float XTop, float YTop, float XBottom, float YBottom) = _drawningObject.GetCurrentPosition();
bool busy = false;
int i;
int j;
int jt;
int i1;
switch (direction)
{
// вправо
case Direction.Right:
busy = false;
i = Math.Abs((int)Math.Ceiling(XBottom / _size_x));
j = Math.Abs((int)Math.Ceiling(YBottom / _size_y));
jt = Math.Abs((int)Math.Ceiling(YTop / _size_y));
i1 = Math.Abs((int)Math.Ceiling((XBottom + _drawningObject.Step)/ _size_x));
for (int r = i; r < i1; ++r)
{
for (int b = jt; b < j; ++b)
{
if (_map[r, b] == _barrier)
{
busy = true;
break;
}
}
if (busy)
{
break;
}
}
break;
//влево
case Direction.Left:
busy = false;
i = (int)Math.Ceiling((XTop - _drawningObject.Step )/ _size_x);
j = (int)Math.Ceiling(YBottom / _size_y);
jt = (int)Math.Ceiling(YTop / _size_y);
i1 = (int)Math.Ceiling((XTop)/ _size_x);
for (int r = i; r < i1; ++r)
{
for (int b = jt; b < j; ++b)
{
if (_map[r, b] == _barrier)
{
busy = true;
break;
}
}
if (busy)
{
break;
}
}
break;
//вверх
case Direction.Up:
{
busy = false;
i = (int)Math.Ceiling((XTop) / _size_x);
j = (int)((YTop)/ _size_y);
jt = (int)((YTop - _drawningObject.Step )/ _size_y);
i1 = (int)Math.Ceiling(XBottom / _size_x);
for (int r = i; r < i1; ++r)
{
for (int b = jt; b < j; ++b)
{
if (_map[r, b] == _barrier)
{
busy = true;
break;
}
}
if (busy)
{
break;
}
}
break;
}
//вниз
case Direction.Down:
{
busy = false;
i = (int)Math.Ceiling(XTop / _size_x);
j = (int)((YBottom + _drawningObject.Step) / _size_y);
jt = (int)(YBottom / _size_y);
i1 = (int)Math.Ceiling(XBottom / _size_x);
for (int r = i; r <= i1; r++)
{
for (int b = jt; b <= j; b++)
{
if (_map[r, b] == _barrier)
{
busy = true;
break;
}
}
if (busy)
{
break;
}
}
break;
}
}
if (busy)
{
possibility = false;
}
if (possibility)
{
_drawningObject.MoveObject(direction);
}
return DrawMapWithObject();
}
private bool SetObjectOnMap()
{
if (_drawningObject == null || _map == null)
{
return false;
}
int x = _random.Next(0, 10);
int y = _random.Next(0, 10);
_drawningObject.SetObject(x, y, _width, _height);
// TODO првоерка, что объект не "накладывается" на закрытые участки
return true;
}
private Bitmap DrawMapWithObject()
{
Bitmap bmp = new(_width, _height);
if (_drawningObject == null || _map == null)
{
return bmp;
}
Graphics gr = Graphics.FromImage(bmp);
for (int i = 0; i < _map.GetLength(0); ++i)
{
for (int j = 0; j < _map.GetLength(1); ++j)
{
if (_map[i, j] == _freeRoad)
{
DrawRoadPart(gr, i, j);
}
else if (_map[i, j] == _barrier)
{
DrawBarrierPart(gr, i, j);
}
}
}
DrawRec(gr, 50, 50);
_drawningObject.DrawningObject(gr);
return bmp;
}
public void DrawRec(Graphics g, int countI, int couJj)
{
Pen p = new Pen(Color.Black);
for (int i = 0; i < countI; i++)
{
g.DrawLine(p, i * _size_x, 0, i * _size_x, 1000);
g.DrawLine(p, 0, i * _size_y, 1000, i * _size_y);
}
}
protected abstract void GenerateMap();
protected abstract void DrawRoadPart(Graphics g, int i, int j);
protected abstract void DrawBarrierPart(Graphics g, int i, int j);
}
}

View File

@ -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>

View File

@ -11,6 +11,7 @@ namespace ArmoredVehicle
/// </summary>
internal enum Direction
{
None = 0,
Up = 1,
Down = 2,
Left = 3,

View File

@ -31,11 +31,11 @@ namespace ArmoredVehicle
/// <summary>
/// Ширина отрисовки
/// </summary>
private readonly int _ArmoredVehicleWidth = 500;
private readonly int _ArmoredVehicleWidth = 200;
/// <summary>
/// Высота отрисовки
/// </summary>
private readonly int _ArmoredVehicleHeight = 100;
private readonly int _ArmoredVehicleHeight = 60;
/// <summary>
/// Инициализация свойств
/// </summary>
@ -161,9 +161,9 @@ namespace ArmoredVehicle
g.DrawRectangle(pen, _startPosX + 15, _startPosY+20, 200, 20);
g.DrawEllipse(pen, _startPosX + 15, _startPosY + 25, 200, 35);
pen = new(Color.Red);
g.DrawRectangle(pen, _startPosX + 15, _startPosY, _ArmoredVehicleWidth, _ArmoredVehicleHeight);
}
/// <summary>
/// Смена границ формы отрисовки
@ -195,7 +195,7 @@ namespace ArmoredVehicle
/// <returns></returns>
public (float Left, float Right, float Top, float Bottom) GetCurrentPosition()
{
return (_startPosX, _startPosY, _startPosX + _carWidth, _startPosY + _carHeight);
return (_startPosX + 15, _startPosY, _startPosX + 15 + _ArmoredVehicleWidth, _startPosY + _ArmoredVehicleHeight);
}
}
}

210
ArmoredVehicle/FormMap.Designer.cs generated Normal file
View File

@ -0,0 +1,210 @@
namespace ArmoredVehicle
{
partial class FormMap
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 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)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.ButtonDown = new System.Windows.Forms.Button();
this.ButtonRight = new System.Windows.Forms.Button();
this.ButtonLeft = new System.Windows.Forms.Button();
this.ButtonUp = new System.Windows.Forms.Button();
this.CreateButton = new System.Windows.Forms.Button();
this.DrawingPictureBox = new System.Windows.Forms.PictureBox();
this.toolStripStatusLabelSpeed = new System.Windows.Forms.ToolStripStatusLabel();
this.toolStripStatusLabelWeight = new System.Windows.Forms.ToolStripStatusLabel();
this.toolStripStatusLabelColor = new System.Windows.Forms.ToolStripStatusLabel();
this.statusStrip = new System.Windows.Forms.StatusStrip();
this.TankButton = new System.Windows.Forms.Button();
this.comboBoxSelectorMap = new System.Windows.Forms.ComboBox();
((System.ComponentModel.ISupportInitialize)(this.DrawingPictureBox)).BeginInit();
this.statusStrip.SuspendLayout();
this.SuspendLayout();
//
// ButtonDown
//
this.ButtonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.ButtonDown.BackgroundImage = global::ArmoredVehicle.Properties.Resources.arrowDown;
this.ButtonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.ButtonDown.Location = new System.Drawing.Point(711, 373);
this.ButtonDown.Name = "ButtonDown";
this.ButtonDown.Size = new System.Drawing.Size(30, 30);
this.ButtonDown.TabIndex = 13;
this.ButtonDown.UseVisualStyleBackColor = true;
this.ButtonDown.Click += new System.EventHandler(this.ButtonMove_Click);
//
// ButtonRight
//
this.ButtonRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.ButtonRight.BackgroundImage = global::ArmoredVehicle.Properties.Resources.arrowRight;
this.ButtonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.ButtonRight.Location = new System.Drawing.Point(754, 326);
this.ButtonRight.Name = "ButtonRight";
this.ButtonRight.Size = new System.Drawing.Size(30, 30);
this.ButtonRight.TabIndex = 12;
this.ButtonRight.UseVisualStyleBackColor = true;
this.ButtonRight.Click += new System.EventHandler(this.ButtonMove_Click);
//
// ButtonLeft
//
this.ButtonLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.ButtonLeft.BackgroundImage = global::ArmoredVehicle.Properties.Resources.arrowLeft;
this.ButtonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.ButtonLeft.Location = new System.Drawing.Point(671, 328);
this.ButtonLeft.Name = "ButtonLeft";
this.ButtonLeft.Size = new System.Drawing.Size(30, 30);
this.ButtonLeft.TabIndex = 11;
this.ButtonLeft.UseVisualStyleBackColor = true;
this.ButtonLeft.Click += new System.EventHandler(this.ButtonMove_Click);
//
// ButtonUp
//
this.ButtonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.ButtonUp.BackgroundImage = global::ArmoredVehicle.Properties.Resources.arrowUp;
this.ButtonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.ButtonUp.Location = new System.Drawing.Point(711, 278);
this.ButtonUp.Name = "ButtonUp";
this.ButtonUp.Size = new System.Drawing.Size(30, 30);
this.ButtonUp.TabIndex = 10;
this.ButtonUp.UseVisualStyleBackColor = true;
this.ButtonUp.Click += new System.EventHandler(this.ButtonMove_Click);
//
// CreateButton
//
this.CreateButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.CreateButton.Location = new System.Drawing.Point(12, 362);
this.CreateButton.Name = "CreateButton";
this.CreateButton.Size = new System.Drawing.Size(112, 34);
this.CreateButton.TabIndex = 9;
this.CreateButton.Text = "Создать";
this.CreateButton.UseVisualStyleBackColor = true;
this.CreateButton.Click += new System.EventHandler(this.ButtonCreate_Click);
//
// DrawingPictureBox
//
this.DrawingPictureBox.Dock = System.Windows.Forms.DockStyle.Fill;
this.DrawingPictureBox.Location = new System.Drawing.Point(0, 0);
this.DrawingPictureBox.Name = "DrawingPictureBox";
this.DrawingPictureBox.Size = new System.Drawing.Size(800, 418);
this.DrawingPictureBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
this.DrawingPictureBox.TabIndex = 7;
this.DrawingPictureBox.TabStop = false;
//
// toolStripStatusLabelSpeed
//
this.toolStripStatusLabelSpeed.Name = "toolStripStatusLabelSpeed";
this.toolStripStatusLabelSpeed.Size = new System.Drawing.Size(89, 25);
this.toolStripStatusLabelSpeed.Text = "Скорость";
//
// toolStripStatusLabelWeight
//
this.toolStripStatusLabelWeight.Name = "toolStripStatusLabelWeight";
this.toolStripStatusLabelWeight.Size = new System.Drawing.Size(39, 25);
this.toolStripStatusLabelWeight.Text = "Вес";
//
// toolStripStatusLabelColor
//
this.toolStripStatusLabelColor.Name = "toolStripStatusLabelColor";
this.toolStripStatusLabelColor.Size = new System.Drawing.Size(51, 25);
this.toolStripStatusLabelColor.Text = "Цвет";
//
// statusStrip
//
this.statusStrip.ImageScalingSize = new System.Drawing.Size(24, 24);
this.statusStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.toolStripStatusLabelSpeed,
this.toolStripStatusLabelWeight,
this.toolStripStatusLabelColor});
this.statusStrip.Location = new System.Drawing.Point(0, 418);
this.statusStrip.Name = "statusStrip";
this.statusStrip.Size = new System.Drawing.Size(800, 32);
this.statusStrip.TabIndex = 8;
this.statusStrip.Text = "statusStrip1";
//
// TankButton
//
this.TankButton.Location = new System.Drawing.Point(139, 365);
this.TankButton.Name = "TankButton";
this.TankButton.Size = new System.Drawing.Size(143, 34);
this.TankButton.TabIndex = 14;
this.TankButton.Text = "Модификация";
this.TankButton.UseVisualStyleBackColor = true;
this.TankButton.Click += new System.EventHandler(this.TankButton_Click);
//
// comboBoxSelectorMap
//
this.comboBoxSelectorMap.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBoxSelectorMap.FormattingEnabled = true;
this.comboBoxSelectorMap.Items.AddRange(new object[] {
"Простая карта"});
this.comboBoxSelectorMap.Location = new System.Drawing.Point(13, 321);
this.comboBoxSelectorMap.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.comboBoxSelectorMap.Name = "comboBoxSelectorMap";
this.comboBoxSelectorMap.Size = new System.Drawing.Size(171, 33);
this.comboBoxSelectorMap.TabIndex = 15;
this.comboBoxSelectorMap.SelectedIndexChanged += new System.EventHandler(this.comboBoxSelectorMap_SelectedIndexChanged_1);
//
// FormMap
//
this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 25F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Controls.Add(this.comboBoxSelectorMap);
this.Controls.Add(this.TankButton);
this.Controls.Add(this.ButtonDown);
this.Controls.Add(this.ButtonRight);
this.Controls.Add(this.ButtonLeft);
this.Controls.Add(this.ButtonUp);
this.Controls.Add(this.CreateButton);
this.Controls.Add(this.DrawingPictureBox);
this.Controls.Add(this.statusStrip);
this.MinimumSize = new System.Drawing.Size(210, 50);
this.Name = "FormMap";
this.Text = "Карта";
((System.ComponentModel.ISupportInitialize)(this.DrawingPictureBox)).EndInit();
this.statusStrip.ResumeLayout(false);
this.statusStrip.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private Button ButtonDown;
private Button ButtonRight;
private Button ButtonLeft;
private Button ButtonUp;
private Button CreateButton;
private PictureBox DrawingPictureBox;
private ToolStripStatusLabel toolStripStatusLabelSpeed;
private ToolStripStatusLabel toolStripStatusLabelWeight;
private ToolStripStatusLabel toolStripStatusLabelColor;
private StatusStrip statusStrip;
private Button TankButton;
private ComboBox comboBoxSelectorMap;
}
}

90
ArmoredVehicle/FormMap.cs Normal file
View File

@ -0,0 +1,90 @@
namespace ArmoredVehicle
{
public partial class FormMap : Form
{
private AbstractMap _abstractMap;
public FormMap()
{
InitializeComponent();
_abstractMap = new SimpleMap();
}
/// <summary>
/// Заполнение информации по объекту
/// </summary>
/// <param name="car"></param>
private void SetData(DrawingArmoredVehicle armoredVehicle)
{
toolStripStatusLabelSpeed.Text = $"Скорость: {armoredVehicle.ArmoredVehicle.Speed}";
toolStripStatusLabelWeight.Text = $"Вес: {armoredVehicle.ArmoredVehicle.Weight}";
toolStripStatusLabelColor.Text = $"Цвет: {armoredVehicle.ArmoredVehicle.BodyColor.Name}";
DrawingPictureBox.Image = _abstractMap.CreateMap(DrawingPictureBox.Width, DrawingPictureBox.Height,
new DrawningObject(armoredVehicle));
}
/// <summary>
/// Обработка нажатия кнопки "Создать"
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ButtonCreate_Click(object sender, EventArgs e)
{
Random rnd = new();
var machine = new DrawingArmoredVehicle(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
SetData(machine);
}
/// <summary>
/// Изменение размеров формы
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ButtonMove_Click(object sender, EventArgs e)
{
//получаем имя кнопки
string name = ((Button)sender)?.Name ?? string.Empty;
Direction dir = Direction.None;
switch (name)
{
case "ButtonUp":
dir = Direction.Up;
break;
case "ButtonDown":
dir = Direction.Down;
break;
case "ButtonLeft":
dir = Direction.Left;
break;
case "ButtonRight":
dir = Direction.Right;
break;
}
DrawingPictureBox.Image = _abstractMap?.MoveObject(dir);
}
/// <summary>
/// Смена карты
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void comboBoxSelectorMap_SelectedIndexChanged_1(object sender, EventArgs e)
{
switch (comboBoxSelectorMap.Text)
{
case "Простая карта":
_abstractMap = new SimpleMap();
break;
}
}
private void TankButton_Click(object sender, EventArgs e)
{
Random rnd = new();
var tank = new DrawingTank(rnd.Next(100, 300), rnd.Next(1000, 2000),
Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)),
Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)),
Convert.ToBoolean(rnd.Next(0, 2)), Convert.ToBoolean(rnd.Next(0, 2)), Convert.ToBoolean(rnd.Next(0, 2)));
SetData(tank);
}
}
}

View File

@ -0,0 +1,63 @@
<root>
<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>
<metadata name="statusStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>

View File

@ -40,6 +40,7 @@
this.toolStripStatusLabelColor = new System.Windows.Forms.ToolStripStatusLabel();
this.statusStrip = new System.Windows.Forms.StatusStrip();
this.TankButton = new System.Windows.Forms.Button();
this.Mapbutton = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.DrawingPictureBox)).BeginInit();
this.statusStrip.SuspendLayout();
this.SuspendLayout();
@ -155,11 +156,22 @@
this.TankButton.UseVisualStyleBackColor = true;
this.TankButton.Click += new System.EventHandler(this.TankButton_Click);
//
// Mapbutton
//
this.Mapbutton.Location = new System.Drawing.Point(304, 362);
this.Mapbutton.Name = "Mapbutton";
this.Mapbutton.Size = new System.Drawing.Size(179, 34);
this.Mapbutton.TabIndex = 15;
this.Mapbutton.Text = "Перейти на карту";
this.Mapbutton.UseVisualStyleBackColor = true;
this.Mapbutton.Click += new System.EventHandler(this.Mapbutton_Click);
//
// MainForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 25F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Controls.Add(this.Mapbutton);
this.Controls.Add(this.TankButton);
this.Controls.Add(this.ButtonDown);
this.Controls.Add(this.ButtonRight);
@ -192,5 +204,6 @@
private ToolStripStatusLabel toolStripStatusLabelColor;
private StatusStrip statusStrip;
private Button TankButton;
private Button Mapbutton;
}
}

View File

@ -99,5 +99,11 @@ namespace ArmoredVehicle
SetData();
Draw();
}
private void Mapbutton_Click(object sender, EventArgs e)
{
FormMap map = new FormMap();
map.Show();
}
}
}

View File

@ -61,7 +61,7 @@
<data name="ButtonDown.BackgroundImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAABkAAAAZACAIAAACubhnwAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO
vgAADr4B6kKxwAAAy5RJREFUeF7s/emTZGd54O/3L9eqbkkI1GKxkUHsCA8gsXhACBNsxoBsY2BYhIkY
vAAADrwBlbxySQAAy5RJREFUeF7s/emTZGd54O/3L9eqbkkI1GKxkUHsCA8gsXhACBNsxoBsY2BYhIkY
ApgAIeMxYRADg74QNjJbBMYwrIPD0oBZBHjAbGYkbGMW4wn+GI/VXZVL+XdX3tmHstDSLVU/dVfmdb04
8WTptfq583Oec/LIvwFAbV/+8pf/fwDU0+v1cnHkyJG4vu1tb1v+ww0A+03AAqA6AQugJgELgGYELACq
E7AAahKwAGhGwAKgOgELoCYBC4BmBCwAqhOwAGoSsABoRsACoDoBC6AmAQuAZgQsAKoTsABqErAAaEbA
@ -936,7 +936,7 @@
<data name="ButtonRight.BackgroundImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAABkAAAAZACAIAAACubhnwAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO
vgAADr4B6kKxwAAAtnhJREFUeF7s3fmbZXdVL/7NHs6p6m4ydRIvQwgJiQgSCJDwRUaVYICAPqjhEmVw
vAAADrwBlbxySQAAtnhJREFUeF7s3fmbZXdVL/7NHs6p6m4ydRIvQwgJiQgSCJDwRUaVYICAPqjhEmVw
iAo3xAjKKBBl8MEQUO5FgSBwITIJ6FUMgyZBCSjivX9O0nXG+q7aq2p7aELS6VTX2afq9frh86z92QdI
uqvO4367PmsXmwAAAADQYwIsAAAAAHpNgAUAAABArwmwAAAAAOg1ARYAAAAAvSbAAgAAAKDXBFgAAAAA
9JoACwAAAIBeE2ABAAAA0GsCLAAAAAB6TYAFAAAAQK8JsAAAAADoNQEWAAAAAL0mwAIAAACg1wRYAAAA
@ -1721,7 +1721,7 @@
<data name="ButtonLeft.BackgroundImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAABkAAAAZACAIAAACubhnwAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO
vgAADr4B6kKxwAAAt0tJREFUeF7s3fmXbHdZL/7qGvucEwicDBgkEIYwKCEB4mJIIiKwkEEGXQHBCA5c
vAAADrwBlbxySQAAt0tJREFUeF7s3fmXbHdZL/7qGvucEwicDBgkEIYwKCEB4mJIIiKwkEEGXQHBCA5c
hst0EQ34lcGrQBACsq5BJhUvYYoQVCZRQlBALsa77h9z17rprtq7Nt+n9lO9LUJCzsnp7r2r6/X64bOe
/al2mdNdVWvtN8/n2b0fAgAAAECHCbAAAAAA6DQBFgAAAACdJsACAAAAoNMEWAAAAAB0mgALAAAAgE4T
YAEAAADQaQIsAAAAADpNgAUAAABApwmwAAAAAOg0ARYAAAAAnSbAAgAAAKDTBFgAAAAAdJoACwAAAIBO
@ -2509,7 +2509,7 @@
<data name="ButtonUp.BackgroundImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAABkAAAAZACAIAAACubhnwAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO
vgAADr4B6kKxwAAAy01JREFUeF7s3fm/ZFV5L/7TVbWr6nTTjM0QBUQhikMEgsQBiYYEoqJGo8YxJlGD
vAAADrwBlbxySQAAy01JREFUeF7s3fm/ZFV5L/7TVbWr6nTTjM0QBUQhikMEgsQBiYYEoqJGo8YxJlGD
XxViNIng1WBiDEQxwRgvDhiNosYB472KQyBgohLuNa/c1/1fbuxTs9/n7Kd6WSLQ0+lzani/f1ivtTcK
3edU7f2sz15r7bUfAwAAAMAcE2ABAAAAMNcEWAAAAADMNQEWAAAAAHNNgAUAAADAXBNgAQAAADDXBFgA
AAAAzDUBFgAAAABzTYAFAAAAwFwTYAEAAAAw1wRYAAAAAMw1ARYAAAAAc02ABQAAAMBcE2ABAAAAMNcE

View File

@ -11,7 +11,7 @@ namespace ArmoredVehicle
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
Application.Run(new MainForm());
Application.Run(new FormMap());
}
}
}

View File

@ -0,0 +1,103 @@
//------------------------------------------------------------------------------
// <auto-generated>
// Этот код создан программой.
// Исполняемая версия:4.0.30319.42000
//
// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
// повторной генерации кода.
// </auto-generated>
//------------------------------------------------------------------------------
namespace ArmoredVehicle.Properties {
using System;
/// <summary>
/// Класс ресурса со строгой типизацией для поиска локализованных строк и т.д.
/// </summary>
// Этот класс создан автоматически классом StronglyTypedResourceBuilder
// с помощью такого средства, как ResGen или Visual Studio.
// Чтобы добавить или удалить член, измените файл .ResX и снова запустите ResGen
// с параметром /str или перестройте свой проект VS.
[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>
/// Возвращает кэшированный экземпляр ResourceManager, использованный этим классом.
/// </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("ArmoredVehicle.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Перезаписывает свойство CurrentUICulture текущего потока для всех
/// обращений к ресурсу с помощью этого класса ресурса со строгой типизацией.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
/// <summary>
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap arrowDown {
get {
object obj = ResourceManager.GetObject("arrowDown", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap arrowLeft {
get {
object obj = ResourceManager.GetObject("arrowLeft", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap arrowRight {
get {
object obj = ResourceManager.GetObject("arrowRight", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap arrowUp {
get {
object obj = ResourceManager.GetObject("arrowUp", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
}
}

View 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>

View File

@ -0,0 +1,52 @@
namespace ArmoredVehicle
{
/// <summary>
/// Простая реализация абсрактного класса AbstractMap
/// </summary>
internal class SimpleMap : AbstractMap
{
/// <summary>
/// Цвет участка закрытого
/// </summary>
private readonly Brush barrierColor = new SolidBrush(Color.Black);
/// <summary>
/// Цвет участка открытого
/// </summary>
private readonly Brush roadColor = new SolidBrush(Color.Gray);
protected override void DrawBarrierPart(Graphics g, int i, int j)
{
g.FillRectangle(barrierColor, i * _size_x, j * _size_y, i * (_size_x + 1), j * (_size_y + 1));
}
protected override void DrawRoadPart(Graphics g, int i, int j)
{
g.FillRectangle(roadColor, i * _size_x, j * _size_y, (i+1) * (_size_x + 1), (j+1) * (_size_y + 1));
}
protected override void GenerateMap()
{
_map = new int[50, 50];
_size_x = (float)_width / _map.GetLength(0);
_size_y = (float)_height / _map.GetLength(1);
int counter = 0;
for (int i = 0; i < _map.GetLength(0); ++i)
{
for (int j = 0; j < _map.GetLength(1); ++j)
{
_map[i, j] = _freeRoad;
}
}
while (counter < 50)
{
int x = _random.Next(0, 50);
int y = _random.Next(0, 50);
if (_map[x, y] == _freeRoad)
{
_map[x, y] = _barrier;
counter++;
}
}
}
}
}