lab3(complete)
This commit is contained in:
parent
efa7099a7a
commit
1d9c71e330
208
Stormtrooper/Stormtrooper/FormMap.Designer.cs
generated
208
Stormtrooper/Stormtrooper/FormMap.Designer.cs
generated
@ -1,208 +0,0 @@
|
|||||||
namespace Stormtrooper
|
|
||||||
{
|
|
||||||
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.pictureBoxStormtrooper = new System.Windows.Forms.PictureBox();
|
|
||||||
this.statusStrip1 = new System.Windows.Forms.StatusStrip();
|
|
||||||
this.toolStripStatusLabelSpeed = new System.Windows.Forms.ToolStripStatusLabel();
|
|
||||||
this.toolStripStatusLabelWeight = new System.Windows.Forms.ToolStripStatusLabel();
|
|
||||||
this.toolStripStatusLabelBodyColor = new System.Windows.Forms.ToolStripStatusLabel();
|
|
||||||
this.buttonCreate = new System.Windows.Forms.Button();
|
|
||||||
this.buttonUp = new System.Windows.Forms.Button();
|
|
||||||
this.buttonDown = new System.Windows.Forms.Button();
|
|
||||||
this.buttonLeft = new System.Windows.Forms.Button();
|
|
||||||
this.buttonRight = new System.Windows.Forms.Button();
|
|
||||||
this.buttonCreateModif = new System.Windows.Forms.Button();
|
|
||||||
this.comboBoxSelectorMap = new System.Windows.Forms.ComboBox();
|
|
||||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxStormtrooper)).BeginInit();
|
|
||||||
this.statusStrip1.SuspendLayout();
|
|
||||||
this.SuspendLayout();
|
|
||||||
//
|
|
||||||
// pictureBoxStormtrooper
|
|
||||||
//
|
|
||||||
this.pictureBoxStormtrooper.Dock = System.Windows.Forms.DockStyle.Fill;
|
|
||||||
this.pictureBoxStormtrooper.Location = new System.Drawing.Point(0, 0);
|
|
||||||
this.pictureBoxStormtrooper.Name = "pictureBoxStormtrooper";
|
|
||||||
this.pictureBoxStormtrooper.Size = new System.Drawing.Size(800, 424);
|
|
||||||
this.pictureBoxStormtrooper.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
|
|
||||||
this.pictureBoxStormtrooper.TabIndex = 0;
|
|
||||||
this.pictureBoxStormtrooper.TabStop = false;
|
|
||||||
//
|
|
||||||
// statusStrip1
|
|
||||||
//
|
|
||||||
this.statusStrip1.ImageScalingSize = new System.Drawing.Size(20, 20);
|
|
||||||
this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
|
||||||
this.toolStripStatusLabelSpeed,
|
|
||||||
this.toolStripStatusLabelWeight,
|
|
||||||
this.toolStripStatusLabelBodyColor});
|
|
||||||
this.statusStrip1.Location = new System.Drawing.Point(0, 424);
|
|
||||||
this.statusStrip1.Name = "statusStrip1";
|
|
||||||
this.statusStrip1.Size = new System.Drawing.Size(800, 26);
|
|
||||||
this.statusStrip1.TabIndex = 1;
|
|
||||||
this.statusStrip1.Text = "statusStrip1";
|
|
||||||
//
|
|
||||||
// toolStripStatusLabelSpeed
|
|
||||||
//
|
|
||||||
this.toolStripStatusLabelSpeed.Name = "toolStripStatusLabelSpeed";
|
|
||||||
this.toolStripStatusLabelSpeed.Size = new System.Drawing.Size(76, 20);
|
|
||||||
this.toolStripStatusLabelSpeed.Text = "Скорость:";
|
|
||||||
//
|
|
||||||
// toolStripStatusLabelWeight
|
|
||||||
//
|
|
||||||
this.toolStripStatusLabelWeight.Name = "toolStripStatusLabelWeight";
|
|
||||||
this.toolStripStatusLabelWeight.Size = new System.Drawing.Size(36, 20);
|
|
||||||
this.toolStripStatusLabelWeight.Text = "Вес:";
|
|
||||||
//
|
|
||||||
// toolStripStatusLabelBodyColor
|
|
||||||
//
|
|
||||||
this.toolStripStatusLabelBodyColor.Name = "toolStripStatusLabelBodyColor";
|
|
||||||
this.toolStripStatusLabelBodyColor.Size = new System.Drawing.Size(45, 20);
|
|
||||||
this.toolStripStatusLabelBodyColor.Text = "Цвет:";
|
|
||||||
//
|
|
||||||
// buttonCreate
|
|
||||||
//
|
|
||||||
this.buttonCreate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
|
||||||
this.buttonCreate.Location = new System.Drawing.Point(31, 364);
|
|
||||||
this.buttonCreate.Name = "buttonCreate";
|
|
||||||
this.buttonCreate.Size = new System.Drawing.Size(94, 29);
|
|
||||||
this.buttonCreate.TabIndex = 2;
|
|
||||||
this.buttonCreate.Text = "Create";
|
|
||||||
this.buttonCreate.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonCreate.Click += new System.EventHandler(this.ButtonCreate_Click);
|
|
||||||
//
|
|
||||||
// buttonUp
|
|
||||||
//
|
|
||||||
this.buttonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
|
||||||
this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
|
||||||
this.buttonUp.Location = new System.Drawing.Point(713, 328);
|
|
||||||
this.buttonUp.Name = "buttonUp";
|
|
||||||
this.buttonUp.Size = new System.Drawing.Size(30, 30);
|
|
||||||
this.buttonUp.TabIndex = 3;
|
|
||||||
this.buttonUp.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonUp.Click += new System.EventHandler(this.ButtonMove_Click);
|
|
||||||
//
|
|
||||||
// buttonDown
|
|
||||||
//
|
|
||||||
this.buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
|
||||||
this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
|
||||||
this.buttonDown.Location = new System.Drawing.Point(713, 364);
|
|
||||||
this.buttonDown.Name = "buttonDown";
|
|
||||||
this.buttonDown.Size = new System.Drawing.Size(30, 30);
|
|
||||||
this.buttonDown.TabIndex = 4;
|
|
||||||
this.buttonDown.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonDown.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.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
|
||||||
this.buttonLeft.Location = new System.Drawing.Point(677, 365);
|
|
||||||
this.buttonLeft.Name = "buttonLeft";
|
|
||||||
this.buttonLeft.Size = new System.Drawing.Size(30, 30);
|
|
||||||
this.buttonLeft.TabIndex = 5;
|
|
||||||
this.buttonLeft.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonLeft.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.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
|
||||||
this.buttonRight.Location = new System.Drawing.Point(749, 364);
|
|
||||||
this.buttonRight.Name = "buttonRight";
|
|
||||||
this.buttonRight.Size = new System.Drawing.Size(30, 30);
|
|
||||||
this.buttonRight.TabIndex = 6;
|
|
||||||
this.buttonRight.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonRight.Click += new System.EventHandler(this.ButtonMove_Click);
|
|
||||||
|
|
||||||
//
|
|
||||||
// buttonCreateModif
|
|
||||||
//
|
|
||||||
this.buttonCreateModif.Location = new System.Drawing.Point(150, 364);
|
|
||||||
this.buttonCreateModif.Name = "buttonCreateModif";
|
|
||||||
this.buttonCreateModif.Size = new System.Drawing.Size(129, 29);
|
|
||||||
this.buttonCreateModif.TabIndex = 7;
|
|
||||||
this.buttonCreateModif.Text = "Модификация";
|
|
||||||
this.buttonCreateModif.UseVisualStyleBackColor = true;
|
|
||||||
this.buttonCreateModif.Click += new System.EventHandler(this.buttonCreateModif_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(31, 12);
|
|
||||||
this.comboBoxSelectorMap.Name = "comboBoxSelectorMap";
|
|
||||||
this.comboBoxSelectorMap.Size = new System.Drawing.Size(151, 28);
|
|
||||||
this.comboBoxSelectorMap.TabIndex = 8;
|
|
||||||
this.comboBoxSelectorMap.SelectedIndexChanged += new System.EventHandler(this.ComboBoxSelectorMap_SelectedIndexChanged);
|
|
||||||
|
|
||||||
//
|
|
||||||
// FormMap
|
|
||||||
//
|
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
|
||||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
|
||||||
this.Controls.Add(this.comboBoxSelectorMap);
|
|
||||||
this.Controls.Add(this.buttonCreateModif);
|
|
||||||
this.Controls.Add(this.buttonRight);
|
|
||||||
this.Controls.Add(this.buttonLeft);
|
|
||||||
this.Controls.Add(this.buttonDown);
|
|
||||||
this.Controls.Add(this.buttonUp);
|
|
||||||
this.Controls.Add(this.buttonCreate);
|
|
||||||
this.Controls.Add(this.pictureBoxStormtrooper);
|
|
||||||
this.Controls.Add(this.statusStrip1);
|
|
||||||
this.Name = "FormMap";
|
|
||||||
this.Text = "FormMap";
|
|
||||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxStormtrooper)).EndInit();
|
|
||||||
this.statusStrip1.ResumeLayout(false);
|
|
||||||
this.statusStrip1.PerformLayout();
|
|
||||||
this.ResumeLayout(false);
|
|
||||||
this.PerformLayout();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private PictureBox pictureBoxStormtrooper;
|
|
||||||
private StatusStrip statusStrip1;
|
|
||||||
private ToolStripStatusLabel toolStripStatusLabelSpeed;
|
|
||||||
private ToolStripStatusLabel toolStripStatusLabelWeight;
|
|
||||||
private ToolStripStatusLabel toolStripStatusLabelBodyColor;
|
|
||||||
private Button buttonCreate;
|
|
||||||
private Button buttonUp;
|
|
||||||
private Button buttonDown;
|
|
||||||
private Button buttonLeft;
|
|
||||||
private Button buttonRight;
|
|
||||||
private Button buttonCreateModif;
|
|
||||||
private ComboBox comboBoxSelectorMap;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,106 +0,0 @@
|
|||||||
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 Stormtrooper
|
|
||||||
{
|
|
||||||
public partial class FormMap : Form
|
|
||||||
{
|
|
||||||
private AbstractMap _abstractMap;
|
|
||||||
public FormMap()
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
_abstractMap = new SimpleMap();
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Заполнение информации по объекту
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="car"></param>
|
|
||||||
private void SetData(DrowningStormtrooper car)
|
|
||||||
{
|
|
||||||
toolStripStatusLabelSpeed.Text = $"Скорость: {car.Stormtrooper.Speed}";
|
|
||||||
toolStripStatusLabelWeight.Text = $"Вес: {car.Stormtrooper.Weight}";
|
|
||||||
toolStripStatusLabelBodyColor.Text = $"Цвет:{ car.Stormtrooper.BodyColor.Name}";
|
|
||||||
pictureBoxStormtrooper.Image = _abstractMap.CreateMap(pictureBoxStormtrooper.Width, pictureBoxStormtrooper.Height, new DrawningObjectStormtrooper(car));
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Обработка нажатия кнопки "Создать"
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="sender"></param>
|
|
||||||
/// <param name="e"></param>
|
|
||||||
private void ButtonCreate_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
Random rnd = new();
|
|
||||||
var car = new DrowningStormtrooper(rnd.Next(100, 300), rnd.Next(1000, 2000),
|
|
||||||
Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
|
|
||||||
SetData(car);
|
|
||||||
}
|
|
||||||
/// <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;
|
|
||||||
}
|
|
||||||
pictureBoxStormtrooper.Image = _abstractMap?.MoveObject(dir);
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Обработка нажатия кнопки "Модификация"
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="sender"></param>
|
|
||||||
/// <param name="e"></param>
|
|
||||||
private void buttonCreateModif_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
Random rnd = new();
|
|
||||||
var car = new DrowningSuperStormtrooper(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(car);
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Смена карты
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="sender"></param>
|
|
||||||
/// <param name="e"></param>
|
|
||||||
private void ComboBoxSelectorMap_SelectedIndexChanged(object sender,
|
|
||||||
EventArgs e)
|
|
||||||
{
|
|
||||||
switch (comboBoxSelectorMap.Text)
|
|
||||||
{
|
|
||||||
case "Простая карта":
|
|
||||||
_abstractMap = new SimpleMap();
|
|
||||||
break;
|
|
||||||
case "Своя карта":
|
|
||||||
_abstractMap = new MyMap();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,63 +0,0 @@
|
|||||||
<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="statusStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
|
||||||
<value>17, 17</value>
|
|
||||||
</metadata>
|
|
||||||
</root>
|
|
@ -28,6 +28,7 @@
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
|
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FormMapWithSetStormtroopers));
|
||||||
this.groupBox1 = new System.Windows.Forms.GroupBox();
|
this.groupBox1 = new System.Windows.Forms.GroupBox();
|
||||||
this.buttonShowOnMap = new System.Windows.Forms.Button();
|
this.buttonShowOnMap = new System.Windows.Forms.Button();
|
||||||
this.buttonShowStorage = new System.Windows.Forms.Button();
|
this.buttonShowStorage = new System.Windows.Forms.Button();
|
||||||
@ -36,6 +37,10 @@
|
|||||||
this.buttonAddStormtrooper = new System.Windows.Forms.Button();
|
this.buttonAddStormtrooper = new System.Windows.Forms.Button();
|
||||||
this.comboBoxSelectorMap = new System.Windows.Forms.ComboBox();
|
this.comboBoxSelectorMap = new System.Windows.Forms.ComboBox();
|
||||||
this.pictureBox = new System.Windows.Forms.PictureBox();
|
this.pictureBox = new System.Windows.Forms.PictureBox();
|
||||||
|
this.buttonRight = new System.Windows.Forms.Button();
|
||||||
|
this.buttonLeft = new System.Windows.Forms.Button();
|
||||||
|
this.buttonDown = new System.Windows.Forms.Button();
|
||||||
|
this.buttonUp = new System.Windows.Forms.Button();
|
||||||
this.groupBox1.SuspendLayout();
|
this.groupBox1.SuspendLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
@ -48,13 +53,17 @@
|
|||||||
this.groupBox1.Controls.Add(this.maskedTextBoxPosition);
|
this.groupBox1.Controls.Add(this.maskedTextBoxPosition);
|
||||||
this.groupBox1.Controls.Add(this.buttonAddStormtrooper);
|
this.groupBox1.Controls.Add(this.buttonAddStormtrooper);
|
||||||
this.groupBox1.Controls.Add(this.comboBoxSelectorMap);
|
this.groupBox1.Controls.Add(this.comboBoxSelectorMap);
|
||||||
|
this.groupBox1.Controls.Add(this.buttonDown);
|
||||||
|
this.groupBox1.Controls.Add(this.buttonRight);
|
||||||
|
this.groupBox1.Controls.Add(this.buttonLeft);
|
||||||
|
this.groupBox1.Controls.Add(this.buttonUp);
|
||||||
this.groupBox1.Dock = System.Windows.Forms.DockStyle.Right;
|
this.groupBox1.Dock = System.Windows.Forms.DockStyle.Right;
|
||||||
this.groupBox1.Location = new System.Drawing.Point(550, 0);
|
this.groupBox1.Location = new System.Drawing.Point(550, 0);
|
||||||
this.groupBox1.Name = "groupBox1";
|
this.groupBox1.Name = "groupBox1";
|
||||||
this.groupBox1.Size = new System.Drawing.Size(250, 450);
|
this.groupBox1.Size = new System.Drawing.Size(250, 450);
|
||||||
this.groupBox1.TabIndex = 0;
|
this.groupBox1.TabIndex = 0;
|
||||||
this.groupBox1.TabStop = false;
|
this.groupBox1.TabStop = false;
|
||||||
this.groupBox1.Text = "groupBox1";
|
this.groupBox1.Text = "Инструменты";
|
||||||
//
|
//
|
||||||
// buttonShowOnMap
|
// buttonShowOnMap
|
||||||
//
|
//
|
||||||
@ -93,6 +102,7 @@
|
|||||||
this.maskedTextBoxPosition.Name = "maskedTextBoxPosition";
|
this.maskedTextBoxPosition.Name = "maskedTextBoxPosition";
|
||||||
this.maskedTextBoxPosition.Size = new System.Drawing.Size(125, 27);
|
this.maskedTextBoxPosition.Size = new System.Drawing.Size(125, 27);
|
||||||
this.maskedTextBoxPosition.TabIndex = 2;
|
this.maskedTextBoxPosition.TabIndex = 2;
|
||||||
|
this.maskedTextBoxPosition.ValidatingType = typeof(int);
|
||||||
//
|
//
|
||||||
// buttonAddStormtrooper
|
// buttonAddStormtrooper
|
||||||
//
|
//
|
||||||
@ -106,11 +116,16 @@
|
|||||||
//
|
//
|
||||||
// comboBoxSelectorMap
|
// comboBoxSelectorMap
|
||||||
//
|
//
|
||||||
|
this.comboBoxSelectorMap.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||||
this.comboBoxSelectorMap.FormattingEnabled = true;
|
this.comboBoxSelectorMap.FormattingEnabled = true;
|
||||||
|
this.comboBoxSelectorMap.Items.AddRange(new object[] {
|
||||||
|
"Простая карта",
|
||||||
|
"Собственная карта"});
|
||||||
this.comboBoxSelectorMap.Location = new System.Drawing.Point(41, 35);
|
this.comboBoxSelectorMap.Location = new System.Drawing.Point(41, 35);
|
||||||
this.comboBoxSelectorMap.Name = "comboBoxSelectorMap";
|
this.comboBoxSelectorMap.Name = "comboBoxSelectorMap";
|
||||||
this.comboBoxSelectorMap.Size = new System.Drawing.Size(151, 28);
|
this.comboBoxSelectorMap.Size = new System.Drawing.Size(151, 28);
|
||||||
this.comboBoxSelectorMap.TabIndex = 0;
|
this.comboBoxSelectorMap.TabIndex = 0;
|
||||||
|
this.comboBoxSelectorMap.SelectedIndexChanged += new System.EventHandler(this.ComboBoxSelectorMap_SelectedIndexChanged);
|
||||||
//
|
//
|
||||||
// pictureBox
|
// pictureBox
|
||||||
//
|
//
|
||||||
@ -120,12 +135,66 @@
|
|||||||
this.pictureBox.Size = new System.Drawing.Size(550, 450);
|
this.pictureBox.Size = new System.Drawing.Size(550, 450);
|
||||||
this.pictureBox.TabIndex = 1;
|
this.pictureBox.TabIndex = 1;
|
||||||
this.pictureBox.TabStop = false;
|
this.pictureBox.TabStop = false;
|
||||||
|
//
|
||||||
|
// buttonRight
|
||||||
|
//
|
||||||
|
this.buttonRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.buttonRight.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("buttonRight.BackgroundImage")));
|
||||||
|
this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||||
|
this.buttonRight.Location = new System.Drawing.Point(501, 408);
|
||||||
|
this.buttonRight.Name = "buttonRight";
|
||||||
|
this.buttonRight.Size = new System.Drawing.Size(30, 30);
|
||||||
|
this.buttonRight.TabIndex = 10;
|
||||||
|
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 = ((System.Drawing.Image)(resources.GetObject("buttonLeft.BackgroundImage")));
|
||||||
|
this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||||
|
this.buttonLeft.Location = new System.Drawing.Point(429, 409);
|
||||||
|
this.buttonLeft.Name = "buttonLeft";
|
||||||
|
this.buttonLeft.Size = new System.Drawing.Size(30, 30);
|
||||||
|
this.buttonLeft.TabIndex = 9;
|
||||||
|
this.buttonLeft.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonLeft.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||||
|
//
|
||||||
|
// buttonDown
|
||||||
|
//
|
||||||
|
this.buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.buttonDown.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("buttonDown.BackgroundImage")));
|
||||||
|
this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||||
|
this.buttonDown.Location = new System.Drawing.Point(465, 408);
|
||||||
|
this.buttonDown.Name = "buttonDown";
|
||||||
|
this.buttonDown.Size = new System.Drawing.Size(30, 30);
|
||||||
|
this.buttonDown.TabIndex = 8;
|
||||||
|
this.buttonDown.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonDown.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 = ((System.Drawing.Image)(resources.GetObject("buttonUp.BackgroundImage")));
|
||||||
|
this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||||
|
this.buttonUp.Location = new System.Drawing.Point(465, 372);
|
||||||
|
this.buttonUp.Name = "buttonUp";
|
||||||
|
this.buttonUp.Size = new System.Drawing.Size(30, 30);
|
||||||
|
this.buttonUp.TabIndex = 7;
|
||||||
|
this.buttonUp.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonUp.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||||
|
|
||||||
//
|
//
|
||||||
// FormMapWithSetStormtroopers
|
// FormMapWithSetStormtroopers
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||||
|
this.Controls.Add(this.buttonRight);
|
||||||
|
this.Controls.Add(this.buttonLeft);
|
||||||
|
this.Controls.Add(this.buttonDown);
|
||||||
|
this.Controls.Add(this.buttonUp);
|
||||||
this.Controls.Add(this.pictureBox);
|
this.Controls.Add(this.pictureBox);
|
||||||
this.Controls.Add(this.groupBox1);
|
this.Controls.Add(this.groupBox1);
|
||||||
this.Name = "FormMapWithSetStormtroopers";
|
this.Name = "FormMapWithSetStormtroopers";
|
||||||
@ -147,5 +216,9 @@
|
|||||||
private Button buttonAddStormtrooper;
|
private Button buttonAddStormtrooper;
|
||||||
private ComboBox comboBoxSelectorMap;
|
private ComboBox comboBoxSelectorMap;
|
||||||
private PictureBox pictureBox;
|
private PictureBox pictureBox;
|
||||||
|
private Button buttonRight;
|
||||||
|
private Button buttonLeft;
|
||||||
|
private Button buttonDown;
|
||||||
|
private Button buttonUp;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -30,8 +30,7 @@ namespace Stormtrooper
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="sender"></param>
|
/// <param name="sender"></param>
|
||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
private void ComboBoxSelectorMap_SelectedIndexChanged(object sender,
|
private void ComboBoxSelectorMap_SelectedIndexChanged(object sender, EventArgs e)
|
||||||
EventArgs e)
|
|
||||||
{
|
{
|
||||||
AbstractMap map = null;
|
AbstractMap map = null;
|
||||||
switch (comboBoxSelectorMap.Text)
|
switch (comboBoxSelectorMap.Text)
|
||||||
@ -39,12 +38,14 @@ namespace Stormtrooper
|
|||||||
case "Простая карта":
|
case "Простая карта":
|
||||||
map = new SimpleMap();
|
map = new SimpleMap();
|
||||||
break;
|
break;
|
||||||
|
case "Собственная карта":
|
||||||
|
map = new MyMap();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if (map != null)
|
if (map != null)
|
||||||
{
|
{
|
||||||
_mapCarsCollectionGeneric = new
|
_mapCarsCollectionGeneric = new
|
||||||
MapWithSetStormtroopersGeneric<DrawningObjectStormtrooper, AbstractMap>(
|
MapWithSetStormtroopersGeneric<DrawningObjectStormtrooper, AbstractMap>(pictureBox.Width, pictureBox.Height, map);
|
||||||
pictureBox.Width, pictureBox.Height, map);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -65,8 +66,8 @@ namespace Stormtrooper
|
|||||||
FormStormtrooper form = new();
|
FormStormtrooper form = new();
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
{
|
{
|
||||||
DrawningObjectStormtrooper car = new(form.SelectedStormtrooper);
|
DrawningObjectStormtrooper stormtrooper = new(form.SelectedStormtrooper);
|
||||||
if (_mapCarsCollectionGeneric + car)
|
if (_mapCarsCollectionGeneric + stormtrooper != -1)
|
||||||
{
|
{
|
||||||
MessageBox.Show("Объект добавлен");
|
MessageBox.Show("Объект добавлен");
|
||||||
pictureBox.Image = _mapCarsCollectionGeneric.ShowSet();
|
pictureBox.Image = _mapCarsCollectionGeneric.ShowSet();
|
||||||
@ -88,13 +89,12 @@ namespace Stormtrooper
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (MessageBox.Show("Удалить объект?", "Удаление",
|
if (MessageBox.Show("Удалить объект?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
|
||||||
MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
|
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int pos = Convert.ToInt32(maskedTextBoxPosition.Text);
|
int pos = Convert.ToInt32(maskedTextBoxPosition.Text);
|
||||||
if (_mapCarsCollectionGeneric - pos)
|
if (_mapCarsCollectionGeneric - pos != null)
|
||||||
{
|
{
|
||||||
MessageBox.Show("Объект удален");
|
MessageBox.Show("Объект удален");
|
||||||
pictureBox.Image = _mapCarsCollectionGeneric.ShowSet();
|
pictureBox.Image = _mapCarsCollectionGeneric.ShowSet();
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -34,11 +34,11 @@ namespace Stormtrooper
|
|||||||
pictureBoxStormtrooper.Image = bmp;
|
pictureBoxStormtrooper.Image = bmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetData(DrowningStormtrooper stormtrooper)
|
private void SetData()
|
||||||
{
|
{
|
||||||
toolStripStatusLabelSpeed.Text = $"Скорость: {stormtrooper.Stormtrooper.Speed}";
|
toolStripStatusLabelSpeed.Text = $"Скорость: {_stormtrooper.Stormtrooper.Speed}";
|
||||||
toolStripStatusLabelWeight.Text = $"Вес: {stormtrooper.Stormtrooper.Weight}";
|
toolStripStatusLabelWeight.Text = $"Вес: {_stormtrooper.Stormtrooper.Weight}";
|
||||||
toolStripStatusLabelBodyColor.Text = $"Цвет:{ stormtrooper.Stormtrooper.BodyColor.Name}";
|
toolStripStatusLabelBodyColor.Text = $"Цвет:{ _stormtrooper.Stormtrooper.BodyColor.Name}";
|
||||||
//pictureBoxCar.Image = _abstractMap.CreateMap(pictureBoxCar.Width, pictureBoxCar.Height, new DrawningObjectCar(car));
|
//pictureBoxCar.Image = _abstractMap.CreateMap(pictureBoxCar.Width, pictureBoxCar.Height, new DrawningObjectCar(car));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,12 +49,37 @@ namespace Stormtrooper
|
|||||||
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)));
|
||||||
_stormtrooper.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100),
|
_stormtrooper.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100),
|
||||||
pictureBoxStormtrooper.Width, pictureBoxStormtrooper.Height);
|
pictureBoxStormtrooper.Width, pictureBoxStormtrooper.Height);
|
||||||
toolStripStatusLabelSpeed.Text = $"Скорость: {_stormtrooper.Stormtrooper.Speed}";
|
SetData();
|
||||||
toolStripStatusLabelWeight.Text = $"Вес: {_stormtrooper.Stormtrooper.Weight}";
|
|
||||||
toolStripStatusLabelBodyColor.Text = $"Цвет:{ _stormtrooper.Stormtrooper.BodyColor.Name}";
|
|
||||||
Draw();
|
Draw();
|
||||||
}
|
}
|
||||||
|
private void buttonCreateModif_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
Random rnd = new();
|
||||||
|
Color color = Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256),
|
||||||
|
rnd.Next(0, 256));
|
||||||
|
ColorDialog dialog = new();
|
||||||
|
if (dialog.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
color = dialog.Color;
|
||||||
|
}
|
||||||
|
Color dopColor = Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256),
|
||||||
|
rnd.Next(0, 256));
|
||||||
|
ColorDialog dialogDop = new();
|
||||||
|
if (dialogDop.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
dopColor = dialogDop.Color;
|
||||||
|
}
|
||||||
|
_stormtrooper = new DrowningSuperStormtrooper(rnd.Next(100, 300), rnd.Next(1000, 2000),
|
||||||
|
color, dopColor,
|
||||||
|
Convert.ToBoolean(rnd.Next(0, 2)), Convert.ToBoolean(rnd.Next(0,
|
||||||
|
2)), Convert.ToBoolean(rnd.Next(0, 2)));
|
||||||
|
_stormtrooper.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100),
|
||||||
|
pictureBoxStormtrooper.Width, pictureBoxStormtrooper.Height);
|
||||||
|
|
||||||
|
|
||||||
|
SetData();
|
||||||
|
Draw();
|
||||||
|
}
|
||||||
private void ButtonMove_Click(object sender, EventArgs e)
|
private void ButtonMove_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
//получаем имя кнопки
|
//получаем имя кнопки
|
||||||
@ -83,16 +108,7 @@ namespace Stormtrooper
|
|||||||
Draw();
|
Draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void buttonCreateModif_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
Random rnd = new();
|
|
||||||
var stormtrooper = new DrowningSuperStormtrooper(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(stormtrooper);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonSelectStormtrooper_Click(object sender, EventArgs e)
|
private void ButtonSelectStormtrooper_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
@ -55,7 +55,7 @@ namespace Stormtrooper
|
|||||||
/// <param name="map"></param>
|
/// <param name="map"></param>
|
||||||
/// <param name="car"></param>
|
/// <param name="car"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static bool operator + (MapWithSetStormtroopersGeneric<T, U> map, T car)
|
public static int operator + (MapWithSetStormtroopersGeneric<T, U> map, T car)
|
||||||
{
|
{
|
||||||
return map._setStormtroopers.Insert(car);
|
return map._setStormtroopers.Insert(car);
|
||||||
}
|
}
|
||||||
@ -65,8 +65,8 @@ namespace Stormtrooper
|
|||||||
/// <param name="map"></param>
|
/// <param name="map"></param>
|
||||||
/// <param name="position"></param>
|
/// <param name="position"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static bool operator - (MapWithSetStormtroopersGeneric<T, U> map, int
|
public static T operator - (MapWithSetStormtroopersGeneric<T, U> map, int
|
||||||
position)
|
position)
|
||||||
{
|
{
|
||||||
return map._setStormtroopers.Remove(position);
|
return map._setStormtroopers.Remove(position);
|
||||||
}
|
}
|
||||||
@ -78,6 +78,7 @@ namespace Stormtrooper
|
|||||||
{
|
{
|
||||||
Bitmap bmp = new(_pictureWidth, _pictureHeight);
|
Bitmap bmp = new(_pictureWidth, _pictureHeight);
|
||||||
Graphics gr = Graphics.FromImage(bmp);
|
Graphics gr = Graphics.FromImage(bmp);
|
||||||
|
ShowOnMap();
|
||||||
DrawBackground(gr);
|
DrawBackground(gr);
|
||||||
DrawCars(gr);
|
DrawCars(gr);
|
||||||
return bmp;
|
return bmp;
|
||||||
@ -146,10 +147,13 @@ namespace Stormtrooper
|
|||||||
private void DrawBackground(Graphics g)
|
private void DrawBackground(Graphics g)
|
||||||
{
|
{
|
||||||
Pen pen = new(Color.Black, 3);
|
Pen pen = new(Color.Black, 3);
|
||||||
|
g.FillRectangle(new SolidBrush(Color.Green), 0, 0, _pictureWidth, _pictureHeight);
|
||||||
for (int i = 0; i < _pictureWidth / _placeSizeWidth; i++)
|
for (int i = 0; i < _pictureWidth / _placeSizeWidth; i++)
|
||||||
{
|
{
|
||||||
for (int j = 0; j < _pictureHeight / _placeSizeHeight + 1; ++j)
|
for (int j = 0; j < _pictureHeight / _placeSizeHeight; ++j)
|
||||||
{//линия рамзетки места
|
{//линия рамзетки места
|
||||||
|
g.FillRectangle(new SolidBrush(Color.Gray), i *_placeSizeWidth , j *_placeSizeHeight ,_placeSizeWidth / 2,_placeSizeHeight);
|
||||||
|
|
||||||
g.DrawLine(pen, i * _placeSizeWidth, j * _placeSizeHeight, i *
|
g.DrawLine(pen, i * _placeSizeWidth, j * _placeSizeHeight, i *
|
||||||
_placeSizeWidth + _placeSizeWidth / 2, j * _placeSizeHeight);
|
_placeSizeWidth + _placeSizeWidth / 2, j * _placeSizeHeight);
|
||||||
}
|
}
|
||||||
@ -163,16 +167,16 @@ namespace Stormtrooper
|
|||||||
/// <param name="g"></param>
|
/// <param name="g"></param>
|
||||||
private void DrawCars(Graphics g)
|
private void DrawCars(Graphics g)
|
||||||
{
|
{
|
||||||
int x = 5;
|
int x = _pictureWidth;
|
||||||
int y = 5;
|
int y = _pictureHeight;
|
||||||
for (int i = 0; i < _setStormtroopers.Count; i++)
|
for (int i = 0; i < _setStormtroopers.Count; i++)
|
||||||
{
|
{
|
||||||
_setStormtroopers.Get(i)?.SetObject(x, y, _pictureWidth, _pictureHeight);
|
_setStormtroopers.Get(i)?.SetObject(x, y + 10, _pictureWidth, _pictureHeight);
|
||||||
_setStormtroopers.Get(i)?.DrawningObject(g);
|
_setStormtroopers.Get(i)?.DrawningObject(g);
|
||||||
x += _placeSizeWidth;
|
x -= _placeSizeWidth;
|
||||||
if (x + _placeSizeWidth > _pictureWidth)
|
if (x + _placeSizeWidth > _pictureWidth)
|
||||||
{
|
{
|
||||||
y += _placeSizeHeight;
|
y -= _placeSizeHeight;
|
||||||
x = 5;
|
x = 5;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ namespace Stormtrooper
|
|||||||
// To customize application configuration such as set high DPI settings or default font,
|
// To customize application configuration such as set high DPI settings or default font,
|
||||||
// see https://aka.ms/applicationconfiguration.
|
// see https://aka.ms/applicationconfiguration.
|
||||||
ApplicationConfiguration.Initialize();
|
ApplicationConfiguration.Initialize();
|
||||||
Application.Run(new FormMap());
|
Application.Run(new FormMapWithSetStormtroopers());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -48,30 +48,51 @@ namespace Stormtrooper
|
|||||||
/// <param name="car">Добавляемый автомобиль</param>
|
/// <param name="car">Добавляемый автомобиль</param>
|
||||||
/// <param name="position">Позиция</param>
|
/// <param name="position">Позиция</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public bool Insert(T car, int position)
|
public bool Insert(T stormtrooper, int position)
|
||||||
{
|
{
|
||||||
// TODO проверка позиции
|
if (position < 0 || position > _places.Length)
|
||||||
// TODO проверка, что элемент массива по этой позиции пустой, если нет, то
|
{
|
||||||
// проверка, что после вставляемого элемента в массиве есть пустой элемент
|
return false;
|
||||||
// сдвиг всех объектов, находящихся справа от позиции до первого пустого элемента
|
}
|
||||||
// TODO вставка по позиции
|
if (_places[position] != null)
|
||||||
|
{
|
||||||
// hz kak sdelat s bool
|
int pos = -1;
|
||||||
|
for (int i = position + 1; i < _places.Length; i++)
|
||||||
_places[position] = car;
|
{
|
||||||
return true;
|
if (_places[i] == null)
|
||||||
|
{
|
||||||
|
pos = i;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
if (pos != -1)
|
||||||
|
{
|
||||||
|
for (int i = pos; i > position; i--)
|
||||||
|
{
|
||||||
|
_places[i] = _places[i - 1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_places[position] = stormtrooper;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Удаление объекта из набора с конкретной позиции
|
/// Удаление объекта из набора с конкретной позиции
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="position"></param>
|
/// <param name="position"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public bool Remove(int position)
|
public T Remove(int position)
|
||||||
{
|
{
|
||||||
// TODO проверка позиции
|
if (position < 0 || position > _places.Length)
|
||||||
// TODO удаление объекта из массива, присовив элементу массива значение null
|
{
|
||||||
// hz kak sdelat s bool
|
return null;
|
||||||
return true;
|
}
|
||||||
|
T removed = _places[position];
|
||||||
|
_places[position] = null;
|
||||||
|
return removed;
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Получение объекта из набора по позиции
|
/// Получение объекта из набора по позиции
|
||||||
|
Loading…
Reference in New Issue
Block a user