PIbd-23. Kislitsa E.D. Lab work 05 #5 #5
@ -10,6 +10,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<None Remove="DirectionType.enum" />
|
||||
<None Remove="FormAirplaneConfig.Designer.cs~RF9e39eb.TMP" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
11
AirFighter/AirplaneDelegate.cs
Normal file
11
AirFighter/AirplaneDelegate.cs
Normal file
@ -0,0 +1,11 @@
|
||||
using ProjectAirFighter.DrawningObjects;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectAirFighter
|
||||
{
|
||||
public delegate void AirplaneDelegate(DrawningAirplane airplane);
|
||||
|
||||
}
|
@ -84,7 +84,7 @@ pos)
|
||||
if (airplane != null)
|
||||
{
|
||||
int inRow = _pictureWidth / _placeSizeWidth;
|
||||
airplane.SetPosition(_pictureWidth - _placeSizeWidth - (i % inRow * _placeSizeWidth) - _placeSizeWidth / 8 * 3, _pictureHeight - _pictureHeight % _placeSizeHeight - (i / inRow + 1) * _placeSizeHeight + (_placeSizeHeight - _placeSizeHeight * 170 / 1000) / 2);
|
||||
airplane.SetPosition(_pictureWidth - _placeSizeWidth - (i % inRow * _placeSizeWidth) - _placeSizeWidth / 24, _pictureHeight - _pictureHeight % _placeSizeHeight - (i / inRow + 1) * _placeSizeHeight + (_placeSizeHeight - _placeSizeHeight * 170 / 1000) / 2);
|
||||
airplane.DrawTransport(g);
|
||||
|
||||
|
||||
|
@ -1,4 +1,10 @@
|
||||
using ProjectAirFighter.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectAirFighter.DrawningObjects
|
||||
{
|
||||
@ -13,7 +19,11 @@ namespace ProjectAirFighter.DrawningObjects
|
||||
EntityAirplane = new EntityAirFighter(speed, weight, bodyColor, additionalColor, racket, wing);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void ChangeAddColor(Color col)
|
||||
{
|
||||
((EntityAirFighter)EntityAirplane).AdditionalColor = col;
|
||||
}
|
||||
public override void DrawTransport(Graphics g)
|
||||
{
|
||||
if (EntityAirplane is not EntityAirFighter airFighter)
|
||||
|
@ -50,7 +50,18 @@ width, int height, int airplaneWidth, int airplaneHeight)
|
||||
|
||||
EntityAirplane = new EntityAirplane(speed, weight, bodyColor);
|
||||
}
|
||||
public void ChangeColor(Color col)
|
||||
{
|
||||
if (EntityAirplane == null)
|
||||
return;
|
||||
EntityAirplane.BodyColor= col;
|
||||
}
|
||||
|
||||
public void ChangePictureBoxSize(int pictureBoxWidth, int pictureBoxHeight)
|
||||
{
|
||||
_pictureHeight = pictureBoxHeight;
|
||||
_pictureWidth = pictureBoxWidth;
|
||||
}
|
||||
public void SetPosition(int x, int y)
|
||||
{
|
||||
if (EntityAirplane == null)
|
||||
|
@ -9,7 +9,7 @@ namespace ProjectAirFighter.Entities
|
||||
{
|
||||
public class EntityAirFighter: EntityAirplane
|
||||
{
|
||||
public Color AdditionalColor { get; private set; }
|
||||
public Color AdditionalColor { get; set; }
|
||||
eegov
commented
В классах-сущностях требовалось прописать методы для смены основного и дополнительного цветов В классах-сущностях требовалось прописать методы для смены основного и дополнительного цветов
|
||||
public bool Racket { get; private set; }
|
||||
public bool Wing { get; private set; }
|
||||
|
||||
|
@ -10,7 +10,7 @@ namespace ProjectAirFighter.Entities
|
||||
{
|
||||
public int Speed { get; private set; }
|
||||
public double Weight { get; private set; }
|
||||
public Color BodyColor { get; private set; }
|
||||
public Color BodyColor { get; set; }
|
||||
eegov
commented
В классах-сущностях требовалось прописать методы для смены основного и дополнительного цветов В классах-сущностях требовалось прописать методы для смены основного и дополнительного цветов
|
||||
public double Step => (double)Speed * 100 / Weight;
|
||||
|
||||
public EntityAirplane(int speed, double weight, Color bodyColor)
|
||||
|
39
AirFighter/FormAirplaneCollection.Designer.cs
generated
39
AirFighter/FormAirplaneCollection.Designer.cs
generated
@ -51,16 +51,16 @@
|
||||
this.toolGroupBox.Controls.Add(this.updateCollectionButton);
|
||||
this.toolGroupBox.Controls.Add(this.deleteAirplaneButton);
|
||||
this.toolGroupBox.Controls.Add(this.addAirplaneButton);
|
||||
this.toolGroupBox.Location = new System.Drawing.Point(744, 12);
|
||||
this.toolGroupBox.Location = new System.Drawing.Point(769, 12);
|
||||
this.toolGroupBox.Name = "toolGroupBox";
|
||||
this.toolGroupBox.Size = new System.Drawing.Size(223, 530);
|
||||
this.toolGroupBox.Size = new System.Drawing.Size(232, 632);
|
||||
this.toolGroupBox.TabIndex = 0;
|
||||
this.toolGroupBox.TabStop = false;
|
||||
this.toolGroupBox.Text = "Инструменты";
|
||||
//
|
||||
// maskedTextBoxNumber
|
||||
//
|
||||
this.maskedTextBoxNumber.Location = new System.Drawing.Point(-2, 367);
|
||||
this.maskedTextBoxNumber.Location = new System.Drawing.Point(7, 387);
|
||||
this.maskedTextBoxNumber.Name = "maskedTextBoxNumber";
|
||||
this.maskedTextBoxNumber.Size = new System.Drawing.Size(215, 27);
|
||||
this.maskedTextBoxNumber.TabIndex = 7;
|
||||
@ -71,7 +71,7 @@
|
||||
this.kitGroupbox.Controls.Add(this.ButtonDelObject);
|
||||
this.kitGroupbox.Controls.Add(this.ButtonAddObject);
|
||||
this.kitGroupbox.Controls.Add(this.listBoxStorages);
|
||||
this.kitGroupbox.Location = new System.Drawing.Point(6, 26);
|
||||
this.kitGroupbox.Location = new System.Drawing.Point(8, 39);
|
||||
this.kitGroupbox.Name = "kitGroupbox";
|
||||
this.kitGroupbox.Size = new System.Drawing.Size(217, 280);
|
||||
this.kitGroupbox.TabIndex = 5;
|
||||
@ -80,9 +80,9 @@
|
||||
//
|
||||
// textBoxStorageName
|
||||
//
|
||||
this.textBoxStorageName.Location = new System.Drawing.Point(23, 26);
|
||||
this.textBoxStorageName.Location = new System.Drawing.Point(23, 27);
|
||||
this.textBoxStorageName.Name = "textBoxStorageName";
|
||||
this.textBoxStorageName.Size = new System.Drawing.Size(184, 27);
|
||||
this.textBoxStorageName.Size = new System.Drawing.Size(185, 27);
|
||||
this.textBoxStorageName.TabIndex = 9;
|
||||
//
|
||||
// ButtonDelObject
|
||||
@ -97,7 +97,7 @@
|
||||
//
|
||||
// ButtonAddObject
|
||||
//
|
||||
this.ButtonAddObject.Location = new System.Drawing.Point(23, 59);
|
||||
this.ButtonAddObject.Location = new System.Drawing.Point(23, 63);
|
||||
this.ButtonAddObject.Name = "ButtonAddObject";
|
||||
this.ButtonAddObject.Size = new System.Drawing.Size(184, 29);
|
||||
this.ButtonAddObject.TabIndex = 7;
|
||||
@ -109,15 +109,14 @@
|
||||
//
|
||||
this.listBoxStorages.FormattingEnabled = true;
|
||||
this.listBoxStorages.ItemHeight = 20;
|
||||
this.listBoxStorages.Location = new System.Drawing.Point(23, 106);
|
||||
this.listBoxStorages.Location = new System.Drawing.Point(23, 107);
|
||||
this.listBoxStorages.Name = "listBoxStorages";
|
||||
this.listBoxStorages.Size = new System.Drawing.Size(184, 104);
|
||||
this.listBoxStorages.Size = new System.Drawing.Size(185, 104);
|
||||
this.listBoxStorages.TabIndex = 6;
|
||||
this.listBoxStorages.Click += new System.EventHandler(this.listBoxStorages_SelectedIndexChanged);
|
||||
//
|
||||
// updateCollectionButton
|
||||
//
|
||||
this.updateCollectionButton.Location = new System.Drawing.Point(-2, 471);
|
||||
this.updateCollectionButton.Location = new System.Drawing.Point(6, 484);
|
||||
this.updateCollectionButton.Name = "updateCollectionButton";
|
||||
this.updateCollectionButton.Size = new System.Drawing.Size(215, 40);
|
||||
this.updateCollectionButton.TabIndex = 3;
|
||||
@ -127,7 +126,7 @@
|
||||
//
|
||||
// deleteAirplaneButton
|
||||
//
|
||||
this.deleteAirplaneButton.Location = new System.Drawing.Point(-2, 409);
|
||||
this.deleteAirplaneButton.Location = new System.Drawing.Point(7, 439);
|
||||
this.deleteAirplaneButton.Name = "deleteAirplaneButton";
|
||||
this.deleteAirplaneButton.Size = new System.Drawing.Size(215, 40);
|
||||
this.deleteAirplaneButton.TabIndex = 2;
|
||||
@ -137,7 +136,7 @@
|
||||
//
|
||||
// addAirplaneButton
|
||||
//
|
||||
this.addAirplaneButton.Location = new System.Drawing.Point(0, 312);
|
||||
this.addAirplaneButton.Location = new System.Drawing.Point(8, 324);
|
||||
this.addAirplaneButton.Name = "addAirplaneButton";
|
||||
this.addAirplaneButton.Size = new System.Drawing.Size(215, 40);
|
||||
this.addAirplaneButton.TabIndex = 0;
|
||||
@ -149,7 +148,7 @@
|
||||
//
|
||||
this.pictureBoxCollection.Location = new System.Drawing.Point(12, 12);
|
||||
this.pictureBoxCollection.Name = "pictureBoxCollection";
|
||||
this.pictureBoxCollection.Size = new System.Drawing.Size(726, 524);
|
||||
this.pictureBoxCollection.Size = new System.Drawing.Size(675, 632);
|
||||
this.pictureBoxCollection.TabIndex = 1;
|
||||
this.pictureBoxCollection.TabStop = false;
|
||||
//
|
||||
@ -157,7 +156,7 @@
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(980, 548);
|
||||
this.ClientSize = new System.Drawing.Size(1017, 654);
|
||||
this.Controls.Add(this.pictureBoxCollection);
|
||||
this.Controls.Add(this.toolGroupBox);
|
||||
this.Name = "FormAirplaneCollection";
|
||||
@ -173,11 +172,11 @@
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.GroupBox toolGroupBox;
|
||||
private System.Windows.Forms.Button updateCollectionButton;
|
||||
private System.Windows.Forms.Button deleteAirplaneButton;
|
||||
private System.Windows.Forms.Button addAirplaneButton;
|
||||
private System.Windows.Forms.PictureBox pictureBoxCollection;
|
||||
private GroupBox toolGroupBox;
|
||||
private Button updateCollectionButton;
|
||||
private Button deleteAirplaneButton;
|
||||
private Button addAirplaneButton;
|
||||
private PictureBox pictureBoxCollection;
|
||||
private GroupBox kitGroupbox;
|
||||
private Button ButtonAddObject;
|
||||
private ListBox listBoxStorages;
|
||||
|
@ -42,6 +42,17 @@ namespace ProjectAirFighter
|
||||
{
|
||||
listBoxStorages.SelectedIndex = index;
|
||||
}
|
||||
if (listBoxStorages.SelectedIndex == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var obj = _storage[listBoxStorages.SelectedItem.ToString() ??
|
||||
string.Empty];
|
||||
if (obj == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
pictureBoxCollection.Image = obj.ShowAirplanes();
|
||||
|
||||
}
|
||||
private void ButtonAddObject_Click(object sender, EventArgs e)
|
||||
@ -113,10 +124,12 @@ namespace ProjectAirFighter
|
||||
{
|
||||
return;
|
||||
}
|
||||
FormAirFighter form = new();
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
FormAirplaneConfig form = new();
|
||||
form.Show();
|
||||
Action<DrawningAirplane>? airplaneDelegate = new((m) =>
|
||||
{
|
||||
if (obj + form.SelectedAirplane)
|
||||
bool q = (obj + m);
|
||||
if (q)
|
||||
{
|
||||
MessageBox.Show("Объект добавлен");
|
||||
pictureBoxCollection.Image = obj.ShowAirplanes();
|
||||
@ -125,8 +138,8 @@ namespace ProjectAirFighter
|
||||
{
|
||||
MessageBox.Show("Не удалось добавить объект");
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
form.AddEvent(airplaneDelegate);
|
||||
}
|
||||
private void listBoxStorages_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
|
391
AirFighter/FormAirplaneConfig.Designer.cs
generated
Normal file
391
AirFighter/FormAirplaneConfig.Designer.cs
generated
Normal file
@ -0,0 +1,391 @@
|
||||
namespace ProjectAirFighter
|
||||
{
|
||||
partial class FormAirplaneConfig
|
||||
{
|
||||
/// <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.configGroupBox = new System.Windows.Forms.GroupBox();
|
||||
this.colorGroupBox = new System.Windows.Forms.GroupBox();
|
||||
this.yellowPanel = new System.Windows.Forms.Panel();
|
||||
this.bluePanel = new System.Windows.Forms.Panel();
|
||||
this.greenPanel = new System.Windows.Forms.Panel();
|
||||
this.purplePanel = new System.Windows.Forms.Panel();
|
||||
this.blackPanel = new System.Windows.Forms.Panel();
|
||||
this.greyPanel = new System.Windows.Forms.Panel();
|
||||
this.whitePanel = new System.Windows.Forms.Panel();
|
||||
this.redPanel = new System.Windows.Forms.Panel();
|
||||
this.airfighterLabel = new System.Windows.Forms.Label();
|
||||
this.airplaneLabel = new System.Windows.Forms.Label();
|
||||
this.checkwing = new System.Windows.Forms.CheckBox();
|
||||
this.checkracket = new System.Windows.Forms.CheckBox();
|
||||
this.numericWeight = new System.Windows.Forms.NumericUpDown();
|
||||
this.numericSpeed = new System.Windows.Forms.NumericUpDown();
|
||||
this.weightLabel = new System.Windows.Forms.Label();
|
||||
this.speedLabel = new System.Windows.Forms.Label();
|
||||
this.allowPanel = new System.Windows.Forms.Panel();
|
||||
this.addColorLabel = new System.Windows.Forms.Label();
|
||||
this.pictureBox = new System.Windows.Forms.PictureBox();
|
||||
this.colorLabel = new System.Windows.Forms.Label();
|
||||
this.addButton = new System.Windows.Forms.Button();
|
||||
this.cancelButton = new System.Windows.Forms.Button();
|
||||
this.configGroupBox.SuspendLayout();
|
||||
this.colorGroupBox.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericWeight)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericSpeed)).BeginInit();
|
||||
this.allowPanel.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// configGroupBox
|
||||
//
|
||||
this.configGroupBox.Controls.Add(this.colorGroupBox);
|
||||
this.configGroupBox.Controls.Add(this.airfighterLabel);
|
||||
this.configGroupBox.Controls.Add(this.airplaneLabel);
|
||||
this.configGroupBox.Controls.Add(this.checkwing);
|
||||
this.configGroupBox.Controls.Add(this.checkracket);
|
||||
this.configGroupBox.Controls.Add(this.numericWeight);
|
||||
this.configGroupBox.Controls.Add(this.numericSpeed);
|
||||
this.configGroupBox.Controls.Add(this.weightLabel);
|
||||
this.configGroupBox.Controls.Add(this.speedLabel);
|
||||
this.configGroupBox.Location = new System.Drawing.Point(11, 12);
|
||||
this.configGroupBox.Name = "configGroupBox";
|
||||
this.configGroupBox.Size = new System.Drawing.Size(446, 279);
|
||||
this.configGroupBox.TabIndex = 0;
|
||||
this.configGroupBox.TabStop = false;
|
||||
this.configGroupBox.Text = "Параметры";
|
||||
//
|
||||
// colorGroupBox
|
||||
//
|
||||
this.colorGroupBox.Controls.Add(this.yellowPanel);
|
||||
this.colorGroupBox.Controls.Add(this.bluePanel);
|
||||
this.colorGroupBox.Controls.Add(this.greenPanel);
|
||||
this.colorGroupBox.Controls.Add(this.purplePanel);
|
||||
this.colorGroupBox.Controls.Add(this.blackPanel);
|
||||
this.colorGroupBox.Controls.Add(this.greyPanel);
|
||||
this.colorGroupBox.Controls.Add(this.whitePanel);
|
||||
this.colorGroupBox.Controls.Add(this.redPanel);
|
||||
this.colorGroupBox.Location = new System.Drawing.Point(171, 23);
|
||||
this.colorGroupBox.Name = "colorGroupBox";
|
||||
this.colorGroupBox.Size = new System.Drawing.Size(234, 143);
|
||||
this.colorGroupBox.TabIndex = 7;
|
||||
this.colorGroupBox.TabStop = false;
|
||||
this.colorGroupBox.Text = "Цвета";
|
||||
//
|
||||
// yellowPanel
|
||||
//
|
||||
this.yellowPanel.AllowDrop = true;
|
||||
this.yellowPanel.BackColor = System.Drawing.Color.Yellow;
|
||||
this.yellowPanel.Location = new System.Drawing.Point(174, 27);
|
||||
this.yellowPanel.Name = "yellowPanel";
|
||||
this.yellowPanel.Size = new System.Drawing.Size(50, 51);
|
||||
this.yellowPanel.TabIndex = 3;
|
||||
//
|
||||
// bluePanel
|
||||
//
|
||||
this.bluePanel.AllowDrop = true;
|
||||
this.bluePanel.BackColor = System.Drawing.Color.Blue;
|
||||
this.bluePanel.Location = new System.Drawing.Point(118, 27);
|
||||
this.bluePanel.Name = "bluePanel";
|
||||
this.bluePanel.Size = new System.Drawing.Size(50, 51);
|
||||
this.bluePanel.TabIndex = 2;
|
||||
//
|
||||
// greenPanel
|
||||
//
|
||||
this.greenPanel.AllowDrop = true;
|
||||
this.greenPanel.BackColor = System.Drawing.Color.Green;
|
||||
this.greenPanel.Location = new System.Drawing.Point(62, 27);
|
||||
this.greenPanel.Name = "greenPanel";
|
||||
this.greenPanel.Size = new System.Drawing.Size(50, 51);
|
||||
this.greenPanel.TabIndex = 1;
|
||||
//
|
||||
// purplePanel
|
||||
//
|
||||
this.purplePanel.AllowDrop = true;
|
||||
this.purplePanel.BackColor = System.Drawing.Color.Purple;
|
||||
this.purplePanel.Location = new System.Drawing.Point(174, 83);
|
||||
this.purplePanel.Name = "purplePanel";
|
||||
this.purplePanel.Size = new System.Drawing.Size(50, 51);
|
||||
this.purplePanel.TabIndex = 3;
|
||||
//
|
||||
// blackPanel
|
||||
//
|
||||
this.blackPanel.AllowDrop = true;
|
||||
this.blackPanel.BackColor = System.Drawing.Color.Black;
|
||||
this.blackPanel.Location = new System.Drawing.Point(118, 83);
|
||||
this.blackPanel.Name = "blackPanel";
|
||||
this.blackPanel.Size = new System.Drawing.Size(50, 51);
|
||||
this.blackPanel.TabIndex = 2;
|
||||
//
|
||||
// greyPanel
|
||||
//
|
||||
this.greyPanel.AllowDrop = true;
|
||||
this.greyPanel.BackColor = System.Drawing.Color.Silver;
|
||||
this.greyPanel.Location = new System.Drawing.Point(62, 83);
|
||||
this.greyPanel.Name = "greyPanel";
|
||||
this.greyPanel.Size = new System.Drawing.Size(50, 51);
|
||||
this.greyPanel.TabIndex = 1;
|
||||
//
|
||||
// whitePanel
|
||||
//
|
||||
this.whitePanel.AllowDrop = true;
|
||||
this.whitePanel.BackColor = System.Drawing.Color.White;
|
||||
this.whitePanel.Location = new System.Drawing.Point(6, 83);
|
||||
this.whitePanel.Name = "whitePanel";
|
||||
this.whitePanel.Size = new System.Drawing.Size(50, 51);
|
||||
this.whitePanel.TabIndex = 1;
|
||||
//
|
||||
// redPanel
|
||||
//
|
||||
this.redPanel.AllowDrop = true;
|
||||
this.redPanel.BackColor = System.Drawing.Color.Red;
|
||||
this.redPanel.Location = new System.Drawing.Point(6, 27);
|
||||
this.redPanel.Name = "redPanel";
|
||||
this.redPanel.Size = new System.Drawing.Size(50, 51);
|
||||
this.redPanel.TabIndex = 0;
|
||||
//
|
||||
// airfighterLabel
|
||||
//
|
||||
this.airfighterLabel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
this.airfighterLabel.Location = new System.Drawing.Point(297, 169);
|
||||
this.airfighterLabel.Name = "airfighterLabel";
|
||||
this.airfighterLabel.Size = new System.Drawing.Size(120, 50);
|
||||
this.airfighterLabel.TabIndex = 9;
|
||||
this.airfighterLabel.Text = "Продвинутый";
|
||||
this.airfighterLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
//
|
||||
// airplaneLabel
|
||||
//
|
||||
this.airplaneLabel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
this.airplaneLabel.Location = new System.Drawing.Point(171, 169);
|
||||
this.airplaneLabel.Name = "airplaneLabel";
|
||||
this.airplaneLabel.Size = new System.Drawing.Size(120, 50);
|
||||
this.airplaneLabel.TabIndex = 8;
|
||||
this.airplaneLabel.Text = "Простой";
|
||||
this.airplaneLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
//
|
||||
// checkwing
|
||||
//
|
||||
this.checkwing.AutoSize = true;
|
||||
this.checkwing.Location = new System.Drawing.Point(6, 163);
|
||||
this.checkwing.Name = "checkwing";
|
||||
this.checkwing.Size = new System.Drawing.Size(183, 24);
|
||||
this.checkwing.TabIndex = 5;
|
||||
this.checkwing.Text = "наличие доп крыльев";
|
||||
this.checkwing.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// checkracket
|
||||
//
|
||||
this.checkracket.AutoSize = true;
|
||||
this.checkracket.Location = new System.Drawing.Point(6, 132);
|
||||
this.checkracket.Name = "checkracket";
|
||||
this.checkracket.Size = new System.Drawing.Size(132, 24);
|
||||
this.checkracket.TabIndex = 4;
|
||||
this.checkracket.Text = "наличие ракет";
|
||||
this.checkracket.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// numericWeight
|
||||
//
|
||||
this.numericWeight.Location = new System.Drawing.Point(6, 99);
|
||||
this.numericWeight.Maximum = new decimal(new int[] {
|
||||
1000,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.numericWeight.Minimum = new decimal(new int[] {
|
||||
100,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.numericWeight.Name = "numericWeight";
|
||||
this.numericWeight.Size = new System.Drawing.Size(150, 27);
|
||||
this.numericWeight.TabIndex = 3;
|
||||
this.numericWeight.Value = new decimal(new int[] {
|
||||
100,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
//
|
||||
// numericSpeed
|
||||
//
|
||||
this.numericSpeed.Location = new System.Drawing.Point(6, 45);
|
||||
this.numericSpeed.Maximum = new decimal(new int[] {
|
||||
1000,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.numericSpeed.Minimum = new decimal(new int[] {
|
||||
100,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.numericSpeed.Name = "numericSpeed";
|
||||
this.numericSpeed.Size = new System.Drawing.Size(150, 27);
|
||||
this.numericSpeed.TabIndex = 2;
|
||||
this.numericSpeed.Value = new decimal(new int[] {
|
||||
100,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
//
|
||||
// weightLabel
|
||||
//
|
||||
this.weightLabel.AutoSize = true;
|
||||
this.weightLabel.Location = new System.Drawing.Point(6, 76);
|
||||
this.weightLabel.Name = "weightLabel";
|
||||
this.weightLabel.Size = new System.Drawing.Size(33, 20);
|
||||
this.weightLabel.TabIndex = 1;
|
||||
this.weightLabel.Text = "Вес";
|
||||
//
|
||||
// speedLabel
|
||||
//
|
||||
this.speedLabel.AutoSize = true;
|
||||
this.speedLabel.Location = new System.Drawing.Point(6, 23);
|
||||
this.speedLabel.Name = "speedLabel";
|
||||
this.speedLabel.Size = new System.Drawing.Size(73, 20);
|
||||
this.speedLabel.TabIndex = 0;
|
||||
this.speedLabel.Text = "Скорость";
|
||||
//
|
||||
// allowPanel
|
||||
//
|
||||
this.allowPanel.AllowDrop = true;
|
||||
this.allowPanel.Controls.Add(this.addColorLabel);
|
||||
this.allowPanel.Controls.Add(this.pictureBox);
|
||||
this.allowPanel.Controls.Add(this.colorLabel);
|
||||
this.allowPanel.Location = new System.Drawing.Point(463, 12);
|
||||
this.allowPanel.Name = "allowPanel";
|
||||
this.allowPanel.Size = new System.Drawing.Size(819, 642);
|
||||
this.allowPanel.TabIndex = 1;
|
||||
this.allowPanel.DragDrop += new System.Windows.Forms.DragEventHandler(this.allowPanel_DragDrop);
|
||||
this.allowPanel.DragEnter += new System.Windows.Forms.DragEventHandler(this.allowPanel_DragEnter);
|
||||
//
|
||||
// addColorLabel
|
||||
//
|
||||
this.addColorLabel.AllowDrop = true;
|
||||
this.addColorLabel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
this.addColorLabel.Location = new System.Drawing.Point(470, 17);
|
||||
this.addColorLabel.Name = "addColorLabel";
|
||||
this.addColorLabel.Size = new System.Drawing.Size(104, 33);
|
||||
this.addColorLabel.TabIndex = 2;
|
||||
this.addColorLabel.Text = "Доп. цвет";
|
||||
this.addColorLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
this.addColorLabel.DragDrop += new System.Windows.Forms.DragEventHandler(this.addColorLabel_DragDrop);
|
||||
this.addColorLabel.DragEnter += new System.Windows.Forms.DragEventHandler(this.colorLabel_DragEnter);
|
||||
//
|
||||
// pictureBox
|
||||
//
|
||||
this.pictureBox.Location = new System.Drawing.Point(17, 51);
|
||||
this.pictureBox.Name = "pictureBox";
|
||||
this.pictureBox.Size = new System.Drawing.Size(787, 575);
|
||||
this.pictureBox.TabIndex = 0;
|
||||
this.pictureBox.TabStop = false;
|
||||
//
|
||||
// colorLabel
|
||||
//
|
||||
this.colorLabel.AllowDrop = true;
|
||||
this.colorLabel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
this.colorLabel.Location = new System.Drawing.Point(172, 10);
|
||||
this.colorLabel.Name = "colorLabel";
|
||||
this.colorLabel.Size = new System.Drawing.Size(104, 33);
|
||||
this.colorLabel.TabIndex = 1;
|
||||
this.colorLabel.Text = "Цвет";
|
||||
this.colorLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
this.colorLabel.DragDrop += new System.Windows.Forms.DragEventHandler(this.colorLabel_DragDrop);
|
||||
this.colorLabel.DragEnter += new System.Windows.Forms.DragEventHandler(this.colorLabel_DragEnter);
|
||||
//
|
||||
// addButton
|
||||
//
|
||||
this.addButton.Location = new System.Drawing.Point(710, 660);
|
||||
this.addButton.Name = "addButton";
|
||||
this.addButton.Size = new System.Drawing.Size(94, 29);
|
||||
this.addButton.TabIndex = 2;
|
||||
this.addButton.Text = "Добавить";
|
||||
this.addButton.UseVisualStyleBackColor = true;
|
||||
this.addButton.Click += new System.EventHandler(this.addButton_Click);
|
||||
//
|
||||
// cancelButton
|
||||
//
|
||||
this.cancelButton.Location = new System.Drawing.Point(1042, 660);
|
||||
this.cancelButton.Name = "cancelButton";
|
||||
this.cancelButton.Size = new System.Drawing.Size(94, 29);
|
||||
this.cancelButton.TabIndex = 3;
|
||||
this.cancelButton.Text = "Отменить";
|
||||
this.cancelButton.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// FormAirplaneConfig
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(1294, 701);
|
||||
this.Controls.Add(this.cancelButton);
|
||||
this.Controls.Add(this.addButton);
|
||||
this.Controls.Add(this.allowPanel);
|
||||
this.Controls.Add(this.configGroupBox);
|
||||
this.Name = "FormAirplaneConfig";
|
||||
this.Text = "FormMonorailConfig";
|
||||
this.configGroupBox.ResumeLayout(false);
|
||||
this.configGroupBox.PerformLayout();
|
||||
this.colorGroupBox.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericWeight)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericSpeed)).EndInit();
|
||||
this.allowPanel.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private GroupBox configGroupBox;
|
||||
private CheckBox checkracket;
|
||||
private NumericUpDown numericWeight;
|
||||
private NumericUpDown numericSpeed;
|
||||
private Label weightLabel;
|
||||
private Label speedLabel;
|
||||
private CheckBox checkwing;
|
||||
private GroupBox colorGroupBox;
|
||||
private Panel panel5;
|
||||
private Panel panel4;
|
||||
private Panel panel3;
|
||||
private Panel panel2;
|
||||
private Panel redPanel;
|
||||
private Panel purplePanel;
|
||||
private Panel blackPanel;
|
||||
private Panel greyPanel;
|
||||
private Panel whitePanel;
|
||||
private Label airfighterLabel;
|
||||
private Label airplaneLabel;
|
||||
private Panel yellowPanel;
|
||||
private Panel bluePanel;
|
||||
private Panel greenPanel;
|
||||
private Panel allowPanel;
|
||||
private PictureBox pictureBox;
|
||||
private Label addColorLabel;
|
||||
private Label colorLabel;
|
||||
private Button addButton;
|
||||
private Button cancelButton;
|
||||
}
|
||||
}
|
141
AirFighter/FormAirplaneConfig.cs
Normal file
141
AirFighter/FormAirplaneConfig.cs
Normal file
@ -0,0 +1,141 @@
|
||||
using ProjectAirFighter.DrawningObjects;
|
||||
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 ProjectAirFighter
|
||||
{
|
||||
public partial class FormAirplaneConfig : Form
|
||||
{
|
||||
DrawningAirplane? _airplane = null;
|
||||
|
||||
private event Action<DrawningAirplane>? EventAddAirplane;
|
||||
public void AddEvent(Action<DrawningAirplane> ev)
|
||||
{
|
||||
if (EventAddAirplane == null)
|
||||
{
|
||||
EventAddAirplane = ev;
|
||||
}
|
||||
else
|
||||
{
|
||||
EventAddAirplane += ev;
|
||||
}
|
||||
}
|
||||
|
||||
public FormAirplaneConfig()
|
||||
{
|
||||
InitializeComponent();
|
||||
blackPanel.MouseDown += PanelColor_MouseDown;
|
||||
greenPanel.MouseDown += PanelColor_MouseDown;
|
||||
redPanel.MouseDown += PanelColor_MouseDown;
|
||||
bluePanel.MouseDown += PanelColor_MouseDown;
|
||||
greyPanel.MouseDown += PanelColor_MouseDown;
|
||||
yellowPanel.MouseDown += PanelColor_MouseDown;
|
||||
purplePanel.MouseDown += PanelColor_MouseDown;
|
||||
whitePanel.MouseDown += PanelColor_MouseDown;
|
||||
airplaneLabel.MouseDown += LabelObject_MouseDown;
|
||||
airfighterLabel.MouseDown += LabelObject_MouseDown;
|
||||
cancelButton.Click += (s, e) => Close();
|
||||
}
|
||||
|
||||
public void DrawAirplane()
|
||||
{
|
||||
Bitmap bmp = new Bitmap(pictureBox.Width, pictureBox.Height);
|
||||
Graphics gr = Graphics.FromImage(bmp);
|
||||
_airplane?.SetPosition(5, 70);
|
||||
_airplane?.DrawTransport(gr);
|
||||
pictureBox.Image = bmp;
|
||||
}
|
||||
|
||||
private void PanelColor_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
(sender as Panel)?.DoDragDrop((sender as Panel)?.BackColor,
|
||||
DragDropEffects.Move | DragDropEffects.Copy);
|
||||
|
||||
}
|
||||
|
||||
private void allowPanel_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
switch (e.Data?.GetData(DataFormats.Text).ToString())
|
||||
{
|
||||
case "airplaneLabel":
|
||||
_airplane = new DrawningAirplane((int)numericSpeed.Value,
|
||||
(int)numericWeight.Value, Color.White, pictureBox.Width,
|
||||
pictureBox.Height);
|
||||
break;
|
||||
case "airfighterLabel":
|
||||
_airplane = new DrawningAirFighter((int)numericSpeed.Value,
|
||||
(int)numericWeight.Value, Color.White, Color.Silver, checkracket.Checked, checkwing.Checked, pictureBox.Width,
|
||||
pictureBox.Height);
|
||||
break;
|
||||
}
|
||||
colorLabel.BackColor = Color.Empty;
|
||||
addColorLabel.BackColor = Color.Empty;
|
||||
DrawAirplane();
|
||||
|
||||
}
|
||||
|
||||
private void allowPanel_DragEnter(object sender, DragEventArgs e)
|
||||
{
|
||||
if (e.Data?.GetDataPresent(DataFormats.Text) ?? false)
|
||||
{
|
||||
e.Effect = DragDropEffects.Copy;
|
||||
}
|
||||
else
|
||||
{
|
||||
e.Effect = DragDropEffects.None;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void addButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
EventAddAirplane?.Invoke(_airplane);
|
||||
Close();
|
||||
}
|
||||
|
||||
private void LabelObject_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
(sender as Label)?.DoDragDrop((sender as Label)?.Name, DragDropEffects.Move | DragDropEffects.Copy);
|
||||
}
|
||||
|
||||
|
||||
private void colorLabel_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
if (_airplane == null)
|
||||
return;
|
||||
colorLabel.BackColor = (Color)e.Data.GetData(typeof(Color));
|
||||
_airplane.ChangeColor(colorLabel.BackColor);
|
||||
DrawAirplane();
|
||||
}
|
||||
|
||||
private void colorLabel_DragEnter(object sender, DragEventArgs e)
|
||||
{
|
||||
if (e.Data.GetDataPresent(typeof(Color)))
|
||||
{
|
||||
e.Effect = DragDropEffects.Copy;
|
||||
}
|
||||
else
|
||||
{
|
||||
e.Effect = DragDropEffects.None;
|
||||
}
|
||||
}
|
||||
|
||||
private void addColorLabel_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
if ((_airplane == null) || (_airplane is DrawningAirFighter == false))
|
||||
return;
|
||||
addColorLabel.BackColor = (Color)e.Data.GetData(typeof(Color));
|
||||
((DrawningAirFighter)_airplane).ChangeAddColor(addColorLabel.BackColor);
|
||||
DrawAirplane();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
60
AirFighter/FormAirplaneConfig.resx
Normal file
60
AirFighter/FormAirplaneConfig.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>
|
Loading…
Reference in New Issue
Block a user
Не используется