PIbd-23_Ivanova_S.V._Lab5 #7
@ -69,7 +69,7 @@ namespace MotorBoat.Generics
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return collect?._collection.Insert(obj) ?? false;
|
||||
return (bool)collect?._collection.Insert(obj);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -78,14 +78,14 @@ namespace MotorBoat.Generics
|
||||
/// <param name="collect"></param>
|
||||
/// <param name="pos"></param>
|
||||
/// <returns></returns>
|
||||
public static T? operator -(BoatsGenericCollection<T, U>? collect, int pos)
|
||||
public static bool operator -(BoatsGenericCollection<T, U>? collect, int pos)
|
||||
{
|
||||
T? obj = collect._collection[pos];
|
||||
if (obj != null)
|
||||
{
|
||||
collect._collection.Remove(pos);
|
||||
}
|
||||
return obj;
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -43,5 +43,9 @@ namespace MotorBoat.Entities
|
||||
Weight = weight;
|
||||
BodyColor = bodyColor;
|
||||
}
|
||||
internal void setBodyColor(Color color)
|
||||
{
|
||||
BodyColor = color;
|
||||
}
|
||||
}
|
||||
}
|
@ -44,5 +44,10 @@ namespace MotorBoat.Entities
|
||||
Engine = engine;
|
||||
Glass = glass;
|
||||
}
|
||||
|
||||
internal void setAdditionalColor(Color color)
|
||||
{
|
||||
AdditionalColor = color;
|
||||
}
|
||||
}
|
||||
}
|
@ -114,18 +114,29 @@ namespace MotorBoat
|
||||
if (obj == null)
|
||||
return;
|
||||
|
||||
FormMotorBoat form = new();
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
var FormBoatConfig = new FormBoatConfig();
|
||||
FormBoatConfig.AddEvent(AddBoat);
|
||||
FormBoatConfig.Show();
|
||||
}
|
||||
|
||||
private void AddBoat(DrawningBoat drawningBoat)
|
||||
{
|
||||
if (listBoxStorages.SelectedIndex == -1)
|
||||
return;
|
||||
|
||||
var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? string.Empty];
|
||||
|
||||
if (obj == null)
|
||||
return;
|
||||
|
||||
if (obj + drawningBoat)
|
||||
{
|
||||
if (obj + form.SelectedBoat)
|
||||
{
|
||||
MessageBox.Show("Объект добавлен");
|
||||
pictureBoxCollection.Image = obj.ShowBoats();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Не удалось добавить объект");
|
||||
}
|
||||
MessageBox.Show("Объект добавлен");
|
||||
pictureBoxCollection.Image = obj.ShowBoats();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Не удалось добавить объект");
|
||||
}
|
||||
}
|
||||
|
||||
|
393
MotorBoat/MotorBoat/FormBoatConfig.Designer.cs
generated
Normal file
393
MotorBoat/MotorBoat/FormBoatConfig.Designer.cs
generated
Normal file
@ -0,0 +1,393 @@
|
||||
namespace MotorBoat
|
||||
{
|
||||
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()
|
||||
{
|
||||
groupBox1 = new GroupBox();
|
||||
labelModifiedObject = new Label();
|
||||
labelSimpleObject = new Label();
|
||||
PanelColor = new GroupBox();
|
||||
panelMilky = new Panel();
|
||||
panelRed = new Panel();
|
||||
panel8 = new Panel();
|
||||
panelCherry = new Panel();
|
||||
panelPeach = new Panel();
|
||||
panelGreen = new Panel();
|
||||
panelOrange = new Panel();
|
||||
panelGrey = new Panel();
|
||||
panelBrown = new Panel();
|
||||
checkBoxEngine = new CheckBox();
|
||||
checkBoxGlass = new CheckBox();
|
||||
label2 = new Label();
|
||||
label1 = new Label();
|
||||
numericUpDownWeight = new NumericUpDown();
|
||||
numericUpDownSpeed = new NumericUpDown();
|
||||
buttonAdd = new Button();
|
||||
buttonCancel = new Button();
|
||||
PanelObject = new Panel();
|
||||
labelBodyColor = new Label();
|
||||
labelAdditionalColor = new Label();
|
||||
pictureBoxObject = new PictureBox();
|
||||
groupBox1.SuspendLayout();
|
||||
PanelColor.SuspendLayout();
|
||||
panelRed.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownWeight).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).BeginInit();
|
||||
PanelObject.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBoxObject).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// groupBox1
|
||||
//
|
||||
groupBox1.Controls.Add(labelModifiedObject);
|
||||
groupBox1.Controls.Add(labelSimpleObject);
|
||||
groupBox1.Controls.Add(PanelColor);
|
||||
groupBox1.Controls.Add(checkBoxEngine);
|
||||
groupBox1.Controls.Add(checkBoxGlass);
|
||||
groupBox1.Controls.Add(label2);
|
||||
groupBox1.Controls.Add(label1);
|
||||
groupBox1.Controls.Add(numericUpDownWeight);
|
||||
groupBox1.Controls.Add(numericUpDownSpeed);
|
||||
groupBox1.Location = new Point(12, 12);
|
||||
groupBox1.Name = "groupBox1";
|
||||
groupBox1.Size = new Size(499, 264);
|
||||
groupBox1.TabIndex = 1;
|
||||
groupBox1.TabStop = false;
|
||||
groupBox1.Text = "Настройки объекта";
|
||||
//
|
||||
// labelModifiedObject
|
||||
//
|
||||
labelModifiedObject.AllowDrop = true;
|
||||
labelModifiedObject.BorderStyle = BorderStyle.FixedSingle;
|
||||
labelModifiedObject.Location = new Point(368, 178);
|
||||
labelModifiedObject.Margin = new Padding(0);
|
||||
labelModifiedObject.Name = "labelModifiedObject";
|
||||
labelModifiedObject.Padding = new Padding(12);
|
||||
labelModifiedObject.Size = new Size(119, 42);
|
||||
labelModifiedObject.TabIndex = 10;
|
||||
labelModifiedObject.Text = "Продвинутый";
|
||||
labelModifiedObject.TextAlign = ContentAlignment.TopCenter;
|
||||
labelModifiedObject.MouseDown += labelSimpleObject_MouseDown;
|
||||
//
|
||||
// labelSimpleObject
|
||||
//
|
||||
labelSimpleObject.AllowDrop = true;
|
||||
labelSimpleObject.BorderStyle = BorderStyle.FixedSingle;
|
||||
labelSimpleObject.Location = new Point(242, 178);
|
||||
labelSimpleObject.Name = "labelSimpleObject";
|
||||
labelSimpleObject.Padding = new Padding(12);
|
||||
labelSimpleObject.Size = new Size(120, 42);
|
||||
labelSimpleObject.TabIndex = 9;
|
||||
labelSimpleObject.Text = "Простой";
|
||||
labelSimpleObject.TextAlign = ContentAlignment.TopCenter;
|
||||
labelSimpleObject.MouseDown += labelSimpleObject_MouseDown;
|
||||
//
|
||||
// PanelColor
|
||||
//
|
||||
PanelColor.Controls.Add(panelMilky);
|
||||
PanelColor.Controls.Add(panelRed);
|
||||
PanelColor.Controls.Add(panelCherry);
|
||||
PanelColor.Controls.Add(panelPeach);
|
||||
PanelColor.Controls.Add(panelGreen);
|
||||
PanelColor.Controls.Add(panelOrange);
|
||||
PanelColor.Controls.Add(panelGrey);
|
||||
PanelColor.Controls.Add(panelBrown);
|
||||
PanelColor.Location = new Point(242, 22);
|
||||
PanelColor.Name = "PanelColor";
|
||||
PanelColor.Size = new Size(245, 141);
|
||||
PanelColor.TabIndex = 8;
|
||||
PanelColor.TabStop = false;
|
||||
PanelColor.Text = "Выбор цвета";
|
||||
//
|
||||
// panelMilky
|
||||
//
|
||||
panelMilky.AllowDrop = true;
|
||||
panelMilky.BackColor = Color.LightGoldenrodYellow;
|
||||
panelMilky.BorderStyle = BorderStyle.FixedSingle;
|
||||
panelMilky.Location = new Point(126, 19);
|
||||
panelMilky.Name = "panelMilky";
|
||||
panelMilky.Size = new Size(50, 50);
|
||||
panelMilky.TabIndex = 7;
|
||||
//
|
||||
// panelRed
|
||||
//
|
||||
panelRed.AllowDrop = true;
|
||||
panelRed.BackColor = Color.Firebrick;
|
||||
panelRed.BorderStyle = BorderStyle.FixedSingle;
|
||||
panelRed.Controls.Add(panel8);
|
||||
panelRed.Location = new Point(70, 19);
|
||||
panelRed.Name = "panelRed";
|
||||
panelRed.Size = new Size(50, 50);
|
||||
panelRed.TabIndex = 6;
|
||||
//
|
||||
// panel8
|
||||
//
|
||||
panel8.BackColor = Color.FromArgb(255, 255, 192);
|
||||
panel8.Location = new Point(53, 8);
|
||||
panel8.Name = "panel8";
|
||||
panel8.Size = new Size(50, 50);
|
||||
panel8.TabIndex = 7;
|
||||
//
|
||||
// panelCherry
|
||||
//
|
||||
panelCherry.AllowDrop = true;
|
||||
panelCherry.BackColor = Color.Maroon;
|
||||
panelCherry.BorderStyle = BorderStyle.FixedSingle;
|
||||
panelCherry.Location = new Point(14, 78);
|
||||
panelCherry.Name = "panelCherry";
|
||||
panelCherry.Size = new Size(50, 50);
|
||||
panelCherry.TabIndex = 5;
|
||||
//
|
||||
// panelPeach
|
||||
//
|
||||
panelPeach.AllowDrop = true;
|
||||
panelPeach.BackColor = Color.SandyBrown;
|
||||
panelPeach.BorderStyle = BorderStyle.FixedSingle;
|
||||
panelPeach.Location = new Point(182, 19);
|
||||
panelPeach.Name = "panelPeach";
|
||||
panelPeach.Size = new Size(50, 50);
|
||||
panelPeach.TabIndex = 4;
|
||||
//
|
||||
// panelGreen
|
||||
//
|
||||
panelGreen.AllowDrop = true;
|
||||
panelGreen.BackColor = Color.DarkGreen;
|
||||
panelGreen.BorderStyle = BorderStyle.FixedSingle;
|
||||
panelGreen.Location = new Point(70, 78);
|
||||
panelGreen.Name = "panelGreen";
|
||||
panelGreen.Size = new Size(50, 50);
|
||||
panelGreen.TabIndex = 3;
|
||||
//
|
||||
// panelOrange
|
||||
//
|
||||
panelOrange.AllowDrop = true;
|
||||
panelOrange.BackColor = Color.Orange;
|
||||
panelOrange.BorderStyle = BorderStyle.FixedSingle;
|
||||
panelOrange.Location = new Point(126, 78);
|
||||
panelOrange.Name = "panelOrange";
|
||||
panelOrange.Size = new Size(50, 50);
|
||||
panelOrange.TabIndex = 2;
|
||||
//
|
||||
// panelGrey
|
||||
//
|
||||
panelGrey.AllowDrop = true;
|
||||
panelGrey.BackColor = Color.Silver;
|
||||
panelGrey.BorderStyle = BorderStyle.FixedSingle;
|
||||
panelGrey.Location = new Point(182, 78);
|
||||
panelGrey.Name = "panelGrey";
|
||||
panelGrey.Size = new Size(50, 50);
|
||||
panelGrey.TabIndex = 1;
|
||||
//
|
||||
// panelBrown
|
||||
//
|
||||
panelBrown.AllowDrop = true;
|
||||
panelBrown.BackColor = Color.SaddleBrown;
|
||||
panelBrown.BorderStyle = BorderStyle.FixedSingle;
|
||||
panelBrown.Location = new Point(14, 19);
|
||||
panelBrown.Name = "panelBrown";
|
||||
panelBrown.Size = new Size(50, 50);
|
||||
panelBrown.TabIndex = 0;
|
||||
//
|
||||
// checkBoxEngine
|
||||
//
|
||||
checkBoxEngine.AutoSize = true;
|
||||
checkBoxEngine.Location = new Point(11, 126);
|
||||
checkBoxEngine.Name = "checkBoxEngine";
|
||||
checkBoxEngine.Size = new Size(225, 19);
|
||||
checkBoxEngine.TabIndex = 7;
|
||||
checkBoxEngine.Text = "Признак наличия защитного стекла";
|
||||
checkBoxEngine.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// checkBoxGlass
|
||||
//
|
||||
checkBoxGlass.AutoSize = true;
|
||||
checkBoxGlass.Location = new Point(11, 99);
|
||||
checkBoxGlass.Name = "checkBoxGlass";
|
||||
checkBoxGlass.Size = new Size(180, 19);
|
||||
checkBoxGlass.TabIndex = 6;
|
||||
checkBoxGlass.Text = "Признак наличия двигателя";
|
||||
checkBoxGlass.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// label2
|
||||
//
|
||||
label2.AutoSize = true;
|
||||
label2.Location = new Point(11, 51);
|
||||
label2.Name = "label2";
|
||||
label2.Size = new Size(29, 15);
|
||||
label2.TabIndex = 5;
|
||||
label2.Text = "Вес:";
|
||||
//
|
||||
// label1
|
||||
//
|
||||
label1.AutoSize = true;
|
||||
label1.Location = new Point(8, 24);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new Size(62, 15);
|
||||
label1.TabIndex = 4;
|
||||
label1.Text = "Скорость:";
|
||||
//
|
||||
// numericUpDownWeight
|
||||
//
|
||||
numericUpDownWeight.Location = new Point(74, 51);
|
||||
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(120, 23);
|
||||
numericUpDownWeight.TabIndex = 3;
|
||||
numericUpDownWeight.Value = new decimal(new int[] { 100, 0, 0, 0 });
|
||||
//
|
||||
// numericUpDownSpeed
|
||||
//
|
||||
numericUpDownSpeed.Location = new Point(74, 22);
|
||||
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(120, 23);
|
||||
numericUpDownSpeed.TabIndex = 2;
|
||||
numericUpDownSpeed.Value = new decimal(new int[] { 100, 0, 0, 0 });
|
||||
//
|
||||
// buttonAdd
|
||||
//
|
||||
buttonAdd.Location = new Point(544, 230);
|
||||
buttonAdd.Name = "buttonAdd";
|
||||
buttonAdd.Size = new Size(112, 46);
|
||||
buttonAdd.TabIndex = 13;
|
||||
buttonAdd.Text = "Добавить";
|
||||
buttonAdd.UseVisualStyleBackColor = true;
|
||||
buttonAdd.Click += buttonAdd_Click;
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
buttonCancel.Location = new Point(661, 230);
|
||||
buttonCancel.Name = "buttonCancel";
|
||||
buttonCancel.Size = new Size(111, 46);
|
||||
buttonCancel.TabIndex = 14;
|
||||
buttonCancel.Text = "Отмена";
|
||||
buttonCancel.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// PanelObject
|
||||
//
|
||||
PanelObject.AllowDrop = true;
|
||||
PanelObject.Controls.Add(labelBodyColor);
|
||||
PanelObject.Controls.Add(labelAdditionalColor);
|
||||
PanelObject.Controls.Add(pictureBoxObject);
|
||||
PanelObject.Location = new Point(527, 16);
|
||||
PanelObject.Name = "PanelObject";
|
||||
PanelObject.Size = new Size(259, 208);
|
||||
PanelObject.TabIndex = 15;
|
||||
PanelObject.DragDrop += labelObject_DragDrop;
|
||||
PanelObject.DragEnter += labelObject_DragEnter;
|
||||
//
|
||||
// labelBodyColor
|
||||
//
|
||||
labelBodyColor.AllowDrop = true;
|
||||
labelBodyColor.BorderStyle = BorderStyle.FixedSingle;
|
||||
labelBodyColor.Location = new Point(16, 5);
|
||||
labelBodyColor.Margin = new Padding(0);
|
||||
labelBodyColor.Name = "labelBodyColor";
|
||||
labelBodyColor.Padding = new Padding(12);
|
||||
labelBodyColor.Size = new Size(112, 48);
|
||||
labelBodyColor.TabIndex = 14;
|
||||
labelBodyColor.Text = "Цвет";
|
||||
labelBodyColor.TextAlign = ContentAlignment.TopCenter;
|
||||
labelBodyColor.DragDrop += labelBodyColor_DragDrop;
|
||||
labelBodyColor.DragEnter += labelColor_DragEnter;
|
||||
//
|
||||
// labelAdditionalColor
|
||||
//
|
||||
labelAdditionalColor.AllowDrop = true;
|
||||
labelAdditionalColor.BorderStyle = BorderStyle.FixedSingle;
|
||||
labelAdditionalColor.Location = new Point(133, 5);
|
||||
labelAdditionalColor.Margin = new Padding(0);
|
||||
labelAdditionalColor.Name = "labelAdditionalColor";
|
||||
labelAdditionalColor.Padding = new Padding(12);
|
||||
labelAdditionalColor.Size = new Size(112, 48);
|
||||
labelAdditionalColor.TabIndex = 13;
|
||||
labelAdditionalColor.Text = "Доп. цвет";
|
||||
labelAdditionalColor.TextAlign = ContentAlignment.TopCenter;
|
||||
labelAdditionalColor.DragDrop += labelAdditionalColor_DragDrop;
|
||||
labelAdditionalColor.DragEnter += labelColor_DragEnter;
|
||||
//
|
||||
// pictureBoxObject
|
||||
//
|
||||
pictureBoxObject.Location = new Point(16, 61);
|
||||
pictureBoxObject.Name = "pictureBoxObject";
|
||||
pictureBoxObject.Size = new Size(229, 137);
|
||||
pictureBoxObject.TabIndex = 4;
|
||||
pictureBoxObject.TabStop = false;
|
||||
//
|
||||
// FormBoatConfig
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(802, 288);
|
||||
Controls.Add(PanelObject);
|
||||
Controls.Add(buttonCancel);
|
||||
Controls.Add(buttonAdd);
|
||||
Controls.Add(groupBox1);
|
||||
Name = "FormBoatConfig";
|
||||
Text = "Создание объекта";
|
||||
groupBox1.ResumeLayout(false);
|
||||
groupBox1.PerformLayout();
|
||||
PanelColor.ResumeLayout(false);
|
||||
panelRed.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownWeight).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).EndInit();
|
||||
PanelObject.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)pictureBoxObject).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
private GroupBox groupBox1;
|
||||
private CheckBox checkBoxEngine;
|
||||
private CheckBox checkBoxGlass;
|
||||
private Label label2;
|
||||
private Label label1;
|
||||
private NumericUpDown numericUpDownWeight;
|
||||
private NumericUpDown numericUpDownSpeed;
|
||||
private GroupBox PanelColor;
|
||||
private Panel panelMilky;
|
||||
private Panel panelRed;
|
||||
private Panel panel8;
|
||||
private Panel panelCherry;
|
||||
private Panel panelPeach;
|
||||
private Panel panelGreen;
|
||||
private Panel panelOrange;
|
||||
private Panel panelGrey;
|
||||
private Panel panelBrown;
|
||||
private Label labelModifiedObject;
|
||||
private Label labelSimpleObject;
|
||||
private Button buttonAdd;
|
||||
private Button buttonCancel;
|
||||
private Panel PanelObject;
|
||||
private PictureBox pictureBoxObject;
|
||||
private Label labelBodyColor;
|
||||
private Label labelAdditionalColor;
|
||||
}
|
||||
}
|
168
MotorBoat/MotorBoat/FormBoatConfig.cs
Normal file
168
MotorBoat/MotorBoat/FormBoatConfig.cs
Normal file
@ -0,0 +1,168 @@
|
||||
using MotorBoat.DrawningObjects;
|
||||
using MotorBoat.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 MotorBoat
|
||||
{
|
||||
public partial class FormBoatConfig : Form
|
||||
{
|
||||
/// <summary>
|
||||
/// Переменная-выбранная лодка
|
||||
/// </summary>
|
||||
DrawningBoat? _boat = null;
|
||||
|
||||
/// <summary>
|
||||
/// Событие
|
||||
/// </summary>
|
||||
public event Action<DrawningBoat>? EventAddBoat;
|
||||
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
public FormBoatConfig()
|
||||
{
|
||||
InitializeComponent();
|
||||
panelBrown.MouseDown += PanelColor_MouseDown;
|
||||
panelRed.MouseDown += PanelColor_MouseDown;
|
||||
panelMilky.MouseDown += PanelColor_MouseDown;
|
||||
panelPeach.MouseDown += PanelColor_MouseDown;
|
||||
panelGrey.MouseDown += PanelColor_MouseDown;
|
||||
panelOrange.MouseDown += PanelColor_MouseDown;
|
||||
panelGreen.MouseDown += PanelColor_MouseDown;
|
||||
panelCherry.MouseDown += PanelColor_MouseDown;
|
||||
|
||||
buttonCancel.Click += (s, e) => Close();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Отрисовать лодку
|
||||
/// </summary>
|
||||
private void DrawBoat()
|
||||
{
|
||||
Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height);
|
||||
Graphics gr = Graphics.FromImage(bmp);
|
||||
_boat?.SetPosition(5, 5);
|
||||
_boat?.DrawTransport(gr);
|
||||
pictureBoxObject.Image = bmp;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Передаем информацию при нажатии на Label
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void labelSimpleObject_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
(sender as Label)?.DoDragDrop((sender as Label)?.Name, DragDropEffects.Move | DragDropEffects.Copy);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Проверка получаемой информации (ее типа на соответствие требуемому)
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void labelObject_DragEnter(object sender, DragEventArgs e)
|
||||
{
|
||||
if (e.Data?.GetDataPresent(DataFormats.Text) ?? false)
|
||||
{
|
||||
e.Effect = DragDropEffects.Copy;
|
||||
}
|
||||
else
|
||||
{
|
||||
e.Effect = DragDropEffects.None;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Действия при приеме перетаскиваемой информации
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void labelObject_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
switch (e.Data?.GetData(DataFormats.Text).ToString())
|
||||
{
|
||||
case "labelSimpleObject":
|
||||
_boat = new DrawningBoat((int)numericUpDownSpeed.Value,
|
||||
(int)numericUpDownWeight.Value, Color.White, pictureBoxObject.Width, pictureBoxObject.Height);
|
||||
break;
|
||||
case "labelModifiedObject":
|
||||
_boat = new DrawningMotorBoat((int)numericUpDownSpeed.Value,
|
||||
(int)numericUpDownWeight.Value, Color.White, Color.Black, checkBoxGlass.Checked,
|
||||
checkBoxEngine.Checked, pictureBoxObject.Width, pictureBoxObject.Height);
|
||||
break;
|
||||
}
|
||||
DrawBoat();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Добавление лодки
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void PanelColor_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
(sender as Panel)?.DoDragDrop((sender as Panel)?.BackColor, DragDropEffects.Move | DragDropEffects.Copy);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Добавление события
|
||||
/// </summary>
|
||||
/// <param name="ev">Привязанный метод</param>
|
||||
internal void AddEvent(Action<DrawningBoat> ev)
|
||||
{
|
||||
if (EventAddBoat == null)
|
||||
{
|
||||
EventAddBoat = ev;
|
||||
}
|
||||
else
|
||||
{
|
||||
EventAddBoat += ev;
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
EventAddBoat?.Invoke(_boat);
|
||||
Close();
|
||||
}
|
||||
|
||||
private void labelBodyColor_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
if (_boat == null)
|
||||
return;
|
||||
_boat?.EntityBoat?.setBodyColor((Color)e.Data.GetData(typeof(Color)));
|
||||
DrawBoat();
|
||||
}
|
||||
|
||||
private void labelAdditionalColor_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
if (_boat == null)
|
||||
return;
|
||||
if (!(_boat is DrawningMotorBoat))
|
||||
return;
|
||||
(_boat.EntityBoat as EntityMotorBoat)?.setAdditionalColor(color: (Color)e.Data.GetData(typeof(Color)));
|
||||
DrawBoat();
|
||||
}
|
||||
|
||||
private void labelColor_DragEnter(object sender, DragEventArgs e)
|
||||
{
|
||||
if (e.Data?.GetDataPresent(typeof(Color)) ?? false)
|
||||
{
|
||||
e.Effect = DragDropEffects.Copy;
|
||||
}
|
||||
else
|
||||
{
|
||||
e.Effect = DragDropEffects.None;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
60
MotorBoat/MotorBoat/FormBoatConfig.resx
Normal file
60
MotorBoat/MotorBoat/FormBoatConfig.resx
Normal file
@ -0,0 +1,60 @@
|
||||
<root>
|
||||
<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>
|
@ -108,7 +108,7 @@ namespace MotorBoat.Generics
|
||||
/// </summary>
|
||||
/// <param name="maxShips"></param>
|
||||
/// <returns></returns>
|
||||
public IEnumerable<T> GetBoats(int? maxBoats = null)
|
||||
public IEnumerable<T?> GetBoats(int? maxBoats = null)
|
||||
{
|
||||
for (int i = 0; i < _places.Count; ++i)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user