Compare commits
2 Commits
07fe09f7e1
...
a0aee749e1
Author | SHA1 | Date | |
---|---|---|---|
a0aee749e1 | |||
9a8d51e3aa |
@ -6,7 +6,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace AirBomber
|
||||
{
|
||||
internal enum Direction
|
||||
public enum Direction
|
||||
{
|
||||
None = 0,
|
||||
Up = 1,
|
||||
|
@ -9,7 +9,7 @@ namespace AirBomber
|
||||
/// <summary>
|
||||
/// Класс, отвечающий за прорисовку и перемещение объекта-сущности
|
||||
/// </summary>
|
||||
internal class DrawningJet
|
||||
public class DrawningJet
|
||||
{
|
||||
/// <summary>
|
||||
/// Класс-сущность
|
||||
|
@ -6,7 +6,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace AirBomber
|
||||
{
|
||||
internal class EntityJet
|
||||
public class EntityJet
|
||||
{
|
||||
/// <summary>
|
||||
/// Скорость
|
||||
|
21
AirBomber/AirBomber/FormMap.Designer.cs
generated
21
AirBomber/AirBomber/FormMap.Designer.cs
generated
@ -40,6 +40,7 @@
|
||||
this.buttonDown = new System.Windows.Forms.Button();
|
||||
this.buttonCreateModif = new System.Windows.Forms.Button();
|
||||
this.comboBoxCelectorMap1 = new System.Windows.Forms.ComboBox();
|
||||
this.ButtonSelectJet = new System.Windows.Forms.Button();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxJet)).BeginInit();
|
||||
this.statusStrip1.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
@ -105,7 +106,7 @@
|
||||
this.buttonUp.Size = new System.Drawing.Size(40, 40);
|
||||
this.buttonUp.TabIndex = 3;
|
||||
this.buttonUp.UseVisualStyleBackColor = true;
|
||||
this.buttonUp.Click += new System.EventHandler(this.buttonMove_Click);
|
||||
this.buttonUp.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||
//
|
||||
// buttonLeft
|
||||
//
|
||||
@ -117,7 +118,7 @@
|
||||
this.buttonLeft.Size = new System.Drawing.Size(40, 40);
|
||||
this.buttonLeft.TabIndex = 4;
|
||||
this.buttonLeft.UseVisualStyleBackColor = true;
|
||||
this.buttonLeft.Click += new System.EventHandler(this.buttonMove_Click);
|
||||
this.buttonLeft.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||
//
|
||||
// buttonRight
|
||||
//
|
||||
@ -129,7 +130,7 @@
|
||||
this.buttonRight.Size = new System.Drawing.Size(40, 40);
|
||||
this.buttonRight.TabIndex = 5;
|
||||
this.buttonRight.UseVisualStyleBackColor = true;
|
||||
this.buttonRight.Click += new System.EventHandler(this.buttonMove_Click);
|
||||
this.buttonRight.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||
//
|
||||
// buttonDown
|
||||
//
|
||||
@ -141,7 +142,7 @@
|
||||
this.buttonDown.Size = new System.Drawing.Size(40, 40);
|
||||
this.buttonDown.TabIndex = 6;
|
||||
this.buttonDown.UseVisualStyleBackColor = true;
|
||||
this.buttonDown.Click += new System.EventHandler(this.buttonMove_Click);
|
||||
this.buttonDown.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||
//
|
||||
// buttonCreateModif
|
||||
//
|
||||
@ -166,11 +167,22 @@
|
||||
this.comboBoxCelectorMap1.TabIndex = 8;
|
||||
this.comboBoxCelectorMap1.SelectedIndexChanged += new System.EventHandler(this.comboBoxCelectorMap1_SelectedIndexChanged);
|
||||
//
|
||||
// ButtonSelectJet
|
||||
//
|
||||
this.ButtonSelectJet.Location = new System.Drawing.Point(559, 394);
|
||||
this.ButtonSelectJet.Name = "ButtonSelectJet";
|
||||
this.ButtonSelectJet.Size = new System.Drawing.Size(75, 23);
|
||||
this.ButtonSelectJet.TabIndex = 9;
|
||||
this.ButtonSelectJet.Text = "Выбрать";
|
||||
this.ButtonSelectJet.UseVisualStyleBackColor = true;
|
||||
//this.ButtonSelectJet.Click += new System.EventHandler(this.ButtonSelectJet_Click);
|
||||
//
|
||||
// FormMap
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||
this.Controls.Add(this.ButtonSelectJet);
|
||||
this.Controls.Add(this.comboBoxCelectorMap1);
|
||||
this.Controls.Add(this.buttonCreateModif);
|
||||
this.Controls.Add(this.buttonDown);
|
||||
@ -204,5 +216,6 @@
|
||||
private Button buttonDown;
|
||||
private Button buttonCreateModif;
|
||||
private ComboBox comboBoxCelectorMap1;
|
||||
private Button ButtonSelectJet;
|
||||
}
|
||||
}
|
@ -35,11 +35,11 @@ namespace AirBomber
|
||||
/// <param name="e"></param>
|
||||
private void buttonCreate_Click(object sender, EventArgs e)
|
||||
{
|
||||
Random rnd = new Random();
|
||||
Random rnd = new Random();
|
||||
var jet = new DrawningJet(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
|
||||
SetData(jet);
|
||||
}
|
||||
private void buttonMove_Click(object sender, EventArgs e)
|
||||
private void ButtonMove_Click(object sender, EventArgs e)
|
||||
{
|
||||
//получаем имя кнопки
|
||||
string name = ((Button)sender)?.Name ?? string.Empty;
|
||||
@ -61,7 +61,6 @@ namespace AirBomber
|
||||
}
|
||||
pictureBoxJet.Image = _abstractMap?.MoveObject(dir);
|
||||
}
|
||||
|
||||
private void buttonCreateModif_Click(object sender, EventArgs e)
|
||||
{
|
||||
Random rnd = new Random();
|
||||
|
215
AirBomber/AirBomber/FormMapWithSetJets.Designer.cs
generated
Normal file
215
AirBomber/AirBomber/FormMapWithSetJets.Designer.cs
generated
Normal file
@ -0,0 +1,215 @@
|
||||
namespace AirBomber
|
||||
{
|
||||
partial class FormMapWithSetJets
|
||||
{
|
||||
/// <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.groupBox1 = new System.Windows.Forms.GroupBox();
|
||||
this.ButtonShowOnMap = new System.Windows.Forms.Button();
|
||||
this.ButtonShowStorage = new System.Windows.Forms.Button();
|
||||
this.ButtonRemoveJet = new System.Windows.Forms.Button();
|
||||
this.maskedTextBoxPosition = new System.Windows.Forms.TextBox();
|
||||
this.ButtonAddJet = new System.Windows.Forms.Button();
|
||||
this.comboBoxCelectorMap1 = new System.Windows.Forms.ComboBox();
|
||||
this.buttonLeft = new System.Windows.Forms.Button();
|
||||
this.buttonRight = new System.Windows.Forms.Button();
|
||||
this.buttonDown = new System.Windows.Forms.Button();
|
||||
this.buttonUp = new System.Windows.Forms.Button();
|
||||
this.pictureBoxJet = new System.Windows.Forms.PictureBox();
|
||||
this.groupBox1.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxJet)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// groupBox1
|
||||
//
|
||||
this.groupBox1.Controls.Add(this.ButtonShowOnMap);
|
||||
this.groupBox1.Controls.Add(this.ButtonShowStorage);
|
||||
this.groupBox1.Controls.Add(this.ButtonRemoveJet);
|
||||
this.groupBox1.Controls.Add(this.maskedTextBoxPosition);
|
||||
this.groupBox1.Controls.Add(this.ButtonAddJet);
|
||||
this.groupBox1.Controls.Add(this.comboBoxCelectorMap1);
|
||||
this.groupBox1.Controls.Add(this.buttonLeft);
|
||||
this.groupBox1.Controls.Add(this.buttonRight);
|
||||
this.groupBox1.Controls.Add(this.buttonDown);
|
||||
this.groupBox1.Controls.Add(this.buttonUp);
|
||||
this.groupBox1.Dock = System.Windows.Forms.DockStyle.Right;
|
||||
this.groupBox1.Location = new System.Drawing.Point(680, 0);
|
||||
this.groupBox1.Name = "groupBox1";
|
||||
this.groupBox1.Size = new System.Drawing.Size(200, 524);
|
||||
this.groupBox1.TabIndex = 0;
|
||||
this.groupBox1.TabStop = false;
|
||||
this.groupBox1.Text = "Инструменты";
|
||||
//
|
||||
// ButtonShowOnMap
|
||||
//
|
||||
this.ButtonShowOnMap.Location = new System.Drawing.Point(6, 276);
|
||||
this.ButtonShowOnMap.Name = "ButtonShowOnMap";
|
||||
this.ButtonShowOnMap.Size = new System.Drawing.Size(182, 23);
|
||||
this.ButtonShowOnMap.TabIndex = 15;
|
||||
this.ButtonShowOnMap.Text = "Посмотреть карту";
|
||||
this.ButtonShowOnMap.UseVisualStyleBackColor = true;
|
||||
this.ButtonShowOnMap.Click += new System.EventHandler(this.ButtonShowOnMap_Click);
|
||||
//
|
||||
// ButtonShowStorage
|
||||
//
|
||||
this.ButtonShowStorage.Location = new System.Drawing.Point(6, 223);
|
||||
this.ButtonShowStorage.Name = "ButtonShowStorage";
|
||||
this.ButtonShowStorage.Size = new System.Drawing.Size(182, 23);
|
||||
this.ButtonShowStorage.TabIndex = 14;
|
||||
this.ButtonShowStorage.Text = "Посмотреть хранилище";
|
||||
this.ButtonShowStorage.UseVisualStyleBackColor = true;
|
||||
this.ButtonShowStorage.Click += new System.EventHandler(this.ButtonShowStorage_Click);
|
||||
//
|
||||
// ButtonRemoveJet
|
||||
//
|
||||
this.ButtonRemoveJet.Location = new System.Drawing.Point(6, 144);
|
||||
this.ButtonRemoveJet.Name = "ButtonRemoveJet";
|
||||
this.ButtonRemoveJet.Size = new System.Drawing.Size(182, 23);
|
||||
this.ButtonRemoveJet.TabIndex = 13;
|
||||
this.ButtonRemoveJet.Text = "Удалить самолет";
|
||||
this.ButtonRemoveJet.UseVisualStyleBackColor = true;
|
||||
this.ButtonRemoveJet.Click += new System.EventHandler(this.ButtonRemoveJet_Click);
|
||||
//
|
||||
// maskedTextBoxPosition
|
||||
//
|
||||
this.maskedTextBoxPosition.Location = new System.Drawing.Point(6, 115);
|
||||
this.maskedTextBoxPosition.Name = "maskedTextBoxPosition";
|
||||
this.maskedTextBoxPosition.Size = new System.Drawing.Size(182, 23);
|
||||
this.maskedTextBoxPosition.TabIndex = 12;
|
||||
//
|
||||
// ButtonAddJet
|
||||
//
|
||||
this.ButtonAddJet.Location = new System.Drawing.Point(6, 68);
|
||||
this.ButtonAddJet.Name = "ButtonAddJet";
|
||||
this.ButtonAddJet.Size = new System.Drawing.Size(182, 23);
|
||||
this.ButtonAddJet.TabIndex = 11;
|
||||
this.ButtonAddJet.Text = "Добавить самолет";
|
||||
this.ButtonAddJet.UseVisualStyleBackColor = true;
|
||||
this.ButtonAddJet.Click += new System.EventHandler(this.ButtonAddJet_Click);
|
||||
//
|
||||
// comboBoxCelectorMap1
|
||||
//
|
||||
this.comboBoxCelectorMap1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.comboBoxCelectorMap1.FormattingEnabled = true;
|
||||
this.comboBoxCelectorMap1.Items.AddRange(new object[] {
|
||||
"Простоя карта",
|
||||
"Небо"});
|
||||
this.comboBoxCelectorMap1.Location = new System.Drawing.Point(6, 22);
|
||||
this.comboBoxCelectorMap1.Name = "comboBoxCelectorMap1";
|
||||
this.comboBoxCelectorMap1.Size = new System.Drawing.Size(182, 23);
|
||||
this.comboBoxCelectorMap1.TabIndex = 10;
|
||||
this.comboBoxCelectorMap1.SelectedIndexChanged += new System.EventHandler(this.comboBoxCelectorMap1_SelectedIndexChanged);
|
||||
//
|
||||
// buttonLeft
|
||||
//
|
||||
this.buttonLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonLeft.BackgroundImage = global::AirBomber.Properties.Resources.arrowLeft;
|
||||
this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||
this.buttonLeft.Location = new System.Drawing.Point(51, 467);
|
||||
this.buttonLeft.Name = "buttonLeft";
|
||||
this.buttonLeft.Size = new System.Drawing.Size(35, 30);
|
||||
this.buttonLeft.TabIndex = 9;
|
||||
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.BackgroundImage = global::AirBomber.Properties.Resources.arrowRight;
|
||||
this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||
this.buttonRight.Location = new System.Drawing.Point(133, 467);
|
||||
this.buttonRight.Name = "buttonRight";
|
||||
this.buttonRight.Size = new System.Drawing.Size(35, 30);
|
||||
this.buttonRight.TabIndex = 8;
|
||||
this.buttonRight.UseVisualStyleBackColor = true;
|
||||
this.buttonRight.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 = global::AirBomber.Properties.Resources.arrowDown;
|
||||
this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||
this.buttonDown.Location = new System.Drawing.Point(92, 467);
|
||||
this.buttonDown.Name = "buttonDown";
|
||||
this.buttonDown.Size = new System.Drawing.Size(35, 30);
|
||||
this.buttonDown.TabIndex = 7;
|
||||
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 = global::AirBomber.Properties.Resources.arrowUp;
|
||||
this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||
this.buttonUp.Location = new System.Drawing.Point(92, 431);
|
||||
this.buttonUp.Name = "buttonUp";
|
||||
this.buttonUp.Size = new System.Drawing.Size(35, 30);
|
||||
this.buttonUp.TabIndex = 4;
|
||||
this.buttonUp.UseVisualStyleBackColor = true;
|
||||
this.buttonUp.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||
//
|
||||
// pictureBoxJet
|
||||
//
|
||||
this.pictureBoxJet.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.pictureBoxJet.Location = new System.Drawing.Point(0, 0);
|
||||
this.pictureBoxJet.Name = "pictureBoxJet";
|
||||
this.pictureBoxJet.Size = new System.Drawing.Size(680, 524);
|
||||
this.pictureBoxJet.TabIndex = 1;
|
||||
this.pictureBoxJet.TabStop = false;
|
||||
//
|
||||
// FormMapWithSetJets
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(880, 524);
|
||||
this.Controls.Add(this.pictureBoxJet);
|
||||
this.Controls.Add(this.groupBox1);
|
||||
this.Name = "FormMapWithSetJets";
|
||||
this.Text = "Карта с набором объектов";
|
||||
this.groupBox1.ResumeLayout(false);
|
||||
this.groupBox1.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxJet)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private GroupBox groupBox1;
|
||||
private PictureBox pictureBoxJet;
|
||||
private Button buttonUp;
|
||||
private Button buttonDown;
|
||||
private Button buttonRight;
|
||||
private Button buttonLeft;
|
||||
private Button ButtonShowOnMap;
|
||||
private Button ButtonShowStorage;
|
||||
private Button ButtonRemoveJet;
|
||||
private TextBox maskedTextBoxPosition;
|
||||
private Button ButtonAddJet;
|
||||
private ComboBox comboBoxCelectorMap1;
|
||||
}
|
||||
}
|
163
AirBomber/AirBomber/FormMapWithSetJets.cs
Normal file
163
AirBomber/AirBomber/FormMapWithSetJets.cs
Normal file
@ -0,0 +1,163 @@
|
||||
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;
|
||||
using static System.Windows.Forms.DataFormats;
|
||||
|
||||
namespace AirBomber
|
||||
{
|
||||
public partial class FormMapWithSetJets : Form
|
||||
{
|
||||
/// <summary>
|
||||
/// Объект от класса карты с набором объектов
|
||||
/// </summary>
|
||||
private MapWithSetJetsGeneric<DrawningObjectJet, AbstractMap> _mapJetsCollectionGeneric;
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
public FormMapWithSetJets()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
/// <summary>
|
||||
/// Выбор карты
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void comboBoxCelectorMap1_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
AbstractMap map = null;
|
||||
switch (comboBoxCelectorMap1.Text)
|
||||
{
|
||||
case "Простая карта":
|
||||
map = new SimpleMap();
|
||||
break;
|
||||
case "Небо":
|
||||
map = new SkyMap();
|
||||
break;
|
||||
}
|
||||
if (map != null)
|
||||
{
|
||||
_mapJetsCollectionGeneric = new MapWithSetJetsGeneric<DrawningObjectJet, AbstractMap>(pictureBoxJet.Width, pictureBoxJet.Height, map);
|
||||
}
|
||||
else
|
||||
{
|
||||
_mapJetsCollectionGeneric = null;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Добавление объекта
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonAddJet_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_mapJetsCollectionGeneric == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
WarJet form = new();
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
if (form.SelectedJet == null)
|
||||
{
|
||||
MessageBox.Show("Сначала создайте объект");
|
||||
return;
|
||||
}
|
||||
DrawningObjectJet bus = new(form.SelectedJet);
|
||||
if (_mapJetsCollectionGeneric + bus != -1)
|
||||
{
|
||||
MessageBox.Show("Объект добавлен");
|
||||
pictureBoxJet.Image = _mapJetsCollectionGeneric.ShowSet();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Не удалось добавить объект");
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Удаление объекта
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonRemoveJet_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(maskedTextBoxPosition.Text))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (MessageBox.Show("Удалить объект?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
|
||||
{
|
||||
return;
|
||||
}
|
||||
int pos = Convert.ToInt32(maskedTextBoxPosition.Text);
|
||||
if (_mapJetsCollectionGeneric - pos != null)
|
||||
{
|
||||
MessageBox.Show("Объект удален");
|
||||
pictureBoxJet.Image = _mapJetsCollectionGeneric.ShowSet();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Не удалось удалить объект");
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Вывод набора
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonShowStorage_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_mapJetsCollectionGeneric == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
pictureBoxJet.Image = _mapJetsCollectionGeneric.ShowSet();
|
||||
}
|
||||
/// <summary>
|
||||
/// Вывод карты
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonShowOnMap_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_mapJetsCollectionGeneric == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
pictureBoxJet.Image = _mapJetsCollectionGeneric.ShowOnMap();
|
||||
}
|
||||
private void ButtonMove_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_mapJetsCollectionGeneric == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
//получаем имя кнопки
|
||||
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;
|
||||
}
|
||||
pictureBoxJet.Image = _mapJetsCollectionGeneric.MoveObject(dir);
|
||||
}
|
||||
}
|
||||
}
|
60
AirBomber/AirBomber/FormMapWithSetJets.resx
Normal file
60
AirBomber/AirBomber/FormMapWithSetJets.resx
Normal file
@ -0,0 +1,60 @@
|
||||
<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>
|
||||
</root>
|
205
AirBomber/AirBomber/MapWithSetJetsGeneric.cs
Normal file
205
AirBomber/AirBomber/MapWithSetJetsGeneric.cs
Normal file
@ -0,0 +1,205 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AirBomber
|
||||
{
|
||||
internal class MapWithSetJetsGeneric<T, U>
|
||||
where T : class, IDrawningObject
|
||||
where U : AbstractMap
|
||||
{
|
||||
/// <summary>
|
||||
/// Ширина окна отрисовки
|
||||
/// </summary>
|
||||
private readonly int _pictureWidth;
|
||||
|
||||
/// <summary>
|
||||
/// Высота окна отрисовки
|
||||
/// </summary>
|
||||
private readonly int _pictureHeight;
|
||||
|
||||
/// <summary>
|
||||
/// Размер занимаемого объектом места (ширина)
|
||||
/// </summary>
|
||||
private readonly int _placeSizeWidth = 210;
|
||||
|
||||
/// <summary>
|
||||
/// Размер занимаемого объектом места (высота)
|
||||
/// </summary>
|
||||
private readonly int _placeSizeHeight = 122;
|
||||
|
||||
/// <summary>
|
||||
/// Набор объектов
|
||||
/// </summary>
|
||||
private readonly SetJetGeneric<T> _setJets;
|
||||
|
||||
/// <summary>
|
||||
/// Карта
|
||||
/// </summary>
|
||||
private readonly U _map;
|
||||
public U Map => _map;
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
/// <param name="picWidth">Ширина</param>
|
||||
/// <param name="picHeight">Высота</param>
|
||||
/// <param name="map">Карта</param>
|
||||
public MapWithSetJetsGeneric(int picWidth, int picHeight, U map)
|
||||
{
|
||||
int width = picWidth / _placeSizeWidth;
|
||||
int height = picHeight / _placeSizeHeight;
|
||||
_setJets = new SetJetGeneric<T>(width * height);
|
||||
_pictureWidth = picWidth;
|
||||
_pictureHeight = picHeight;
|
||||
_map = map;
|
||||
}
|
||||
/// <summary>
|
||||
/// Перегрузка оператора сложения
|
||||
/// </summary>
|
||||
/// <param name="map"></param>
|
||||
/// <param name="jet"></param>
|
||||
/// <returns></returns>
|
||||
public static int operator +(MapWithSetJetsGeneric<T, U> map, T jet)
|
||||
{
|
||||
return map._setJets.Insert(jet);
|
||||
}
|
||||
/// <summary>
|
||||
/// Перегрузка оператора вычитания
|
||||
/// </summary>
|
||||
/// <param name="map"></param>
|
||||
/// <param name="position"></param>
|
||||
/// <returns></returns>
|
||||
public static T operator -(MapWithSetJetsGeneric<T, U> map, int position)
|
||||
{
|
||||
return map._setJets.Remove(position);
|
||||
}
|
||||
/// <summary>
|
||||
/// Вывод всего набора объектов
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Bitmap ShowSet()
|
||||
{
|
||||
Bitmap bmp = new(_pictureWidth, _pictureHeight);
|
||||
Graphics gr = Graphics.FromImage(bmp);
|
||||
DrawBackground(gr);
|
||||
DrawJets(gr);
|
||||
return bmp;
|
||||
}
|
||||
/// <summary>
|
||||
/// Просмотр объекта на карте
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Bitmap ShowOnMap()
|
||||
{
|
||||
Shaking();
|
||||
for (int i = 0; i < _setJets.Count; i++)
|
||||
{
|
||||
var car = _setJets.Get(i);
|
||||
if (car != null)
|
||||
{
|
||||
return _map.CreateMap(_pictureWidth, _pictureHeight, car);
|
||||
}
|
||||
}
|
||||
return new(_pictureWidth, _pictureHeight);
|
||||
}
|
||||
/// <summary>
|
||||
/// Перемещение объекта по крате
|
||||
/// </summary>
|
||||
/// <param name="direction"></param>
|
||||
/// <returns></returns>
|
||||
public Bitmap MoveObject(Direction direction)
|
||||
{
|
||||
if (_map != null)
|
||||
{
|
||||
return _map.MoveObject(direction);
|
||||
}
|
||||
return new(_pictureWidth, _pictureHeight);
|
||||
}
|
||||
/// <summary>
|
||||
/// "Взбалтываем" набор, чтобы все элементы оказались в начале
|
||||
/// </summary>
|
||||
private void Shaking()
|
||||
{
|
||||
int j = _setJets.Count - 1;
|
||||
for (int i = 0; i < _setJets.Count; i++)
|
||||
{
|
||||
if (_setJets.Get(i) == null)
|
||||
{
|
||||
for (; j > i; j--)
|
||||
{
|
||||
var car = _setJets.Get(j);
|
||||
if (car != null)
|
||||
{
|
||||
_setJets.Insert(car, i);
|
||||
_setJets.Remove(j);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (j <= i)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Метод отрисовки фона
|
||||
/// </summary>
|
||||
/// <param name="g"></param>
|
||||
private void DrawBackground(Graphics g)
|
||||
{
|
||||
for (int x = 0; x < _pictureWidth; x++)
|
||||
{
|
||||
for (int y = 0; y < _pictureWidth; y++)
|
||||
{
|
||||
Brush hangarColor = new SolidBrush(Color.Silver);
|
||||
g.FillRectangle(hangarColor, x * x, y * y, x * (x + 1), y * (y + 1));
|
||||
}
|
||||
}
|
||||
Pen pen = new(Color.Black, 3);
|
||||
for (int i = 0; i < _pictureWidth / _placeSizeWidth; i++)
|
||||
{
|
||||
for (int j = 0; j < _pictureHeight / _placeSizeHeight + 1; ++j)
|
||||
{//линия рамзетки места
|
||||
g.DrawLine(pen, i * _placeSizeWidth, j * _placeSizeHeight, i * _placeSizeWidth + _placeSizeWidth * 3 / 4, j * _placeSizeHeight);
|
||||
}
|
||||
g.DrawLine(pen, i * _placeSizeWidth, 0, i * _placeSizeWidth, (_pictureHeight / _placeSizeHeight) * _placeSizeHeight);
|
||||
g.DrawLine(pen, i * _placeSizeWidth, 0, i * _placeSizeWidth, (_pictureHeight / _placeSizeHeight) * _placeSizeHeight);
|
||||
}
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// Метод прорисовки объектов
|
||||
/// </summary>
|
||||
/// <param name="g"></param>
|
||||
private void DrawJets(Graphics g)
|
||||
{
|
||||
// максимальное количество колонок и строк
|
||||
int cols = _pictureWidth / _placeSizeWidth;
|
||||
//int rows = _pictureHeight / _placeSizeHeight;
|
||||
int rows = (cols - 1) * _placeSizeWidth;
|
||||
// счетчик колонок и строк
|
||||
int ccol = 0;
|
||||
int crow = 0;
|
||||
|
||||
for (int i = 0; i < _setJets.Count; i++)
|
||||
{
|
||||
// установка позиции
|
||||
//_setJets.Get(i)?.SetObject(ccol * _placeSizeWidth, crow * _placeSizeHeight, _pictureWidth, _pictureHeight);
|
||||
_setJets.Get(i)?.SetObject(rows - i % cols * _placeSizeWidth, i / cols * _placeSizeHeight + 3, _pictureWidth, _pictureHeight);
|
||||
_setJets.Get(i)?.DrawningObject(g);
|
||||
// (сначала передвигаемся влево)
|
||||
ccol++;
|
||||
if (ccol >= cols)
|
||||
{
|
||||
//(потом двигаемся вниз)
|
||||
crow++;
|
||||
ccol = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -11,7 +11,7 @@ namespace AirBomber
|
||||
// To customize application configuration such as set high DPI settings or default font,
|
||||
// see https://aka.ms/applicationconfiguration.
|
||||
ApplicationConfiguration.Initialize();
|
||||
Application.Run(new FormMap());
|
||||
Application.Run(new FormMapWithSetJets());
|
||||
}
|
||||
}
|
||||
}
|
87
AirBomber/AirBomber/SetJetGeneric.cs
Normal file
87
AirBomber/AirBomber/SetJetGeneric.cs
Normal file
@ -0,0 +1,87 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AirBomber
|
||||
{
|
||||
internal class SetJetGeneric<T> where T : class
|
||||
{
|
||||
/// <summary>
|
||||
/// Массив объектов, которые храним (самолетов)
|
||||
/// </summary>
|
||||
private readonly T[] _places;
|
||||
|
||||
/// <summary>
|
||||
/// Количество объектов в массиве
|
||||
/// </summary>
|
||||
public int Count => _places.Length;
|
||||
private int JetPlaces = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
/// <param name="count">Количество самолетов</param>
|
||||
public SetJetGeneric(int count)
|
||||
{
|
||||
_places = new T[count];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Добавление самолета в набор на конкретную позицию
|
||||
/// </summary>
|
||||
/// <param name="jet">Добавляемый самолет</param>
|
||||
/// <param name="position">Позиция</param>
|
||||
/// <returns></returns>
|
||||
public int Insert(T jet)
|
||||
{
|
||||
return Insert(jet, 0);
|
||||
}
|
||||
public int Insert(T jet, int position = 0)
|
||||
{
|
||||
if (position < 0 || position >= _places.Length || JetPlaces == _places.Length)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
JetPlaces++;
|
||||
while (_places[position] != null)
|
||||
{
|
||||
for (int i = _places.Length - 1; i > 0; --i)
|
||||
{
|
||||
if (_places[i] == null && _places[i - 1] != null)
|
||||
{
|
||||
_places[i] = _places[i - 1];
|
||||
_places[i - 1] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
_places[position] = jet;
|
||||
return position;
|
||||
}
|
||||
/// <summary>
|
||||
/// Удаление объекта из набора с конкретной позиции
|
||||
/// </summary>
|
||||
/// <param name="position"></param>
|
||||
/// <returns></returns>
|
||||
public T Remove(int position)
|
||||
{
|
||||
if (position < 0 || position >= _places.Length) return null;
|
||||
T savedJet = _places[position];
|
||||
_places[position] = null;
|
||||
return savedJet;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Получение объекта из набора по позиции
|
||||
/// </summary>
|
||||
/// <param name="position">Позиция получаемого самолета</param>
|
||||
/// <returns></returns>
|
||||
public T Get(int position)
|
||||
{
|
||||
// проверка позиции
|
||||
if (position < 0 || position >= _places.Length) return null;
|
||||
return _places[position];
|
||||
}
|
||||
}
|
||||
}
|
25
AirBomber/AirBomber/WarJet.Designer.cs
generated
25
AirBomber/AirBomber/WarJet.Designer.cs
generated
@ -39,6 +39,7 @@
|
||||
this.buttonRight = new System.Windows.Forms.Button();
|
||||
this.buttonDown = new System.Windows.Forms.Button();
|
||||
this.buttonCreateModif = new System.Windows.Forms.Button();
|
||||
this.ButtonSelectJet = new System.Windows.Forms.Button();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxJet)).BeginInit();
|
||||
this.statusStrip1.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
@ -52,7 +53,7 @@
|
||||
this.pictureBoxJet.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
|
||||
this.pictureBoxJet.TabIndex = 0;
|
||||
this.pictureBoxJet.TabStop = false;
|
||||
this.pictureBoxJet.Click += new System.EventHandler(this.PictureBoxCar_Resize);
|
||||
this.pictureBoxJet.Click += new System.EventHandler(this.PictureBoxJet_Resize);
|
||||
//
|
||||
// statusStrip1
|
||||
//
|
||||
@ -105,7 +106,7 @@
|
||||
this.buttonUp.Size = new System.Drawing.Size(40, 40);
|
||||
this.buttonUp.TabIndex = 3;
|
||||
this.buttonUp.UseVisualStyleBackColor = true;
|
||||
this.buttonUp.Click += new System.EventHandler(this.buttonMove_Click);
|
||||
this.buttonUp.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||
//
|
||||
// buttonLeft
|
||||
//
|
||||
@ -117,7 +118,7 @@
|
||||
this.buttonLeft.Size = new System.Drawing.Size(40, 40);
|
||||
this.buttonLeft.TabIndex = 4;
|
||||
this.buttonLeft.UseVisualStyleBackColor = true;
|
||||
this.buttonLeft.Click += new System.EventHandler(this.buttonMove_Click);
|
||||
this.buttonLeft.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||
//
|
||||
// buttonRight
|
||||
//
|
||||
@ -129,7 +130,7 @@
|
||||
this.buttonRight.Size = new System.Drawing.Size(40, 40);
|
||||
this.buttonRight.TabIndex = 5;
|
||||
this.buttonRight.UseVisualStyleBackColor = true;
|
||||
this.buttonRight.Click += new System.EventHandler(this.buttonMove_Click);
|
||||
this.buttonRight.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||
//
|
||||
// buttonDown
|
||||
//
|
||||
@ -141,7 +142,7 @@
|
||||
this.buttonDown.Size = new System.Drawing.Size(40, 40);
|
||||
this.buttonDown.TabIndex = 6;
|
||||
this.buttonDown.UseVisualStyleBackColor = true;
|
||||
this.buttonDown.Click += new System.EventHandler(this.buttonMove_Click);
|
||||
this.buttonDown.Click += new System.EventHandler(this.ButtonMove_Click);
|
||||
//
|
||||
// buttonCreateModif
|
||||
//
|
||||
@ -151,13 +152,24 @@
|
||||
this.buttonCreateModif.TabIndex = 7;
|
||||
this.buttonCreateModif.Text = "Модификация";
|
||||
this.buttonCreateModif.UseVisualStyleBackColor = true;
|
||||
this.buttonCreateModif.Click += new System.EventHandler(this.buttonCreateModif_Click);
|
||||
this.buttonCreateModif.Click += new System.EventHandler(this.ButtonCreateModif_Click);
|
||||
//
|
||||
// ButtonSelectJet
|
||||
//
|
||||
this.ButtonSelectJet.Location = new System.Drawing.Point(554, 394);
|
||||
this.ButtonSelectJet.Name = "ButtonSelectJet";
|
||||
this.ButtonSelectJet.Size = new System.Drawing.Size(75, 23);
|
||||
this.ButtonSelectJet.TabIndex = 8;
|
||||
this.ButtonSelectJet.Text = "Выбрать";
|
||||
this.ButtonSelectJet.UseVisualStyleBackColor = true;
|
||||
this.ButtonSelectJet.Click += new System.EventHandler(this.ButtonSelectJet_Click);
|
||||
//
|
||||
// WarJet
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||
this.Controls.Add(this.ButtonSelectJet);
|
||||
this.Controls.Add(this.buttonCreateModif);
|
||||
this.Controls.Add(this.buttonDown);
|
||||
this.Controls.Add(this.buttonRight);
|
||||
@ -189,5 +201,6 @@
|
||||
private Button buttonRight;
|
||||
private Button buttonDown;
|
||||
private Button buttonCreateModif;
|
||||
private Button ButtonSelectJet;
|
||||
}
|
||||
}
|
@ -3,6 +3,7 @@ namespace AirBomber
|
||||
public partial class WarJet : Form
|
||||
{
|
||||
private DrawningJet _jet;
|
||||
public DrawningJet SelectedJet { get; private set; }
|
||||
public WarJet()
|
||||
{
|
||||
InitializeComponent();
|
||||
@ -28,7 +29,26 @@ namespace AirBomber
|
||||
toolStripStatusLabelWeight.Text = $"Âåñ: {_jet.Jet.Weight}";
|
||||
toolStripStatusLabelBodyColor.Text = $"Öâåò: {_jet.Jet.BodyColor.Name}";
|
||||
}
|
||||
private void buttonMove_Click(object sender, EventArgs e)
|
||||
/// <summary>
|
||||
/// Îáđŕáîňęŕ íŕćŕňč˙ ęíîďęč "Ńîçäŕňü"
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void buttonCreate_Click(object sender, EventArgs e)
|
||||
{
|
||||
Random rnd = new Random();
|
||||
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;
|
||||
}
|
||||
_jet = new DrawningJet(rnd.Next(100, 300), rnd.Next(1000, 2000), color);
|
||||
//_jet.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100), pictureBoxJet.Width, pictureBoxJet.Height);
|
||||
SetData();
|
||||
Draw();
|
||||
}
|
||||
private void ButtonMove_Click(object sender, EventArgs e)
|
||||
{
|
||||
//ïîëó÷àåì èìÿ êíîïêè
|
||||
string name = ((Button)sender)?.Name ?? string.Empty;
|
||||
@ -54,34 +74,48 @@ namespace AirBomber
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void PictureBoxCar_Resize(object sender, EventArgs e)
|
||||
private void PictureBoxJet_Resize(object sender, EventArgs e)
|
||||
{
|
||||
_jet?.ChangeBorders(pictureBoxJet.Width, pictureBoxJet.Height);
|
||||
Draw();
|
||||
}
|
||||
/// <summary>
|
||||
/// Îáðàáîòêà íàæàòèÿ êíîïêè "Ñîçäàòü"
|
||||
/// Îáđŕáîňęŕ íŕćŕňč˙ ęíîďęč "Ěîäčôčęŕöč˙"
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void buttonCreate_Click(object sender, EventArgs e)
|
||||
private void ButtonCreateModif_Click(object sender, EventArgs e)
|
||||
{
|
||||
Random rnd = new Random();
|
||||
_jet = new DrawningJet(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
|
||||
_jet.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100), pictureBoxJet.Width, pictureBoxJet.Height);
|
||||
SetData();
|
||||
Draw();
|
||||
}
|
||||
|
||||
private void buttonCreateModif_Click(object sender, EventArgs e)
|
||||
{
|
||||
Random rnd = new Random();
|
||||
var jet = new DrawningSportJet(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)),
|
||||
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;
|
||||
}
|
||||
_jet = new DrawningSportJet(rnd.Next(100, 300), rnd.Next(1000, 2000), color, dopColor,
|
||||
//var jet = new DrawningSportJet(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();
|
||||
Draw();
|
||||
}
|
||||
/// <summary>
|
||||
/// Îáđŕáîňęŕ íŕćŕňč˙ ęíîďęč "Âűáđŕňü"
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonSelectJet_Click(object sender, EventArgs e)
|
||||
{
|
||||
SelectedJet = _jet;
|
||||
DialogResult = DialogResult.OK;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user