diff --git a/AntiAirCraftGun/AntiAirCraftGun/DrawingAntiAirCraftGun.cs b/AntiAirCraftGun/AntiAirCraftGun/DrawingAntiAirCraftGun.cs
index e1b597f..e4de4a3 100644
--- a/AntiAirCraftGun/AntiAirCraftGun/DrawingAntiAirCraftGun.cs
+++ b/AntiAirCraftGun/AntiAirCraftGun/DrawingAntiAirCraftGun.cs
@@ -35,11 +35,11 @@ namespace AntiAircraftGun
///
/// Ширина прорисовки автомобиля
///
- private readonly int _carWidth = 110;
+ private readonly int _zenitWidth = 110;
///
/// Высота прорисовки автомобиля
///
- private readonly int _carHeight = 60;
+ private readonly int _zenitHeight = 60;
///
/// Инициализация свойств
///
@@ -54,7 +54,8 @@ namespace AntiAircraftGun
public bool Init(int speed, double weight, Color bodyColor, Color
additionalColor, Color dopColor, bool rocket, bool radar, int width, int height)
{
- // TODO: Продумать проверки
+ if (width <= _zenitWidth || height <= _zenitHeight) return false;
+
_pictureWidth = width;
_pictureHeight = height;
AntiAircraftGun = new EntityAntiAircraftGun();
@@ -68,9 +69,14 @@ namespace AntiAircraftGun
/// Координата Y
public void SetPosition(int x, int y)
{
- // TODO: Изменение x, y
+ if (AntiAircraftGun == null) return;
_startPosX = x;
_startPosY = y;
+ if (x + _zenitWidth >= _pictureWidth || y + _zenitHeight>= _pictureHeight)
+ {
+ _startPosX = 1;
+ _startPosY = 1;
+ }
}
///
/// Изменение направления перемещения
@@ -82,14 +88,6 @@ namespace AntiAircraftGun
{
return;
}
-
- FormAntiAirCraftGun form1 = new FormAntiAirCraftGun();
- Size windowSize = form1.Size;
- int windowWidth = windowSize.Width;
- int windowHeight = windowSize.Height;
-
- // Теперь вы можете получить ширину и высоту отдельно, если это необходимо
-
switch (direction)
{
//влево
@@ -108,14 +106,14 @@ namespace AntiAircraftGun
break;
// вправо
case DirectionType.Right:
- if (_startPosX + AntiAircraftGun.Step < windowWidth-150)
+ if (_startPosX + AntiAircraftGun.Step < _pictureWidth-110)
{
_startPosX += (int)AntiAircraftGun.Step;
}
break;
//вниз
case DirectionType.Down:
- if (_startPosY + AntiAircraftGun.Step < windowHeight-100)
+ if (_startPosY + AntiAircraftGun.Step < _pictureHeight-60)
{
_startPosY += (int)AntiAircraftGun.Step;
}
@@ -149,8 +147,6 @@ namespace AntiAircraftGun
g.DrawEllipse(pen, trackRect);
g.FillEllipse(Brushes.Black, trackRect);
}
-
-
Brush dopBrush = new SolidBrush(AntiAircraftGun.DopColor);
Pen dopPen = new Pen(AntiAircraftGun.DopColor);
if (AntiAircraftGun.Rocket)
@@ -169,12 +165,6 @@ namespace AntiAircraftGun
g.DrawLine(dopPen, _startPosX + 98, _startPosY, _startPosX + 93, _startPosY + 10);
g.FillEllipse(dopBrush, _startPosX + 88, _startPosY -10, 10, 10);
}
-
-
-
-
-
-
}
}
}
diff --git a/AntiAirCraftGun/AntiAirCraftGun/EntityAntiAircraftGun.cs b/AntiAirCraftGun/AntiAirCraftGun/EntityAntiAircraftGun.cs
index 9e0de1e..c6c6b17 100644
--- a/AntiAirCraftGun/AntiAirCraftGun/EntityAntiAircraftGun.cs
+++ b/AntiAirCraftGun/AntiAirCraftGun/EntityAntiAircraftGun.cs
@@ -28,11 +28,17 @@ namespace AntiAircraftGun
/// Шаг перемещения автомобиля
///
public double Step => (double)Speed * 100 / Weight;
-
+ ///
+ /// Цвет для доп. деталей
+ ///
public Color DopColor { get; private set; }
-
+ ///
+ /// Ракета
+ ///
public bool Rocket { get; private set; }
-
+ ///
+ /// Радар
+ ///
public bool Radar { get; private set; }
///
/// Инициализация полей объекта-класса спортивного автомобиля
diff --git a/AntiAirCraftGun/AntiAirCraftGun/FormAntiAirCraftGun.Designer.cs b/AntiAirCraftGun/AntiAirCraftGun/FormAntiAirCraftGun.Designer.cs
index 7990e0f..347ee34 100644
--- a/AntiAirCraftGun/AntiAirCraftGun/FormAntiAirCraftGun.Designer.cs
+++ b/AntiAirCraftGun/AntiAirCraftGun/FormAntiAirCraftGun.Designer.cs
@@ -2,34 +2,34 @@
{
partial class FormAntiAirCraftGun
{
- ///
- /// Required designer variable.
- ///
- private System.ComponentModel.IContainer components = null;
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
- ///
- /// Clean up any resources being used.
- ///
- /// true if managed resources should be disposed; otherwise, false.
- protected override void Dispose(bool disposing)
- {
- if (disposing && (components != null))
- {
- components.Dispose();
- }
- base.Dispose(disposing);
- }
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
- #region Windows Form Designer generated code
+ #region Windows Form Designer generated code
- ///
- /// Required method for Designer support - do not modify
- /// the contents of this method with the code editor.
- ///
- private void InitializeComponent()
- {
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
this.pictureBoxAntiAircraftGun = new System.Windows.Forms.PictureBox();
- this.Create = new System.Windows.Forms.Button();
+ this.buttonCreate = new System.Windows.Forms.Button();
this.buttonLeft = new System.Windows.Forms.Button();
this.buttonUp = new System.Windows.Forms.Button();
this.buttonRight = new System.Windows.Forms.Button();
@@ -47,16 +47,16 @@
this.pictureBoxAntiAircraftGun.TabIndex = 0;
this.pictureBoxAntiAircraftGun.TabStop = false;
//
- // Create
+ // buttonCreate
//
- this.Create.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
- this.Create.Location = new System.Drawing.Point(32, 577);
- this.Create.Name = "Create";
- this.Create.Size = new System.Drawing.Size(75, 23);
- this.Create.TabIndex = 1;
- this.Create.Text = "Создать";
- this.Create.UseVisualStyleBackColor = true;
- this.Create.Click += new System.EventHandler(this.Create_Click_1);
+ this.buttonCreate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
+ this.buttonCreate.Location = new System.Drawing.Point(32, 577);
+ this.buttonCreate.Name = "buttonCreate";
+ this.buttonCreate.Size = new System.Drawing.Size(75, 23);
+ this.buttonCreate.TabIndex = 1;
+ this.buttonCreate.Text = "Создать";
+ this.buttonCreate.UseVisualStyleBackColor = true;
+ this.buttonCreate.Click += new System.EventHandler(this.buttonCreate_Click);
//
// buttonLeft
//
@@ -106,7 +106,7 @@
this.buttonDown.UseVisualStyleBackColor = true;
this.buttonDown.Click += new System.EventHandler(this.ButtonMove_Click);
//
- // Form1
+ // FormAntiAirCraftGun
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
@@ -115,23 +115,24 @@
this.Controls.Add(this.buttonRight);
this.Controls.Add(this.buttonUp);
this.Controls.Add(this.buttonLeft);
- this.Controls.Add(this.Create);
+ this.Controls.Add(this.buttonCreate);
this.Controls.Add(this.pictureBoxAntiAircraftGun);
- this.Name = "Form1";
+ this.Name = "FormAntiAirCraftGun";
this.Text = "Form1";
((System.ComponentModel.ISupportInitialize)(this.pictureBoxAntiAircraftGun)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
- }
+ }
- #endregion
+ #endregion
- private PictureBox pictureBoxAntiAircraftGun;
- private Button Create;
- private Button buttonLeft;
- private Button buttonUp;
- private Button buttonRight;
- private Button buttonDown;
- }
+ private PictureBox pictureBoxAntiAircraftGun;
+ private Button buttonCreate;
+ private Button buttonLeft;
+ private Button buttonUp;
+ private Button buttonRight;
+ private Button buttonDown;
+
+ }
}
\ No newline at end of file
diff --git a/AntiAirCraftGun/AntiAirCraftGun/FormAntiAirCraftGun.cs b/AntiAirCraftGun/AntiAirCraftGun/FormAntiAirCraftGun.cs
index 4f42f5b..c8b7f39 100644
--- a/AntiAirCraftGun/AntiAirCraftGun/FormAntiAirCraftGun.cs
+++ b/AntiAirCraftGun/AntiAirCraftGun/FormAntiAirCraftGun.cs
@@ -37,11 +37,7 @@ namespace AntiAircraftGun
- ///
- ///
- ///
- ///
- ///
+
private void pictureBoxZenit_Click(object sender, EventArgs e)
{
@@ -62,11 +58,7 @@ namespace AntiAircraftGun
pictureBoxAntiAircraftGun.Image = bmp;
}
- ///
- ///
- ///
- ///
- ///
+
private void ButtonMove_Click(object sender, EventArgs e)
{
if (_drawing == null)
@@ -91,8 +83,7 @@ namespace AntiAircraftGun
}
Draw();
}
-
- private void Create_Click_1(object sender, EventArgs e)
+ private void buttonCreate_Click(object sender, EventArgs e)
{
Random random = new();
_drawing = new DrawingAntiAirCraftGun();
@@ -102,7 +93,7 @@ namespace AntiAircraftGun
random.Next(0, 256)),
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)), // . 2
Convert.ToBoolean(random.Next(2)), // Rocket
Convert.ToBoolean(random.Next(2)), // Radar
@@ -111,8 +102,9 @@ namespace AntiAircraftGun
_drawing.SetPosition(random.Next(10, 100),
random.Next(10, 100));
-
+
Draw();
}
+
}
}
\ No newline at end of file
diff --git a/AntiAirCraftGun/AntiAirCraftGun/Vopros.cs b/AntiAirCraftGun/AntiAirCraftGun/Vopros.cs
deleted file mode 100644
index c1932e3..0000000
--- a/AntiAirCraftGun/AntiAirCraftGun/Vopros.cs
+++ /dev/null
@@ -1,20 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace AntiAircraftGun
-{
- public class Vopros
- {
- private int _id;
-
- public int change_id { set { _id = value; } }
-
- public void Change(int id)
- {
- change_id = id;
- }
- }
-}