Лёвушкина Анна, ПИбд-21, лаб5 простая #11

Closed
AnnaLioness wants to merge 8 commits from лаб5 into лаб4
13 changed files with 747 additions and 169 deletions

View File

@ -1,9 +1,9 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.4.33122.133
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lab1ContainersShip", "Lab1ContainersShip\Lab1ContainersShip.csproj", "{AFA56719-1551-4DFA-9EC2-1FD7AB801A5E}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Lab1ContainersShip", "Lab1ContainersShip\Lab1ContainersShip.csproj", "{AFA56719-1551-4DFA-9EC2-1FD7AB801A5E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution

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,16 +68,30 @@ 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 ((obj + form.SelectedShip) != 1)
if (listBoxStorages.SelectedIndex == -1)
{
return;
}
var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? string.Empty];
if (obj == null)
{
return;
}
if ((obj + drawningShip) != -1)
{
MessageBox.Show("Объект добавлен");
pictureBoxCollection.Image = obj.ShowShips();
@ -86,8 +100,6 @@ namespace Lab1ContainersShip
{
MessageBox.Show("Не удалось добавить объект");
}
}
}

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,138 @@
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 Action<DrawingShip> EventAddShip;
public void AddEvent(Action<DrawingShip> 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

@ -1,120 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{AFA56719-1551-4DFA-9EC2-1FD7AB801A5E}</ProjectGuid>
<TargetFramework>net7.0-windows</TargetFramework>
<OutputType>WinExe</OutputType>
<RootNamespace>Lab1ContainersShip</RootNamespace>
<AssemblyName>Lab1ContainersShip</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<UseWindowsForms>true</UseWindowsForms>
<ImportWindowsDesktopTargets>true</ImportWindowsDesktopTargets>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="System.Data.DataSetExtensions" Version="4.5.0" />
</ItemGroup>
<ItemGroup>
<Compile Include="AbstractStrategy.cs" />
<Compile Include="FormShipCollection.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="FormShipCollection.Designer.cs">
<DependentUpon>FormShipCollection.cs</DependentUpon>
</Compile>
<Compile Include="ShipGenericCollection.cs" />
<Compile Include="Direction.cs" />
<Compile Include="DrawingContainerShip.cs" />
<Compile Include="DrawingShip.cs" />
<Compile Include="DrawningObjectShip.cs" />
<Compile Include="EntityContainerShip.cs" />
<Compile Include="EntityShip.cs" />
<Compile Include="FormContainerShip.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="FormContainerShip.Designer.cs">
<DependentUpon>FormContainerShip.cs</DependentUpon>
</Compile>
<Compile Include="IMoveableObject.cs" />
<Compile Include="MoveToBorder.cs" />
<Compile Include="MoveToCenter.cs" />
<Compile Include="ObjectParameters.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SetGeneric.cs" />
<Compile Include="ShipGenericStorage.cs" />
<Compile Include="Status.cs" />
<EmbeddedResource Include="FormContainerShip.resx">
<DependentUpon>FormContainerShip.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="FormShipCollection.resx">
<DependentUpon>FormShipCollection.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<EmbeddedResource Remove="ShipCollection.resx" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\photo.png" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\photo1.png" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\photo2.png" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\photo3.png" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@ -1,36 +0,0 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// Общие сведения об этой сборке предоставляются следующим набором
// набора атрибутов. Измените значения этих атрибутов для изменения сведений,
// связанных со сборкой.
[assembly: AssemblyTitle("Lab1ContainersShip")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Lab1ContainersShip")]
[assembly: AssemblyCopyright("Copyright © 2023")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Установка значения False для параметра ComVisible делает типы в этой сборке невидимыми
// для компонентов COM. Если необходимо обратиться к типу в этой сборке через
// COM, следует установить атрибут ComVisible в TRUE для этого типа.
[assembly: ComVisible(false)]
// Следующий GUID служит для идентификации библиотеки типов, если этот проект будет видимым для COM
[assembly: Guid("afa56719-1551-4dfa-9ec2-1fd7ab801a5e")]
// Сведения о версии сборки состоят из указанных ниже четырех значений:
//
// Основной номер версии
// Дополнительный номер версии
// Номер сборки
// Редакция
//
// Можно задать все значения или принять номера сборки и редакции по умолчанию
// используя "*", как показано ниже:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

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);
}