PIbd-14 Pruidze_I.K. LabWork05 Simple #12

Closed
Delphy wants to merge 2 commits from Lab5 into Lab4
9 changed files with 725 additions and 172 deletions
Showing only changes of commit f52c0fc2ca - Show all commits

View File

@ -46,12 +46,6 @@ where T : class
public ICollectionGenObj<T>? this[string name]
{
get => _storages.ContainsKey(name) ? _storages[name] : null;
/* ^^^
{
if (_storages.ContainsKey(name)) return _storages[name];
return null;
}
*/
}
}

344
ProjectCruiser/EditorForm3.Designer.cs generated Normal file
View File

@ -0,0 +1,344 @@
namespace ProjectCruiser
{
partial class EditorForm3
{
/// <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()
{
ParametersBox = new GroupBox();
AdvLabel = new Label();
BaseLabel = new Label();
groupBox2 = new GroupBox();
PurpleP = new Panel();
GreenP = new Panel();
PinkP = new Panel();
OrangeP = new Panel();
CyanP = new Panel();
YellowP = new Panel();
RedP = new Panel();
BlueP = new Panel();
checkBoxPads = new CheckBox();
checkBoxHangars = new CheckBox();
WeightN = new NumericUpDown();
SpeedN = new NumericUpDown();
Label = new Label();
Showcase = new PictureBox();
btnAdd = new Button();
btnCancel = new Button();
panelObject = new Panel();
labelAcolor = new Label();
labelMcolor = new Label();
ParametersBox.SuspendLayout();
groupBox2.SuspendLayout();
((System.ComponentModel.ISupportInitialize)WeightN).BeginInit();
((System.ComponentModel.ISupportInitialize)SpeedN).BeginInit();
((System.ComponentModel.ISupportInitialize)Showcase).BeginInit();
panelObject.SuspendLayout();
SuspendLayout();
//
// ParametersBox
//
ParametersBox.Controls.Add(AdvLabel);
ParametersBox.Controls.Add(BaseLabel);
ParametersBox.Controls.Add(groupBox2);
ParametersBox.Controls.Add(checkBoxPads);
ParametersBox.Controls.Add(checkBoxHangars);
ParametersBox.Controls.Add(WeightN);
ParametersBox.Controls.Add(SpeedN);
ParametersBox.Controls.Add(Label);
ParametersBox.Location = new Point(12, 0);
ParametersBox.Name = "ParametersBox";
ParametersBox.Size = new Size(388, 495);
ParametersBox.TabIndex = 0;
ParametersBox.TabStop = false;
ParametersBox.Text = "Parameters";
//
// AdvLabel
//
AdvLabel.BorderStyle = BorderStyle.FixedSingle;
AdvLabel.Location = new Point(175, 428);
AdvLabel.Name = "AdvLabel";
AdvLabel.Size = new Size(184, 46);
AdvLabel.TabIndex = 5;
AdvLabel.Text = "Advanced";
AdvLabel.TextAlign = ContentAlignment.MiddleCenter;
AdvLabel.MouseDown += BaseAdvLabel_MouseDown;
//
// BaseLabel
//
BaseLabel.BorderStyle = BorderStyle.FixedSingle;
BaseLabel.Location = new Point(17, 428);
BaseLabel.Name = "BaseLabel";
BaseLabel.Size = new Size(132, 46);
BaseLabel.TabIndex = 4;
BaseLabel.Text = "Base";
BaseLabel.TextAlign = ContentAlignment.MiddleCenter;
BaseLabel.MouseDown += BaseAdvLabel_MouseDown;
//
// groupBox2
//
groupBox2.Controls.Add(PurpleP);
groupBox2.Controls.Add(GreenP);
groupBox2.Controls.Add(PinkP);
groupBox2.Controls.Add(OrangeP);
groupBox2.Controls.Add(CyanP);
groupBox2.Controls.Add(YellowP);
groupBox2.Controls.Add(RedP);
groupBox2.Controls.Add(BlueP);
groupBox2.Location = new Point(17, 197);
groupBox2.Name = "groupBox2";
groupBox2.Size = new Size(342, 213);
groupBox2.TabIndex = 1;
groupBox2.TabStop = false;
groupBox2.Text = "Color picker";
//
// PurpleP
//
PurpleP.BackColor = Color.DarkViolet;
PurpleP.Location = new Point(260, 126);
PurpleP.Name = "PurpleP";
PurpleP.Size = new Size(63, 59);
PurpleP.TabIndex = 12;
//
// GreenP
//
GreenP.BackColor = Color.SpringGreen;
GreenP.Location = new Point(259, 49);
GreenP.Name = "GreenP";
GreenP.Size = new Size(63, 59);
GreenP.TabIndex = 9;
//
// PinkP
//
PinkP.BackColor = Color.DeepPink;
PinkP.Location = new Point(180, 126);
PinkP.Name = "PinkP";
PinkP.Size = new Size(63, 59);
PinkP.TabIndex = 11;
//
// OrangeP
//
OrangeP.BackColor = Color.DarkOrange;
OrangeP.Location = new Point(180, 49);
OrangeP.Name = "OrangeP";
OrangeP.Size = new Size(63, 59);
OrangeP.TabIndex = 8;
//
// CyanP
//
CyanP.BackColor = Color.Cyan;
CyanP.Location = new Point(100, 126);
CyanP.Name = "CyanP";
CyanP.Size = new Size(63, 59);
CyanP.TabIndex = 10;
//
// YellowP
//
YellowP.BackColor = Color.Gold;
YellowP.Location = new Point(19, 126);
YellowP.Name = "YellowP";
YellowP.Size = new Size(63, 59);
YellowP.TabIndex = 9;
//
// RedP
//
RedP.BackColor = Color.Firebrick;
RedP.Location = new Point(100, 49);
RedP.Name = "RedP";
RedP.Size = new Size(63, 59);
RedP.TabIndex = 7;
//
// BlueP
//
BlueP.BackColor = SystemColors.Highlight;
BlueP.Location = new Point(19, 49);
BlueP.Name = "BlueP";
BlueP.Size = new Size(63, 59);
BlueP.TabIndex = 6;
//
// checkBoxPads
//
checkBoxPads.AutoSize = true;
checkBoxPads.Location = new Point(24, 142);
checkBoxPads.Name = "checkBoxPads";
checkBoxPads.Size = new Size(203, 36);
checkBoxPads.TabIndex = 3;
checkBoxPads.Text = "Helicopter pad";
checkBoxPads.UseVisualStyleBackColor = true;
//
// checkBoxHangars
//
checkBoxHangars.AutoSize = true;
checkBoxHangars.Location = new Point(234, 142);
checkBoxHangars.Name = "checkBoxHangars";
checkBoxHangars.Size = new Size(133, 36);
checkBoxHangars.TabIndex = 1;
checkBoxHangars.Text = "Hangars";
checkBoxHangars.UseVisualStyleBackColor = true;
//
// WeightN
//
WeightN.Location = new Point(198, 88);
WeightN.Maximum = new decimal(new int[] { 1000, 0, 0, 0 });
WeightN.Minimum = new decimal(new int[] { 100, 0, 0, 0 });
WeightN.Name = "WeightN";
WeightN.Size = new Size(142, 39);
WeightN.TabIndex = 2;
WeightN.Value = new decimal(new int[] { 100, 0, 0, 0 });
//
// SpeedN
//
SpeedN.Location = new Point(36, 88);
SpeedN.Maximum = new decimal(new int[] { 1000, 0, 0, 0 });
SpeedN.Minimum = new decimal(new int[] { 100, 0, 0, 0 });
SpeedN.Name = "SpeedN";
SpeedN.Size = new Size(142, 39);
SpeedN.TabIndex = 1;
SpeedN.Value = new decimal(new int[] { 100, 0, 0, 0 });
//
// Label
//
Label.AutoSize = true;
Label.Location = new Point(36, 53);
Label.Name = "Label";
Label.Size = new Size(304, 32);
Label.TabIndex = 1;
Label.Text = "Speed Weight";
//
// Showcase
//
Showcase.Location = new Point(58, 98);
Showcase.Name = "Showcase";
Showcase.Size = new Size(458, 272);
Showcase.TabIndex = 1;
Showcase.TabStop = false;
//
// btnAdd
//
btnAdd.Location = new Point(419, 447);
btnAdd.Name = "btnAdd";
btnAdd.Size = new Size(268, 46);
btnAdd.TabIndex = 2;
btnAdd.Text = "Add";
btnAdd.UseVisualStyleBackColor = true;
btnAdd.Click += AddButton_Click;
//
// btnCancel
//
btnCancel.Location = new Point(694, 447);
btnCancel.Name = "btnCancel";
btnCancel.Size = new Size(286, 46);
btnCancel.TabIndex = 3;
btnCancel.Text = "Cancel";
btnCancel.UseVisualStyleBackColor = true;
//
// panelObject
//
panelObject.AllowDrop = true;
panelObject.Controls.Add(labelAcolor);
panelObject.Controls.Add(labelMcolor);
panelObject.Controls.Add(Showcase);
panelObject.Location = new Point(419, 12);
panelObject.Name = "panelObject";
panelObject.Size = new Size(561, 410);
panelObject.TabIndex = 4;
panelObject.DragDrop += PanelObject_DragDrop;
panelObject.DragEnter += PanelObject_DragEnter;
//
// labelAcolor
//
labelAcolor.AllowDrop = true;
labelAcolor.BorderStyle = BorderStyle.FixedSingle;
labelAcolor.Location = new Point(253, 39);
labelAcolor.Name = "labelAcolor";
labelAcolor.Size = new Size(263, 42);
labelAcolor.TabIndex = 7;
labelAcolor.Text = "Additional color";
labelAcolor.TextAlign = ContentAlignment.MiddleCenter;
labelAcolor.DragDrop += AdditionalColor_DragDrop;
labelAcolor.DragEnter += AdditionalColor_DragEnter;
//
// labelMcolor
//
labelMcolor.AllowDrop = true;
labelMcolor.BorderStyle = BorderStyle.FixedSingle;
labelMcolor.Location = new Point(58, 39);
labelMcolor.Name = "labelMcolor";
labelMcolor.Size = new Size(180, 42);
labelMcolor.TabIndex = 6;
labelMcolor.Text = "Main color";
labelMcolor.TextAlign = ContentAlignment.MiddleCenter;
labelMcolor.DragDrop += BodyColor_DragDrop;
labelMcolor.DragEnter += BodyColor_DragEnter;
//
// EditorForm3
//
AutoScaleDimensions = new SizeF(13F, 32F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(992, 516);
Controls.Add(panelObject);
Controls.Add(btnCancel);
Controls.Add(btnAdd);
Controls.Add(ParametersBox);
Name = "EditorForm3";
Text = "FormTransportConfig";
ParametersBox.ResumeLayout(false);
ParametersBox.PerformLayout();
groupBox2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)WeightN).EndInit();
((System.ComponentModel.ISupportInitialize)SpeedN).EndInit();
((System.ComponentModel.ISupportInitialize)Showcase).EndInit();
panelObject.ResumeLayout(false);
ResumeLayout(false);
}
#endregion
private GroupBox ParametersBox;
private Label Label;
private CheckBox checkBoxPads;
private CheckBox checkBoxHangars;
private NumericUpDown WeightN;
private NumericUpDown SpeedN;
private GroupBox groupBox2;
private Label BaseLabel;
private Label AdvLabel;
private Panel PurpleP;
private Panel GreenP;
private Panel PinkP;
private Panel OrangeP;
private Panel CyanP;
private Panel YellowP;
private Panel RedP;
private Panel BlueP;
private PictureBox Showcase;
private Button btnAdd;
private Button btnCancel;
private Panel panelObject;
private Label labelMcolor;
private Label labelAcolor;
}
}

View File

@ -0,0 +1,124 @@
using ProjectCruiser.DrawningSamples;
using ProjectCruiser.Entities;
using System;
namespace ProjectCruiser;
public partial class EditorForm3 : Form
Review

Имена классов должны быть логичны

Имена классов должны быть логичны
{
private DrawningBase _cruiser;
// private event Action<DrawingBase>? shipDelegate;
Review

Закомментированного кода быть не должно

Закомментированного кода быть не должно
private event ShipDelegate? shipDelegate;
Review

Делегат следовало заменить на встроенный

Делегат следовало заменить на встроенный
public EditorForm3()
{
InitializeComponent();
BlueP.MouseDown += Panel_MouseDown;
RedP.MouseDown += Panel_MouseDown;
PinkP.MouseDown += Panel_MouseDown;
YellowP.MouseDown += Panel_MouseDown;
CyanP.MouseDown += Panel_MouseDown;
PurpleP.MouseDown += Panel_MouseDown;
GreenP.MouseDown += Panel_MouseDown;
OrangeP.MouseDown += Panel_MouseDown;
btnCancel.Click += (sender, e) => Close();
}
public void AddEvent(ShipDelegate del)// Action<DrawingBase> delegator)
{
if (shipDelegate == null) shipDelegate = del;
else shipDelegate += del;
//shipDelegate += del;
}
private void DrawObject()
{
Bitmap bmp = new(Showcase.Width, Showcase.Height);
Graphics gr = Graphics.FromImage(bmp);
_cruiser?.SetPictureSize(Showcase.Width, Showcase.Height);
_cruiser?.SetPosition(Showcase.Width - 400, Showcase.Height - 120);
_cruiser?.DrawTransport(gr);
Showcase.Image = bmp;
}
private void Panel_MouseDown(object? sender, MouseEventArgs e)
{
// TODO отправка цвета в Drag&Drop
(sender as Control).DoDragDrop((sender as Control).BackColor, DragDropEffects.Move | DragDropEffects.Copy);
}
private void BaseAdvLabel_MouseDown(object sender, MouseEventArgs e)
{
(sender as Label)?.DoDragDrop((sender as Label)?.Name ?? string.Empty, 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 "BaseLabel":
_cruiser = new DrawningBase((int)SpeedN.Value, (double)WeightN.Value, Color.White);
break;
case "AdvLabel":
Random rn = new Random();
_cruiser = new DrawningCruiser((int)SpeedN.Value, (double)WeightN.Value,
Color.White, Color.Black,checkBoxHangars.Checked);
// ADD helicopter PAD as NOT DEFAULT - checkBoxPads.Checked [!]
// Convert.ToBoolean(rn.Next(0, 2)));
break;
}
labelMcolor.BackColor = Color.Empty;
labelAcolor.BackColor = Color.Empty;
DrawObject();
}
// TODO Реализовать логику смены цветов: основного и дополнительного (для продвинутого объекта)
private void BodyColor_DragEnter(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(typeof(Color))) e.Effect = DragDropEffects.Copy;
else e.Effect = DragDropEffects.None;
}
private void BodyColor_DragDrop(object sender, DragEventArgs e)
{
if (_cruiser != null)
{
_cruiser.EntityTransport.setMainColor((Color)e.Data.GetData(typeof(Color)));
DrawObject();
}
}
private void AdditionalColor_DragEnter(object sender, DragEventArgs e)
{
if (_cruiser is DrawningCruiser)
{
if (e.Data.GetDataPresent(typeof(Color))) e.Effect = DragDropEffects.Copy;
else e.Effect = DragDropEffects.None;
}
}
private void AdditionalColor_DragDrop(object sender, DragEventArgs e)
{
if (_cruiser.EntityTransport is EntityCruiser _ship)
{
_ship.setAdditionalColor((Color)e.Data.GetData(typeof(Color)));
}
DrawObject();
}
private void AddButton_Click(object sender, EventArgs e)
{
if (_cruiser != null)
{
shipDelegate?.Invoke(_cruiser);
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

@ -7,6 +7,11 @@ public class EntityBase
public double Weight { get; private set; } // вес
public Color MainColor { get; private set; } // основной цвет
public void setMainColor(Color clr)
{
MainColor = clr;
}
// public bool Deckhouse { get; private set; } // салон на верхней палубе
public double Step => Speed * 100 / Weight;

View File

@ -4,6 +4,11 @@ public class EntityCruiser : EntityBase
{
public Color AdditionalColor { get; private set; } // доп. цвет
public void setAdditionalColor(Color clr)
{
AdditionalColor = clr;
}
// признаки (наличия)
public bool HelicopterPads { get; private set; } // вертолетная площадка
public bool Hangars { get; private set; } // ангар

View File

@ -29,16 +29,7 @@
private void InitializeComponent()
{
comboBoxArrList = new ComboBox();
btnAddBase = new Button();
groupBox = new GroupBox();
toolPanel = new Panel();
btnUpdate = new Button();
btnTest = new Button();
maskedTextBoxPosition = new MaskedTextBox();
btnDelete = new Button();
btnAddCruiser = new Button();
btnCreateCompany = new Button();
pictureBox = new PictureBox();
companyPanel = new Panel();
btnDeleteCollection = new Button();
listBox = new ListBox();
@ -47,10 +38,18 @@
rBtnArray = new RadioButton();
maskedTxtBoxCName = new MaskedTextBox();
label = new Label();
toolPanel = new Panel();
btnUpdate = new Button();
btnTest = new Button();
maskedTextBoxPosition = new MaskedTextBox();
btnDelete = new Button();
btnAddCruiser = new Button();
btnCreateCompany = new Button();
pictureBox = new PictureBox();
groupBox.SuspendLayout();
companyPanel.SuspendLayout();
toolPanel.SuspendLayout();
((System.ComponentModel.ISupportInitialize)pictureBox).BeginInit();
companyPanel.SuspendLayout();
SuspendLayout();
//
// comboBoxArrList
@ -64,17 +63,6 @@
comboBoxArrList.TabIndex = 0;
comboBoxArrList.SelectedIndexChanged += SelectorCompany_SelectedIndexChanged;
//
// btnAddBase
//
btnAddBase.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
btnAddBase.Location = new Point(17, 13);
btnAddBase.Name = "btnAddBase";
btnAddBase.Size = new Size(192, 43);
btnAddBase.TabIndex = 1;
btnAddBase.Text = "Add ship";
btnAddBase.UseVisualStyleBackColor = true;
btnAddBase.Click += btnAddBase_Click;
//
// groupBox
//
groupBox.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
@ -89,6 +77,89 @@
groupBox.TabStop = false;
groupBox.Text = "Tool panel";
//
// companyPanel
//
companyPanel.Controls.Add(btnDeleteCollection);
companyPanel.Controls.Add(listBox);
companyPanel.Controls.Add(btnAddCollection);
companyPanel.Controls.Add(rBtnList);
companyPanel.Controls.Add(rBtnArray);
companyPanel.Controls.Add(maskedTxtBoxCName);
companyPanel.Controls.Add(label);
companyPanel.Location = new Point(17, 91);
companyPanel.Name = "companyPanel";
companyPanel.Size = new Size(243, 391);
companyPanel.TabIndex = 7;
//
// btnDeleteCollection
//
btnDeleteCollection.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
btnDeleteCollection.Location = new Point(15, 312);
btnDeleteCollection.Name = "btnDeleteCollection";
btnDeleteCollection.Size = new Size(214, 73);
btnDeleteCollection.TabIndex = 11;
btnDeleteCollection.Text = "Remove Collection";
btnDeleteCollection.UseVisualStyleBackColor = true;
btnDeleteCollection.Click += btnCollectionDel_Click;
//
// listBox
//
listBox.FormattingEnabled = true;
listBox.Location = new Point(16, 174);
listBox.Name = "listBox";
listBox.Size = new Size(214, 132);
listBox.TabIndex = 10;
//
// btnAddCollection
//
btnAddCollection.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
btnAddCollection.Location = new Point(15, 119);
btnAddCollection.Name = "btnAddCollection";
btnAddCollection.Size = new Size(214, 50);
btnAddCollection.TabIndex = 7;
btnAddCollection.Text = "Add Collection";
btnAddCollection.UseVisualStyleBackColor = true;
btnAddCollection.Click += btnCollectionAdd_Click;
//
// rBtnList
//
rBtnList.AutoSize = true;
rBtnList.Location = new Point(150, 80);
rBtnList.Name = "rBtnList";
rBtnList.Size = new Size(80, 36);
rBtnList.TabIndex = 9;
rBtnList.TabStop = true;
rBtnList.Text = "List";
rBtnList.UseVisualStyleBackColor = true;
//
// rBtnArray
//
rBtnArray.AutoSize = true;
rBtnArray.Location = new Point(16, 80);
rBtnArray.Name = "rBtnArray";
rBtnArray.Size = new Size(100, 36);
rBtnArray.TabIndex = 8;
rBtnArray.TabStop = true;
rBtnArray.Text = "Array";
rBtnArray.UseVisualStyleBackColor = true;
//
// maskedTxtBoxCName
//
maskedTxtBoxCName.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
maskedTxtBoxCName.Location = new Point(16, 40);
maskedTxtBoxCName.Name = "maskedTxtBoxCName";
maskedTxtBoxCName.Size = new Size(214, 39);
maskedTxtBoxCName.TabIndex = 7;
//
// label
//
label.AutoSize = true;
label.Location = new Point(29, 5);
label.Name = "label";
label.Size = new Size(188, 32);
label.TabIndex = 0;
label.Text = "Collection name";
//
// toolPanel
//
toolPanel.Controls.Add(btnUpdate);
@ -96,19 +167,18 @@
toolPanel.Controls.Add(maskedTextBoxPosition);
toolPanel.Controls.Add(btnDelete);
toolPanel.Controls.Add(btnAddCruiser);
toolPanel.Controls.Add(btnAddBase);
toolPanel.Enabled = false;
toolPanel.Location = new Point(26, 593);
toolPanel.Location = new Point(26, 567);
toolPanel.Name = "toolPanel";
toolPanel.Size = new Size(226, 377);
toolPanel.Size = new Size(226, 317);
toolPanel.TabIndex = 13;
//
// btnUpdate
//
btnUpdate.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
btnUpdate.Location = new Point(17, 315);
btnUpdate.Location = new Point(16, 257);
btnUpdate.Name = "btnUpdate";
btnUpdate.Size = new Size(192, 49);
btnUpdate.Size = new Size(192, 41);
btnUpdate.TabIndex = 6;
btnUpdate.Text = "Update";
btnUpdate.UseVisualStyleBackColor = true;
@ -117,9 +187,9 @@
// btnTest
//
btnTest.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
btnTest.Location = new Point(17, 224);
btnTest.Location = new Point(17, 162);
btnTest.Name = "btnTest";
btnTest.Size = new Size(192, 85);
btnTest.Size = new Size(192, 89);
btnTest.TabIndex = 5;
btnTest.Text = "Choose\r\nfor testing";
btnTest.UseVisualStyleBackColor = true;
@ -128,7 +198,7 @@
// maskedTextBoxPosition
//
maskedTextBoxPosition.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
maskedTextBoxPosition.Location = new Point(17, 119);
maskedTextBoxPosition.Location = new Point(17, 68);
maskedTextBoxPosition.Mask = "00";
maskedTextBoxPosition.Name = "maskedTextBoxPosition";
maskedTextBoxPosition.Size = new Size(192, 39);
@ -138,9 +208,9 @@
// btnDelete
//
btnDelete.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
btnDelete.Location = new Point(17, 170);
btnDelete.Location = new Point(16, 113);
btnDelete.Name = "btnDelete";
btnDelete.Size = new Size(192, 48);
btnDelete.Size = new Size(192, 43);
btnDelete.TabIndex = 4;
btnDelete.Text = "Delete";
btnDelete.UseVisualStyleBackColor = true;
@ -149,22 +219,22 @@
// btnAddCruiser
//
btnAddCruiser.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
btnAddCruiser.Location = new Point(17, 62);
btnAddCruiser.Location = new Point(17, 13);
btnAddCruiser.Name = "btnAddCruiser";
btnAddCruiser.Size = new Size(192, 51);
btnAddCruiser.Size = new Size(192, 49);
btnAddCruiser.TabIndex = 2;
btnAddCruiser.Text = "Add cruiser";
btnAddCruiser.UseVisualStyleBackColor = true;
btnAddCruiser.Click += btnAddAdvanced_Click;
btnAddCruiser.Click += btnAddTransport_Click;
//
// btnCreateCompany
//
btnCreateCompany.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
btnCreateCompany.Location = new Point(17, 526);
btnCreateCompany.Location = new Point(16, 488);
btnCreateCompany.Name = "btnCreateCompany";
btnCreateCompany.Size = new Size(243, 61);
btnCreateCompany.Size = new Size(245, 73);
btnCreateCompany.TabIndex = 12;
btnCreateCompany.Text = "Create Company";
btnCreateCompany.Text = "Create or switch to Company";
btnCreateCompany.UseVisualStyleBackColor = true;
btnCreateCompany.Click += btnCreateCompany_Click;
//
@ -177,89 +247,6 @@
pictureBox.TabIndex = 3;
pictureBox.TabStop = false;
//
// companyPanel
//
companyPanel.Controls.Add(btnDeleteCollection);
companyPanel.Controls.Add(listBox);
companyPanel.Controls.Add(btnAddCollection);
companyPanel.Controls.Add(rBtnList);
companyPanel.Controls.Add(rBtnArray);
companyPanel.Controls.Add(maskedTxtBoxCName);
companyPanel.Controls.Add(label);
companyPanel.Location = new Point(17, 91);
companyPanel.Name = "companyPanel";
companyPanel.Size = new Size(243, 429);
companyPanel.TabIndex = 7;
//
// btnDeleteCollection
//
btnDeleteCollection.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
btnDeleteCollection.Location = new Point(15, 371);
btnDeleteCollection.Name = "btnDeleteCollection";
btnDeleteCollection.Size = new Size(214, 43);
btnDeleteCollection.TabIndex = 11;
btnDeleteCollection.Text = "Remove Collection";
btnDeleteCollection.UseVisualStyleBackColor = true;
btnDeleteCollection.Click += btnCollectionDel_Click;
//
// listBox
//
listBox.FormattingEnabled = true;
listBox.Location = new Point(16, 199);
listBox.Name = "listBox";
listBox.Size = new Size(214, 164);
listBox.TabIndex = 10;
//
// btnAddCollection
//
btnAddCollection.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
btnAddCollection.Location = new Point(15, 130);
btnAddCollection.Name = "btnAddCollection";
btnAddCollection.Size = new Size(214, 61);
btnAddCollection.TabIndex = 7;
btnAddCollection.Text = "Add Collection";
btnAddCollection.UseVisualStyleBackColor = true;
btnAddCollection.Click += btnCollectionAdd_Click;
//
// rBtnList
//
rBtnList.AutoSize = true;
rBtnList.Location = new Point(150, 88);
rBtnList.Name = "rBtnList";
rBtnList.Size = new Size(80, 36);
rBtnList.TabIndex = 9;
rBtnList.TabStop = true;
rBtnList.Text = "List";
rBtnList.UseVisualStyleBackColor = true;
//
// rBtnArray
//
rBtnArray.AutoSize = true;
rBtnArray.Location = new Point(16, 88);
rBtnArray.Name = "rBtnArray";
rBtnArray.Size = new Size(100, 36);
rBtnArray.TabIndex = 8;
rBtnArray.TabStop = true;
rBtnArray.Text = "Array";
rBtnArray.UseVisualStyleBackColor = true;
//
// maskedTxtBoxCName
//
maskedTxtBoxCName.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
maskedTxtBoxCName.Location = new Point(16, 43);
maskedTxtBoxCName.Name = "maskedTxtBoxCName";
maskedTxtBoxCName.Size = new Size(214, 39);
maskedTxtBoxCName.TabIndex = 7;
//
// label
//
label.AutoSize = true;
label.Location = new Point(29, 6);
label.Name = "label";
label.Size = new Size(188, 32);
label.TabIndex = 0;
label.Text = "Collection name";
//
// ServiceForm2
//
AutoScaleDimensions = new SizeF(13F, 32F);
@ -270,18 +257,17 @@
Name = "ServiceForm2";
Text = "ServiceForm2";
groupBox.ResumeLayout(false);
companyPanel.ResumeLayout(false);
companyPanel.PerformLayout();
toolPanel.ResumeLayout(false);
toolPanel.PerformLayout();
((System.ComponentModel.ISupportInitialize)pictureBox).EndInit();
companyPanel.ResumeLayout(false);
companyPanel.PerformLayout();
ResumeLayout(false);
}
#endregion
private ComboBox comboBoxArrList;
private Button btnAddBase;
private GroupBox groupBox;
private Button btnAddCruiser;
private Button btnUpdate;

View File

@ -1,9 +1,5 @@
using System.Collections.Generic;
using System.Windows.Forms;
using System.Xml.Linq;
using ProjectCruiser.CollectionGenericObj;
using ProjectCruiser.CollectionGenericObj;
using ProjectCruiser.DrawningSamples;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
namespace ProjectCruiser;
public partial class ServiceForm2 : Form
@ -22,16 +18,6 @@ public partial class ServiceForm2 : Form
// Выбор компании
private void SelectorCompany_SelectedIndexChanged(object sender, EventArgs e)
{
/*
switch (comboBoxArrList.Text)
{
case "Storage":
_company = new ShipSharingService(pictureBox.Width, pictureBox.Height,
new ArrayGenObj<DrawningBase>());
break;
}
*/
toolPanel.Enabled = false;
}
@ -47,40 +33,23 @@ public partial class ServiceForm2 : Form
return cl;
}
// Добавление обычного корабля
private void btnAddBase_Click(object sender, EventArgs e) =>
CreateObject(nameof(DrawningBase));
// Добавление продвинутого
private void btnAddAdvanced_Click(object sender, EventArgs e) =>
CreateObject(nameof(DrawningCruiser));
// Добавление корабля
private void btnAddTransport_Click(object sender, EventArgs e)
{
EditorForm3 form3 = new();
// TODO передать метод :
form3.AddEvent(CreateObject);
form3.Show();
}
// Создание объекта класса-перемещения
private void CreateObject(string type)
private void CreateObject(DrawningBase? ship)
{
if (_company == null)
if (_company == null || ship == null)
{
return;
}
Random random = new();
DrawningBase drawningCar;
switch (type)
{
case nameof(DrawningBase):
drawningCar = new DrawningBase(random.Next(100, 300),
random.Next(1000, 3000), pickColor(random));
break;
case nameof(DrawningCruiser):
drawningCar = new DrawningCruiser(random.Next(100, 300),
random.Next(1000, 3000), pickColor(random), pickColor(random),
Convert.ToBoolean(random.Next(0, 2)));
break;
default:
return;
}
if (_company + drawningCar != -1)
if (_company + ship != -1)
{
MessageBox.Show("> Object was added");
pictureBox.Image = _company.Show();

View File

@ -0,0 +1,6 @@
using ProjectCruiser.DrawningSamples;
namespace ProjectCruiser
{
public delegate void ShipDelegate(DrawningBase transport);
}