файлы лабораторной

This commit is contained in:
Ivan_Starostin 2023-12-19 19:24:25 +04:00
parent afeffbc024
commit ec901ec714
5 changed files with 609 additions and 0 deletions

View File

@ -12,5 +12,9 @@ namespace ProjectLainer.Entities
Weight = weight; Weight = weight;
BodyColor = bodyColor; BodyColor = bodyColor;
} }
public void ChangeColor(Color bodyColor)
{
BodyColor = bodyColor;
}
} }
} }

View File

@ -12,5 +12,9 @@ namespace ProjectLainer.Entities
Pools = pools; Pools = pools;
Decks = decks; Decks = decks;
} }
public void ChangeAddColor(Color additionalColor)
{
AdditionalColor = additionalColor;
}
} }
} }

View File

@ -0,0 +1,367 @@
namespace ProjectLainer
{
partial class FormLainerConfig
{
/// <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();
labelSuper = new Label();
labelBase = new Label();
groupBoxColors = new GroupBox();
panelColorCyan = new Panel();
panelColorGray = new Panel();
panelColorBlue = new Panel();
panelColorGreen = new Panel();
panelColorBlack = new Panel();
panelColorPurple = new Panel();
panelColorYellow = new Panel();
panelColorRed = new Panel();
checkBoxPool = new CheckBox();
checkBoxDecks = new CheckBox();
numericUpDownWeight = new NumericUpDown();
numericUpDownSpeed = new NumericUpDown();
labelweight = new Label();
labelspeed = new Label();
pictureBoxDragAndDrop = new PictureBox();
panelDragAndDrop = new Panel();
labelAddColor = new Label();
labelColor = new Label();
buttonDone = new Button();
buttonCancel = new Button();
groupBoxParameters.SuspendLayout();
groupBoxColors.SuspendLayout();
((System.ComponentModel.ISupportInitialize)numericUpDownWeight).BeginInit();
((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).BeginInit();
((System.ComponentModel.ISupportInitialize)pictureBoxDragAndDrop).BeginInit();
panelDragAndDrop.SuspendLayout();
SuspendLayout();
//
// groupBoxParameters
//
groupBoxParameters.Controls.Add(labelSuper);
groupBoxParameters.Controls.Add(labelBase);
groupBoxParameters.Controls.Add(groupBoxColors);
groupBoxParameters.Controls.Add(checkBoxPool);
groupBoxParameters.Controls.Add(checkBoxDecks);
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(682, 426);
groupBoxParameters.TabIndex = 0;
groupBoxParameters.TabStop = false;
groupBoxParameters.Text = "параметры";
//
// labelSuper
//
labelSuper.BorderStyle = BorderStyle.FixedSingle;
labelSuper.Location = new Point(489, 269);
labelSuper.Name = "labelSuper";
labelSuper.Size = new Size(124, 43);
labelSuper.TabIndex = 8;
labelSuper.Text = "продвинутый";
labelSuper.TextAlign = ContentAlignment.MiddleCenter;
labelSuper.MouseDown += labelObject_mouseDown;
//
// labelBase
//
labelBase.BorderStyle = BorderStyle.FixedSingle;
labelBase.Location = new Point(322, 269);
labelBase.Name = "labelBase";
labelBase.Size = new Size(116, 40);
labelBase.TabIndex = 7;
labelBase.Text = "простой";
labelBase.TextAlign = ContentAlignment.MiddleCenter;
labelBase.MouseDown += labelObject_mouseDown;
//
// groupBoxColors
//
groupBoxColors.Controls.Add(panelColorCyan);
groupBoxColors.Controls.Add(panelColorGray);
groupBoxColors.Controls.Add(panelColorBlue);
groupBoxColors.Controls.Add(panelColorGreen);
groupBoxColors.Controls.Add(panelColorBlack);
groupBoxColors.Controls.Add(panelColorPurple);
groupBoxColors.Controls.Add(panelColorYellow);
groupBoxColors.Controls.Add(panelColorRed);
groupBoxColors.Location = new Point(322, 26);
groupBoxColors.Name = "groupBoxColors";
groupBoxColors.Size = new Size(354, 228);
groupBoxColors.TabIndex = 6;
groupBoxColors.TabStop = false;
groupBoxColors.Text = "цвета";
//
// panelColorCyan
//
panelColorCyan.BackColor = Color.Cyan;
panelColorCyan.Location = new Point(256, 124);
panelColorCyan.Name = "panelColorCyan";
panelColorCyan.Size = new Size(54, 57);
panelColorCyan.TabIndex = 7;
panelColorCyan.MouseDown += PanelColor_MouseDown;
//
// panelColorGray
//
panelColorGray.BackColor = SystemColors.ButtonShadow;
panelColorGray.Location = new Point(178, 124);
panelColorGray.Name = "panelColorGray";
panelColorGray.Size = new Size(53, 55);
panelColorGray.TabIndex = 6;
panelColorGray.MouseDown += PanelColor_MouseDown;
//
// panelColorBlue
//
panelColorBlue.BackColor = Color.DarkBlue;
panelColorBlue.Location = new Point(107, 126);
panelColorBlue.Name = "panelColorBlue";
panelColorBlue.Size = new Size(51, 53);
panelColorBlue.TabIndex = 5;
panelColorBlue.MouseDown += PanelColor_MouseDown;
//
// panelColorGreen
//
panelColorGreen.BackColor = Color.Green;
panelColorGreen.Location = new Point(28, 129);
panelColorGreen.Name = "panelColorGreen";
panelColorGreen.Size = new Size(50, 50);
panelColorGreen.TabIndex = 4;
panelColorGreen.MouseDown += PanelColor_MouseDown;
//
// panelColorBlack
//
panelColorBlack.BackColor = SystemColors.ActiveCaptionText;
panelColorBlack.Location = new Point(256, 37);
panelColorBlack.Name = "panelColorBlack";
panelColorBlack.Size = new Size(54, 50);
panelColorBlack.TabIndex = 3;
panelColorBlack.MouseDown += PanelColor_MouseDown;
//
// panelColorPurple
//
panelColorPurple.BackColor = Color.DarkOrchid;
panelColorPurple.Location = new Point(178, 35);
panelColorPurple.Name = "panelColorPurple";
panelColorPurple.Size = new Size(53, 52);
panelColorPurple.TabIndex = 2;
panelColorPurple.MouseDown += PanelColor_MouseDown;
//
// panelColorYellow
//
panelColorYellow.BackColor = Color.Yellow;
panelColorYellow.Location = new Point(107, 35);
panelColorYellow.Name = "panelColorYellow";
panelColorYellow.Size = new Size(51, 50);
panelColorYellow.TabIndex = 1;
panelColorYellow.MouseDown += PanelColor_MouseDown;
//
// panelColorRed
//
panelColorRed.BackColor = Color.IndianRed;
panelColorRed.Location = new Point(28, 34);
panelColorRed.Name = "panelColorRed";
panelColorRed.Size = new Size(50, 51);
panelColorRed.TabIndex = 0;
panelColorRed.MouseDown += PanelColor_MouseDown;
//
// checkBoxPool
//
checkBoxPool.AutoSize = true;
checkBoxPool.Location = new Point(34, 230);
checkBoxPool.Name = "checkBoxPool";
checkBoxPool.Size = new Size(88, 24);
checkBoxPool.TabIndex = 5;
checkBoxPool.Text = "бассейн";
checkBoxPool.UseVisualStyleBackColor = true;
//
// checkBoxDecks
//
checkBoxDecks.AutoSize = true;
checkBoxDecks.Location = new Point(34, 172);
checkBoxDecks.Name = "checkBoxDecks";
checkBoxDecks.Size = new Size(181, 24);
checkBoxDecks.TabIndex = 4;
checkBoxDecks.Text = "новый вид доп палуб";
checkBoxDecks.UseVisualStyleBackColor = true;
//
// numericUpDownWeight
//
numericUpDownWeight.Location = new Point(129, 91);
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 = 3;
numericUpDownWeight.Value = new decimal(new int[] { 100, 0, 0, 0 });
//
// numericUpDownSpeed
//
numericUpDownSpeed.Location = new Point(129, 47);
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 = 2;
numericUpDownSpeed.Value = new decimal(new int[] { 100, 0, 0, 0 });
//
// labelweight
//
labelweight.AutoSize = true;
labelweight.Location = new Point(19, 91);
labelweight.Name = "labelweight";
labelweight.Size = new Size(32, 20);
labelweight.TabIndex = 1;
labelweight.Text = "вес";
//
// labelspeed
//
labelspeed.AutoSize = true;
labelspeed.Location = new Point(19, 43);
labelspeed.Name = "labelspeed";
labelspeed.Size = new Size(71, 20);
labelspeed.TabIndex = 0;
labelspeed.Text = "скорость";
//
// pictureBoxDragAndDrop
//
pictureBoxDragAndDrop.Location = new Point(13, 79);
pictureBoxDragAndDrop.Name = "pictureBoxDragAndDrop";
pictureBoxDragAndDrop.Size = new Size(355, 150);
pictureBoxDragAndDrop.TabIndex = 1;
pictureBoxDragAndDrop.TabStop = false;
//pictureBoxDragAndDrop.Click += pictureBoxDragAndDrop_Click;
//
// panelDragAndDrop
//
panelDragAndDrop.AllowDrop = true;
panelDragAndDrop.Controls.Add(labelAddColor);
panelDragAndDrop.Controls.Add(labelColor);
panelDragAndDrop.Controls.Add(pictureBoxDragAndDrop);
panelDragAndDrop.Location = new Point(711, 24);
panelDragAndDrop.Name = "panelDragAndDrop";
panelDragAndDrop.Size = new Size(387, 242);
panelDragAndDrop.TabIndex = 2;
panelDragAndDrop.DragDrop += panelObject_DragDrop;
panelDragAndDrop.DragEnter += panelObject_DragEnter;
//
// labelAddColor
//
labelAddColor.AllowDrop = true;
labelAddColor.BorderStyle = BorderStyle.FixedSingle;
labelAddColor.Location = new Point(189, 14);
labelAddColor.Name = "labelAddColor";
labelAddColor.Size = new Size(179, 40);
labelAddColor.TabIndex = 9;
labelAddColor.Text = "дополнительный цвет";
labelAddColor.TextAlign = ContentAlignment.MiddleCenter;
labelAddColor.DragDrop += labelAddColor_DragDrop;
labelAddColor.DragEnter += labelColor_DragEnter;
//
// labelColor
//
labelColor.AllowDrop = true;
labelColor.BorderStyle = BorderStyle.FixedSingle;
labelColor.Location = new Point(13, 14);
labelColor.Name = "labelColor";
labelColor.Size = new Size(116, 40);
labelColor.TabIndex = 8;
labelColor.Text = "цвет";
labelColor.TextAlign = ContentAlignment.MiddleCenter;
labelColor.DragDrop += labelColor_DragDrop;
labelColor.DragEnter += labelColor_DragEnter;
//
// buttonDone
//
buttonDone.Location = new Point(700, 397);
buttonDone.Name = "buttonDone";
buttonDone.Size = new Size(152, 41);
buttonDone.TabIndex = 3;
buttonDone.Text = "готово";
buttonDone.UseVisualStyleBackColor = true;
buttonDone.Click += buttonDone_Click;
//
// buttonCancel
//
buttonCancel.Location = new Point(900, 397);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(169, 41);
buttonCancel.TabIndex = 4;
buttonCancel.Text = "отмена";
buttonCancel.UseVisualStyleBackColor = true;
//
// FormLainerConfig
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(1110, 450);
Controls.Add(buttonCancel);
Controls.Add(buttonDone);
Controls.Add(panelDragAndDrop);
Controls.Add(groupBoxParameters);
Name = "FormLainerConfig";
Text = "FormLainerConfig";
DragDrop += panelObject_DragDrop;
DragEnter += panelObject_DragEnter;
groupBoxParameters.ResumeLayout(false);
groupBoxParameters.PerformLayout();
groupBoxColors.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)numericUpDownWeight).EndInit();
((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).EndInit();
((System.ComponentModel.ISupportInitialize)pictureBoxDragAndDrop).EndInit();
panelDragAndDrop.ResumeLayout(false);
ResumeLayout(false);
}
#endregion
private GroupBox groupBoxParameters;
private CheckBox checkBoxPool;
private CheckBox checkBoxDecks;
private NumericUpDown numericUpDownWeight;
private NumericUpDown numericUpDownSpeed;
private Label labelweight;
private Label labelspeed;
private GroupBox groupBoxColors;
private Panel panelColorPurple;
private Panel panelColorYellow;
private Panel panelColorRed;
private Label labelSuper;
private Label labelBase;
private Panel panelColorCyan;
private Panel panelColorGray;
private Panel panelColorBlue;
private Panel panelColorGreen;
private Panel panelColorBlack;
private PictureBox pictureBoxDragAndDrop;
private Panel panelDragAndDrop;
private Label labelAddColor;
private Label labelColor;
private Button buttonDone;
private Button buttonCancel;
}
}

View File

@ -0,0 +1,114 @@
using ProjectLainer.DrawningObjects;
using ProjectLainer.Entities;
namespace ProjectLainer
{
public partial class FormLainerConfig : Form
{
DrawingEntity? _lainer = null;
Action<DrawingEntity>? EventAddLainer;
public FormLainerConfig()
{
InitializeComponent();
panelColorBlack.MouseDown += PanelColor_MouseDown;
panelColorPurple.MouseDown += PanelColor_MouseDown;
panelColorGray.MouseDown += PanelColor_MouseDown;
panelColorGreen.MouseDown += PanelColor_MouseDown;
panelColorRed.MouseDown += PanelColor_MouseDown;
panelColorCyan.MouseDown += PanelColor_MouseDown;
panelColorYellow.MouseDown += PanelColor_MouseDown;
panelColorBlue.MouseDown += PanelColor_MouseDown;
buttonCancel.Click += (sender, e) => Close();
}
private void PanelColor_MouseDown(object? sender, MouseEventArgs e)
{
(sender as Panel)?.DoDragDrop((sender as Panel)?.BackColor,
DragDropEffects.Move | DragDropEffects.Copy);
}
private void DrawLainer()
{
Bitmap bmp = new(pictureBoxDragAndDrop.Width, pictureBoxDragAndDrop.Height);
Graphics gr = Graphics.FromImage(bmp);
_lainer?.SetPosition(5, 5);
_lainer?.DrawTransport(gr);
pictureBoxDragAndDrop.Image = bmp;
}
public void AddEvent(Action<DrawingEntity> ev)
{
if (EventAddLainer == null)
{
EventAddLainer = ev;
}
else
{
EventAddLainer += ev;
}
}
private void labelObject_mouseDown(object sender, MouseEventArgs e)
{
(sender as Label)?.DoDragDrop((sender as Label)?.Name,
DragDropEffects.Move | DragDropEffects.Copy);
}
private void buttonDone_Click(object sender, EventArgs e)
{
if (_lainer == null)
return;
EventAddLainer?.Invoke(_lainer);
Close();
}
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 "labelBase":
_lainer = new DrawingEntity((int)numericUpDownSpeed.Value,
(int)numericUpDownWeight.Value, Color.White, 729, 397);
break;
case "labelSuper":
_lainer = new DrawningSuperLainer((int)numericUpDownSpeed.Value,
(int)numericUpDownWeight.Value, Color.White, Color.Black, checkBoxPool.Checked, checkBoxDecks.Checked, pictureBoxDragAndDrop.Width, pictureBoxDragAndDrop.Height);
break;
}
DrawLainer();
}
private void labelColor_DragDrop(object sender, DragEventArgs e)
{
if (_lainer?.EntityLainer == null)
return;
Color bodyColor = (Color)e.Data.GetData(typeof(Color));
_lainer.EntityLainer.ChangeColor(bodyColor);
DrawLainer();
}
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 labelAddColor_DragDrop(object sender, DragEventArgs e)
{
if ((_lainer?.EntityLainer == null) || (_lainer is DrawningSuperLainer == false))
return;
Color additionalColor = (Color)e.Data.GetData(typeof(Color));
((EntitySuperLainer)_lainer.EntityLainer).ChangeAddColor(additionalColor);
DrawLainer();
}
}
}

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>