fix
This commit is contained in:
parent
339545f735
commit
ecffc2f002
@ -224,5 +224,20 @@ namespace WarmlyShip.DrawningObjects
|
||||
Point point_8 = new Point(_startPosX + 131, _startPosY + 35);
|
||||
g.DrawLine(pen, point_7, point_8);
|
||||
}
|
||||
|
||||
public void SetColor(Color color)
|
||||
{
|
||||
if (EntityShip == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
EntityShip.BodyColor = color;
|
||||
}
|
||||
|
||||
public void ChangePictureBoxSize(int pictureBoxWidth, int pictureBoxHeight)
|
||||
{
|
||||
_pictureWidth = pictureBoxWidth;
|
||||
_pictureHeight = pictureBoxHeight;
|
||||
}
|
||||
}
|
||||
}
|
@ -80,5 +80,10 @@ additionalColor, bool pipe, bool fuelCompartment, int width, int height) :
|
||||
g.DrawRectangle(pen, _startPosX + 70, _startPosY + 45, 20, 15);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetAddColor(Color color)
|
||||
{
|
||||
((EntityWarmlyShip)EntityShip).AdditionalColor = color;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -22,7 +22,7 @@ namespace WarmlyShip.Entities
|
||||
/// <summary>
|
||||
/// Основной цвет
|
||||
/// </summary>
|
||||
public Color BodyColor { get; private set; }
|
||||
public Color BodyColor { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Шаг перемещения корабля
|
||||
|
@ -14,7 +14,7 @@ namespace WarmlyShip.Entities
|
||||
/// <summary>
|
||||
/// Дополнительный цвет (для опциональных элементов)
|
||||
/// </summary>
|
||||
public Color AdditionalColor { get; private set; }
|
||||
public Color AdditionalColor { get; set; }
|
||||
/// <summary>
|
||||
/// Признак (опция) наличия труб
|
||||
/// </summary>
|
||||
|
@ -118,19 +118,24 @@ namespace WarmlyShip
|
||||
{
|
||||
return;
|
||||
}
|
||||
FormWarmlyShip form = new();
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
|
||||
FormShipConfig form = new();
|
||||
form.Show();
|
||||
Action<DrawningShip>? shipDelegate = new((m) =>
|
||||
{
|
||||
if (obj + form.SelectedShip)
|
||||
bool isAdditionSuccessful = (obj + m);
|
||||
if (isAdditionSuccessful)
|
||||
{
|
||||
MessageBox.Show("Объект добавлен");
|
||||
m.ChangePictureBoxSize(pictureBoxCollection.Width, pictureBoxCollection.Height);
|
||||
pictureBoxCollection.Image = obj.ShowShips();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Не удалось добавить объект");
|
||||
}
|
||||
}
|
||||
});
|
||||
form.AddEvent(shipDelegate);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
355
WarmlyShip/FormShipConfig.Designer.cs
generated
Normal file
355
WarmlyShip/FormShipConfig.Designer.cs
generated
Normal file
@ -0,0 +1,355 @@
|
||||
namespace WarmlyShip
|
||||
{
|
||||
partial class FormShipConfig
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
groupBoxParameters = new GroupBox();
|
||||
labelModifiedObject = new Label();
|
||||
labelSimpleObject = new Label();
|
||||
groupBoxColor = new GroupBox();
|
||||
panelPurple = new Panel();
|
||||
panelYellow = new Panel();
|
||||
panelBlack = new Panel();
|
||||
panelBlue = new Panel();
|
||||
panelGray = new Panel();
|
||||
panelGreen = new Panel();
|
||||
panelWhite = new Panel();
|
||||
panelRed = new Panel();
|
||||
checkBoxFuelCompartment = new CheckBox();
|
||||
checkBoxPipe = new CheckBox();
|
||||
numericUpDownWeight = new NumericUpDown();
|
||||
numericUpDownSpeed = new NumericUpDown();
|
||||
labelWeight = new Label();
|
||||
labelSpeed = new Label();
|
||||
panelObject = new Panel();
|
||||
pictureBoxObject = new PictureBox();
|
||||
labelExtraColor = new Label();
|
||||
labelColor = new Label();
|
||||
buttonAdd = new Button();
|
||||
buttonCancel = new Button();
|
||||
groupBoxParameters.SuspendLayout();
|
||||
groupBoxColor.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownWeight).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).BeginInit();
|
||||
panelObject.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBoxObject).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// groupBoxParameters
|
||||
//
|
||||
groupBoxParameters.Controls.Add(labelModifiedObject);
|
||||
groupBoxParameters.Controls.Add(labelSimpleObject);
|
||||
groupBoxParameters.Controls.Add(groupBoxColor);
|
||||
groupBoxParameters.Controls.Add(checkBoxFuelCompartment);
|
||||
groupBoxParameters.Controls.Add(checkBoxPipe);
|
||||
groupBoxParameters.Controls.Add(numericUpDownWeight);
|
||||
groupBoxParameters.Controls.Add(numericUpDownSpeed);
|
||||
groupBoxParameters.Controls.Add(labelWeight);
|
||||
groupBoxParameters.Controls.Add(labelSpeed);
|
||||
groupBoxParameters.Location = new Point(12, 12);
|
||||
groupBoxParameters.Name = "groupBoxParameters";
|
||||
groupBoxParameters.Size = new Size(407, 207);
|
||||
groupBoxParameters.TabIndex = 0;
|
||||
groupBoxParameters.TabStop = false;
|
||||
groupBoxParameters.Text = "Параметры";
|
||||
//
|
||||
// labelModifiedObject
|
||||
//
|
||||
labelModifiedObject.BorderStyle = BorderStyle.FixedSingle;
|
||||
labelModifiedObject.Location = new Point(309, 150);
|
||||
labelModifiedObject.Name = "labelModifiedObject";
|
||||
labelModifiedObject.Size = new Size(88, 30);
|
||||
labelModifiedObject.TabIndex = 8;
|
||||
labelModifiedObject.Text = "Продвинутый";
|
||||
labelModifiedObject.TextAlign = ContentAlignment.MiddleCenter;
|
||||
//
|
||||
// labelSimpleObject
|
||||
//
|
||||
labelSimpleObject.BorderStyle = BorderStyle.FixedSingle;
|
||||
labelSimpleObject.Location = new Point(215, 150);
|
||||
labelSimpleObject.Name = "labelSimpleObject";
|
||||
labelSimpleObject.Size = new Size(88, 30);
|
||||
labelSimpleObject.TabIndex = 7;
|
||||
labelSimpleObject.Text = "Простой";
|
||||
labelSimpleObject.TextAlign = ContentAlignment.MiddleCenter;
|
||||
//
|
||||
// groupBoxColor
|
||||
//
|
||||
groupBoxColor.Controls.Add(panelPurple);
|
||||
groupBoxColor.Controls.Add(panelYellow);
|
||||
groupBoxColor.Controls.Add(panelBlack);
|
||||
groupBoxColor.Controls.Add(panelBlue);
|
||||
groupBoxColor.Controls.Add(panelGray);
|
||||
groupBoxColor.Controls.Add(panelGreen);
|
||||
groupBoxColor.Controls.Add(panelWhite);
|
||||
groupBoxColor.Controls.Add(panelRed);
|
||||
groupBoxColor.Location = new Point(215, 22);
|
||||
groupBoxColor.Name = "groupBoxColor";
|
||||
groupBoxColor.Size = new Size(183, 115);
|
||||
groupBoxColor.TabIndex = 6;
|
||||
groupBoxColor.TabStop = false;
|
||||
groupBoxColor.Text = "Цвета";
|
||||
//
|
||||
// panelPurple
|
||||
//
|
||||
panelPurple.BackColor = Color.Purple;
|
||||
panelPurple.Location = new Point(138, 66);
|
||||
panelPurple.Name = "panelPurple";
|
||||
panelPurple.Size = new Size(38, 38);
|
||||
panelPurple.TabIndex = 5;
|
||||
//
|
||||
// panelYellow
|
||||
//
|
||||
panelYellow.BackColor = Color.Yellow;
|
||||
panelYellow.Location = new Point(138, 22);
|
||||
panelYellow.Name = "panelYellow";
|
||||
panelYellow.Size = new Size(38, 38);
|
||||
panelYellow.TabIndex = 4;
|
||||
//
|
||||
// panelBlack
|
||||
//
|
||||
panelBlack.BackColor = Color.Black;
|
||||
panelBlack.Location = new Point(94, 66);
|
||||
panelBlack.Name = "panelBlack";
|
||||
panelBlack.Size = new Size(38, 38);
|
||||
panelBlack.TabIndex = 3;
|
||||
//
|
||||
// panelBlue
|
||||
//
|
||||
panelBlue.BackColor = Color.Blue;
|
||||
panelBlue.Location = new Point(94, 22);
|
||||
panelBlue.Name = "panelBlue";
|
||||
panelBlue.Size = new Size(38, 38);
|
||||
panelBlue.TabIndex = 2;
|
||||
//
|
||||
// panelGray
|
||||
//
|
||||
panelGray.BackColor = Color.Gray;
|
||||
panelGray.Location = new Point(50, 66);
|
||||
panelGray.Name = "panelGray";
|
||||
panelGray.Size = new Size(38, 38);
|
||||
panelGray.TabIndex = 1;
|
||||
//
|
||||
// panelGreen
|
||||
//
|
||||
panelGreen.BackColor = Color.Green;
|
||||
panelGreen.Location = new Point(50, 22);
|
||||
panelGreen.Name = "panelGreen";
|
||||
panelGreen.Size = new Size(38, 38);
|
||||
panelGreen.TabIndex = 0;
|
||||
//
|
||||
// panelWhite
|
||||
//
|
||||
panelWhite.BackColor = Color.White;
|
||||
panelWhite.Location = new Point(6, 66);
|
||||
panelWhite.Name = "panelWhite";
|
||||
panelWhite.Size = new Size(38, 38);
|
||||
panelWhite.TabIndex = 0;
|
||||
//
|
||||
// panelRed
|
||||
//
|
||||
panelRed.BackColor = Color.Red;
|
||||
panelRed.Location = new Point(6, 22);
|
||||
panelRed.Name = "panelRed";
|
||||
panelRed.Size = new Size(38, 38);
|
||||
panelRed.TabIndex = 0;
|
||||
//
|
||||
// checkBoxFuelCompartment
|
||||
//
|
||||
checkBoxFuelCompartment.AutoSize = true;
|
||||
checkBoxFuelCompartment.Location = new Point(6, 138);
|
||||
checkBoxFuelCompartment.Name = "checkBoxFuelCompartment";
|
||||
checkBoxFuelCompartment.Size = new Size(186, 19);
|
||||
checkBoxFuelCompartment.TabIndex = 5;
|
||||
checkBoxFuelCompartment.Text = "Наличие отсека под топливо";
|
||||
checkBoxFuelCompartment.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// checkBoxPipe
|
||||
//
|
||||
checkBoxPipe.AutoSize = true;
|
||||
checkBoxPipe.Location = new Point(6, 102);
|
||||
checkBoxPipe.Name = "checkBoxPipe";
|
||||
checkBoxPipe.Size = new Size(103, 19);
|
||||
checkBoxPipe.TabIndex = 4;
|
||||
checkBoxPipe.Text = "Наличие труб";
|
||||
checkBoxPipe.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// numericUpDownWeight
|
||||
//
|
||||
numericUpDownWeight.Location = new Point(76, 61);
|
||||
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(74, 23);
|
||||
numericUpDownWeight.TabIndex = 3;
|
||||
numericUpDownWeight.Value = new decimal(new int[] { 100, 0, 0, 0 });
|
||||
//
|
||||
// numericUpDownSpeed
|
||||
//
|
||||
numericUpDownSpeed.Location = new Point(76, 27);
|
||||
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(74, 23);
|
||||
numericUpDownSpeed.TabIndex = 2;
|
||||
numericUpDownSpeed.Value = new decimal(new int[] { 100, 0, 0, 0 });
|
||||
//
|
||||
// labelWeight
|
||||
//
|
||||
labelWeight.AutoSize = true;
|
||||
labelWeight.Location = new Point(6, 63);
|
||||
labelWeight.Name = "labelWeight";
|
||||
labelWeight.Size = new Size(29, 15);
|
||||
labelWeight.TabIndex = 1;
|
||||
labelWeight.Text = "Вес:";
|
||||
//
|
||||
// labelSpeed
|
||||
//
|
||||
labelSpeed.AutoSize = true;
|
||||
labelSpeed.Location = new Point(6, 29);
|
||||
labelSpeed.Name = "labelSpeed";
|
||||
labelSpeed.Size = new Size(62, 15);
|
||||
labelSpeed.TabIndex = 0;
|
||||
labelSpeed.Text = "Скорость:";
|
||||
//
|
||||
// panelObject
|
||||
//
|
||||
panelObject.AllowDrop = true;
|
||||
panelObject.Controls.Add(pictureBoxObject);
|
||||
panelObject.Controls.Add(labelExtraColor);
|
||||
panelObject.Controls.Add(labelColor);
|
||||
panelObject.Location = new Point(434, 12);
|
||||
panelObject.Name = "panelObject";
|
||||
panelObject.Size = new Size(345, 217);
|
||||
panelObject.TabIndex = 2;
|
||||
panelObject.DragDrop += new System.Windows.Forms.DragEventHandler(this.PanelObject_DragDrop);
|
||||
panelObject.DragEnter += new System.Windows.Forms.DragEventHandler(this.PanelObject_DragEnter);
|
||||
//
|
||||
// pictureBoxObject
|
||||
//
|
||||
pictureBoxObject.Location = new Point(7, 40);
|
||||
pictureBoxObject.Name = "pictureBoxObject";
|
||||
pictureBoxObject.Size = new Size(331, 167);
|
||||
pictureBoxObject.TabIndex = 0;
|
||||
pictureBoxObject.TabStop = false;
|
||||
//
|
||||
// labelExtraColor
|
||||
//
|
||||
labelExtraColor.AllowDrop = true;
|
||||
labelExtraColor.BorderStyle = BorderStyle.FixedSingle;
|
||||
labelExtraColor.Location = new Point(215, 7);
|
||||
labelExtraColor.Name = "labelExtraColor";
|
||||
labelExtraColor.Size = new Size(89, 30);
|
||||
labelExtraColor.TabIndex = 2;
|
||||
labelExtraColor.Text = "Доп. цвет";
|
||||
labelExtraColor.TextAlign = ContentAlignment.MiddleCenter;
|
||||
labelExtraColor.DragDrop += new System.Windows.Forms.DragEventHandler(this.LabelDopColor_DragDrop);
|
||||
labelExtraColor.DragEnter += new System.Windows.Forms.DragEventHandler(this.LabelColor_DragEnter);
|
||||
//
|
||||
// labelColor
|
||||
//
|
||||
labelColor.AllowDrop = true;
|
||||
labelColor.BorderStyle = BorderStyle.FixedSingle;
|
||||
labelColor.Location = new Point(44, 7);
|
||||
labelColor.Name = "labelColor";
|
||||
labelColor.Size = new Size(89, 30);
|
||||
labelColor.TabIndex = 1;
|
||||
labelColor.Text = "Цвет";
|
||||
labelColor.TextAlign = ContentAlignment.MiddleCenter;
|
||||
labelColor.DragDrop += new System.Windows.Forms.DragEventHandler(this.LabelColor_DragDrop);
|
||||
labelColor.DragEnter += new System.Windows.Forms.DragEventHandler(this.LabelColor_DragEnter);
|
||||
//
|
||||
// buttonAdd
|
||||
//
|
||||
buttonAdd.Location = new Point(478, 235);
|
||||
buttonAdd.Name = "buttonAdd";
|
||||
buttonAdd.Size = new Size(89, 32);
|
||||
buttonAdd.TabIndex = 3;
|
||||
buttonAdd.Text = "Добавить";
|
||||
buttonAdd.UseVisualStyleBackColor = true;
|
||||
buttonAdd.UseVisualStyleBackColor = true;
|
||||
buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click);
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
buttonCancel.Location = new Point(649, 235);
|
||||
buttonCancel.Name = "buttonCancel";
|
||||
buttonCancel.Size = new Size(89, 32);
|
||||
buttonCancel.TabIndex = 4;
|
||||
buttonCancel.Text = "Отмена";
|
||||
buttonCancel.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// FormShipConfig
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(791, 279);
|
||||
Controls.Add(buttonCancel);
|
||||
Controls.Add(buttonAdd);
|
||||
Controls.Add(panelObject);
|
||||
Controls.Add(groupBoxParameters);
|
||||
Name = "FormShipConfig";
|
||||
Text = "Создание объекта";
|
||||
groupBoxParameters.ResumeLayout(false);
|
||||
groupBoxParameters.PerformLayout();
|
||||
groupBoxColor.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownWeight).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).EndInit();
|
||||
panelObject.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)pictureBoxObject).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private GroupBox groupBoxParameters;
|
||||
private Label labelWeight;
|
||||
private Label labelSpeed;
|
||||
private NumericUpDown numericUpDownWeight;
|
||||
private NumericUpDown numericUpDownSpeed;
|
||||
private CheckBox checkBoxFuelCompartment;
|
||||
private CheckBox checkBoxPipe;
|
||||
private GroupBox groupBoxColor;
|
||||
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 labelModifiedObject;
|
||||
private Label labelSimpleObject;
|
||||
private Panel panelObject;
|
||||
private Button buttonAdd;
|
||||
private Button buttonCancel;
|
||||
private PictureBox pictureBoxObject;
|
||||
private Label labelExtraColor;
|
||||
private Label labelColor;
|
||||
}
|
||||
}
|
198
WarmlyShip/FormShipConfig.cs
Normal file
198
WarmlyShip/FormShipConfig.cs
Normal file
@ -0,0 +1,198 @@
|
||||
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 System.Windows.Forms.VisualStyles;
|
||||
using WarmlyShip.DrawningObjects;
|
||||
|
||||
namespace WarmlyShip
|
||||
{
|
||||
/// <summary>
|
||||
/// Форма создания объекта
|
||||
/// </summary>
|
||||
public partial class FormShipConfig : Form
|
||||
{
|
||||
/// <summary>
|
||||
/// Переменная-выбранный корабль
|
||||
/// </summary>
|
||||
DrawningShip? _ship = null;
|
||||
|
||||
/// <summary>
|
||||
/// Событие
|
||||
/// </summary>
|
||||
private event Action<DrawningShip>? EventAddShip;
|
||||
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
public FormShipConfig()
|
||||
{
|
||||
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;
|
||||
labelSimpleObject.MouseDown += LabelObject_MouseDown;
|
||||
labelModifiedObject.MouseDown += LabelObject_MouseDown;
|
||||
buttonCancel.Click += (s, e) => Close();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Отрисовать корабль
|
||||
/// </summary>
|
||||
private void DrawShip()
|
||||
{
|
||||
Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height);
|
||||
Graphics gr = Graphics.FromImage(bmp);
|
||||
_ship?.SetPosition(5, 5);
|
||||
_ship?.DrawTransport(gr);
|
||||
pictureBoxObject.Image = bmp;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Добавление события
|
||||
/// </summary>
|
||||
/// <param name="ev">Привязанный метод</param>
|
||||
public void AddEvent(Action<DrawningShip> ev)
|
||||
{
|
||||
if (EventAddShip == null)
|
||||
{
|
||||
EventAddShip = ev;
|
||||
}
|
||||
else
|
||||
{
|
||||
EventAddShip += ev;
|
||||
}
|
||||
}
|
||||
|
||||
/// <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 "labelSimpleObject":
|
||||
_ship = new DrawningShip((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value,
|
||||
Color.White, pictureBoxObject.Width, pictureBoxObject.Height);
|
||||
break;
|
||||
case "labelModifiedObject":
|
||||
_ship = new DrawningWarmlyShip((int)numericUpDownSpeed.Value, (int)numericUpDownWeight.Value,
|
||||
Color.White, Color.Black, checkBoxPipe.Checked, checkBoxFuelCompartment.Checked,
|
||||
pictureBoxObject.Width, pictureBoxObject.Height);
|
||||
break;
|
||||
}
|
||||
labelColor.BackColor = Color.Empty;
|
||||
labelExtraColor.BackColor = Color.Empty;
|
||||
DrawShip();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Отправляем цвет с панели
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void PanelColor_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
(sender as Control)?.DoDragDrop((sender as Control)?.BackColor, DragDropEffects.Move | DragDropEffects.Copy);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Принимаем основной цвет
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void LabelColor_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
if (_ship == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
labelColor.BackColor = (Color)e.Data.GetData(typeof(Color));
|
||||
_ship.SetColor(labelColor.BackColor);
|
||||
DrawShip();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Проверка получаемой информации (ее типа на соответствие требуемому)
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void LabelColor_DragEnter(object sender, DragEventArgs e)
|
||||
{
|
||||
if (e.Data.GetDataPresent(typeof(Color)))
|
||||
{
|
||||
e.Effect = DragDropEffects.Copy;
|
||||
}
|
||||
else
|
||||
{
|
||||
e.Effect = DragDropEffects.None;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Принимаем дополнительный цвет
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void LabelDopColor_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
if ((_ship == null) || (_ship is DrawningWarmlyShip == false))
|
||||
{
|
||||
return;
|
||||
}
|
||||
labelExtraColor.BackColor = (Color)e.Data.GetData(typeof(Color));
|
||||
((DrawningWarmlyShip)_ship).SetAddColor(labelExtraColor.BackColor);
|
||||
DrawShip();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Добавление корабля
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
EventAddShip?.Invoke(_ship);
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
120
WarmlyShip/FormShipConfig.resx
Normal file
120
WarmlyShip/FormShipConfig.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?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>
|
||||
</root>
|
Loading…
x
Reference in New Issue
Block a user