Усложнение первой лабораторной
This commit is contained in:
parent
557f5c50f4
commit
82bd7f3bca
15
AntiAircraftGun/AntiAircraftGun/CountRollers.cs
Normal file
15
AntiAircraftGun/AntiAircraftGun/CountRollers.cs
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AntiAircraftGun
|
||||||
|
{
|
||||||
|
internal enum CountRollers
|
||||||
|
{
|
||||||
|
Four = 4,
|
||||||
|
Five = 5,
|
||||||
|
Six = 6,
|
||||||
|
}
|
||||||
|
}
|
@ -15,6 +15,7 @@ namespace AntiAircraftGun
|
|||||||
/// Класс-сущность
|
/// Класс-сущность
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public EntityAntiAircraftGun AntiAircraftGun { private set; get; }
|
public EntityAntiAircraftGun AntiAircraftGun { private set; get; }
|
||||||
|
public DrawningAntiAircraftGunRollers DrawningRollers { get; private set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Левая координата отрисовки зенитного орудия
|
/// Левая координата отрисовки зенитного орудия
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -49,6 +50,8 @@ namespace AntiAircraftGun
|
|||||||
{
|
{
|
||||||
AntiAircraftGun = new EntityAntiAircraftGun();
|
AntiAircraftGun = new EntityAntiAircraftGun();
|
||||||
AntiAircraftGun.Init(speed, weight, bodyColor);
|
AntiAircraftGun.Init(speed, weight, bodyColor);
|
||||||
|
DrawningRollers = new();
|
||||||
|
DrawningRollers.CountRollers = 4;
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Установка позиции зенитного орудия
|
/// Установка позиции зенитного орудия
|
||||||
@ -132,15 +135,12 @@ namespace AntiAircraftGun
|
|||||||
Brush brBlack = new SolidBrush(Color.Black);
|
Brush brBlack = new SolidBrush(Color.Black);
|
||||||
g.FillEllipse(brBlack, _startPosX +1, _startPosY + 21, 18, 18);
|
g.FillEllipse(brBlack, _startPosX +1, _startPosY + 21, 18, 18);
|
||||||
g.FillEllipse(brBlack, _startPosX + 71, _startPosY + 21, 18, 18);
|
g.FillEllipse(brBlack, _startPosX + 71, _startPosY + 21, 18, 18);
|
||||||
g.FillEllipse(brBlack, _startPosX + 19, _startPosY + 30, 11, 11);
|
|
||||||
g.FillEllipse(brBlack, _startPosX + 58, _startPosY + 30, 11, 11);
|
|
||||||
g.FillEllipse(brBlack, _startPosX + 32, _startPosY + 30, 11, 11);
|
|
||||||
g.FillEllipse(brBlack, _startPosX + 45, _startPosY + 30, 11, 11);
|
|
||||||
//корпус
|
//корпус
|
||||||
Brush br = new SolidBrush(AntiAircraftGun?.BodyColor ?? Color.Black);
|
Brush br = new SolidBrush(AntiAircraftGun?.BodyColor ?? Color.Black);
|
||||||
g.FillRectangle(br, _startPosX + 20, _startPosY + 2, 50, 8);
|
g.FillRectangle(br, _startPosX + 20, _startPosY + 2, 50, 8);
|
||||||
g.FillRectangle(br, _startPosX + 5, _startPosY + 10, 80, 15);
|
g.FillRectangle(br, _startPosX + 5, _startPosY + 10, 80, 15);
|
||||||
g.FillEllipse(br, _startPosX + 6, _startPosY + 20, 78, 10);
|
g.FillEllipse(br, _startPosX + 6, _startPosY + 20, 78, 10);
|
||||||
|
DrawningRollers.DrawRollers(g, (int)_startPosX + 19, (int)_startPosY + 30, (int)_antiAircrafGunWidth);
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Смена границ формы отрисовки
|
/// Смена границ формы отрисовки
|
||||||
|
@ -0,0 +1,37 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AntiAircraftGun
|
||||||
|
{
|
||||||
|
internal class DrawningAntiAircraftGunRollers
|
||||||
|
{
|
||||||
|
private CountRollers _countRollers;
|
||||||
|
|
||||||
|
public int CountRollers
|
||||||
|
{
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_countRollers = (CountRollers)(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void DrawRollers(Graphics g, int _startPosX, int _startPosY, int _antiAircrafGunWidth)
|
||||||
|
{
|
||||||
|
int left = _startPosX;
|
||||||
|
for (var i = 0; i < (int)_countRollers; i += 1)
|
||||||
|
{
|
||||||
|
DrawRoller(g, left, _startPosY);
|
||||||
|
left += 52 / (int)_countRollers;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DrawRoller(Graphics g, int _startPosX, int _startPosY)
|
||||||
|
{
|
||||||
|
Brush brBlack = new SolidBrush(Color.Black);
|
||||||
|
g.FillEllipse(brBlack, _startPosX, _startPosY, 10, 10);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -38,6 +38,8 @@
|
|||||||
this.buttonLeft = new System.Windows.Forms.Button();
|
this.buttonLeft = new System.Windows.Forms.Button();
|
||||||
this.buttonRight = new System.Windows.Forms.Button();
|
this.buttonRight = new System.Windows.Forms.Button();
|
||||||
this.buttonDown = new System.Windows.Forms.Button();
|
this.buttonDown = new System.Windows.Forms.Button();
|
||||||
|
this.labelPortholes = new System.Windows.Forms.Label();
|
||||||
|
this.comboBoxRollers = new System.Windows.Forms.ComboBox();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxAntiAircraftGun)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.pictureBoxAntiAircraftGun)).BeginInit();
|
||||||
this.statusStrip.SuspendLayout();
|
this.statusStrip.SuspendLayout();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
@ -52,7 +54,6 @@
|
|||||||
this.pictureBoxAntiAircraftGun.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
|
this.pictureBoxAntiAircraftGun.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
|
||||||
this.pictureBoxAntiAircraftGun.TabIndex = 0;
|
this.pictureBoxAntiAircraftGun.TabIndex = 0;
|
||||||
this.pictureBoxAntiAircraftGun.TabStop = false;
|
this.pictureBoxAntiAircraftGun.TabStop = false;
|
||||||
this.pictureBoxAntiAircraftGun.Click += new System.EventHandler(this.pictureBoxAntiAircraftGun_Click);
|
|
||||||
this.pictureBoxAntiAircraftGun.Resize += new System.EventHandler(this.PictureBoxAntiAircraftGun_Resize);
|
this.pictureBoxAntiAircraftGun.Resize += new System.EventHandler(this.PictureBoxAntiAircraftGun_Resize);
|
||||||
//
|
//
|
||||||
// statusStrip
|
// statusStrip
|
||||||
@ -150,11 +151,35 @@
|
|||||||
this.buttonDown.UseVisualStyleBackColor = true;
|
this.buttonDown.UseVisualStyleBackColor = true;
|
||||||
this.buttonDown.Click += new System.EventHandler(this.ButtonMove_Click);
|
this.buttonDown.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||||
//
|
//
|
||||||
|
// labelPortholes
|
||||||
|
//
|
||||||
|
this.labelPortholes.AutoSize = true;
|
||||||
|
this.labelPortholes.Location = new System.Drawing.Point(98, 290);
|
||||||
|
this.labelPortholes.Name = "labelPortholes";
|
||||||
|
this.labelPortholes.Size = new System.Drawing.Size(121, 15);
|
||||||
|
this.labelPortholes.TabIndex = 8;
|
||||||
|
this.labelPortholes.Text = "Колличество катков:";
|
||||||
|
//
|
||||||
|
// comboBoxRollers
|
||||||
|
//
|
||||||
|
this.comboBoxRollers.FormattingEnabled = true;
|
||||||
|
this.comboBoxRollers.Items.AddRange(new object[] {
|
||||||
|
"4",
|
||||||
|
"5",
|
||||||
|
"6"});
|
||||||
|
this.comboBoxRollers.Location = new System.Drawing.Point(225, 285);
|
||||||
|
this.comboBoxRollers.Name = "comboBoxRollers";
|
||||||
|
this.comboBoxRollers.Size = new System.Drawing.Size(44, 23);
|
||||||
|
this.comboBoxRollers.TabIndex = 9;
|
||||||
|
this.comboBoxRollers.Text = "4";
|
||||||
|
//
|
||||||
// FormAntiAircraftGun
|
// FormAntiAircraftGun
|
||||||
//
|
//
|
||||||
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(700, 338);
|
this.ClientSize = new System.Drawing.Size(700, 338);
|
||||||
|
this.Controls.Add(this.comboBoxRollers);
|
||||||
|
this.Controls.Add(this.labelPortholes);
|
||||||
this.Controls.Add(this.buttonDown);
|
this.Controls.Add(this.buttonDown);
|
||||||
this.Controls.Add(this.buttonRight);
|
this.Controls.Add(this.buttonRight);
|
||||||
this.Controls.Add(this.buttonLeft);
|
this.Controls.Add(this.buttonLeft);
|
||||||
@ -187,5 +212,7 @@
|
|||||||
private Button buttonLeft;
|
private Button buttonLeft;
|
||||||
private Button buttonRight;
|
private Button buttonRight;
|
||||||
private Button buttonDown;
|
private Button buttonDown;
|
||||||
|
private Label labelPortholes;
|
||||||
|
private ComboBox comboBoxRollers;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -35,6 +35,7 @@ namespace AntiAircraftGun
|
|||||||
_antiAircrafGun = new DrawingAntiAircraftGun();
|
_antiAircrafGun = new DrawingAntiAircraftGun();
|
||||||
_antiAircrafGun.Init(rnd.Next(100, 300), rnd.Next(1000, 2000),
|
_antiAircrafGun.Init(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)));
|
||||||
|
_antiAircrafGun.DrawningRollers.CountRollers = Convert.ToInt32(comboBoxRollers.Text);
|
||||||
_antiAircrafGun.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100),
|
_antiAircrafGun.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100),
|
||||||
pictureBoxAntiAircraftGun.Width, pictureBoxAntiAircraftGun.Height);
|
pictureBoxAntiAircraftGun.Width, pictureBoxAntiAircraftGun.Height);
|
||||||
toolStripStatusLabelSpeed.Text = $"Ñêîðîñòü: {_antiAircrafGun.AntiAircraftGun.Speed}";
|
toolStripStatusLabelSpeed.Text = $"Ñêîðîñòü: {_antiAircrafGun.AntiAircraftGun.Speed}";
|
||||||
@ -78,10 +79,5 @@ namespace AntiAircraftGun
|
|||||||
_antiAircrafGun?.ChangeBorders(pictureBoxAntiAircraftGun.Width, pictureBoxAntiAircraftGun.Height);
|
_antiAircrafGun?.ChangeBorders(pictureBoxAntiAircraftGun.Width, pictureBoxAntiAircraftGun.Height);
|
||||||
Draw();
|
Draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void pictureBoxAntiAircraftGun_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user