This commit is contained in:
AnnaLioness 2023-11-03 22:07:45 +04:00
parent 203249781c
commit 9ab0f8fa63
11 changed files with 753 additions and 17 deletions

View File

@ -60,5 +60,13 @@ additionalColor, bool crane, bool containers, int width, int height) :
g.DrawLine(pen, _startPosX + 47, _startPosY + 13, _startPosX + 47, _startPosY + 25);
}
}
public void setAddColor(Color color)
{
if (EntityShip is EntityContainerShip )
{
(EntityShip as EntityContainerShip).setAddColor(color);
}
}
}
}

View File

@ -16,11 +16,11 @@ namespace Lab1ContainersShip.DrawingObjects
/// <summary>
/// Ширина окна
/// </summary>
private int _pictureWidth;
public int _pictureWidth;
/// <summary>
/// Высота окна
/// </summary>
private int _pictureHeight;
public int _pictureHeight;
/// <summary>
/// Левая координата прорисовки автомобиля
/// </summary>
@ -182,5 +182,9 @@ namespace Lab1ContainersShip.DrawingObjects
//контейнеры
}
public void setColor(Color color)
{
EntityShip.setColor(color);
}
}
}

View File

@ -25,5 +25,9 @@ namespace Lab1ContainersShip.Entities
Crane = crane;
Conteiners = containers;
}
public void setAddColor(Color color)
{
AdditionalColor = color;
}
}
}

View File

@ -30,5 +30,9 @@ namespace Lab1ContainersShip.Entities
BodyColor = bodyColor;
}
public void setColor(Color color)
{
BodyColor = color;
}
}
}

View File

@ -68,27 +68,39 @@ namespace Lab1ContainersShip
{
return;
}
var obj = _storage[listBoxStorages.SelectedItem.ToString() ??
string.Empty];
var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? string.Empty];
if (obj == null)
{
return;
}
FormContainerShip form = new FormContainerShip();
if (form.ShowDialog() == DialogResult.OK)
FormShipConfig formShipConfig = new FormShipConfig();
formShipConfig.AddEvent(addShip);
formShipConfig.Show();
}
private void addShip(DrawingShip drawningShip)
{
if (listBoxStorages.SelectedIndex == -1)
{
if ((obj + form.SelectedShip) != 1)
{
MessageBox.Show("Объект добавлен");
pictureBoxCollection.Image = obj.ShowShips();
}
else
{
MessageBox.Show("Не удалось добавить объект");
}
return;
}
var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? string.Empty];
if (obj == null)
{
return;
}
if ((obj + drawningShip) != -1)
{
MessageBox.Show("Объект добавлен");
pictureBoxCollection.Image = obj.ShowShips();
}
else
{
MessageBox.Show("Не удалось добавить объект");
}
}
private void ButtonRemoveCar_Click(object sender, EventArgs e)

View File

@ -0,0 +1,426 @@
namespace Lab1ContainersShip
{
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()
{
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.panelPink = new System.Windows.Forms.Panel();
this.panelPurple = new System.Windows.Forms.Panel();
this.panelBlue = new System.Windows.Forms.Panel();
this.panelLightBlue = new System.Windows.Forms.Panel();
this.panelGreen = new System.Windows.Forms.Panel();
this.panelYellow = new System.Windows.Forms.Panel();
this.panel6 = new System.Windows.Forms.Panel();
this.panelOrange = new System.Windows.Forms.Panel();
this.panel4 = new System.Windows.Forms.Panel();
this.panelRed = new System.Windows.Forms.Panel();
this.panel2 = new System.Windows.Forms.Panel();
this.checkBoxContainers = new System.Windows.Forms.CheckBox();
this.checkBoxCrane = new System.Windows.Forms.CheckBox();
this.numericUpDownWeight = new System.Windows.Forms.NumericUpDown();
this.numericUpDownSpeed = new System.Windows.Forms.NumericUpDown();
this.label3 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.panel12 = new System.Windows.Forms.Panel();
this.pictureBoxObject = new System.Windows.Forms.PictureBox();
this.buttonOk = new System.Windows.Forms.Button();
this.buttonCancel = new System.Windows.Forms.Button();
this.labelColor = new System.Windows.Forms.Label();
this.labelAddColor = new System.Windows.Forms.Label();
this.groupBox1.SuspendLayout();
this.groupBox2.SuspendLayout();
this.panelYellow.SuspendLayout();
this.panelOrange.SuspendLayout();
this.panelRed.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownWeight)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownSpeed)).BeginInit();
this.panel12.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.checkBoxContainers);
this.groupBox1.Controls.Add(this.checkBoxCrane);
this.groupBox1.Controls.Add(this.numericUpDownWeight);
this.groupBox1.Controls.Add(this.numericUpDownSpeed);
this.groupBox1.Controls.Add(this.label3);
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(466, 323);
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(331, 229);
this.labelModifiedObject.Name = "labelModifiedObject";
this.labelModifiedObject.Size = new System.Drawing.Size(100, 32);
this.labelModifiedObject.TabIndex = 10;
this.labelModifiedObject.Text = "Продвинутый";
this.labelModifiedObject.MouseDown += new System.Windows.Forms.MouseEventHandler(this.LabelObject_MouseDown);
//
// labelSimpleObject
//
this.labelSimpleObject.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.labelSimpleObject.Location = new System.Drawing.Point(206, 229);
this.labelSimpleObject.Name = "labelSimpleObject";
this.labelSimpleObject.Size = new System.Drawing.Size(100, 32);
this.labelSimpleObject.TabIndex = 9;
this.labelSimpleObject.Text = "Простой";
this.labelSimpleObject.MouseDown += new System.Windows.Forms.MouseEventHandler(this.LabelObject_MouseDown);
//
// groupBox2
//
this.groupBox2.Controls.Add(this.panelPink);
this.groupBox2.Controls.Add(this.panelPurple);
this.groupBox2.Controls.Add(this.panelBlue);
this.groupBox2.Controls.Add(this.panelLightBlue);
this.groupBox2.Controls.Add(this.panelGreen);
this.groupBox2.Controls.Add(this.panelYellow);
this.groupBox2.Controls.Add(this.panelOrange);
this.groupBox2.Controls.Add(this.panelRed);
this.groupBox2.Location = new System.Drawing.Point(196, 31);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(246, 158);
this.groupBox2.TabIndex = 8;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "Цвета";
//
// panelPink
//
this.panelPink.BackColor = System.Drawing.Color.Fuchsia;
this.panelPink.Location = new System.Drawing.Point(187, 75);
this.panelPink.Name = "panelPink";
this.panelPink.Size = new System.Drawing.Size(43, 41);
this.panelPink.TabIndex = 0;
//
// panelPurple
//
this.panelPurple.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(0)))), ((int)(((byte)(64)))));
this.panelPurple.Location = new System.Drawing.Point(125, 75);
this.panelPurple.Name = "panelPurple";
this.panelPurple.Size = new System.Drawing.Size(43, 40);
this.panelPurple.TabIndex = 0;
//
// panelBlue
//
this.panelBlue.BackColor = System.Drawing.Color.Blue;
this.panelBlue.Location = new System.Drawing.Point(64, 75);
this.panelBlue.Name = "panelBlue";
this.panelBlue.Size = new System.Drawing.Size(43, 40);
this.panelBlue.TabIndex = 0;
//
// panelLightBlue
//
this.panelLightBlue.BackColor = System.Drawing.Color.Cyan;
this.panelLightBlue.Location = new System.Drawing.Point(6, 75);
this.panelLightBlue.Name = "panelLightBlue";
this.panelLightBlue.Size = new System.Drawing.Size(40, 40);
this.panelLightBlue.TabIndex = 13;
//
// panelGreen
//
this.panelGreen.BackColor = System.Drawing.Color.Lime;
this.panelGreen.Location = new System.Drawing.Point(187, 19);
this.panelGreen.Name = "panelGreen";
this.panelGreen.Size = new System.Drawing.Size(43, 41);
this.panelGreen.TabIndex = 12;
//
// panelYellow
//
this.panelYellow.BackColor = System.Drawing.Color.Yellow;
this.panelYellow.Controls.Add(this.panel6);
this.panelYellow.Location = new System.Drawing.Point(125, 19);
this.panelYellow.Name = "panelYellow";
this.panelYellow.Size = new System.Drawing.Size(43, 38);
this.panelYellow.TabIndex = 11;
//
// panel6
//
this.panel6.Location = new System.Drawing.Point(0, 44);
this.panel6.Name = "panel6";
this.panel6.Size = new System.Drawing.Size(43, 56);
this.panel6.TabIndex = 0;
//
// panelOrange
//
this.panelOrange.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(0)))));
this.panelOrange.Controls.Add(this.panel4);
this.panelOrange.Location = new System.Drawing.Point(64, 19);
this.panelOrange.Name = "panelOrange";
this.panelOrange.Size = new System.Drawing.Size(43, 38);
this.panelOrange.TabIndex = 10;
//
// panel4
//
this.panel4.Location = new System.Drawing.Point(0, 44);
this.panel4.Name = "panel4";
this.panel4.Size = new System.Drawing.Size(43, 56);
this.panel4.TabIndex = 0;
//
// panelRed
//
this.panelRed.BackColor = System.Drawing.Color.Red;
this.panelRed.Controls.Add(this.panel2);
this.panelRed.Location = new System.Drawing.Point(6, 19);
this.panelRed.Name = "panelRed";
this.panelRed.Size = new System.Drawing.Size(40, 38);
this.panelRed.TabIndex = 9;
this.panelRed.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown);
//
// panel2
//
this.panel2.Location = new System.Drawing.Point(157, 72);
this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(43, 28);
this.panel2.TabIndex = 0;
//
// checkBoxContainers
//
this.checkBoxContainers.AutoSize = true;
this.checkBoxContainers.Location = new System.Drawing.Point(9, 129);
this.checkBoxContainers.Name = "checkBoxContainers";
this.checkBoxContainers.Size = new System.Drawing.Size(88, 17);
this.checkBoxContainers.TabIndex = 7;
this.checkBoxContainers.Text = "Контейнеры";
this.checkBoxContainers.UseVisualStyleBackColor = true;
//
// checkBoxCrane
//
this.checkBoxCrane.AutoSize = true;
this.checkBoxCrane.Location = new System.Drawing.Point(9, 106);
this.checkBoxCrane.Name = "checkBoxCrane";
this.checkBoxCrane.Size = new System.Drawing.Size(51, 17);
this.checkBoxCrane.TabIndex = 6;
this.checkBoxCrane.Text = "Кран";
this.checkBoxCrane.UseVisualStyleBackColor = true;
//
// numericUpDownWeight
//
this.numericUpDownWeight.Location = new System.Drawing.Point(41, 65);
this.numericUpDownWeight.Maximum = new decimal(new int[] {
1000,
0,
0,
0});
this.numericUpDownWeight.Minimum = new decimal(new int[] {
100,
0,
0,
0});
this.numericUpDownWeight.Name = "numericUpDownWeight";
this.numericUpDownWeight.Size = new System.Drawing.Size(120, 20);
this.numericUpDownWeight.TabIndex = 5;
this.numericUpDownWeight.Value = new decimal(new int[] {
100,
0,
0,
0});
//
// numericUpDownSpeed
//
this.numericUpDownSpeed.Location = new System.Drawing.Point(70, 29);
this.numericUpDownSpeed.Maximum = new decimal(new int[] {
1000,
0,
0,
0});
this.numericUpDownSpeed.Minimum = new decimal(new int[] {
100,
0,
0,
0});
this.numericUpDownSpeed.Name = "numericUpDownSpeed";
this.numericUpDownSpeed.Size = new System.Drawing.Size(120, 20);
this.numericUpDownSpeed.TabIndex = 4;
this.numericUpDownSpeed.Value = new decimal(new int[] {
100,
0,
0,
0});
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(17, 47);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(0, 13);
this.label3.TabIndex = 3;
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(6, 67);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(29, 13);
this.label2.TabIndex = 2;
this.label2.Text = "Вес:";
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(6, 31);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(58, 13);
this.label1.TabIndex = 1;
this.label1.Text = "Скорость:";
//
// panel12
//
this.panel12.AllowDrop = true;
this.panel12.Controls.Add(this.pictureBoxObject);
this.panel12.Location = new System.Drawing.Point(484, 43);
this.panel12.Name = "panel12";
this.panel12.Size = new System.Drawing.Size(316, 235);
this.panel12.TabIndex = 1;
this.panel12.DragDrop += new System.Windows.Forms.DragEventHandler(this.PanelObject_DragDrop);
this.panel12.DragEnter += new System.Windows.Forms.DragEventHandler(this.PanelObject_DragEnter);
//
// pictureBoxObject
//
this.pictureBoxObject.Location = new System.Drawing.Point(3, 3);
this.pictureBoxObject.Name = "pictureBoxObject";
this.pictureBoxObject.Size = new System.Drawing.Size(310, 204);
this.pictureBoxObject.TabIndex = 0;
this.pictureBoxObject.TabStop = false;
//
// buttonOk
//
this.buttonOk.Location = new System.Drawing.Point(526, 284);
this.buttonOk.Name = "buttonOk";
this.buttonOk.Size = new System.Drawing.Size(89, 39);
this.buttonOk.TabIndex = 2;
this.buttonOk.Text = "Добавить";
this.buttonOk.UseVisualStyleBackColor = true;
this.buttonOk.Click += new System.EventHandler(this.ButtonOk_Click);
//
// buttonCancel
//
this.buttonCancel.Location = new System.Drawing.Point(702, 284);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(95, 39);
this.buttonCancel.TabIndex = 3;
this.buttonCancel.Text = "Отмена";
this.buttonCancel.UseVisualStyleBackColor = true;
//
// labelColor
//
this.labelColor.AllowDrop = true;
this.labelColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.labelColor.Location = new System.Drawing.Point(494, 12);
this.labelColor.Name = "labelColor";
this.labelColor.Size = new System.Drawing.Size(100, 23);
this.labelColor.TabIndex = 4;
this.labelColor.Text = "Цвет";
this.labelColor.DragDrop += new System.Windows.Forms.DragEventHandler(this.LabelColor_DragDrop);
this.labelColor.DragEnter += new System.Windows.Forms.DragEventHandler(this.LabelColor_DragEnter);
//
// labelAddColor
//
this.labelAddColor.AllowDrop = true;
this.labelAddColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.labelAddColor.Location = new System.Drawing.Point(632, 13);
this.labelAddColor.Name = "labelAddColor";
this.labelAddColor.Size = new System.Drawing.Size(100, 23);
this.labelAddColor.TabIndex = 5;
this.labelAddColor.Text = "Доп. цвет";
this.labelAddColor.DragDrop += new System.Windows.Forms.DragEventHandler(this.LabelAddColor_DragDrop);
this.labelAddColor.DragEnter += new System.Windows.Forms.DragEventHandler(this.LabelColor_DragEnter);
//
// FormShipConfig
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 347);
this.Controls.Add(this.labelAddColor);
this.Controls.Add(this.labelColor);
this.Controls.Add(this.buttonCancel);
this.Controls.Add(this.buttonOk);
this.Controls.Add(this.panel12);
this.Controls.Add(this.groupBox1);
this.Name = "FormShipConfig";
this.Text = "FormShipConfig";
this.DragDrop += new System.Windows.Forms.DragEventHandler(this.LabelAddColor_DragDrop);
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
this.groupBox2.ResumeLayout(false);
this.panelYellow.ResumeLayout(false);
this.panelOrange.ResumeLayout(false);
this.panelRed.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.numericUpDownWeight)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownSpeed)).EndInit();
this.panel12.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.pictureBoxObject)).EndInit();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.CheckBox checkBoxContainers;
private System.Windows.Forms.CheckBox checkBoxCrane;
private System.Windows.Forms.NumericUpDown numericUpDownWeight;
private System.Windows.Forms.NumericUpDown numericUpDownSpeed;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label labelSimpleObject;
private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.Panel panelPink;
private System.Windows.Forms.Panel panelPurple;
private System.Windows.Forms.Panel panelBlue;
private System.Windows.Forms.Panel panelLightBlue;
private System.Windows.Forms.Panel panelGreen;
private System.Windows.Forms.Panel panelYellow;
private System.Windows.Forms.Panel panel6;
private System.Windows.Forms.Panel panelOrange;
private System.Windows.Forms.Panel panel4;
private System.Windows.Forms.Panel panelRed;
private System.Windows.Forms.Panel panel2;
private System.Windows.Forms.Label labelModifiedObject;
private System.Windows.Forms.Panel panel12;
private System.Windows.Forms.PictureBox pictureBoxObject;
private System.Windows.Forms.Button buttonOk;
private System.Windows.Forms.Button buttonCancel;
private System.Windows.Forms.Label labelColor;
private System.Windows.Forms.Label labelAddColor;
}
}

View File

@ -0,0 +1,134 @@
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 Lab1ContainersShip.DrawingObjects;
using Lab1ContainersShip.Entities;
namespace Lab1ContainersShip
{
public partial class FormShipConfig : Form
{
DrawingShip _ship = null;
/// <summary>
/// Событие
/// </summary>
private event ShipDelegate EventAddShip;
public void AddEvent(ShipDelegate ev)
{
if (EventAddShip == null)
{
EventAddShip = ev;
}
else
{
EventAddShip += ev;
}
}
private void ButtonOk_Click(object sender, EventArgs e)
{
EventAddShip?.Invoke(_ship);
Close();
}
public FormShipConfig()
{
InitializeComponent();
panelRed.MouseDown += PanelColor_MouseDown;
panelOrange.MouseDown += PanelColor_MouseDown;
panelYellow.MouseDown += PanelColor_MouseDown;
panelGreen.MouseDown += PanelColor_MouseDown;
panelLightBlue.MouseDown += PanelColor_MouseDown;
panelBlue.MouseDown += PanelColor_MouseDown;
panelPurple.MouseDown += PanelColor_MouseDown;
panelPink.MouseDown += PanelColor_MouseDown;
buttonCancel.Click += (s, e) => Close();
}
private void DrawShip()
{
Bitmap bmp = new Bitmap(pictureBoxObject.Width, pictureBoxObject.Height);
Graphics gr = Graphics.FromImage(bmp);
_ship?.SetPosition(5, 5);
_ship?.DrawShip(gr);
pictureBoxObject.Image = bmp;
}
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 DrawingShip((int)numericUpDownSpeed.Value,
(int)numericUpDownWeight.Value, Color.White, pictureBoxObject.Width,
pictureBoxObject.Height);
break;
case "labelModifiedObject":
_ship = new DrawingContainerShip((int)numericUpDownSpeed.Value,
(int)numericUpDownWeight.Value, Color.White, Color.Black, checkBoxCrane.Checked,
checkBoxContainers.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 LabelColor_DragEnter(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(typeof(Color)))
e.Effect = DragDropEffects.Copy;
else
{
e.Effect = DragDropEffects.None;
}
}
private void LabelColor_DragDrop(object sender, DragEventArgs e)
{
if (_ship is DrawingShip)
{
labelColor.BackColor = (Color)e.Data.GetData(typeof(Color));
_ship.setColor((Color)e.Data.GetData(typeof(Color)));
}
DrawShip();
}
private void LabelAddColor_DragDrop(object sender, DragEventArgs e)
{
if (_ship is DrawingContainerShip)
{
labelAddColor.BackColor = (Color)e.Data.GetData(typeof(Color));
(_ship as DrawingContainerShip).setAddColor((Color)e.Data.GetData(typeof(Color)));
}
DrawShip();
}
}
}

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

@ -53,6 +53,12 @@
<Compile Include="FormShipCollection.Designer.cs">
<DependentUpon>FormShipCollection.cs</DependentUpon>
</Compile>
<Compile Include="FormShipConfig.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="FormShipConfig.Designer.cs">
<DependentUpon>FormShipConfig.cs</DependentUpon>
</Compile>
<Compile Include="ShipGenericCollection.cs" />
<Compile Include="Direction.cs" />
<Compile Include="DrawingContainerShip.cs" />
@ -74,6 +80,7 @@
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SetGeneric.cs" />
<Compile Include="ShipGenericStorage.cs" />
<Compile Include="ShipDelegate.cs" />
<Compile Include="Status.cs" />
<EmbeddedResource Include="FormContainerShip.resx">
<DependentUpon>FormContainerShip.cs</DependentUpon>
@ -81,6 +88,9 @@
<EmbeddedResource Include="FormShipCollection.resx">
<DependentUpon>FormShipCollection.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="FormShipConfig.resx">
<DependentUpon>FormShipConfig.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>

View File

@ -0,0 +1,12 @@
using Lab1ContainersShip.DrawingObjects;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Lab1ContainersShip
{
public delegate void ShipDelegate(DrawingShip ship);
}

View File

@ -131,6 +131,8 @@ namespace Lab1ContainersShip
if (ship != null)
{
ship._pictureHeight = _pictureHeight;
ship._pictureWidth = _pictureWidth;
ship.SetPosition(((_collection._maxCount -i - 1) % (_pictureWidth / _placeSizeWidth)) * _placeSizeWidth, (_collection._maxCount - i-1) / (_pictureWidth / _placeSizeWidth) * _placeSizeHeight);
ship.DrawShip(g);
}