ISEbd-12_Osyagina_A.A._Simple_LabWork05 #5

Closed
Osyagina_Anna wants to merge 3 commits from LabWork05 into LabWork04
14 changed files with 568 additions and 243 deletions
Showing only changes of commit e3166e83ef - Show all commits

View File

@ -1,25 +0,0 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.8.34525.116
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LAB01", "LAB01\LAB01.csproj", "{34001B70-EBBF-45A9-BEB8-AD3C2CB8B984}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{34001B70-EBBF-45A9-BEB8-AD3C2CB8B984}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{34001B70-EBBF-45A9-BEB8-AD3C2CB8B984}.Debug|Any CPU.Build.0 = Debug|Any CPU
{34001B70-EBBF-45A9-BEB8-AD3C2CB8B984}.Release|Any CPU.ActiveCfg = Release|Any CPU
{34001B70-EBBF-45A9-BEB8-AD3C2CB8B984}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {70E24174-2A6E-49F3-92B6-8C86A8B8C4EF}
EndGlobalSection
EndGlobal

View File

@ -1,39 +0,0 @@
namespace LAB01
{
partial class Form1
{
/// <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.components = new System.ComponentModel.Container();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Text = "Form1";
}
#endregion
}
}

View File

@ -1,10 +0,0 @@
namespace LAB01
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
}
}

View File

@ -1,10 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

View File

@ -1,55 +0,0 @@
using System;
using System.Collections.Generic;
// Структура данных для комплектующих компьютера
public class ComputerComponent
{
public string Name { get; set; }
public string Type { get; set; }
// Другие характеристики компонента
public ComputerComponent(string name, string type)
{
Name = name;
Type = type;
}
}
// Класс для проверки совместимости компонентов в сборке
public class CompatibilityChecker
{
public bool CheckCompatibility(List<ComputerComponent> components)
{
// Логика проверки совместимости компонентов
foreach (var component in components)
{
// Проверка совместимости
if (component.Type == "CPU" && components.Exists(c => c.Type == "Motherboard"))
{
// Логика проверки совместимости процессора и материнской платы
Console.WriteLine($"Процессор {component.Name} совместим с материнской платой.");
}
// Другие логические проверки
}
Console.WriteLine("Проверка совместимости завершена.");
return true; // или false в зависимости от результата проверки
}
}
// Пример использования
class Program
{
static void Main()
{
var components = new List<ComputerComponent>
{
new ComputerComponent("Intel Core i7", "CPU"),
new ComputerComponent("MSI Z390 Gaming Pro", "Motherboard"),
// Другие компоненты
};
var checker = new CompatibilityChecker();
checker.CheckCompatibility(components);
}
}

View File

@ -0,0 +1,10 @@
using ProjectMotorboat.Drownings;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectMotorboat;
public delegate void BoatDelegate(DrawningBoat car);
Review

Не используется

Не используется

View File

@ -9,14 +9,9 @@ namespace ProjectMotorboat.CollectionGenericObjects;
public class StorageCollection<T>
where T : class
{
/// <summary>
/// Словарь (хранилище) с коллекциями
/// </summary>
readonly Dictionary<string, ICollectionGenericObjects<T>> _storages;
/// <summary>
/// Возвращение списка названий коллекций
/// </summary>
public List<string> Keys => _storages.Keys.ToList();
public StorageCollection()
@ -24,11 +19,7 @@ public class StorageCollection<T>
_storages = new Dictionary<string, ICollectionGenericObjects<T>>();
}
/// <summary>
/// Добавление коллекции в хранилище
/// </summary>
/// <param name="name">Название коллекции</param>
/// <param name="collectionType">тип коллекции</param>
public void AddCollection(string name, CollectionType collectionType)
{
// TODO проверка, что name не пустой и нет в словаре записи с таким ключом
@ -48,10 +39,7 @@ public class StorageCollection<T>
}
}
/// <summary>
/// Удаление коллекции
/// </summary>
/// <param name="name">Название коллекции</param>
public void DelCollection(string name)
{
// TODO Прописать логику для удаления коллекции
@ -59,11 +47,7 @@ public class StorageCollection<T>
_storages.Remove(name);
}
/// <summary>
/// Доступ к коллекции
/// </summary>
/// <param name="name">Название коллекции</param>
/// <returns></returns>
public ICollectionGenericObjects<T>? this[string name]
{
get

View File

@ -13,6 +13,11 @@ public class EntityBoat
public double Weight { get; private set; }
public Color BodyColor { get; private set; }
public void SetBodyColor(Color color)
{
BodyColor = color;
}
public double Step => Speed * 100 / Weight;
public EntityBoat(int speed, double weight, Color bodyColor)

View File

@ -4,6 +4,11 @@ public class EntityMotorboat : EntityBoat
{
public Color AdditionalColor { get; private set; }
public void SetAdditionalColor(Color color)
{
AdditionalColor = color;
}
public bool Motor { get; private set; }
public bool Glass { get; private set; }

View File

@ -31,7 +31,6 @@
groupBoxTools = new GroupBox();
panelCompanyTools = new Panel();
buttonAddBoat = new Button();
buttonAddMotorboat = new Button();
maskedTextBox = new MaskedTextBox();
buttonRefresh = new Button();
buttonDelBoat = new Button();
@ -70,7 +69,6 @@
// panelCompanyTools
//
panelCompanyTools.Controls.Add(buttonAddBoat);
panelCompanyTools.Controls.Add(buttonAddMotorboat);
panelCompanyTools.Controls.Add(maskedTextBox);
panelCompanyTools.Controls.Add(buttonRefresh);
panelCompanyTools.Controls.Add(buttonDelBoat);
@ -93,17 +91,6 @@
buttonAddBoat.UseVisualStyleBackColor = true;
buttonAddBoat.Click += ButtonAddBoat_Click;
//
// buttonAddMotorboat
//
buttonAddMotorboat.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
buttonAddMotorboat.Location = new Point(6, 63);
buttonAddMotorboat.Name = "buttonAddMotorboat";
buttonAddMotorboat.Size = new Size(216, 54);
buttonAddMotorboat.TabIndex = 2;
buttonAddMotorboat.Text = "Добавление моторной лодки";
buttonAddMotorboat.UseVisualStyleBackColor = true;
buttonAddMotorboat.Click += ButtonMotorboat_Click;
//
// maskedTextBox
//
maskedTextBox.Location = new Point(3, 123);
@ -282,7 +269,6 @@
private Button buttonAddBoat;
private ComboBox comboBoxSelectorCompany;
private MaskedTextBox maskedTextBox;
private Button buttonAddMotorboat;
private PictureBox pictureBox;
private Button buttonDelBoat;
private Button buttonGoToCheck;

View File

@ -39,43 +39,22 @@ public partial class FormBoatCollection : Form
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ButtonAddBoat_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningBoat));
/// <summary>
/// Добавление спортивного автомобиля
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ButtonMotorboat_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningMotorboat));
/// <summary>
/// Создание объекта класса-перемещения
/// </summary>
/// <param name="type">Тип создаваемого объекта</param>
private void CreateObject(string type)
private void ButtonAddBoat_Click(object sender, EventArgs e)
{
FormBoatConfig form = new();
// TODO передать метод
form.AddEvent(SetBoat);
if (_company == null)
form.Show();
}
private void SetBoat(DrawningBoat? boat)
{
if (_company == null || boat == null)
{
return;
}
Random random = new();
DrawningBoat drawningBoat;
switch (type)
{
case nameof(DrawningBoat):
drawningBoat = new DrawningBoat(random.Next(100, 300), random.Next(1000, 3000), GetColor(random));
break;
case nameof(DrawningMotorboat):
drawningBoat = new DrawningMotorboat(random.Next(100, 300), random.Next(1000, 3000), GetColor(random),
GetColor(random), Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)));
break;
default:
return;
}
if (_company + drawningBoat != -1)
if (_company + boat != -1)
{
MessageBox.Show("Объект добавлен");
pictureBox.Image = _company.Show();
@ -84,24 +63,15 @@ public partial class FormBoatCollection : Form
{
MessageBox.Show("Не удалось добавить объект");
}
}
/// <summary>
/// Получение цвета
/// Создание объекта класса-перемещения
/// </summary>
/// <param name="random">Генератор случайных чисел</param>
/// <returns></returns>
private static Color GetColor(Random random)
{
Color color = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256));
ColorDialog dialog = new();
if (dialog.ShowDialog() == DialogResult.OK)
{
color = dialog.Color;
}
return color;
}
/// <param name="type">Тип создаваемого объекта</param>
/// <summary>
/// Удаление объекта

View File

@ -0,0 +1,357 @@
namespace ProjectMotorboat
{
partial class FormBoatConfig
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
groupBoxConfig = new GroupBox();
groupBoxColors = new GroupBox();
panelPurple = new Panel();
panelYellow = new Panel();
panelBlack = new Panel();
panelGray = new Panel();
panelBlue = new Panel();
panelWhite = new Panel();
panelGreen = new Panel();
panelRed = new Panel();
checkBoxGlass = new CheckBox();
checkBoxMotor = new CheckBox();
numericUpDownWeight = new NumericUpDown();
labelWeight = new Label();
numericUpDownSpeed = new NumericUpDown();
labelSpeed = new Label();
labelModifiedObject = new Label();
labelSimpleObject = new Label();
pictureBoxObject = new PictureBox();
buttonAdd = new Button();
buttonCancel = new Button();
panelObject = new Panel();
labelAdditionalColor = new Label();
labelBodyColor = new Label();
groupBoxConfig.SuspendLayout();
groupBoxColors.SuspendLayout();
((System.ComponentModel.ISupportInitialize)numericUpDownWeight).BeginInit();
((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).BeginInit();
((System.ComponentModel.ISupportInitialize)pictureBoxObject).BeginInit();
panelObject.SuspendLayout();
SuspendLayout();
//
// groupBoxConfig
//
groupBoxConfig.Controls.Add(groupBoxColors);
groupBoxConfig.Controls.Add(checkBoxGlass);
groupBoxConfig.Controls.Add(checkBoxMotor);
groupBoxConfig.Controls.Add(numericUpDownWeight);
groupBoxConfig.Controls.Add(labelWeight);
groupBoxConfig.Controls.Add(numericUpDownSpeed);
groupBoxConfig.Controls.Add(labelSpeed);
groupBoxConfig.Controls.Add(labelModifiedObject);
groupBoxConfig.Controls.Add(labelSimpleObject);
groupBoxConfig.Dock = DockStyle.Left;
groupBoxConfig.Location = new Point(0, 0);
groupBoxConfig.Name = "groupBoxConfig";
groupBoxConfig.Size = new Size(491, 255);
groupBoxConfig.TabIndex = 0;
groupBoxConfig.TabStop = false;
groupBoxConfig.Text = "Параметры";
//
// groupBoxColors
//
groupBoxColors.Controls.Add(panelPurple);
groupBoxColors.Controls.Add(panelYellow);
groupBoxColors.Controls.Add(panelBlack);
groupBoxColors.Controls.Add(panelGray);
groupBoxColors.Controls.Add(panelBlue);
groupBoxColors.Controls.Add(panelWhite);
groupBoxColors.Controls.Add(panelGreen);
groupBoxColors.Controls.Add(panelRed);
groupBoxColors.Location = new Point(227, 26);
groupBoxColors.Name = "groupBoxColors";
groupBoxColors.Size = new Size(252, 133);
groupBoxColors.TabIndex = 8;
groupBoxColors.TabStop = false;
groupBoxColors.Text = "Цвета";
//
// panelPurple
//
panelPurple.BackColor = Color.Purple;
panelPurple.Location = new Point(195, 83);
panelPurple.Name = "panelPurple";
panelPurple.Size = new Size(38, 32);
panelPurple.TabIndex = 3;
//
// panelYellow
//
panelYellow.BackColor = Color.Yellow;
panelYellow.Location = new Point(195, 26);
panelYellow.Name = "panelYellow";
panelYellow.Size = new Size(38, 32);
panelYellow.TabIndex = 1;
//
// panelBlack
//
panelBlack.BackColor = Color.Black;
panelBlack.Location = new Point(134, 83);
panelBlack.Name = "panelBlack";
panelBlack.Size = new Size(38, 32);
panelBlack.TabIndex = 4;
//
// panelGray
//
panelGray.BackColor = Color.Gray;
panelGray.Location = new Point(73, 83);
panelGray.Name = "panelGray";
panelGray.Size = new Size(38, 32);
panelGray.TabIndex = 5;
//
// panelBlue
//
panelBlue.BackColor = Color.Blue;
panelBlue.Location = new Point(134, 26);
panelBlue.Name = "panelBlue";
panelBlue.Size = new Size(38, 32);
panelBlue.TabIndex = 1;
//
// panelWhite
//
panelWhite.BackColor = Color.White;
panelWhite.Location = new Point(12, 83);
panelWhite.Name = "panelWhite";
panelWhite.Size = new Size(38, 32);
panelWhite.TabIndex = 2;
//
// panelGreen
//
panelGreen.BackColor = Color.Green;
panelGreen.Location = new Point(73, 26);
panelGreen.Name = "panelGreen";
panelGreen.Size = new Size(38, 32);
panelGreen.TabIndex = 1;
//
// panelRed
//
panelRed.BackColor = Color.Red;
panelRed.Location = new Point(12, 26);
panelRed.Name = "panelRed";
panelRed.Size = new Size(38, 32);
panelRed.TabIndex = 0;
//
// checkBoxGlass
//
checkBoxGlass.AutoSize = true;
checkBoxGlass.Location = new Point(6, 199);
checkBoxGlass.Name = "checkBoxGlass";
checkBoxGlass.Size = new Size(202, 24);
checkBoxGlass.TabIndex = 7;
checkBoxGlass.Text = "Признак наличия стекла";
checkBoxGlass.UseVisualStyleBackColor = true;
//
// checkBoxMotor
//
checkBoxMotor.AutoSize = true;
checkBoxMotor.Location = new Point(6, 171);
checkBoxMotor.Name = "checkBoxMotor";
checkBoxMotor.Size = new Size(210, 24);
checkBoxMotor.TabIndex = 6;
checkBoxMotor.Text = "Признак наличия мотора";
checkBoxMotor.UseVisualStyleBackColor = true;
//
// numericUpDownWeight
//
numericUpDownWeight.Location = new Point(84, 64);
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(88, 27);
numericUpDownWeight.TabIndex = 5;
numericUpDownWeight.Value = new decimal(new int[] { 100, 0, 0, 0 });
//
// labelWeight
//
labelWeight.AutoSize = true;
labelWeight.Location = new Point(6, 66);
labelWeight.Name = "labelWeight";
labelWeight.Size = new Size(36, 20);
labelWeight.TabIndex = 4;
labelWeight.Text = "Вес:";
//
// numericUpDownSpeed
//
numericUpDownSpeed.Location = new Point(84, 33);
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(88, 27);
numericUpDownSpeed.TabIndex = 3;
numericUpDownSpeed.Value = new decimal(new int[] { 100, 0, 0, 0 });
//
// labelSpeed
//
labelSpeed.AutoSize = true;
labelSpeed.Location = new Point(6, 33);
labelSpeed.Name = "labelSpeed";
labelSpeed.Size = new Size(76, 20);
labelSpeed.TabIndex = 2;
labelSpeed.Text = "Скорость:";
//
// labelModifiedObject
//
labelModifiedObject.BorderStyle = BorderStyle.FixedSingle;
labelModifiedObject.Location = new Point(362, 179);
labelModifiedObject.Name = "labelModifiedObject";
labelModifiedObject.Size = new Size(117, 44);
labelModifiedObject.TabIndex = 1;
labelModifiedObject.Text = "Продвинутый";
labelModifiedObject.TextAlign = ContentAlignment.MiddleCenter;
labelModifiedObject.MouseDown += LabelObject_MouseDown;
//
// labelSimpleObject
//
labelSimpleObject.BorderStyle = BorderStyle.FixedSingle;
labelSimpleObject.Location = new Point(227, 179);
labelSimpleObject.Name = "labelSimpleObject";
labelSimpleObject.Size = new Size(123, 44);
labelSimpleObject.TabIndex = 0;
labelSimpleObject.Text = "Простой";
labelSimpleObject.TextAlign = ContentAlignment.MiddleCenter;
labelSimpleObject.MouseDown += LabelObject_MouseDown;
//
// pictureBoxObject
//
pictureBoxObject.Location = new Point(30, 66);
pictureBoxObject.Name = "pictureBoxObject";
pictureBoxObject.Size = new Size(179, 140);
pictureBoxObject.TabIndex = 1;
pictureBoxObject.TabStop = false;
//
// buttonAdd
//
buttonAdd.Location = new Point(518, 214);
buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(94, 29);
buttonAdd.TabIndex = 2;
buttonAdd.Text = "Добавить";
buttonAdd.UseVisualStyleBackColor = true;
buttonAdd.Click += ButtonAdd_Click;
//
// buttonCancel
//
buttonCancel.Location = new Point(680, 214);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(94, 29);
buttonCancel.TabIndex = 3;
buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true;
//
// panelObject
//
panelObject.AllowDrop = true;
panelObject.Controls.Add(labelAdditionalColor);
panelObject.Controls.Add(labelBodyColor);
panelObject.Controls.Add(pictureBoxObject);
panelObject.Location = new Point(518, 0);
panelObject.Name = "panelObject";
panelObject.Size = new Size(256, 208);
panelObject.TabIndex = 4;
panelObject.DragDrop += PanelObject_DragDrop;
panelObject.DragEnter += PanelObject_DragEnter;
//
// labelAdditionalColor
//
labelAdditionalColor.AllowDrop = true;
labelAdditionalColor.BorderStyle = BorderStyle.FixedSingle;
labelAdditionalColor.Location = new Point(144, 9);
labelAdditionalColor.Name = "labelAdditionalColor";
labelAdditionalColor.Size = new Size(94, 29);
labelAdditionalColor.TabIndex = 3;
labelAdditionalColor.Text = "Доп. цвет";
labelAdditionalColor.TextAlign = ContentAlignment.MiddleCenter;
labelAdditionalColor.DragDrop += LabelAdditionalColor_DragDrop;
labelAdditionalColor.DragEnter += LabelAdditionalColor_DragEnter;
//
// labelBodyColor
//
labelBodyColor.AllowDrop = true;
labelBodyColor.BorderStyle = BorderStyle.FixedSingle;
labelBodyColor.Location = new Point(14, 9);
labelBodyColor.Name = "labelBodyColor";
labelBodyColor.Size = new Size(94, 29);
labelBodyColor.TabIndex = 2;
labelBodyColor.Text = "Цвет";
labelBodyColor.TextAlign = ContentAlignment.MiddleCenter;
labelBodyColor.DragDrop += LabelBodyColor_DragDrop;
labelBodyColor.DragEnter += LabelBodyColor_DragEnter;
//
// FormBoatConfig
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(811, 255);
Controls.Add(panelObject);
Controls.Add(buttonCancel);
Controls.Add(buttonAdd);
Controls.Add(groupBoxConfig);
Name = "FormBoatConfig";
Text = "Создание объекта";
groupBoxConfig.ResumeLayout(false);
groupBoxConfig.PerformLayout();
groupBoxColors.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)numericUpDownWeight).EndInit();
((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).EndInit();
((System.ComponentModel.ISupportInitialize)pictureBoxObject).EndInit();
panelObject.ResumeLayout(false);
ResumeLayout(false);
}
#endregion
private GroupBox groupBoxConfig;
private Label labelSimpleObject;
private Label labelModifiedObject;
private Label labelWeight;
private NumericUpDown numericUpDownSpeed;
private Label labelSpeed;
private NumericUpDown numericUpDownWeight;
private CheckBox checkBoxMotor;
private CheckBox checkBoxGlass;
private GroupBox groupBoxColors;
private Panel panelYellow;
private Panel panelBlue;
private Panel panelGreen;
private Panel panelRed;
private Panel panelPurple;
private Panel panelBlack;
private Panel panelGray;
private Panel panelWhite;
private PictureBox pictureBoxObject;
private Button buttonAdd;
private Button buttonCancel;
private Panel panelObject;
private Label labelAdditionalColor;
private Label labelBodyColor;
}
}

View File

@ -0,0 +1,147 @@
using ProjectMotorboat.Drownings;
using ProjectMotorboat.Entities;
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;
namespace ProjectMotorboat
{
public partial class FormBoatConfig : Form
{
private DrawningBoat? _boat;
private event BoatDelegate? BoatDelegate;
public FormBoatConfig()
{
InitializeComponent();
panelRed.MouseDown += Panel_MouseDown;
panelGreen.MouseDown += Panel_MouseDown;
panelBlue.MouseDown += Panel_MouseDown;
panelYellow.MouseDown += Panel_MouseDown;
panelWhite.MouseDown += Panel_MouseDown;
panelGray.MouseDown += Panel_MouseDown;
panelBlack.MouseDown += Panel_MouseDown;
panelPurple.MouseDown += Panel_MouseDown;
buttonCancel.Click += (sender, e) => Close();
}
public void AddEvent(BoatDelegate boatDelegate)
{
BoatDelegate += boatDelegate;
}
private void DrawObject()
{
Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height);
Graphics gr = Graphics.FromImage(bmp);
_boat?.SetPictureSize(pictureBoxObject.Width, pictureBoxObject.Height);
_boat?.SetPosition(15, 15);
_boat?.DrawTransport(gr);
pictureBoxObject.Image = bmp;
}
private void LabelObject_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)
{
e.Effect = e.Data?.GetDataPresent(DataFormats.Text) ?? false ? DragDropEffects.Copy : DragDropEffects.None;
}
private void PanelObject_DragDrop(object sender, DragEventArgs e)
{
switch (e.Data?.GetData(DataFormats.Text)?.ToString())
{
case "labelSimpleObject":
_boat = new DrawningBoat((int)numericUpDownSpeed.Value, (double)numericUpDownWeight.Value, Color.White);
break;
case "labelModifiedObject":
_boat = new DrawningMotorboat((int)numericUpDownSpeed.Value, (double)numericUpDownWeight.Value, Color.White,
Color.Black, checkBoxMotor.Checked, checkBoxGlass.Checked);
break;
}
DrawObject();
}
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 LabelBodyColor_DragEnter(object sender, DragEventArgs e)
{
if (e.Data?.GetDataPresent(typeof(Color)) ?? false)
{
e.Effect = DragDropEffects.Copy;
}
else
{
e.Effect = DragDropEffects.None;
}
}
private void LabelBodyColor_DragDrop(object sender, DragEventArgs e)
{
if (_boat != null)
{
if (e.Data?.GetDataPresent(typeof(Color)) ?? false)
{
_boat.EntityBoat.SetBodyColor((Color)e.Data.GetData(typeof(Color)));
}
DrawObject();
}
}
private void LabelAdditionalColor_DragEnter(object sender, DragEventArgs e)
{
if (_boat != null && _boat is DrawningMotorboat)
{
if (e.Data?.GetDataPresent(typeof(Color)) ?? false)
{
e.Effect = DragDropEffects.Copy;
}
else
{
e.Effect = DragDropEffects.None;
}
}
}
private void LabelAdditionalColor_DragDrop(object sender, DragEventArgs e)
{
if (_boat != null && _boat.EntityBoat is EntityMotorboat _battleship)
{
if (e.Data.GetDataPresent(typeof(Color)))
{
_battleship.SetAdditionalColor((Color)e.Data.GetData(typeof(Color)));
}
DrawObject();
}
}
private void ButtonAdd_Click(object sender, EventArgs e)
{
if (_boat != null)
{
BoatDelegate?.Invoke(_boat);
Close();
}
}
}
}

View File

@ -1,17 +1,17 @@
<?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
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>
@ -26,36 +26,36 @@
<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
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
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
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
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
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
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
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->