Лаба5
This commit is contained in:
parent
cccdcf3c7d
commit
3035239271
@ -17,11 +17,11 @@ namespace Cruiser.Drawing
|
||||
/// <summary>
|
||||
/// Ширина окна
|
||||
/// </summary>
|
||||
private int _pictureWidth;
|
||||
public int _pictureWidth;// добавил для починки отрисовки на форме коллекций
|
||||
/// <summary>
|
||||
/// Высота окна
|
||||
/// </summary>
|
||||
private int _pictureHeight;
|
||||
public int _pictureHeight;// добавил для починки отрисовки на форме коллекций
|
||||
/// <summary>
|
||||
/// Левая координата прорисовки Крейсера
|
||||
/// </summary>
|
||||
@ -118,6 +118,13 @@ namespace Cruiser.Drawing
|
||||
_startPosY = y;
|
||||
}
|
||||
/// <summary>
|
||||
/// Установка цвета
|
||||
/// </summary>
|
||||
public void setBodyColor(Color color)
|
||||
{
|
||||
EntityCruiser.BodyColor = color;
|
||||
}
|
||||
/// <summary>
|
||||
/// Проверка, что объект может переместится по указанному направлению
|
||||
/// </summary>
|
||||
/// <param name="direction">Направление</param>
|
||||
@ -170,9 +177,6 @@ namespace Cruiser.Drawing
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Прорисовка объекта
|
||||
/// </summary>
|
||||
|
@ -9,6 +9,13 @@ namespace Cruiser.Drawing
|
||||
{
|
||||
public class DrawingProCruiser : DrawingCruiser
|
||||
{
|
||||
/// <summary>
|
||||
/// установка цвета про лайнера
|
||||
/// </summary>
|
||||
public void setElementColor(Color color)
|
||||
{
|
||||
(EntityCruiser as EntityProCruiser).ElementsColor = color;
|
||||
}
|
||||
public DrawingProCruiser(int speed, double weight, Color bodyColor, Color secColor, Color elemColor, bool rocketMines, bool helipad, int width, int height) :
|
||||
base (speed, weight, bodyColor, secColor, width, height, 150, 60)
|
||||
{
|
||||
|
@ -22,11 +22,11 @@ namespace Cruiser.Entities
|
||||
/// <summary>
|
||||
/// Основной цвет
|
||||
/// </summary>
|
||||
public Color BodyColor { get; private set; }
|
||||
public Color BodyColor { get; set; }
|
||||
/// <summary>
|
||||
/// Второстепенный цвет
|
||||
/// </summary>
|
||||
public Color SecondColor { get; private set; }
|
||||
public Color SecondColor { get; set; }
|
||||
/// <summary>
|
||||
/// Шаг перемещения Крейсера
|
||||
/// </summary>
|
||||
|
@ -11,7 +11,7 @@ namespace Cruiser.Entities
|
||||
/// <summary>
|
||||
/// Элементов цвет
|
||||
/// </summary>
|
||||
public Color ElementsColor { get; private set; }
|
||||
public Color ElementsColor { get; set; }
|
||||
/// <summary>
|
||||
/// Признак (опция) наличия ракетных шахт
|
||||
/// </summary>
|
||||
@ -37,5 +37,5 @@ namespace Cruiser.Entities
|
||||
Helipad = helipad;
|
||||
ElementsColor = elemColor;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
48
Cruiser/FormCruiserCollection.Designer.cs
generated
48
Cruiser/FormCruiserCollection.Designer.cs
generated
@ -29,10 +29,10 @@
|
||||
private void InitializeComponent()
|
||||
{
|
||||
groupBoxTools = new GroupBox();
|
||||
buttonDeleteCruiser = new Button();
|
||||
button2 = new Button();
|
||||
textBoxNumber = new TextBox();
|
||||
buttonAddCruiser = new Button();
|
||||
buttonRefreshCollection = new Button();
|
||||
button3 = new Button();
|
||||
pictureBoxCollection = new PictureBox();
|
||||
groupBoxStorage = new GroupBox();
|
||||
listBoxStorages = new ListBox();
|
||||
@ -46,7 +46,7 @@
|
||||
//
|
||||
// groupBoxTools
|
||||
//
|
||||
groupBoxTools.Controls.Add(buttonDeleteCruiser);
|
||||
groupBoxTools.Controls.Add(button2);
|
||||
groupBoxTools.Controls.Add(textBoxNumber);
|
||||
groupBoxTools.Controls.Add(buttonAddCruiser);
|
||||
groupBoxTools.Location = new Point(653, 1);
|
||||
@ -56,15 +56,15 @@
|
||||
groupBoxTools.TabStop = false;
|
||||
groupBoxTools.Text = "Инструменты";
|
||||
//
|
||||
// buttonDeleteCruiser
|
||||
// button2
|
||||
//
|
||||
buttonDeleteCruiser.Location = new Point(15, 95);
|
||||
buttonDeleteCruiser.Name = "buttonDeleteCruiser";
|
||||
buttonDeleteCruiser.Size = new Size(122, 37);
|
||||
buttonDeleteCruiser.TabIndex = 2;
|
||||
buttonDeleteCruiser.Text = "Удалить лайнер";
|
||||
buttonDeleteCruiser.UseVisualStyleBackColor = true;
|
||||
buttonDeleteCruiser.Click += ButtonRemoveCar_Click;
|
||||
button2.Location = new Point(15, 95);
|
||||
button2.Name = "button2";
|
||||
button2.Size = new Size(122, 37);
|
||||
button2.TabIndex = 2;
|
||||
button2.Text = "Удалить лайнер";
|
||||
button2.UseVisualStyleBackColor = true;
|
||||
button2.Click += ButtonRemoveCar_Click;
|
||||
//
|
||||
// textBoxNumber
|
||||
//
|
||||
@ -81,17 +81,17 @@
|
||||
buttonAddCruiser.TabIndex = 0;
|
||||
buttonAddCruiser.Text = "Добавить лайнер";
|
||||
buttonAddCruiser.UseVisualStyleBackColor = true;
|
||||
buttonAddCruiser.Click += buttonAddCruiser_Click;
|
||||
buttonAddCruiser.Click += ButtonAddCruiser_Click;
|
||||
//
|
||||
// buttonRefreshCollection
|
||||
// button3
|
||||
//
|
||||
buttonRefreshCollection.Location = new Point(662, 397);
|
||||
buttonRefreshCollection.Name = "buttonRefreshCollection";
|
||||
buttonRefreshCollection.Size = new Size(131, 41);
|
||||
buttonRefreshCollection.TabIndex = 3;
|
||||
buttonRefreshCollection.Text = "Обновить коллекцию";
|
||||
buttonRefreshCollection.UseVisualStyleBackColor = true;
|
||||
buttonRefreshCollection.Click += ButtonRefreshCollection_Click;
|
||||
button3.Location = new Point(662, 397);
|
||||
button3.Name = "button3";
|
||||
button3.Size = new Size(131, 41);
|
||||
button3.TabIndex = 3;
|
||||
button3.Text = "Обновить коллекцию";
|
||||
button3.UseVisualStyleBackColor = true;
|
||||
button3.Click += ButtonRefreshCollection_Click;
|
||||
//
|
||||
// pictureBoxCollection
|
||||
//
|
||||
@ -156,13 +156,12 @@
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(800, 450);
|
||||
Controls.Add(buttonRefreshCollection);
|
||||
Controls.Add(button3);
|
||||
Controls.Add(groupBoxStorage);
|
||||
Controls.Add(pictureBoxCollection);
|
||||
Controls.Add(groupBoxTools);
|
||||
Name = "FormCruiserCollection";
|
||||
Text = "Набор Крейсеров";
|
||||
Load += FormCruiserCollection_Load;
|
||||
groupBoxTools.ResumeLayout(false);
|
||||
groupBoxTools.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBoxCollection).EndInit();
|
||||
@ -176,10 +175,11 @@
|
||||
private GroupBox groupBoxTools;
|
||||
private TextBox textBoxNumber;
|
||||
private Button buttonAddCruiser;
|
||||
private Button buttonRefreshCollection;
|
||||
private Button buttonDeleteCruiser;
|
||||
private Button button3;
|
||||
private Button button2;
|
||||
private PictureBox pictureBoxCollection;
|
||||
private GroupBox groupBoxStorage;
|
||||
private Button button1;
|
||||
private Button buttonDelObject;
|
||||
private TextBox textBoxStorageName;
|
||||
private Button buttonAddObject;
|
||||
|
@ -101,7 +101,7 @@ namespace Cruiser
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void buttonAddCruiser_Click(object sender, EventArgs e)
|
||||
private void AddCruiser(DrawingCruiser cruiser)
|
||||
{
|
||||
if (listBoxStorages.SelectedIndex == -1)
|
||||
{
|
||||
@ -112,10 +112,7 @@ namespace Cruiser
|
||||
{
|
||||
return;
|
||||
}
|
||||
FormCruiser form = new();
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
if (obj + form.SelectedCruiser)
|
||||
if ((obj + cruiser))
|
||||
{
|
||||
MessageBox.Show("Объект добавлен");
|
||||
pictureBoxCollection.Image = obj.ShowCruiser();
|
||||
@ -125,7 +122,6 @@ namespace Cruiser
|
||||
MessageBox.Show("Не удалось добавить объект");
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Удаление объекта из набора
|
||||
/// </summary>
|
||||
@ -137,7 +133,8 @@ namespace Cruiser
|
||||
{
|
||||
return;
|
||||
}
|
||||
var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? string.Empty];
|
||||
var obj = _storage[listBoxStorages.SelectedItem.ToString() ??
|
||||
string.Empty];
|
||||
if (obj == null)
|
||||
{
|
||||
return;
|
||||
@ -177,12 +174,16 @@ namespace Cruiser
|
||||
}
|
||||
pictureBoxCollection.Image = obj.ShowCruiser();
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void FormCruiserCollection_Load(object sender, EventArgs e)
|
||||
/// <summary>
|
||||
/// Добавление объекта
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonAddCruiser_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
var formCruiserConfig = new FormCruiserConfig();
|
||||
formCruiserConfig.Show();
|
||||
formCruiserConfig.AddEvent(AddCruiser);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
379
Cruiser/FormCruiserConfig.Designer.cs
generated
Normal file
379
Cruiser/FormCruiserConfig.Designer.cs
generated
Normal file
@ -0,0 +1,379 @@
|
||||
namespace Cruiser
|
||||
{
|
||||
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()
|
||||
{
|
||||
groupBoxForTools = new GroupBox();
|
||||
buttonCancel = new Button();
|
||||
buttonAddCruiser = new Button();
|
||||
labelDopColor = new Label();
|
||||
labelColor = new Label();
|
||||
panelToCruiser = new Panel();
|
||||
pictureBoxToCruiser = new PictureBox();
|
||||
labelProCruiser = new Label();
|
||||
labelCruiser = new Label();
|
||||
groupBoxColors = new GroupBox();
|
||||
panelColorGold = new Panel();
|
||||
panelColorCrimson = new Panel();
|
||||
panelColorPlum = new Panel();
|
||||
panelColorDodgerBlue = new Panel();
|
||||
panelColorAquamarine = new Panel();
|
||||
panelColorForestGreen = new Panel();
|
||||
panelColorSienna = new Panel();
|
||||
panelColorRed = new Panel();
|
||||
checkBoxHelipad = new CheckBox();
|
||||
checkBoxRockMines = new CheckBox();
|
||||
numericUpDownWeight = new NumericUpDown();
|
||||
numericUpDownSpeed = new NumericUpDown();
|
||||
labelWeight = new Label();
|
||||
labelSpeed = new Label();
|
||||
groupBoxForTools.SuspendLayout();
|
||||
panelToCruiser.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBoxToCruiser).BeginInit();
|
||||
groupBoxColors.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownWeight).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// groupBoxForTools
|
||||
//
|
||||
groupBoxForTools.Controls.Add(buttonCancel);
|
||||
groupBoxForTools.Controls.Add(buttonAddCruiser);
|
||||
groupBoxForTools.Controls.Add(labelDopColor);
|
||||
groupBoxForTools.Controls.Add(labelColor);
|
||||
groupBoxForTools.Controls.Add(panelToCruiser);
|
||||
groupBoxForTools.Controls.Add(labelProCruiser);
|
||||
groupBoxForTools.Controls.Add(labelCruiser);
|
||||
groupBoxForTools.Controls.Add(groupBoxColors);
|
||||
groupBoxForTools.Controls.Add(checkBoxHelipad);
|
||||
groupBoxForTools.Controls.Add(checkBoxRockMines);
|
||||
groupBoxForTools.Controls.Add(numericUpDownWeight);
|
||||
groupBoxForTools.Controls.Add(numericUpDownSpeed);
|
||||
groupBoxForTools.Controls.Add(labelWeight);
|
||||
groupBoxForTools.Controls.Add(labelSpeed);
|
||||
groupBoxForTools.Location = new Point(15, 8);
|
||||
groupBoxForTools.Name = "groupBoxForTools";
|
||||
groupBoxForTools.Size = new Size(641, 250);
|
||||
groupBoxForTools.TabIndex = 0;
|
||||
groupBoxForTools.TabStop = false;
|
||||
groupBoxForTools.Text = "Tools";
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
buttonCancel.Location = new Point(403, 208);
|
||||
buttonCancel.Name = "buttonCancel";
|
||||
buttonCancel.Size = new Size(206, 26);
|
||||
buttonCancel.TabIndex = 14;
|
||||
buttonCancel.Text = "Cancel";
|
||||
buttonCancel.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// buttonAddCruiser
|
||||
//
|
||||
buttonAddCruiser.Location = new Point(403, 176);
|
||||
buttonAddCruiser.Name = "buttonAddCruiser";
|
||||
buttonAddCruiser.Size = new Size(206, 26);
|
||||
buttonAddCruiser.TabIndex = 13;
|
||||
buttonAddCruiser.Text = "AddCruiser";
|
||||
buttonAddCruiser.UseVisualStyleBackColor = true;
|
||||
buttonAddCruiser.Click += buttonAdd_Click;
|
||||
//
|
||||
// labelDopColor
|
||||
//
|
||||
labelDopColor.AllowDrop = true;
|
||||
labelDopColor.BorderStyle = BorderStyle.FixedSingle;
|
||||
labelDopColor.Location = new Point(509, 19);
|
||||
labelDopColor.Name = "labelDopColor";
|
||||
labelDopColor.Size = new Size(100, 30);
|
||||
labelDopColor.TabIndex = 12;
|
||||
labelDopColor.Text = "DopColor";
|
||||
labelDopColor.TextAlign = ContentAlignment.MiddleCenter;
|
||||
labelDopColor.DragDrop += labelColor_DragDrop;
|
||||
labelDopColor.DragEnter += labelColor_DragEnter;
|
||||
labelDopColor.MouseDown += LabelObject_MouseDown;
|
||||
//
|
||||
// labelColor
|
||||
//
|
||||
labelColor.AllowDrop = true;
|
||||
labelColor.BorderStyle = BorderStyle.FixedSingle;
|
||||
labelColor.Location = new Point(403, 19);
|
||||
labelColor.Name = "labelColor";
|
||||
labelColor.Size = new Size(100, 30);
|
||||
labelColor.TabIndex = 11;
|
||||
labelColor.Text = "Color";
|
||||
labelColor.TextAlign = ContentAlignment.MiddleCenter;
|
||||
labelColor.DragDrop += labelColor_DragDrop;
|
||||
labelColor.DragEnter += labelColor_DragEnter;
|
||||
labelColor.MouseDown += LabelObject_MouseDown;
|
||||
//
|
||||
// panelToCruiser
|
||||
//
|
||||
panelToCruiser.AllowDrop = true;
|
||||
panelToCruiser.Controls.Add(pictureBoxToCruiser);
|
||||
panelToCruiser.Location = new Point(403, 52);
|
||||
panelToCruiser.Name = "panelToCruiser";
|
||||
panelToCruiser.Size = new Size(206, 118);
|
||||
panelToCruiser.TabIndex = 10;
|
||||
panelToCruiser.DragDrop += PanelObject_DragDrop;
|
||||
panelToCruiser.DragEnter += PanelObject_DragEnter;
|
||||
panelToCruiser.MouseDown += LabelObject_MouseDown;
|
||||
//
|
||||
// pictureBoxToCruiser
|
||||
//
|
||||
pictureBoxToCruiser.Location = new Point(3, 3);
|
||||
pictureBoxToCruiser.Name = "pictureBoxToCruiser";
|
||||
pictureBoxToCruiser.Size = new Size(200, 112);
|
||||
pictureBoxToCruiser.TabIndex = 9;
|
||||
pictureBoxToCruiser.TabStop = false;
|
||||
//
|
||||
// labelProCruiser
|
||||
//
|
||||
labelProCruiser.AllowDrop = true;
|
||||
labelProCruiser.BorderStyle = BorderStyle.FixedSingle;
|
||||
labelProCruiser.Location = new Point(270, 155);
|
||||
labelProCruiser.Name = "labelProCruiser";
|
||||
labelProCruiser.Size = new Size(100, 30);
|
||||
labelProCruiser.TabIndex = 8;
|
||||
labelProCruiser.Text = "ProCruiser";
|
||||
labelProCruiser.TextAlign = ContentAlignment.MiddleCenter;
|
||||
labelProCruiser.MouseDown += LabelObject_MouseDown;
|
||||
//
|
||||
// labelCruiser
|
||||
//
|
||||
labelCruiser.AllowDrop = true;
|
||||
labelCruiser.BorderStyle = BorderStyle.FixedSingle;
|
||||
labelCruiser.Location = new Point(155, 155);
|
||||
labelCruiser.Name = "labelCruiser";
|
||||
labelCruiser.Size = new Size(100, 30);
|
||||
labelCruiser.TabIndex = 7;
|
||||
labelCruiser.Text = "Cruiser";
|
||||
labelCruiser.TextAlign = ContentAlignment.MiddleCenter;
|
||||
labelCruiser.MouseDown += LabelObject_MouseDown;
|
||||
//
|
||||
// groupBoxColors
|
||||
//
|
||||
groupBoxColors.Controls.Add(panelColorGold);
|
||||
groupBoxColors.Controls.Add(panelColorCrimson);
|
||||
groupBoxColors.Controls.Add(panelColorPlum);
|
||||
groupBoxColors.Controls.Add(panelColorDodgerBlue);
|
||||
groupBoxColors.Controls.Add(panelColorAquamarine);
|
||||
groupBoxColors.Controls.Add(panelColorForestGreen);
|
||||
groupBoxColors.Controls.Add(panelColorSienna);
|
||||
groupBoxColors.Controls.Add(panelColorRed);
|
||||
groupBoxColors.Location = new Point(152, 19);
|
||||
groupBoxColors.Name = "groupBoxColors";
|
||||
groupBoxColors.Size = new Size(224, 126);
|
||||
groupBoxColors.TabIndex = 6;
|
||||
groupBoxColors.TabStop = false;
|
||||
groupBoxColors.Text = "Colors";
|
||||
//
|
||||
// panelColorGold
|
||||
//
|
||||
panelColorGold.AllowDrop = true;
|
||||
panelColorGold.BackColor = Color.Gold;
|
||||
panelColorGold.Location = new Point(173, 76);
|
||||
panelColorGold.Name = "panelColorGold";
|
||||
panelColorGold.Size = new Size(37, 35);
|
||||
panelColorGold.TabIndex = 6;
|
||||
panelColorGold.MouseDown += panelColor_MouseDown;
|
||||
//
|
||||
// panelColorCrimson
|
||||
//
|
||||
panelColorCrimson.AllowDrop = true;
|
||||
panelColorCrimson.BackColor = Color.Crimson;
|
||||
panelColorCrimson.Location = new Point(118, 76);
|
||||
panelColorCrimson.Name = "panelColorCrimson";
|
||||
panelColorCrimson.Size = new Size(37, 35);
|
||||
panelColorCrimson.TabIndex = 4;
|
||||
panelColorCrimson.MouseDown += panelColor_MouseDown;
|
||||
//
|
||||
// panelColorPlum
|
||||
//
|
||||
panelColorPlum.AllowDrop = true;
|
||||
panelColorPlum.BackColor = Color.Plum;
|
||||
panelColorPlum.Location = new Point(66, 76);
|
||||
panelColorPlum.Name = "panelColorPlum";
|
||||
panelColorPlum.Size = new Size(37, 35);
|
||||
panelColorPlum.TabIndex = 5;
|
||||
panelColorPlum.MouseDown += panelColor_MouseDown;
|
||||
//
|
||||
// panelColorDodgerBlue
|
||||
//
|
||||
panelColorDodgerBlue.AllowDrop = true;
|
||||
panelColorDodgerBlue.BackColor = Color.DodgerBlue;
|
||||
panelColorDodgerBlue.Location = new Point(12, 76);
|
||||
panelColorDodgerBlue.Name = "panelColorDodgerBlue";
|
||||
panelColorDodgerBlue.Size = new Size(37, 35);
|
||||
panelColorDodgerBlue.TabIndex = 3;
|
||||
panelColorDodgerBlue.MouseDown += panelColor_MouseDown;
|
||||
//
|
||||
// panelColorAquamarine
|
||||
//
|
||||
panelColorAquamarine.AllowDrop = true;
|
||||
panelColorAquamarine.BackColor = Color.Aquamarine;
|
||||
panelColorAquamarine.Location = new Point(173, 23);
|
||||
panelColorAquamarine.Name = "panelColorAquamarine";
|
||||
panelColorAquamarine.Size = new Size(37, 35);
|
||||
panelColorAquamarine.TabIndex = 2;
|
||||
panelColorAquamarine.MouseDown += panelColor_MouseDown;
|
||||
//
|
||||
// panelColorForestGreen
|
||||
//
|
||||
panelColorForestGreen.AllowDrop = true;
|
||||
panelColorForestGreen.BackColor = Color.ForestGreen;
|
||||
panelColorForestGreen.Location = new Point(118, 23);
|
||||
panelColorForestGreen.Name = "panelColorForestGreen";
|
||||
panelColorForestGreen.Size = new Size(37, 35);
|
||||
panelColorForestGreen.TabIndex = 1;
|
||||
panelColorForestGreen.MouseDown += panelColor_MouseDown;
|
||||
//
|
||||
// panelColorSienna
|
||||
//
|
||||
panelColorSienna.AllowDrop = true;
|
||||
panelColorSienna.BackColor = Color.Sienna;
|
||||
panelColorSienna.Location = new Point(66, 23);
|
||||
panelColorSienna.Name = "panelColorSienna";
|
||||
panelColorSienna.Size = new Size(37, 35);
|
||||
panelColorSienna.TabIndex = 1;
|
||||
panelColorSienna.MouseDown += panelColor_MouseDown;
|
||||
//
|
||||
// panelColorRed
|
||||
//
|
||||
panelColorRed.AllowDrop = true;
|
||||
panelColorRed.BackColor = Color.Red;
|
||||
panelColorRed.Location = new Point(12, 23);
|
||||
panelColorRed.Name = "panelColorRed";
|
||||
panelColorRed.Size = new Size(37, 35);
|
||||
panelColorRed.TabIndex = 0;
|
||||
panelColorRed.MouseDown += panelColor_MouseDown;
|
||||
//
|
||||
// checkBoxHelipad
|
||||
//
|
||||
checkBoxHelipad.AutoSize = true;
|
||||
checkBoxHelipad.Location = new Point(6, 161);
|
||||
checkBoxHelipad.Name = "checkBoxHelipad";
|
||||
checkBoxHelipad.Size = new Size(67, 19);
|
||||
checkBoxHelipad.TabIndex = 5;
|
||||
checkBoxHelipad.Text = "Helipad";
|
||||
checkBoxHelipad.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// checkBoxRockMines
|
||||
//
|
||||
checkBoxRockMines.AutoSize = true;
|
||||
checkBoxRockMines.Location = new Point(6, 136);
|
||||
checkBoxRockMines.Name = "checkBoxRockMines";
|
||||
checkBoxRockMines.Size = new Size(94, 19);
|
||||
checkBoxRockMines.TabIndex = 4;
|
||||
checkBoxRockMines.Text = "RocketMines";
|
||||
checkBoxRockMines.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// numericUpDownWeight
|
||||
//
|
||||
numericUpDownWeight.Location = new Point(6, 95);
|
||||
numericUpDownWeight.Maximum = new decimal(new int[] { 1000, 0, 0, 0 });
|
||||
numericUpDownWeight.Minimum = new decimal(new int[] { 100, 0, 0, 0 });
|
||||
numericUpDownWeight.Name = "numericUpDownWeight";
|
||||
numericUpDownWeight.Size = new Size(120, 23);
|
||||
numericUpDownWeight.TabIndex = 3;
|
||||
numericUpDownWeight.Value = new decimal(new int[] { 100, 0, 0, 0 });
|
||||
//
|
||||
// numericUpDownSpeed
|
||||
//
|
||||
numericUpDownSpeed.Location = new Point(6, 37);
|
||||
numericUpDownSpeed.Maximum = new decimal(new int[] { 1000, 0, 0, 0 });
|
||||
numericUpDownSpeed.Minimum = new decimal(new int[] { 100, 0, 0, 0 });
|
||||
numericUpDownSpeed.Name = "numericUpDownSpeed";
|
||||
numericUpDownSpeed.Size = new Size(120, 23);
|
||||
numericUpDownSpeed.TabIndex = 2;
|
||||
numericUpDownSpeed.Value = new decimal(new int[] { 100, 0, 0, 0 });
|
||||
//
|
||||
// labelWeight
|
||||
//
|
||||
labelWeight.AutoSize = true;
|
||||
labelWeight.Location = new Point(6, 77);
|
||||
labelWeight.Name = "labelWeight";
|
||||
labelWeight.Size = new Size(45, 15);
|
||||
labelWeight.TabIndex = 1;
|
||||
labelWeight.Text = "Weight";
|
||||
//
|
||||
// labelSpeed
|
||||
//
|
||||
labelSpeed.AutoSize = true;
|
||||
labelSpeed.Location = new Point(6, 19);
|
||||
labelSpeed.Name = "labelSpeed";
|
||||
labelSpeed.Size = new Size(39, 15);
|
||||
labelSpeed.TabIndex = 0;
|
||||
labelSpeed.Text = "Speed";
|
||||
//
|
||||
// FormCruiserConfig
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(684, 261);
|
||||
Controls.Add(groupBoxForTools);
|
||||
Name = "FormCruiserConfig";
|
||||
Text = "FormCruiserConfig";
|
||||
groupBoxForTools.ResumeLayout(false);
|
||||
groupBoxForTools.PerformLayout();
|
||||
panelToCruiser.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)pictureBoxToCruiser).EndInit();
|
||||
groupBoxColors.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownWeight).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private GroupBox groupBoxForTools;
|
||||
private Label labelWeight;
|
||||
private Label labelSpeed;
|
||||
private CheckBox checkBox3;
|
||||
private CheckBox checkBox2;
|
||||
private CheckBox checkBoxRockMines;
|
||||
private CheckBox checkBoxHelipad;
|
||||
private NumericUpDown numericUpDownWeight;
|
||||
private NumericUpDown numericUpDownSpeed;
|
||||
private GroupBox groupBoxColors;
|
||||
private Panel panelColorGold;
|
||||
private Panel panelColorCrimson;
|
||||
private Panel panelColorPlum;
|
||||
private Panel panelColorDodgerBlue;
|
||||
private Panel panelColorAquamarine;
|
||||
private Panel panelColorForestGreen;
|
||||
private Panel panelColorSienna;
|
||||
private Panel panelColorRed;
|
||||
private PictureBox pictureBoxToCruiser;
|
||||
private Label labelProCruiser;
|
||||
private Label labelCruiser;
|
||||
private Panel panelToCruiser;
|
||||
private Button buttonCancel;
|
||||
private Button buttonAddCruiser;
|
||||
private Label labelDopColor;
|
||||
private Label labelColor;
|
||||
}
|
||||
}
|
160
Cruiser/FormCruiserConfig.cs
Normal file
160
Cruiser/FormCruiserConfig.cs
Normal file
@ -0,0 +1,160 @@
|
||||
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 Cruiser.Drawing;
|
||||
|
||||
namespace Cruiser
|
||||
{
|
||||
public partial class FormCruiserConfig : Form
|
||||
{
|
||||
/// <summary>
|
||||
/// Переменная-выбранная лайнера
|
||||
/// </summary>
|
||||
DrawingCruiser? _cruiser = null;
|
||||
/// <summary>
|
||||
/// Событие
|
||||
/// </summary>
|
||||
private event Action<DrawingCruiser>? EventAddCruiser;
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
public FormCruiserConfig()
|
||||
{
|
||||
InitializeComponent();
|
||||
panelColorRed.MouseDown += panelColor_MouseDown;
|
||||
panelColorSienna.MouseDown += panelColor_MouseDown;
|
||||
panelColorForestGreen.MouseDown += panelColor_MouseDown;
|
||||
panelColorAquamarine.MouseDown += panelColor_MouseDown;
|
||||
panelColorCrimson.MouseDown += panelColor_MouseDown;
|
||||
panelColorDodgerBlue.MouseDown += panelColor_MouseDown;
|
||||
panelColorGold.MouseDown += panelColor_MouseDown;
|
||||
panelColorPlum.MouseDown += panelColor_MouseDown;
|
||||
buttonCancel.Click += (s, e) => Close();
|
||||
}
|
||||
/// <summary>
|
||||
/// Отрисовать лайнер
|
||||
/// </summary>
|
||||
private void DrawCruiser()
|
||||
{
|
||||
Bitmap bmp = new(pictureBoxToCruiser.Width, pictureBoxToCruiser.Height);
|
||||
Graphics gr = Graphics.FromImage(bmp);
|
||||
_cruiser?.SetPosition(15, 15);
|
||||
_cruiser?.DrawTransport(gr);
|
||||
pictureBoxToCruiser.Image = bmp;
|
||||
}
|
||||
/// Добавление события
|
||||
/// </summary>
|
||||
/// <param name="ev">Привязанный метод</param>
|
||||
public void AddEvent(Action<DrawingCruiser> ev)
|
||||
{
|
||||
if (EventAddCruiser == null)
|
||||
{
|
||||
EventAddCruiser = ev;
|
||||
}
|
||||
else
|
||||
{
|
||||
EventAddCruiser += ev;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Добавление лайнера
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void buttonAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
EventAddCruiser?.Invoke(_cruiser);
|
||||
Close();
|
||||
}
|
||||
/// <summary>
|
||||
/// Передаем информацию при нажатии на Label
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void LabelObject_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
(sender as Label)?.DoDragDrop((sender as Label)?.Name, DragDropEffects.Move | DragDropEffects.Copy);
|
||||
}
|
||||
/// <summary>
|
||||
/// Проверка получаемой информации (ее типа на соответствие требуемому)
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void PanelObject_DragEnter(object sender, DragEventArgs e)
|
||||
{
|
||||
if (e.Data?.GetDataPresent(DataFormats.Text) ?? false)
|
||||
{
|
||||
e.Effect = DragDropEffects.Copy;
|
||||
}
|
||||
else
|
||||
{
|
||||
e.Effect = DragDropEffects.None;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Действия при приеме перетаскиваемой информации
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void PanelObject_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
switch (e.Data?.GetData(DataFormats.Text).ToString())
|
||||
{
|
||||
case "labelCruiser":
|
||||
_cruiser = new DrawingCruiser((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value,
|
||||
Color.Orchid, Color.Black,
|
||||
pictureBoxToCruiser.Width,
|
||||
pictureBoxToCruiser.Height);
|
||||
break;
|
||||
case "labelProCruiser":
|
||||
_cruiser = new DrawingProCruiser((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value,
|
||||
Color.Orchid, Color.Black, Color.Aquamarine,
|
||||
checkBoxRockMines.Checked, checkBoxHelipad.Checked,
|
||||
pictureBoxToCruiser.Width,
|
||||
pictureBoxToCruiser.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 labelColor_DragEnter(object sender, DragEventArgs e)
|
||||
{
|
||||
if (e.Data?.GetDataPresent(typeof(Color)) ?? false)
|
||||
{
|
||||
e.Effect = DragDropEffects.Copy;
|
||||
}
|
||||
else
|
||||
{
|
||||
e.Effect = DragDropEffects.None;
|
||||
}
|
||||
}
|
||||
|
||||
private void labelColor_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
if (_cruiser == null)
|
||||
return;
|
||||
switch (((Label)sender).Name)
|
||||
{
|
||||
case "labelColor":
|
||||
_cruiser.setBodyColor((Color)e.Data.GetData(typeof(Color)));
|
||||
break;
|
||||
case "labelDopColor":
|
||||
if (!(_cruiser is DrawingProCruiser))
|
||||
return;
|
||||
(_cruiser as DrawingProCruiser).setElementColor((Color)e.Data.GetData(typeof(Color)));
|
||||
break;
|
||||
}
|
||||
DrawCruiser();
|
||||
}
|
||||
}
|
||||
}
|
123
Cruiser/FormCruiserConfig.resx
Normal file
123
Cruiser/FormCruiserConfig.resx
Normal file
@ -0,0 +1,123 @@
|
||||
<?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">
|
||||
<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>
|
||||
<metadata name="$this.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
</root>
|
@ -127,6 +127,8 @@ namespace Cruiser.Generics
|
||||
int i = 0;
|
||||
foreach (var cruiser in _collection.GetCruisers())
|
||||
{
|
||||
cruiser._pictureHeight = _pictureHeight;// добавил для починки отрисовки на форме коллекций
|
||||
cruiser._pictureWidth = _pictureWidth;// добавил для починки отрисовки на форме коллекций
|
||||
_collection[i]?.SetPosition(Ix, Iy);
|
||||
_collection[i]?.DrawTransport(g);
|
||||
Ix += _placeSizeWidth;
|
||||
|
Loading…
Reference in New Issue
Block a user