Некоторые классы стали публичными. Изменён класс FormArtillery. Изменено главное окно
This commit is contained in:
parent
d8c763c582
commit
5965acca14
@ -6,7 +6,7 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace Artilleries
|
namespace Artilleries
|
||||||
{
|
{
|
||||||
internal enum Direction
|
public enum Direction
|
||||||
{
|
{
|
||||||
Up = 1,
|
Up = 1,
|
||||||
Down = 2,
|
Down = 2,
|
||||||
|
@ -8,7 +8,7 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace Artilleries
|
namespace Artilleries
|
||||||
{
|
{
|
||||||
internal class DrawingArtillery
|
public class DrawingArtillery
|
||||||
{
|
{
|
||||||
public EntityArtillery Artillery { protected set; get; }
|
public EntityArtillery Artillery { protected set; get; }
|
||||||
protected float _startPosX;
|
protected float _startPosX;
|
||||||
|
@ -6,7 +6,7 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace Artilleries
|
namespace Artilleries
|
||||||
{
|
{
|
||||||
internal class EntityArtillery
|
public class EntityArtillery
|
||||||
{
|
{
|
||||||
public int Speed { get; private set; }
|
public int Speed { get; private set; }
|
||||||
public float Weight { get; private set; }
|
public float Weight { get; private set; }
|
||||||
|
28
SelfPropelledArtilleryUnit/FormArtillery.Designer.cs
generated
28
SelfPropelledArtilleryUnit/FormArtillery.Designer.cs
generated
@ -39,6 +39,8 @@
|
|||||||
this.buttonUp = new System.Windows.Forms.Button();
|
this.buttonUp = new System.Windows.Forms.Button();
|
||||||
this.buttonDown = new System.Windows.Forms.Button();
|
this.buttonDown = new System.Windows.Forms.Button();
|
||||||
this.buttonRight = new System.Windows.Forms.Button();
|
this.buttonRight = new System.Windows.Forms.Button();
|
||||||
|
this.createAdvancedButton = new System.Windows.Forms.Button();
|
||||||
|
this.selectArtilleryButton = new System.Windows.Forms.Button();
|
||||||
this.statusStrip1.SuspendLayout();
|
this.statusStrip1.SuspendLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxArtilleries)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.pictureBoxArtilleries)).BeginInit();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
@ -147,11 +149,35 @@
|
|||||||
this.buttonRight.UseVisualStyleBackColor = true;
|
this.buttonRight.UseVisualStyleBackColor = true;
|
||||||
this.buttonRight.Click += new System.EventHandler(this.buttonMove_Click);
|
this.buttonRight.Click += new System.EventHandler(this.buttonMove_Click);
|
||||||
//
|
//
|
||||||
|
// createAdvancedButton
|
||||||
|
//
|
||||||
|
this.createAdvancedButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||||
|
this.createAdvancedButton.Location = new System.Drawing.Point(106, 382);
|
||||||
|
this.createAdvancedButton.Name = "createAdvancedButton";
|
||||||
|
this.createAdvancedButton.Size = new System.Drawing.Size(113, 23);
|
||||||
|
this.createAdvancedButton.TabIndex = 7;
|
||||||
|
this.createAdvancedButton.Text = "Модифицировать";
|
||||||
|
this.createAdvancedButton.UseVisualStyleBackColor = true;
|
||||||
|
this.createAdvancedButton.Click += new System.EventHandler(this.createAdvancedButton_Click);
|
||||||
|
//
|
||||||
|
// selectArtilleryButton
|
||||||
|
//
|
||||||
|
this.selectArtilleryButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.selectArtilleryButton.Location = new System.Drawing.Point(410, 379);
|
||||||
|
this.selectArtilleryButton.Name = "selectArtilleryButton";
|
||||||
|
this.selectArtilleryButton.Size = new System.Drawing.Size(75, 23);
|
||||||
|
this.selectArtilleryButton.TabIndex = 8;
|
||||||
|
this.selectArtilleryButton.Text = "Выбрать";
|
||||||
|
this.selectArtilleryButton.UseVisualStyleBackColor = true;
|
||||||
|
this.selectArtilleryButton.Click += new System.EventHandler(this.selectArtilleryButton_Click);
|
||||||
|
//
|
||||||
// FormArtillery
|
// FormArtillery
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.ClientSize = new System.Drawing.Size(624, 441);
|
this.ClientSize = new System.Drawing.Size(624, 441);
|
||||||
|
this.Controls.Add(this.selectArtilleryButton);
|
||||||
|
this.Controls.Add(this.createAdvancedButton);
|
||||||
this.Controls.Add(this.buttonRight);
|
this.Controls.Add(this.buttonRight);
|
||||||
this.Controls.Add(this.buttonDown);
|
this.Controls.Add(this.buttonDown);
|
||||||
this.Controls.Add(this.buttonUp);
|
this.Controls.Add(this.buttonUp);
|
||||||
@ -183,5 +209,7 @@
|
|||||||
private Button buttonUp;
|
private Button buttonUp;
|
||||||
private Button buttonDown;
|
private Button buttonDown;
|
||||||
private Button buttonRight;
|
private Button buttonRight;
|
||||||
|
private Button createAdvancedButton;
|
||||||
|
private Button selectArtilleryButton;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -4,6 +4,8 @@ namespace Artilleries
|
|||||||
{
|
{
|
||||||
private DrawingArtillery _artillery;
|
private DrawingArtillery _artillery;
|
||||||
|
|
||||||
|
public DrawingArtillery SelectedArtillery { get; private set; }
|
||||||
|
|
||||||
public FormArtillery()
|
public FormArtillery()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
@ -17,14 +19,53 @@ namespace Artilleries
|
|||||||
pictureBoxArtilleries.Image = bmp;
|
pictureBoxArtilleries.Image = bmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void SetData(DrawingArtillery artillery)
|
||||||
|
{
|
||||||
|
Random rnd = new();
|
||||||
|
artillery.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100), pictureBoxArtilleries.Width, pictureBoxArtilleries.Height);
|
||||||
|
SpeedStatusLabel.Text = $"Ñêîðîñòü: {artillery.Artillery.Speed}";
|
||||||
|
WeightStatusLabel.Text = $"Âåñ: {artillery.Artillery.Weight}";
|
||||||
|
ColorStatusLabel.Text = $"Öâåò: {artillery.Artillery.BodyColor.Name}";
|
||||||
|
}
|
||||||
|
|
||||||
private void buttonCreate_Click(object sender, EventArgs e)
|
private void buttonCreate_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
Random rnd = new();
|
Random rnd = new();
|
||||||
_artillery = new DrawingArtillery(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
|
Color color = Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256));
|
||||||
_artillery.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100), pictureBoxArtilleries.Width, pictureBoxArtilleries.Height);
|
ColorDialog dialog = new();
|
||||||
SpeedStatusLabel.Text = $"Ñêîðîñòü: {_artillery.Artillery.Speed}";
|
if (dialog.ShowDialog() == DialogResult.OK)
|
||||||
WeightStatusLabel.Text = $"Âåñ: {_artillery.Artillery.Weight}";
|
{
|
||||||
ColorStatusLabel.Text = $"Öâåò: {_artillery.Artillery.BodyColor.Name}";
|
color = dialog.Color;
|
||||||
|
}
|
||||||
|
_artillery = new DrawingArtillery(rnd.Next(100, 300), rnd.Next(1000, 2000), color);
|
||||||
|
SetData(_artillery);
|
||||||
|
Draw();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createAdvancedButton_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;
|
||||||
|
}
|
||||||
|
_artillery = new DrawingAdvancedArtillery(
|
||||||
|
rnd.Next(100, 300),
|
||||||
|
rnd.Next(1000, 2000),
|
||||||
|
color,
|
||||||
|
dopColor,
|
||||||
|
rnd.Next(0, 2) == 1, rnd.Next(0, 2) == 1
|
||||||
|
);
|
||||||
|
SetData(_artillery);
|
||||||
Draw();
|
Draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,5 +95,11 @@ namespace Artilleries
|
|||||||
_artillery?.ChangeBorders(pictureBoxArtilleries.Width, pictureBoxArtilleries.Height);
|
_artillery?.ChangeBorders(pictureBoxArtilleries.Width, pictureBoxArtilleries.Height);
|
||||||
Draw();
|
Draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void selectArtilleryButton_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
SelectedArtillery = _artillery;
|
||||||
|
DialogResult = DialogResult.OK;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -29,10 +29,35 @@ namespace Artilleries
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_places[position] == null)
|
||||||
|
{
|
||||||
|
_places[position] = artillery;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
int firstNull = -1;
|
||||||
|
|
||||||
|
for (int i = position + 1; i < Count; i++)
|
||||||
|
{
|
||||||
|
if (_places[i] == null)
|
||||||
|
{
|
||||||
|
firstNull = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (firstNull == -1)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = firstNull; i > position; i--)
|
||||||
|
{
|
||||||
|
(_places[i], _places[i - 1]) = (_places[i - 1], _places[i]);
|
||||||
|
}
|
||||||
|
|
||||||
_places[position] = artillery;
|
_places[position] = artillery;
|
||||||
return true; // TODO
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Remove(int position)
|
public bool Remove(int position)
|
||||||
|
Loading…
Reference in New Issue
Block a user