This commit is contained in:
Александр Чегодаев 2023-12-14 01:25:12 +04:00
parent 8d8e031953
commit aeb998110e
16 changed files with 789 additions and 152 deletions

View File

@ -1,5 +1,6 @@
using ProjectCruiser.DrawningObjects;
using ProjectCruiser.MovementStrategy;
using ProjectCruiser.Generics;
using System;
using System.Collections.Generic;
using System.Linq;
@ -73,7 +74,7 @@ namespace ProjectCruiser
1; ++j)
{
g.DrawLine(pen, i * _placeSizeWidth, j *
_placeSizeHeight, i * _placeSizeWidth + _placeSizeWidth / 2 + 2, j *
_placeSizeHeight, i * _placeSizeWidth + _placeSizeWidth / 2, j *
_placeSizeHeight);
}
g.DrawLine(pen, i * _placeSizeWidth, 0, i *
@ -88,6 +89,8 @@ namespace ProjectCruiser
int i = 0;
foreach (var cruiser in _collection.GetCruiser())
{
cruiser._pictureHeight = _pictureHeight;
cruiser._pictureWidth = _pictureWidth;
_collection[i]?.SetPosition(Ix, Iy);
_collection[i]?.DrawTransport(g);
Ix += _placeSizeWidth;

View File

@ -15,9 +15,9 @@ namespace ProjectCruiser.DrawningObjects
{
public EntityCruiser? EntityCruiser { get; protected set; }
private int _pictureWidth;
public int _pictureWidth;
private int _pictureHeight;
public int _pictureHeight;
protected int _startPosX;

View File

@ -11,6 +11,7 @@ namespace ProjectCruiser.DrawningObjects
{
public class DrawningCruiserDou : DrawningCruiser
{
public DrawningCruiserDou(int speed, double weight, Color bodyColor, Color
additionalColor, bool vert, bool rocket, int width, int height) :
base(speed, weight, bodyColor, width, height, 145, 45)
@ -29,6 +30,7 @@ namespace ProjectCruiser.DrawningObjects
return;
}
Pen pen = new(Color.Black);
Brush additionalBrush = new SolidBrush(cruiserDou.AdditionalColor);
Brush brBlack = new SolidBrush(Color.Black);
@ -49,9 +51,7 @@ namespace ProjectCruiser.DrawningObjects
g.FillEllipse(additionalBrush, _startPosX + 8, _startPosY + 18, 15, 12);
g.DrawEllipse(pen, _startPosX + 8, _startPosY + 33, 15, 12);
g.FillEllipse(additionalBrush, _startPosX + 8, _startPosY + 33, 15, 12);
}
}
}
}
}

View File

@ -12,7 +12,7 @@ namespace ProjectCruiser.Entities
public double Weight { get; private set; }
public Color BodyColor { get; private set; }
public Color BodyColor { get; set; }
public double Step => (double)Speed * 100 / Weight;

View File

@ -4,8 +4,7 @@ namespace ProjectCruiser.Entities
{
public class EntityCruiserDou : EntityCruiser
{
public Color AdditionalColor { get; private set; }
public Color AdditionalColor { get; set; }
public bool Vert { get; private set; }

View File

@ -28,151 +28,150 @@
/// </summary>
private void InitializeComponent()
{
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.listBoxStorage = new System.Windows.Forms.ListBox();
this.textBoxStorageName = new System.Windows.Forms.MaskedTextBox();
this.ButtonAddObject = new System.Windows.Forms.Button();
this.ButtonDelObject = new System.Windows.Forms.Button();
this.maskedTextBoxNumber = new System.Windows.Forms.MaskedTextBox();
this.ButtonRefreshCollection = new System.Windows.Forms.Button();
this.ButtonRemoveCruiser = new System.Windows.Forms.Button();
this.buttonAddCruiser = new System.Windows.Forms.Button();
this.pictureBoxCollection = new System.Windows.Forms.PictureBox();
this.groupBox1.SuspendLayout();
this.groupBox2.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxCollection)).BeginInit();
this.SuspendLayout();
groupBox1 = new GroupBox();
groupBox2 = new GroupBox();
listBoxStorage = new ListBox();
textBoxStorageName = new TextBox();
ButtonAddObject = new Button();
ButtonDelObject = new Button();
maskedTextBoxNumber = new MaskedTextBox();
ButtonRefreshCollection = new Button();
ButtonRemoveCruiser = new Button();
buttonAddCruiser = new Button();
pictureBoxCollection = new PictureBox();
groupBox1.SuspendLayout();
groupBox2.SuspendLayout();
((System.ComponentModel.ISupportInitialize)pictureBoxCollection).BeginInit();
SuspendLayout();
//
// groupBox1
//
this.groupBox1.Controls.Add(this.groupBox2);
this.groupBox1.Controls.Add(this.maskedTextBoxNumber);
this.groupBox1.Controls.Add(this.ButtonRefreshCollection);
this.groupBox1.Controls.Add(this.ButtonRemoveCruiser);
this.groupBox1.Controls.Add(this.buttonAddCruiser);
this.groupBox1.Location = new System.Drawing.Point(643, 12);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(196, 436);
this.groupBox1.TabIndex = 0;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "Инструменты";
groupBox1.Controls.Add(groupBox2);
groupBox1.Controls.Add(maskedTextBoxNumber);
groupBox1.Controls.Add(ButtonRefreshCollection);
groupBox1.Controls.Add(ButtonRemoveCruiser);
groupBox1.Controls.Add(buttonAddCruiser);
groupBox1.Location = new Point(643, 12);
groupBox1.Name = "groupBox1";
groupBox1.Size = new Size(196, 436);
groupBox1.TabIndex = 0;
groupBox1.TabStop = false;
groupBox1.Text = "Инструменты";
//
// groupBox2
//
this.groupBox2.Controls.Add(this.listBoxStorage);
this.groupBox2.Controls.Add(this.textBoxStorageName);
this.groupBox2.Controls.Add(this.ButtonAddObject);
this.groupBox2.Controls.Add(this.ButtonDelObject);
this.groupBox2.Location = new System.Drawing.Point(9, 24);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(179, 256);
this.groupBox2.TabIndex = 4;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "Наборы";
groupBox2.Controls.Add(listBoxStorage);
groupBox2.Controls.Add(textBoxStorageName);
groupBox2.Controls.Add(ButtonAddObject);
groupBox2.Controls.Add(ButtonDelObject);
groupBox2.Location = new Point(9, 24);
groupBox2.Name = "groupBox2";
groupBox2.Size = new Size(179, 256);
groupBox2.TabIndex = 4;
groupBox2.TabStop = false;
groupBox2.Text = "Наборы";
//
// listBoxStorage
//
this.listBoxStorage.FormattingEnabled = true;
this.listBoxStorage.ItemHeight = 15;
this.listBoxStorage.Location = new System.Drawing.Point(6, 93);
this.listBoxStorage.Name = "listBoxStorage";
this.listBoxStorage.Size = new System.Drawing.Size(167, 109);
this.listBoxStorage.TabIndex = 5;
listBoxStorage.FormattingEnabled = true;
listBoxStorage.ItemHeight = 15;
listBoxStorage.Location = new Point(6, 93);
listBoxStorage.Name = "listBoxStorage";
listBoxStorage.Size = new Size(167, 109);
listBoxStorage.TabIndex = 5;
listBoxStorage.SelectedIndexChanged += listBoxStorage_SelectedIndexChanged;
//
// textBoxStorageName
//
this.textBoxStorageName.Font = new System.Drawing.Font("Lucida Sans Unicode", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.textBoxStorageName.Location = new System.Drawing.Point(6, 22);
this.textBoxStorageName.Name = "textBoxStorageName";
this.textBoxStorageName.Size = new System.Drawing.Size(167, 26);
this.textBoxStorageName.TabIndex = 4;
textBoxStorageName.Font = new Font("Lucida Sans Unicode", 9F, FontStyle.Regular, GraphicsUnit.Point);
textBoxStorageName.Location = new Point(6, 22);
textBoxStorageName.Name = "textBoxStorageName";
textBoxStorageName.Size = new Size(167, 26);
textBoxStorageName.TabIndex = 4;
//
// ButtonAddObject
//
this.ButtonAddObject.Location = new System.Drawing.Point(6, 54);
this.ButtonAddObject.Name = "ButtonAddObject";
this.ButtonAddObject.Size = new System.Drawing.Size(167, 33);
this.ButtonAddObject.TabIndex = 3;
this.ButtonAddObject.Text = "Добавить набор";
this.ButtonAddObject.UseVisualStyleBackColor = true;
this.ButtonAddObject.Click += new System.EventHandler(this.ButtonAddObject_Click);
ButtonAddObject.Location = new Point(6, 54);
ButtonAddObject.Name = "ButtonAddObject";
ButtonAddObject.Size = new Size(167, 33);
ButtonAddObject.TabIndex = 3;
ButtonAddObject.Text = "Добавить набор";
ButtonAddObject.UseVisualStyleBackColor = true;
ButtonAddObject.Click += ButtonAddObject_Click;
//
// ButtonDelObject
//
this.ButtonDelObject.Location = new System.Drawing.Point(6, 217);
this.ButtonDelObject.Name = "ButtonDelObject";
this.ButtonDelObject.Size = new System.Drawing.Size(167, 33);
this.ButtonDelObject.TabIndex = 2;
this.ButtonDelObject.Text = "Удалить набор";
this.ButtonDelObject.UseVisualStyleBackColor = true;
this.ButtonDelObject.Click += new System.EventHandler(this.ButtonDelObject_Click);
ButtonDelObject.Location = new Point(6, 217);
ButtonDelObject.Name = "ButtonDelObject";
ButtonDelObject.Size = new Size(167, 33);
ButtonDelObject.TabIndex = 2;
ButtonDelObject.Text = "Удалить набор";
ButtonDelObject.UseVisualStyleBackColor = true;
ButtonDelObject.Click += ButtonDelObject_Click;
//
// maskedTextBoxNumber
//
this.maskedTextBoxNumber.Font = new System.Drawing.Font("Lucida Sans Unicode", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.maskedTextBoxNumber.Location = new System.Drawing.Point(34, 325);
this.maskedTextBoxNumber.Mask = "00";
this.maskedTextBoxNumber.Name = "maskedTextBoxNumber";
this.maskedTextBoxNumber.Size = new System.Drawing.Size(130, 26);
this.maskedTextBoxNumber.TabIndex = 3;
maskedTextBoxNumber.Font = new Font("Lucida Sans Unicode", 9F, FontStyle.Regular, GraphicsUnit.Point);
maskedTextBoxNumber.Location = new Point(34, 325);
maskedTextBoxNumber.Mask = "00";
maskedTextBoxNumber.Name = "maskedTextBoxNumber";
maskedTextBoxNumber.Size = new Size(130, 26);
maskedTextBoxNumber.TabIndex = 3;
//
// ButtonRefreshCollection
//
this.ButtonRefreshCollection.Location = new System.Drawing.Point(6, 396);
this.ButtonRefreshCollection.Name = "ButtonRefreshCollection";
this.ButtonRefreshCollection.Size = new System.Drawing.Size(184, 33);
this.ButtonRefreshCollection.TabIndex = 2;
this.ButtonRefreshCollection.Text = "Обовить коллекцию";
this.ButtonRefreshCollection.UseVisualStyleBackColor = true;
this.ButtonRefreshCollection.Click += new System.EventHandler(this.ButtonRefreshCollection_Click);
ButtonRefreshCollection.Location = new Point(6, 396);
ButtonRefreshCollection.Name = "ButtonRefreshCollection";
ButtonRefreshCollection.Size = new Size(184, 33);
ButtonRefreshCollection.TabIndex = 2;
ButtonRefreshCollection.Text = "Обовить коллекцию";
ButtonRefreshCollection.UseVisualStyleBackColor = true;
ButtonRefreshCollection.Click += ButtonRefreshCollection_Click;
//
// ButtonRemoveCruiser
//
this.ButtonRemoveCruiser.Location = new System.Drawing.Point(6, 357);
this.ButtonRemoveCruiser.Name = "ButtonRemoveCruiser";
this.ButtonRemoveCruiser.Size = new System.Drawing.Size(184, 33);
this.ButtonRemoveCruiser.TabIndex = 1;
this.ButtonRemoveCruiser.Text = "Удалить крейсер";
this.ButtonRemoveCruiser.UseVisualStyleBackColor = true;
this.ButtonRemoveCruiser.Click += new System.EventHandler(this.ButtonRemoveCruiser_Click);
ButtonRemoveCruiser.Location = new Point(6, 357);
ButtonRemoveCruiser.Name = "ButtonRemoveCruiser";
ButtonRemoveCruiser.Size = new Size(184, 33);
ButtonRemoveCruiser.TabIndex = 1;
ButtonRemoveCruiser.Text = "Удалить крейсер";
ButtonRemoveCruiser.UseVisualStyleBackColor = true;
ButtonRemoveCruiser.Click += ButtonRemoveCruiser_Click;
//
// buttonAddCruiser
//
this.buttonAddCruiser.Location = new System.Drawing.Point(6, 286);
this.buttonAddCruiser.Name = "buttonAddCruiser";
this.buttonAddCruiser.Size = new System.Drawing.Size(184, 33);
this.buttonAddCruiser.TabIndex = 0;
this.buttonAddCruiser.Text = "Добавить крейсер";
this.buttonAddCruiser.UseVisualStyleBackColor = true;
this.buttonAddCruiser.Click += new System.EventHandler(this.buttonAddCruiser_Click);
buttonAddCruiser.Location = new Point(6, 286);
buttonAddCruiser.Name = "buttonAddCruiser";
buttonAddCruiser.Size = new Size(184, 33);
buttonAddCruiser.TabIndex = 0;
buttonAddCruiser.Text = "Добавить крейсер";
buttonAddCruiser.UseVisualStyleBackColor = true;
buttonAddCruiser.Click += buttonAddCruiser_Click;
//
// pictureBoxCollection
//
this.pictureBoxCollection.Location = new System.Drawing.Point(0, -1);
this.pictureBoxCollection.Name = "pictureBoxCollection";
this.pictureBoxCollection.Size = new System.Drawing.Size(637, 449);
this.pictureBoxCollection.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
this.pictureBoxCollection.TabIndex = 1;
this.pictureBoxCollection.TabStop = false;
pictureBoxCollection.Location = new Point(1, 4);
pictureBoxCollection.Name = "pictureBoxCollection";
pictureBoxCollection.Size = new Size(637, 449);
pictureBoxCollection.SizeMode = PictureBoxSizeMode.Zoom;
pictureBoxCollection.TabIndex = 1;
pictureBoxCollection.TabStop = false;
//
// FormCruiserCollection
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(851, 458);
this.Controls.Add(this.pictureBoxCollection);
this.Controls.Add(this.groupBox1);
this.Name = "FormCruiserCollection";
this.Text = "FormCruiserCollection";
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
this.groupBox2.ResumeLayout(false);
this.groupBox2.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxCollection)).EndInit();
this.ResumeLayout(false);
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(853, 460);
Controls.Add(pictureBoxCollection);
Controls.Add(groupBox1);
Name = "FormCruiserCollection";
Text = "FormCruiserCollection";
groupBox1.ResumeLayout(false);
groupBox1.PerformLayout();
groupBox2.ResumeLayout(false);
groupBox2.PerformLayout();
((System.ComponentModel.ISupportInitialize)pictureBoxCollection).EndInit();
ResumeLayout(false);
}
#endregion
@ -185,7 +184,7 @@
private PictureBox pictureBoxCollection;
private GroupBox groupBox2;
private ListBox listBoxStorage;
private MaskedTextBox textBoxStorageName;
private TextBox textBoxStorageName;
private Button ButtonAddObject;
private Button ButtonDelObject;
}

View File

@ -1,13 +1,7 @@
using ProjectCruiser.DrawningObjects;
using ProjectCruiser.Drawnings;
using ProjectCruiser.Generics;
using ProjectCruiser.MovementStrategy;
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 ProjectCruiser
@ -69,6 +63,7 @@ namespace ProjectCruiser
return;
}
if (MessageBox.Show($"Удалить объект {listBoxStorage.SelectedItem}?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
_storage.DelSet(listBoxStorage.SelectedItem.ToString()
?? string.Empty);
@ -76,22 +71,16 @@ namespace ProjectCruiser
}
}
private void buttonAddCruiser_Click(object sender, EventArgs e)
private void AddCruiser(DrawningCruiser cruiser)
{
if (listBoxStorage.SelectedIndex == -1)
{
return;
}
var obj = _storage[listBoxStorage.SelectedItem.ToString() ??
string.Empty];
if (obj == null)
var obj = _storage[listBoxStorage.SelectedItem.ToString() ?? string.Empty];
if (obj != null)
{
return;
}
FormCruiser form = new();
if (form.ShowDialog() == DialogResult.OK)
{
if (obj + form.SelectedCruiser > -1)
if (obj + cruiser != 1)
{
MessageBox.Show("Объект добавлен");
pictureBoxCollection.Image = obj.ShowCruiser();
@ -103,6 +92,13 @@ namespace ProjectCruiser
}
}
private void buttonAddCruiser_Click(object sender, EventArgs e)
{
var formCruiserConfig = new FormCruiserConfig();
formCruiserConfig.Show();
formCruiserConfig.AddEvent(AddCruiser);
}
private void ButtonRemoveCruiser_Click(object sender, EventArgs e)
{
if (listBoxStorage.SelectedIndex == -1)

View File

@ -1,4 +1,64 @@
<root>
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<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">

View File

@ -0,0 +1,371 @@
namespace ProjectCruiser
{
partial class FormCruiserConfig
{
/// <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.labelModifiedObject = new System.Windows.Forms.Label();
this.labelSimpleObject = new System.Windows.Forms.Label();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.panelPurple = new System.Windows.Forms.Panel();
this.panelYellow = new System.Windows.Forms.Panel();
this.panelBlack = new System.Windows.Forms.Panel();
this.panelBlue = new System.Windows.Forms.Panel();
this.panelGray = new System.Windows.Forms.Panel();
this.panelGreen = new System.Windows.Forms.Panel();
this.panelWhite = new System.Windows.Forms.Panel();
this.panelRed = new System.Windows.Forms.Panel();
this.checkBoxBodyKit = new System.Windows.Forms.CheckBox();
this.checkBoxPushka = new System.Windows.Forms.CheckBox();
this.numericUpDownWeight = new System.Windows.Forms.NumericUpDown();
this.numericUpDownSpeed = new System.Windows.Forms.NumericUpDown();
this.label2 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.panelColor = new System.Windows.Forms.Panel();
this.labelDopColor = new System.Windows.Forms.Label();
this.labelBaseColor = new System.Windows.Forms.Label();
this.pictureBoxObject = new System.Windows.Forms.PictureBox();
this.ButtonOk = new System.Windows.Forms.Button();
this.buttonCancel = new System.Windows.Forms.Button();
this.groupBox1.SuspendLayout();
this.groupBox2.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownWeight)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownSpeed)).BeginInit();
this.panelColor.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxObject)).BeginInit();
this.SuspendLayout();
//
// groupBox1
//
this.groupBox1.Controls.Add(this.labelModifiedObject);
this.groupBox1.Controls.Add(this.labelSimpleObject);
this.groupBox1.Controls.Add(this.groupBox2);
this.groupBox1.Controls.Add(this.checkBoxBodyKit);
this.groupBox1.Controls.Add(this.checkBoxPushka);
this.groupBox1.Controls.Add(this.numericUpDownWeight);
this.groupBox1.Controls.Add(this.numericUpDownSpeed);
this.groupBox1.Controls.Add(this.label2);
this.groupBox1.Controls.Add(this.label1);
this.groupBox1.Location = new System.Drawing.Point(12, 12);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(454, 228);
this.groupBox1.TabIndex = 0;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "Параметры";
//
// labelModifiedObject
//
this.labelModifiedObject.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.labelModifiedObject.Location = new System.Drawing.Point(361, 146);
this.labelModifiedObject.Name = "labelModifiedObject";
this.labelModifiedObject.Size = new System.Drawing.Size(87, 27);
this.labelModifiedObject.TabIndex = 8;
this.labelModifiedObject.Text = "Продвинутый";
this.labelModifiedObject.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
labelModifiedObject.MouseDown += LabelObject_MouseDown;
//
// labelSimpleObject
//
this.labelSimpleObject.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.labelSimpleObject.Location = new System.Drawing.Point(263, 146);
this.labelSimpleObject.Name = "labelSimpleObject";
this.labelSimpleObject.Size = new System.Drawing.Size(87, 27);
this.labelSimpleObject.TabIndex = 7;
this.labelSimpleObject.Text = "Простой";
this.labelSimpleObject.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
labelSimpleObject.MouseDown += LabelObject_MouseDown;
//
// groupBox2
//
this.groupBox2.Controls.Add(this.panelPurple);
this.groupBox2.Controls.Add(this.panelYellow);
this.groupBox2.Controls.Add(this.panelBlack);
this.groupBox2.Controls.Add(this.panelBlue);
this.groupBox2.Controls.Add(this.panelGray);
this.groupBox2.Controls.Add(this.panelGreen);
this.groupBox2.Controls.Add(this.panelWhite);
this.groupBox2.Controls.Add(this.panelRed);
this.groupBox2.Location = new System.Drawing.Point(263, 32);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(185, 106);
this.groupBox2.TabIndex = 6;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "Цвета";
//
// panelPurple
//
this.panelPurple.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(0)))), ((int)(((byte)(192)))));
this.panelPurple.Location = new System.Drawing.Point(139, 63);
this.panelPurple.Name = "panelPurple";
this.panelPurple.Size = new System.Drawing.Size(35, 30);
this.panelPurple.TabIndex = 7;
this.panelPurple.MouseDown += panelColor_MouseDown;
//
// panelYellow
//
this.panelYellow.BackColor = System.Drawing.Color.Yellow;
this.panelYellow.Location = new System.Drawing.Point(139, 22);
this.panelYellow.Name = "panelYellow";
this.panelYellow.Size = new System.Drawing.Size(35, 30);
this.panelYellow.TabIndex = 3;
this.panelYellow.MouseDown += panelColor_MouseDown;
//
// panelBlack
//
this.panelBlack.BackColor = System.Drawing.Color.Black;
this.panelBlack.Location = new System.Drawing.Point(98, 63);
this.panelBlack.Name = "panelBlack";
this.panelBlack.Size = new System.Drawing.Size(35, 30);
this.panelBlack.TabIndex = 6;
this.panelBlack.MouseDown += panelColor_MouseDown;
//
// panelBlue
//
this.panelBlue.BackColor = System.Drawing.Color.Blue;
this.panelBlue.Location = new System.Drawing.Point(98, 22);
this.panelBlue.Name = "panelBlue";
this.panelBlue.Size = new System.Drawing.Size(35, 30);
this.panelBlue.TabIndex = 2;
this.panelBlue.MouseDown += panelColor_MouseDown;
//
// panelGray
//
this.panelGray.BackColor = System.Drawing.Color.Gray;
this.panelGray.Location = new System.Drawing.Point(57, 63);
this.panelGray.Name = "panelGray";
this.panelGray.Size = new System.Drawing.Size(35, 30);
this.panelGray.TabIndex = 5;
this.panelGray.MouseDown += panelColor_MouseDown;
//
// panelGreen
//
this.panelGreen.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(192)))), ((int)(((byte)(0)))));
this.panelGreen.Location = new System.Drawing.Point(57, 22);
this.panelGreen.Name = "panelGreen";
this.panelGreen.Size = new System.Drawing.Size(35, 30);
this.panelGreen.TabIndex = 1;
this.panelGreen.MouseDown += panelColor_MouseDown;
//
// panelWhite
//
this.panelWhite.BackColor = System.Drawing.Color.White;
this.panelWhite.Location = new System.Drawing.Point(16, 63);
this.panelWhite.Name = "panelWhite";
this.panelWhite.Size = new System.Drawing.Size(35, 30);
this.panelWhite.TabIndex = 4;
this.panelWhite.MouseDown += panelColor_MouseDown;
//
// panelRed
//
this.panelRed.BackColor = System.Drawing.Color.Red;
this.panelRed.Location = new System.Drawing.Point(16, 22);
this.panelRed.Name = "panelRed";
this.panelRed.Size = new System.Drawing.Size(35, 30);
this.panelRed.TabIndex = 0;
this.panelRed.MouseDown += panelColor_MouseDown;
//
// checkBoxBodyKit
//
this.checkBoxBodyKit.AutoSize = true;
this.checkBoxBodyKit.Location = new System.Drawing.Point(10, 154);
this.checkBoxBodyKit.Name = "checkBoxBodyKit";
this.checkBoxBodyKit.Size = new System.Drawing.Size(256, 19);
this.checkBoxBodyKit.TabIndex = 5;
this.checkBoxBodyKit.Text = "Признак наличия вертолетной площадки";
this.checkBoxBodyKit.UseVisualStyleBackColor = true;
//
// checkBoxPushka
//
this.checkBoxPushka.AutoSize = true;
this.checkBoxPushka.Location = new System.Drawing.Point(10, 119);
this.checkBoxPushka.Name = "checkBoxPushka";
this.checkBoxPushka.Size = new System.Drawing.Size(227, 19);
this.checkBoxPushka.TabIndex = 4;
this.checkBoxPushka.Text = "Признак наличия отсека под ракеты";
this.checkBoxPushka.UseVisualStyleBackColor = true;
//
// numericUpDownWeight
//
this.numericUpDownWeight.Location = new System.Drawing.Point(76, 60);
this.numericUpDownWeight.Name = "numericUpDownWeight";
this.numericUpDownWeight.Size = new System.Drawing.Size(73, 23);
this.numericUpDownWeight.TabIndex = 3;
this.numericUpDownWeight.Value = new decimal(new int[] {
100,
0,
0,
0});
//
// numericUpDownSpeed
//
this.numericUpDownSpeed.Location = new System.Drawing.Point(76, 31);
this.numericUpDownSpeed.Name = "numericUpDownSpeed";
this.numericUpDownSpeed.Size = new System.Drawing.Size(73, 23);
this.numericUpDownSpeed.TabIndex = 2;
this.numericUpDownSpeed.Value = new decimal(new int[] {
100,
0,
0,
0});
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(10, 62);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(29, 15);
this.label2.TabIndex = 1;
this.label2.Text = "Вес:";
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(10, 33);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(62, 15);
this.label1.TabIndex = 0;
this.label1.Text = "Скорость:";
//
// panelColor
//
this.panelColor.AllowDrop = true;
this.panelColor.Controls.Add(this.labelDopColor);
this.panelColor.Controls.Add(this.labelBaseColor);
this.panelColor.Controls.Add(this.pictureBoxObject);
this.panelColor.Location = new System.Drawing.Point(472, 12);
this.panelColor.Name = "panelColor";
this.panelColor.Size = new System.Drawing.Size(276, 184);
this.panelColor.TabIndex = 1;
this.panelColor.DragDrop += PanelObject_DragDrop;
this.panelColor.DragEnter += PanelObject_DragEnter;
//
// labelDopColor
//
this.labelDopColor.AllowDrop = true;
this.labelDopColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.labelDopColor.Location = new System.Drawing.Point(164, 10);
this.labelDopColor.Name = "labelDopColor";
this.labelDopColor.Size = new System.Drawing.Size(100, 29);
this.labelDopColor.TabIndex = 2;
this.labelDopColor.Text = "Доп. цвет";
this.labelDopColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.labelDopColor.DragDrop += LabelDopColor_DragDrop;
this.labelDopColor.DragEnter += LabelColor_DragEnter;
this.labelDopColor.MouseDown += LabelObject_MouseDown;
//
// labelBaseColor
//
this.labelBaseColor.AllowDrop = true;
this.labelBaseColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.labelBaseColor.Location = new System.Drawing.Point(12, 10);
this.labelBaseColor.Name = "labelBaseColor";
this.labelBaseColor.Size = new System.Drawing.Size(100, 29);
this.labelBaseColor.TabIndex = 2;
this.labelBaseColor.Text = "Цвет";
this.labelBaseColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.labelBaseColor.DragDrop += LabelBaseColor_DragDrop;
this.labelBaseColor.DragEnter += LabelColor_DragEnter;
this.labelBaseColor.MouseDown += LabelObject_MouseDown;
//
// pictureBoxObject
//
this.pictureBoxObject.Location = new System.Drawing.Point(12, 46);
this.pictureBoxObject.Name = "pictureBoxObject";
this.pictureBoxObject.Size = new System.Drawing.Size(252, 127);
this.pictureBoxObject.TabIndex = 0;
this.pictureBoxObject.TabStop = false;
//
// ButtonOk
//
this.ButtonOk.Location = new System.Drawing.Point(484, 208);
this.ButtonOk.Name = "ButtonOk";
this.ButtonOk.Size = new System.Drawing.Size(100, 32);
this.ButtonOk.TabIndex = 2;
this.ButtonOk.Text = "Добавить";
this.ButtonOk.UseVisualStyleBackColor = true;
this.ButtonOk.Click += ButtonOk_Click;
//
// buttonCancel
//
this.buttonCancel.Location = new System.Drawing.Point(636, 208);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(100, 32);
this.buttonCancel.TabIndex = 3;
this.buttonCancel.Text = "Отмена";
this.buttonCancel.UseVisualStyleBackColor = true;
//
// FormCruiserConfig
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 252);
this.Controls.Add(this.buttonCancel);
this.Controls.Add(this.ButtonOk);
this.Controls.Add(this.panelColor);
this.Controls.Add(this.groupBox1);
this.Name = "FormCruiserConfig";
this.Text = "FormLincornConfig";
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
this.groupBox2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.numericUpDownWeight)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownSpeed)).EndInit();
this.panelColor.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.pictureBoxObject)).EndInit();
this.ResumeLayout(false);
}
#endregion
private GroupBox groupBox1;
private NumericUpDown numericUpDownWeight;
private NumericUpDown numericUpDownSpeed;
private Label label2;
private Label label1;
private GroupBox groupBox2;
private CheckBox checkBoxBodyKit;
private CheckBox checkBoxPushka;
private Panel panelPurple;
private Panel panelYellow;
private Panel panelBlack;
private Panel panelBlue;
private Panel panelGray;
private Panel panelGreen;
private Panel panelWhite;
private Panel panelRed;
private Label labelSimpleObject;
private Label labelModifiedObject;
private Panel panelColor;
private PictureBox pictureBoxObject;
private Label labelDopColor;
private Label labelBaseColor;
private Button ButtonOk;
private Button buttonCancel;
}
}

View File

@ -0,0 +1,150 @@
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 ProjectCruiser.Drawnings;
using ProjectCruiser.Entities;
using ProjectCruiser;
using ProjectCruiser.DrawningObjects;
namespace ProjectCruiser
{
public partial class FormCruiserConfig : Form
{
DrawningCruiser? _cruiser = null;
private event Action<DrawningCruiser> EventAddCruiser;
public FormCruiserConfig()
{
InitializeComponent();
panelBlack.MouseDown += panelColor_MouseDown;
panelPurple.MouseDown += panelColor_MouseDown;
panelGray.MouseDown += panelColor_MouseDown;
panelGreen.MouseDown += panelColor_MouseDown;
panelRed.MouseDown += panelColor_MouseDown;
panelWhite.MouseDown += panelColor_MouseDown;
panelYellow.MouseDown += panelColor_MouseDown;
panelBlue.MouseDown += panelColor_MouseDown;
buttonCancel.Click += (sender, e) => Close();
}
private void DrawCruiser()
{
Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height);
Graphics gr = Graphics.FromImage(bmp);
_cruiser?.SetPosition(5, 5);
_cruiser?.DrawTransport(gr);
pictureBoxObject.Image = bmp;
}
public void AddEvent(Action<DrawningCruiser> ev)
{
if (EventAddCruiser == null)
{
EventAddCruiser = new Action<DrawningCruiser>(ev);
}
else
{
EventAddCruiser += ev;
}
}
private void LabelObject_MouseDown(object sender, MouseEventArgs e)
{
(sender as Label)?.DoDragDrop((sender as Label)?.Name, DragDropEffects.Move | DragDropEffects.Copy);
}
private void PanelObject_DragEnter(object sender, DragEventArgs e)
{
if (e.Data?.GetDataPresent(DataFormats.Text) ?? false)
{
e.Effect = DragDropEffects.Copy;
}
else
{
e.Effect = DragDropEffects.None;
}
}
private void PanelObject_DragDrop(object sender, DragEventArgs e)
{
switch (e.Data?.GetData(DataFormats.Text).ToString())
{
case "labelSimpleObject":
_cruiser = new DrawningCruiser((int)numericUpDownSpeed.Value,
(int)numericUpDownWeight.Value, Color.White, pictureBoxObject.Width,
pictureBoxObject.Height);
break;
case "labelModifiedObject":
_cruiser = new DrawningCruiserDou((int)numericUpDownSpeed.Value,
(int)numericUpDownWeight.Value, Color.White, Color.Black, checkBoxBodyKit.Checked,
checkBoxPushka.Checked, pictureBoxObject.Width, pictureBoxObject.Height);
break;
}
DrawCruiser();
}
private void panelColor_MouseDown(object sender, MouseEventArgs e)
{
(sender as Panel)?.DoDragDrop((sender as Panel)?.BackColor, DragDropEffects.Move | DragDropEffects.Copy);
}
private void LabelBaseColor_DragDrop(object sender, DragEventArgs e)
{
if (_cruiser != null)
{
if (e.Data.GetDataPresent(typeof(Color)))
{
_cruiser.EntityCruiser.BodyColor = (Color)e.Data.GetData(typeof(Color));
}
DrawCruiser();
}
}
private void LabelColor_DragEnter(object sender, DragEventArgs e)
{
if (_cruiser != null && _cruiser.EntityCruiser is EntityCruiserDou entityustabat)
{
labelDopColor.AllowDrop = true;
}
else
labelDopColor.AllowDrop = false;
if (e.Data.GetDataPresent(typeof(Color)))
{
e.Effect = DragDropEffects.Copy;
}
else
{
e.Effect = DragDropEffects.None;
}
}
private void LabelDopColor_DragDrop(object sender, DragEventArgs e)
{
if (_cruiser != null && _cruiser.EntityCruiser is EntityCruiserDou entitycruiserdou)
{
if (e.Data.GetDataPresent(typeof(Color)))
{
entitycruiserdou.AdditionalColor = (Color)e.Data.GetData(typeof(Color));
}
DrawCruiser();
}
}
private void ButtonOk_Click(object sender, EventArgs e)
{
EventAddCruiser?.Invoke(_cruiser);
Close();
}
}
}

View 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>

View File

@ -6,15 +6,13 @@ using System.Threading.Tasks;
namespace ProjectCruiser.MovementStrategy
{
/// <summary>
/// Параметры-координаты объекта
/// </summary>
public class ObjectParameters
{
private readonly int _x;
private readonly int _y;
private readonly int _width;
private readonly int _height;
public int LeftBorder => _x;
public int TopBorder => _y;

View File

@ -4,11 +4,12 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectCruiser
namespace ProjectCruiser.Generics
{
internal class SetGeneric<T>
where T : class
{
private readonly List<T?> _places;
public int Count => _places.Count;
@ -28,18 +29,18 @@ namespace ProjectCruiser
public int Insert(T cruiser, int position)
{
if (position < 0 || position >= _maxCount)
return -1;
if (Count >= _maxCount)
return -1;
_places.Insert(position, cruiser);
return position;
}
public bool Remove(int position)
{
if ((position < 0) || (position > _maxCount)) return false;
_places.RemoveAt(position);
return true;