Pibd22_NikiforovaMV_lab5 #5

Closed
Michelty wants to merge 1 commits from lab5 into lab4
11 changed files with 684 additions and 42 deletions

View File

@ -119,5 +119,11 @@ namespace ContainerShip.DrawningObjects
}
public IMoveableObject GetMoveableObject => new DrawingObjectShip(this);
public void ChangeBordersPicture(int width, int height)
{
_pictureWidth = width;
_pictureHeight = height;
}
}
}

View File

@ -20,6 +20,10 @@ namespace ContainerShip.Entities
Load = load;
Crane = crane;
}
public void ChangeAdditionalColor(Color additionalColor)
{
AdditionalColor = additionalColor;
}
}
}

View File

@ -18,5 +18,10 @@ namespace ContainerShip.Entities
Weight = weight;
BodyColor = bodyColor;
}
public void ChangeBodyColor(Color color)
{
BodyColor = color;
}
}
}

View File

@ -44,9 +44,10 @@
//
// buttonAdd
//
buttonAdd.Location = new Point(647, 305);
buttonAdd.Location = new Point(739, 407);
buttonAdd.Margin = new Padding(3, 4, 3, 4);
buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(144, 24);
buttonAdd.Size = new Size(165, 32);
buttonAdd.TabIndex = 0;
buttonAdd.Text = "Добавить корабль";
buttonAdd.UseVisualStyleBackColor = true;
@ -54,9 +55,10 @@
//
// buttonDelete
//
buttonDelete.Location = new Point(645, 362);
buttonDelete.Location = new Point(737, 482);
buttonDelete.Margin = new Padding(3, 4, 3, 4);
buttonDelete.Name = "buttonDelete";
buttonDelete.Size = new Size(143, 24);
buttonDelete.Size = new Size(163, 32);
buttonDelete.TabIndex = 1;
buttonDelete.Text = "Удалить корабль";
buttonDelete.UseVisualStyleBackColor = true;
@ -65,59 +67,62 @@
// labelTools
//
labelTools.AutoSize = true;
labelTools.Location = new Point(677, 9);
labelTools.Location = new Point(774, 12);
labelTools.Name = "labelTools";
labelTools.Size = new Size(83, 15);
labelTools.Size = new Size(103, 20);
labelTools.TabIndex = 3;
labelTools.Text = "Инструменты";
//
// maskedTextBoxNumber
//
maskedTextBoxNumber.Location = new Point(645, 335);
maskedTextBoxNumber.Location = new Point(737, 447);
maskedTextBoxNumber.Margin = new Padding(3, 4, 3, 4);
maskedTextBoxNumber.Name = "maskedTextBoxNumber";
maskedTextBoxNumber.Size = new Size(142, 23);
maskedTextBoxNumber.Size = new Size(162, 27);
maskedTextBoxNumber.TabIndex = 4;
//
// pictureBoxCollection
//
pictureBoxCollection.Location = new Point(0, 0);
pictureBoxCollection.Margin = new Padding(3, 4, 3, 4);
pictureBoxCollection.Name = "pictureBoxCollection";
pictureBoxCollection.Size = new Size(640, 386);
pictureBoxCollection.Size = new Size(731, 609);
pictureBoxCollection.TabIndex = 5;
pictureBoxCollection.TabStop = false;
//
// labelSet
//
labelSet.AutoSize = true;
labelSet.Location = new Point(654, 31);
labelSet.Location = new Point(748, 41);
labelSet.Name = "labelSet";
labelSet.Size = new Size(43, 15);
labelSet.Size = new Size(55, 20);
labelSet.TabIndex = 6;
labelSet.Text = "Набор";
//
// textBoxStorageName
//
textBoxStorageName.Location = new Point(647, 49);
textBoxStorageName.Location = new Point(739, 65);
textBoxStorageName.Margin = new Padding(3, 4, 3, 4);
textBoxStorageName.Name = "textBoxStorageName";
textBoxStorageName.Size = new Size(142, 23);
textBoxStorageName.Size = new Size(162, 27);
textBoxStorageName.TabIndex = 7;
//
// listBoxStorages
//
listBoxStorages.FormattingEnabled = true;
listBoxStorages.ItemHeight = 15;
listBoxStorages.Location = new Point(647, 134);
listBoxStorages.Margin = new Padding(3, 2, 3, 2);
listBoxStorages.ItemHeight = 20;
listBoxStorages.Location = new Point(739, 179);
listBoxStorages.Name = "listBoxStorages";
listBoxStorages.Size = new Size(145, 94);
listBoxStorages.Size = new Size(165, 124);
listBoxStorages.TabIndex = 8;
listBoxStorages.SelectedIndexChanged += buttonUpdate_Click;
//
// buttonAddStorage
//
buttonAddStorage.Location = new Point(647, 75);
buttonAddStorage.Location = new Point(739, 100);
buttonAddStorage.Margin = new Padding(3, 4, 3, 4);
buttonAddStorage.Name = "buttonAddStorage";
buttonAddStorage.Size = new Size(144, 24);
buttonAddStorage.Size = new Size(165, 32);
buttonAddStorage.TabIndex = 9;
buttonAddStorage.Text = "Добавить набор";
buttonAddStorage.UseVisualStyleBackColor = true;
@ -125,9 +130,10 @@
//
// buttonDeleteStorage
//
buttonDeleteStorage.Location = new Point(647, 242);
buttonDeleteStorage.Location = new Point(739, 322);
buttonDeleteStorage.Margin = new Padding(3, 4, 3, 4);
buttonDeleteStorage.Name = "buttonDeleteStorage";
buttonDeleteStorage.Size = new Size(144, 24);
buttonDeleteStorage.Size = new Size(165, 32);
buttonDeleteStorage.TabIndex = 11;
buttonDeleteStorage.Text = "Удалить набор";
buttonDeleteStorage.UseVisualStyleBackColor = true;
@ -135,9 +141,10 @@
//
// buttonUpdate
//
buttonUpdate.Location = new Point(647, 105);
buttonUpdate.Location = new Point(739, 140);
buttonUpdate.Margin = new Padding(3, 4, 3, 4);
buttonUpdate.Name = "buttonUpdate";
buttonUpdate.Size = new Size(143, 24);
buttonUpdate.Size = new Size(163, 32);
buttonUpdate.TabIndex = 2;
buttonUpdate.Text = "Обновить набор";
buttonUpdate.UseVisualStyleBackColor = true;
@ -145,9 +152,9 @@
//
// FormShipCollection
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 393);
ClientSize = new Size(914, 600);
Controls.Add(buttonDeleteStorage);
Controls.Add(buttonAddStorage);
Controls.Add(listBoxStorages);
@ -159,6 +166,7 @@
Controls.Add(buttonUpdate);
Controls.Add(buttonDelete);
Controls.Add(buttonAdd);
Margin = new Padding(3, 4, 3, 4);
Name = "FormShipCollection";
Text = "Набор кораблей";
((System.ComponentModel.ISupportInitialize)pictureBoxCollection).EndInit();

View File

@ -67,9 +67,18 @@ namespace ContainerShip
}
}
private void buttonAdd_Click(object sender, EventArgs e)
{
var formShipConfig = new FormShipConfig();
formShipConfig.AddEvent(AddShip);
formShipConfig.Show();
}
private void AddShip(DrawningShip selectedShip)
{
if (listBoxStorages.SelectedIndex == -1)
{
MessageBox.Show("Не выбран набор");
return;
}
var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? string.Empty];
@ -77,20 +86,16 @@ namespace ContainerShip
{
return;
}
FormShips form = new();
if (form.ShowDialog() == DialogResult.OK)
selectedShip.ChangeBordersPicture(pictureBoxCollection.Width, pictureBoxCollection.Height);
if (obj + selectedShip != -1)
{
if (obj + form.SelectedShip != -1)
{
MessageBox.Show("Объект добавлен");
pictureBoxCollection.Image = obj.ShowShips();
}
else
{
MessageBox.Show("Не удалось добавить объект");
}
MessageBox.Show("Объект добавлен");
pictureBoxCollection.Image = obj.ShowShips();
}
else
{
MessageBox.Show("Не удалось добавить объект");
}
}
private void buttonDelete_Click(object sender, EventArgs e)
{
@ -135,6 +140,5 @@ namespace ContainerShip
}
pictureBoxCollection.Image = obj.ShowShips();
}
}
}

View File

@ -18,7 +18,7 @@
<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="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>

357
ContainerShip/FormShipConfig.Designer.cs generated Normal file
View File

@ -0,0 +1,357 @@
namespace ContainerShip
{
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()
{
groupBoxConfig = new GroupBox();
labelAdvancedObject = new Label();
labelSimpleObject = new Label();
groupBoxColor = new GroupBox();
panelBlue = new Panel();
panelBlack = new Panel();
panelPink = new Panel();
panelGray = new Panel();
panelGreen = new Panel();
panelYellow = new Panel();
panelRoyalBlue = new Panel();
panelFirebrick = new Panel();
checkBoxCrane = new CheckBox();
checkBoxLoad = new CheckBox();
numericUpDownSpeed = new NumericUpDown();
numericUpDownWeight = new NumericUpDown();
labelWeight = new Label();
labelSpeed = new Label();
panelObject = new Panel();
labelAdditionalColor = new Label();
labelMainColor = new Label();
pictureBoxObject = new PictureBox();
buttonCancel = new Button();
buttonAdd = new Button();
groupBoxConfig.SuspendLayout();
groupBoxColor.SuspendLayout();
((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).BeginInit();
((System.ComponentModel.ISupportInitialize)numericUpDownWeight).BeginInit();
panelObject.SuspendLayout();
((System.ComponentModel.ISupportInitialize)pictureBoxObject).BeginInit();
SuspendLayout();
//
// groupBoxConfig
//
groupBoxConfig.Controls.Add(labelAdvancedObject);
groupBoxConfig.Controls.Add(labelSimpleObject);
groupBoxConfig.Controls.Add(groupBoxColor);
groupBoxConfig.Controls.Add(checkBoxCrane);
groupBoxConfig.Controls.Add(checkBoxLoad);
groupBoxConfig.Controls.Add(numericUpDownSpeed);
groupBoxConfig.Controls.Add(numericUpDownWeight);
groupBoxConfig.Controls.Add(labelWeight);
groupBoxConfig.Controls.Add(labelSpeed);
groupBoxConfig.Location = new Point(47, 93);
groupBoxConfig.Name = "groupBoxConfig";
groupBoxConfig.Size = new Size(570, 251);
groupBoxConfig.TabIndex = 3;
groupBoxConfig.TabStop = false;
groupBoxConfig.Text = "Параметры";
//
// labelAdvancedObject
//
labelAdvancedObject.BorderStyle = BorderStyle.FixedSingle;
labelAdvancedObject.Location = new Point(440, 188);
labelAdvancedObject.Name = "labelAdvancedObject";
labelAdvancedObject.Size = new Size(120, 30);
labelAdvancedObject.TabIndex = 8;
labelAdvancedObject.Text = "Продвинутый";
labelAdvancedObject.TextAlign = ContentAlignment.MiddleCenter;
labelAdvancedObject.MouseDown += LabelObject_MouseDown;
//
// labelSimpleObject
//
labelSimpleObject.BorderStyle = BorderStyle.FixedSingle;
labelSimpleObject.Location = new Point(283, 188);
labelSimpleObject.Name = "labelSimpleObject";
labelSimpleObject.Size = new Size(120, 30);
labelSimpleObject.TabIndex = 7;
labelSimpleObject.Text = "Простой";
labelSimpleObject.TextAlign = ContentAlignment.MiddleCenter;
labelSimpleObject.MouseDown += LabelObject_MouseDown;
//
// groupBoxColor
//
groupBoxColor.Controls.Add(panelBlue);
groupBoxColor.Controls.Add(panelBlack);
groupBoxColor.Controls.Add(panelPink);
groupBoxColor.Controls.Add(panelGray);
groupBoxColor.Controls.Add(panelGreen);
groupBoxColor.Controls.Add(panelYellow);
groupBoxColor.Controls.Add(panelRoyalBlue);
groupBoxColor.Controls.Add(panelFirebrick);
groupBoxColor.Location = new Point(283, 32);
groupBoxColor.Name = "groupBoxColor";
groupBoxColor.Size = new Size(277, 145);
groupBoxColor.TabIndex = 6;
groupBoxColor.TabStop = false;
groupBoxColor.Text = "Цвета";
//
// panelBlue
//
panelBlue.BackColor = Color.Blue;
panelBlue.Location = new Point(5, 85);
panelBlue.Name = "panelBlue";
panelBlue.Size = new Size(50, 40);
panelBlue.TabIndex = 0;
//
// panelBlack
//
panelBlack.BackColor = Color.Black;
panelBlack.Location = new Point(75, 85);
panelBlack.Name = "panelBlack";
panelBlack.Size = new Size(50, 40);
panelBlack.TabIndex = 0;
//
// panelPink
//
panelPink.BackColor = Color.DeepPink;
panelPink.Location = new Point(145, 85);
panelPink.Name = "panelPink";
panelPink.Size = new Size(50, 40);
panelPink.TabIndex = 0;
//
// panelGray
//
panelGray.BackColor = Color.Gray;
panelGray.Location = new Point(215, 85);
panelGray.Name = "panelGray";
panelGray.Size = new Size(50, 40);
panelGray.TabIndex = 0;
//
// panelGreen
//
panelGreen.BackColor = Color.FromArgb(0, 192, 0);
panelGreen.Location = new Point(215, 25);
panelGreen.Name = "panelGreen";
panelGreen.Size = new Size(50, 40);
panelGreen.TabIndex = 0;
//
// panelYellow
//
panelYellow.BackColor = Color.Yellow;
panelYellow.Location = new Point(145, 25);
panelYellow.Name = "panelYellow";
panelYellow.Size = new Size(50, 40);
panelYellow.TabIndex = 0;
//
// panelRoyalBlue
//
panelRoyalBlue.BackColor = Color.RoyalBlue;
panelRoyalBlue.Location = new Point(75, 25);
panelRoyalBlue.Name = "panelRoyalBlue";
panelRoyalBlue.Size = new Size(50, 40);
panelRoyalBlue.TabIndex = 0;
//
// panelFirebrick
//
panelFirebrick.BackColor = Color.Firebrick;
panelFirebrick.Location = new Point(5, 25);
panelFirebrick.Name = "panelFirebrick";
panelFirebrick.Size = new Size(50, 40);
panelFirebrick.TabIndex = 0;
//
// checkBoxCrane
//
checkBoxCrane.AutoSize = true;
checkBoxCrane.Location = new Point(13, 149);
checkBoxCrane.Name = "checkBoxCrane";
checkBoxCrane.Size = new Size(137, 24);
checkBoxCrane.TabIndex = 5;
checkBoxCrane.Text = "Наличие крана";
checkBoxCrane.UseVisualStyleBackColor = true;
//
// checkBoxLoad
//
checkBoxLoad.AutoSize = true;
checkBoxLoad.Location = new Point(13, 119);
checkBoxLoad.Name = "checkBoxLoad";
checkBoxLoad.Size = new Size(133, 24);
checkBoxLoad.TabIndex = 4;
checkBoxLoad.Text = "Наличие груза";
checkBoxLoad.UseVisualStyleBackColor = true;
//
// numericUpDownSpeed
//
numericUpDownSpeed.Location = new Point(94, 32);
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(150, 27);
numericUpDownSpeed.TabIndex = 3;
numericUpDownSpeed.Value = new decimal(new int[] { 100, 0, 0, 0 });
//
// numericUpDownWeight
//
numericUpDownWeight.Location = new Point(94, 83);
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(150, 27);
numericUpDownWeight.TabIndex = 2;
numericUpDownWeight.Value = new decimal(new int[] { 100, 0, 0, 0 });
//
// labelWeight
//
labelWeight.AutoSize = true;
labelWeight.Location = new Point(6, 85);
labelWeight.Name = "labelWeight";
labelWeight.Size = new Size(36, 20);
labelWeight.TabIndex = 1;
labelWeight.Text = "Вес:";
//
// labelSpeed
//
labelSpeed.AutoSize = true;
labelSpeed.Location = new Point(6, 32);
labelSpeed.Name = "labelSpeed";
labelSpeed.Size = new Size(76, 20);
labelSpeed.TabIndex = 0;
labelSpeed.Text = "Скорость:";
//
// panelObject
//
panelObject.AllowDrop = true;
panelObject.Controls.Add(labelAdditionalColor);
panelObject.Controls.Add(labelMainColor);
panelObject.Controls.Add(pictureBoxObject);
panelObject.Location = new Point(646, 74);
panelObject.Name = "panelObject";
panelObject.Size = new Size(401, 301);
panelObject.TabIndex = 4;
panelObject.DragDrop += PanelObject_DragDrop;
panelObject.DragEnter += PanelObject_DragEnter;
//
// labelAdditionalColor
//
labelAdditionalColor.AllowDrop = true;
labelAdditionalColor.BorderStyle = BorderStyle.FixedSingle;
labelAdditionalColor.Location = new Point(233, 19);
labelAdditionalColor.Name = "labelAdditionalColor";
labelAdditionalColor.Size = new Size(90, 50);
labelAdditionalColor.TabIndex = 3;
labelAdditionalColor.Text = "Доп. цвет";
labelAdditionalColor.TextAlign = ContentAlignment.MiddleCenter;
labelAdditionalColor.DragDrop += LabelAdditionalColor_DragDrop;
labelAdditionalColor.DragEnter += LabelColor_DragEnter;
//
// labelMainColor
//
labelMainColor.AllowDrop = true;
labelMainColor.BorderStyle = BorderStyle.FixedSingle;
labelMainColor.Location = new Point(77, 19);
labelMainColor.Name = "labelMainColor";
labelMainColor.Size = new Size(90, 50);
labelMainColor.TabIndex = 2;
labelMainColor.Text = "Цвет";
labelMainColor.TextAlign = ContentAlignment.MiddleCenter;
labelMainColor.DragDrop += LabelMainColor_DragDrop;
labelMainColor.DragEnter += LabelMainColor_DragEnter;
//
// pictureBoxObject
//
pictureBoxObject.BorderStyle = BorderStyle.FixedSingle;
pictureBoxObject.Location = new Point(35, 84);
pictureBoxObject.Name = "pictureBoxObject";
pictureBoxObject.Size = new Size(327, 205);
pictureBoxObject.TabIndex = 1;
pictureBoxObject.TabStop = false;
//
// buttonCancel
//
buttonCancel.Location = new Point(879, 394);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(94, 29);
buttonCancel.TabIndex = 6;
buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true;
//
// buttonAdd
//
buttonAdd.Location = new Point(722, 392);
buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(94, 29);
buttonAdd.TabIndex = 5;
buttonAdd.Text = "Добавить";
buttonAdd.UseVisualStyleBackColor = true;
buttonAdd.Click += ButtonAdd_Click;
//
// FormShipConfig
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(1095, 449);
Controls.Add(buttonCancel);
Controls.Add(buttonAdd);
Controls.Add(groupBoxConfig);
Controls.Add(panelObject);
Name = "FormShipConfig";
Text = "FormShipConfig";
groupBoxConfig.ResumeLayout(false);
groupBoxConfig.PerformLayout();
groupBoxColor.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).EndInit();
((System.ComponentModel.ISupportInitialize)numericUpDownWeight).EndInit();
panelObject.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)pictureBoxObject).EndInit();
ResumeLayout(false);
}
#endregion
private GroupBox groupBoxConfig;
private Label labelAdvancedObject;
private Label labelSimpleObject;
private GroupBox groupBoxColor;
private Panel panelBlue;
private Panel panelBlack;
private Panel panelPink;
private Panel panelGray;
private Panel panelGreen;
private Panel panelYellow;
private Panel panelRoyalBlue;
private Panel panelFirebrick;
private CheckBox checkBoxCrane;
private CheckBox checkBoxLoad;
private NumericUpDown numericUpDownSpeed;
private NumericUpDown numericUpDownWeight;
private Label labelWeight;
private Label labelSpeed;
private Panel panelObject;
private Label labelAdditionalColor;
private Label labelMainColor;
private PictureBox pictureBoxObject;
private Button buttonCancel;
private Button buttonAdd;
}
}

View File

@ -0,0 +1,139 @@
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 ContainerShip.DrawningObjects;
using ContainerShip.Entities;
namespace ContainerShip
{
public partial class FormShipConfig : Form
{
DrawningShip? _ship = null;
private event Action<DrawningShip>? EventAddShip;
public FormShipConfig()
{
InitializeComponent();
panelFirebrick.MouseDown += PanelColor_MouseDown;
panelRoyalBlue.MouseDown += PanelColor_MouseDown;
panelYellow.MouseDown += PanelColor_MouseDown;
panelGreen.MouseDown += PanelColor_MouseDown;
panelBlue.MouseDown += PanelColor_MouseDown;
panelBlack.MouseDown += PanelColor_MouseDown;
panelPink.MouseDown += PanelColor_MouseDown;
panelGray.MouseDown += PanelColor_MouseDown;
buttonCancel.Click += (s, e) => Close();
}
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;
}
public void AddEvent(Action<DrawningShip> ev)
{
if (EventAddShip == null)
{
EventAddShip = ev;
}
else
{
EventAddShip += 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":
_ship = new DrawningShip(
(int)numericUpDownSpeed.Value,
(int)numericUpDownWeight.Value,
Color.White,
pictureBoxObject.Width, pictureBoxObject.Height);
break;
case "labelAdvancedObject":
_ship = new DrawingContainerShip(
(int)numericUpDownSpeed.Value,
(int)numericUpDownWeight.Value,
Color.White, Color.Black,
checkBoxLoad.Checked, checkBoxCrane.Checked,
pictureBoxObject.Width, pictureBoxObject.Height);
break;
}
DrawShip();
}
private void PanelColor_MouseDown(object sender, MouseEventArgs e)
{
(sender as Panel)?.DoDragDrop((sender as Panel)?.BackColor,
DragDropEffects.Move | DragDropEffects.Copy);
}
private void LabelMainColor_DragEnter(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(typeof(Color)) && _ship != null)
{
e.Effect = DragDropEffects.Copy;
}
else
{
e.Effect = DragDropEffects.None;
}
}
private void LabelMainColor_DragDrop(object sender, DragEventArgs e)
{
var color = (Color)e.Data.GetData(typeof(Color));
_ship.EntityShip.ChangeBodyColor(color);
DrawShip();
}
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 LabelAdditionalColor_DragDrop(object sender, DragEventArgs e)
{
Color addColor = (Color)e.Data?.GetData(typeof(Color));
if (_ship is DrawingContainerShip)
{
EntityContainerShip _containerShip = _ship.EntityShip as EntityContainerShip;
_containerShip.ChangeAdditionalColor(addColor);
}
DrawShip();
}
private void ButtonAdd_Click(object sender, EventArgs e)
{
EventAddShip?.Invoke(_ship);
Close();
}
}
}

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

View File

@ -24,13 +24,10 @@ namespace ContainerShip.Generic
}
public bool Insert(T ship, int position)
{
// TODO проверка позиции
if (position < 0 || position >= Count || Count >= _maxCount)
{
return false;
}
// TODO вставка по позиции
_places.Insert(position, ship);
return true;
}

View File

@ -78,6 +78,7 @@ namespace ContainerShip.Generic
for (int i = 0; i < _collection.Count; i++)
{
DrawningShip _ship = _collection[i];
if (_ship != null) {
if (x < 0)
{
x = _pictureWidth / _placeSizeWidth - 1;
@ -86,6 +87,7 @@ namespace ContainerShip.Generic
_ship.SetPosition(_placeSizeWidth * x, _placeSizeHeight * y);
_ship.DrawTransport(g);
x--;
}
}
}
}