Lab5 WarmlyShip Barsukov
This commit is contained in:
parent
bfde6534c3
commit
1066642b8d
@ -10,7 +10,7 @@ namespace ProjectWarmlyShip.Entities
|
||||
{
|
||||
public int Speed { get; private set; }
|
||||
public double Weight { get; private set; }
|
||||
public Color MainColor { get; private set; }
|
||||
public Color MainColor { get; set; }
|
||||
public double Step => (double)Speed * 100 / Weight;
|
||||
public EntityShip(int speed, double weight, Color mainColor)
|
||||
{
|
||||
|
@ -8,7 +8,7 @@ namespace ProjectWarmlyShip.Entities
|
||||
{
|
||||
public class EntityWarmlyShip : EntityShip
|
||||
{
|
||||
public Color OptionalColor { get; private set; }
|
||||
public Color OptionalColor { get; set; }
|
||||
public bool Pipes { get; private set; }
|
||||
public bool FuelCompartment { get; private set; }
|
||||
public EntityWarmlyShip(int speed, double weight,
|
||||
|
@ -18,6 +18,14 @@ namespace ProjectWarmlyShip
|
||||
{
|
||||
public partial class FormShipCollection : Form
|
||||
{
|
||||
public int GetWidth()
|
||||
{
|
||||
return pictureBoxCollection.Width;
|
||||
}
|
||||
public int GetHeight()
|
||||
{
|
||||
return pictureBoxCollection.Height;
|
||||
}
|
||||
private readonly ShipsGenericStorage _storage;
|
||||
public FormShipCollection()
|
||||
{
|
||||
@ -83,18 +91,29 @@ namespace ProjectWarmlyShip
|
||||
{
|
||||
return;
|
||||
}
|
||||
WarmlyShipForm form = new();
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
var formShipConfig = new FormShipConfig();
|
||||
formShipConfig.Show();
|
||||
formShipConfig.AddEvent(AddShip);
|
||||
}
|
||||
private void AddShip(DrawingShip ship)
|
||||
{
|
||||
if (listBoxStorage.SelectedIndex == -1)
|
||||
{
|
||||
if (obj + form.SelectedShip)
|
||||
{
|
||||
MessageBox.Show("Object Inserted");
|
||||
pictureBoxCollection.Image = obj.ShowShips();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Object Not Inserted");
|
||||
}
|
||||
return;
|
||||
}
|
||||
var obj = _storage[listBoxStorage.SelectedItem.ToString() ?? string.Empty];
|
||||
if (obj == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (obj + ship)
|
||||
{
|
||||
MessageBox.Show("Object Inserted");
|
||||
pictureBoxCollection.Image = obj.ShowShips();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Object Not Inserted");
|
||||
}
|
||||
}
|
||||
private void ButtonRemoveShip_Click(Object sender, EventArgs e)
|
||||
|
360
ProjectWarmlyShip/ProjectWarmlyShip/FormShipConfig.Designer.cs
generated
Normal file
360
ProjectWarmlyShip/ProjectWarmlyShip/FormShipConfig.Designer.cs
generated
Normal file
@ -0,0 +1,360 @@
|
||||
namespace ProjectWarmlyShip
|
||||
{
|
||||
partial class FormShipConfig
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
groupBoxParameters = new GroupBox();
|
||||
labelAdvancedObject = new Label();
|
||||
labelSimpleObject = new Label();
|
||||
groupBoxColors = new GroupBox();
|
||||
panelGray = new Panel();
|
||||
panelWhite = new Panel();
|
||||
panelPurple = new Panel();
|
||||
panelBlack = new Panel();
|
||||
panelYellow = new Panel();
|
||||
panelGreen = new Panel();
|
||||
panelRed = new Panel();
|
||||
panelBlue = new Panel();
|
||||
checkBoxFuelCompartment = new CheckBox();
|
||||
checkBoxPipes = new CheckBox();
|
||||
numericUpDownWeight = new NumericUpDown();
|
||||
numericUpDownSpeed = new NumericUpDown();
|
||||
labelWeight = new Label();
|
||||
labelSpeed = new Label();
|
||||
panelObject = new Panel();
|
||||
labelMainColor = new Label();
|
||||
labelOptionalColor = new Label();
|
||||
pictureBoxObject = new PictureBox();
|
||||
buttonAdd = new Button();
|
||||
buttonCancel = new Button();
|
||||
groupBoxParameters.SuspendLayout();
|
||||
groupBoxColors.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownWeight).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).BeginInit();
|
||||
panelObject.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBoxObject).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// groupBoxParameters
|
||||
//
|
||||
groupBoxParameters.Controls.Add(labelAdvancedObject);
|
||||
groupBoxParameters.Controls.Add(labelSimpleObject);
|
||||
groupBoxParameters.Controls.Add(groupBoxColors);
|
||||
groupBoxParameters.Controls.Add(checkBoxFuelCompartment);
|
||||
groupBoxParameters.Controls.Add(checkBoxPipes);
|
||||
groupBoxParameters.Controls.Add(numericUpDownWeight);
|
||||
groupBoxParameters.Controls.Add(numericUpDownSpeed);
|
||||
groupBoxParameters.Controls.Add(labelWeight);
|
||||
groupBoxParameters.Controls.Add(labelSpeed);
|
||||
groupBoxParameters.Location = new Point(10, 10);
|
||||
groupBoxParameters.Name = "groupBoxParameters";
|
||||
groupBoxParameters.Size = new Size(450, 220);
|
||||
groupBoxParameters.TabIndex = 7;
|
||||
groupBoxParameters.TabStop = false;
|
||||
groupBoxParameters.Text = "Parameters";
|
||||
//
|
||||
// labelAdvancedObject
|
||||
//
|
||||
labelAdvancedObject.BorderStyle = BorderStyle.FixedSingle;
|
||||
labelAdvancedObject.Font = new Font("Segoe UI", 15.75F, FontStyle.Regular, GraphicsUnit.Point);
|
||||
labelAdvancedObject.Location = new Point(320, 173);
|
||||
labelAdvancedObject.Name = "labelAdvancedObject";
|
||||
labelAdvancedObject.Size = new Size(110, 35);
|
||||
labelAdvancedObject.TabIndex = 8;
|
||||
labelAdvancedObject.Text = "Advanced";
|
||||
labelAdvancedObject.TextAlign = ContentAlignment.MiddleCenter;
|
||||
labelAdvancedObject.MouseDown += LabelObject_MouseDown;
|
||||
//
|
||||
// labelSimpleObject
|
||||
//
|
||||
labelSimpleObject.BorderStyle = BorderStyle.FixedSingle;
|
||||
labelSimpleObject.Font = new Font("Segoe UI", 15.75F, FontStyle.Regular, GraphicsUnit.Point);
|
||||
labelSimpleObject.Location = new Point(200, 173);
|
||||
labelSimpleObject.Name = "labelSimpleObject";
|
||||
labelSimpleObject.Size = new Size(110, 35);
|
||||
labelSimpleObject.TabIndex = 7;
|
||||
labelSimpleObject.Text = "Simple";
|
||||
labelSimpleObject.TextAlign = ContentAlignment.MiddleCenter;
|
||||
labelSimpleObject.MouseDown += LabelObject_MouseDown;
|
||||
//
|
||||
// groupBoxColors
|
||||
//
|
||||
groupBoxColors.Controls.Add(panelGray);
|
||||
groupBoxColors.Controls.Add(panelWhite);
|
||||
groupBoxColors.Controls.Add(panelPurple);
|
||||
groupBoxColors.Controls.Add(panelBlack);
|
||||
groupBoxColors.Controls.Add(panelYellow);
|
||||
groupBoxColors.Controls.Add(panelGreen);
|
||||
groupBoxColors.Controls.Add(panelRed);
|
||||
groupBoxColors.Controls.Add(panelBlue);
|
||||
groupBoxColors.Location = new Point(200, 30);
|
||||
groupBoxColors.Name = "groupBoxColors";
|
||||
groupBoxColors.Size = new Size(230, 140);
|
||||
groupBoxColors.TabIndex = 6;
|
||||
groupBoxColors.TabStop = false;
|
||||
groupBoxColors.Text = "Colors";
|
||||
//
|
||||
// panelGray
|
||||
//
|
||||
panelGray.BackColor = Color.Gray;
|
||||
panelGray.Location = new Point(170, 80);
|
||||
panelGray.Name = "panelGray";
|
||||
panelGray.Size = new Size(50, 50);
|
||||
panelGray.TabIndex = 1;
|
||||
//
|
||||
// panelWhite
|
||||
//
|
||||
panelWhite.BackColor = Color.White;
|
||||
panelWhite.Location = new Point(115, 80);
|
||||
panelWhite.Name = "panelWhite";
|
||||
panelWhite.Size = new Size(50, 50);
|
||||
panelWhite.TabIndex = 1;
|
||||
//
|
||||
// panelPurple
|
||||
//
|
||||
panelPurple.BackColor = Color.Purple;
|
||||
panelPurple.Location = new Point(60, 80);
|
||||
panelPurple.Name = "panelPurple";
|
||||
panelPurple.Size = new Size(50, 50);
|
||||
panelPurple.TabIndex = 2;
|
||||
//
|
||||
// panelBlack
|
||||
//
|
||||
panelBlack.BackColor = Color.Black;
|
||||
panelBlack.Location = new Point(5, 80);
|
||||
panelBlack.Name = "panelBlack";
|
||||
panelBlack.Size = new Size(50, 50);
|
||||
panelBlack.TabIndex = 1;
|
||||
//
|
||||
// panelYellow
|
||||
//
|
||||
panelYellow.BackColor = Color.Yellow;
|
||||
panelYellow.Location = new Point(170, 20);
|
||||
panelYellow.Name = "panelYellow";
|
||||
panelYellow.Size = new Size(50, 50);
|
||||
panelYellow.TabIndex = 1;
|
||||
//
|
||||
// panelGreen
|
||||
//
|
||||
panelGreen.BackColor = Color.Green;
|
||||
panelGreen.Location = new Point(115, 20);
|
||||
panelGreen.Name = "panelGreen";
|
||||
panelGreen.Size = new Size(50, 50);
|
||||
panelGreen.TabIndex = 1;
|
||||
//
|
||||
// panelRed
|
||||
//
|
||||
panelRed.BackColor = Color.Red;
|
||||
panelRed.Location = new Point(60, 20);
|
||||
panelRed.Name = "panelRed";
|
||||
panelRed.Size = new Size(50, 50);
|
||||
panelRed.TabIndex = 1;
|
||||
//
|
||||
// panelBlue
|
||||
//
|
||||
panelBlue.BackColor = Color.Blue;
|
||||
panelBlue.Location = new Point(5, 20);
|
||||
panelBlue.Name = "panelBlue";
|
||||
panelBlue.Size = new Size(50, 50);
|
||||
panelBlue.TabIndex = 0;
|
||||
//
|
||||
// checkBoxFuelCompartment
|
||||
//
|
||||
checkBoxFuelCompartment.AutoSize = true;
|
||||
checkBoxFuelCompartment.Location = new Point(20, 145);
|
||||
checkBoxFuelCompartment.Name = "checkBoxFuelCompartment";
|
||||
checkBoxFuelCompartment.Size = new Size(124, 19);
|
||||
checkBoxFuelCompartment.TabIndex = 5;
|
||||
checkBoxFuelCompartment.Text = "Fuel compartment";
|
||||
checkBoxFuelCompartment.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// checkBoxPipes
|
||||
//
|
||||
checkBoxPipes.AutoSize = true;
|
||||
checkBoxPipes.Location = new Point(20, 120);
|
||||
checkBoxPipes.Name = "checkBoxPipes";
|
||||
checkBoxPipes.Size = new Size(54, 19);
|
||||
checkBoxPipes.TabIndex = 4;
|
||||
checkBoxPipes.Text = "Pipes";
|
||||
checkBoxPipes.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// numericUpDownWeight
|
||||
//
|
||||
numericUpDownWeight.Location = new Point(75, 80);
|
||||
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(75, 40);
|
||||
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 });
|
||||
//
|
||||
// labelWeight
|
||||
//
|
||||
labelWeight.AutoSize = true;
|
||||
labelWeight.Location = new Point(20, 85);
|
||||
labelWeight.Name = "labelWeight";
|
||||
labelWeight.Size = new Size(48, 15);
|
||||
labelWeight.TabIndex = 1;
|
||||
labelWeight.Text = "Weight:";
|
||||
//
|
||||
// labelSpeed
|
||||
//
|
||||
labelSpeed.AutoSize = true;
|
||||
labelSpeed.Location = new Point(20, 45);
|
||||
labelSpeed.Name = "labelSpeed";
|
||||
labelSpeed.Size = new Size(42, 15);
|
||||
labelSpeed.TabIndex = 0;
|
||||
labelSpeed.Text = "Speed:";
|
||||
//
|
||||
// panelObject
|
||||
//
|
||||
panelObject.AllowDrop = true;
|
||||
panelObject.Controls.Add(labelMainColor);
|
||||
panelObject.Controls.Add(labelOptionalColor);
|
||||
panelObject.Controls.Add(pictureBoxObject);
|
||||
panelObject.Location = new Point(465, 20);
|
||||
panelObject.Name = "panelObject";
|
||||
panelObject.Size = new Size(350, 180);
|
||||
panelObject.TabIndex = 8;
|
||||
panelObject.DragDrop += panelObject_DragDrop;
|
||||
panelObject.DragEnter += PanelObject_DragEnter;
|
||||
//
|
||||
// labelMainColor
|
||||
//
|
||||
labelMainColor.AllowDrop = true;
|
||||
labelMainColor.BorderStyle = BorderStyle.FixedSingle;
|
||||
labelMainColor.Font = new Font("Segoe UI", 15.75F, FontStyle.Regular, GraphicsUnit.Point);
|
||||
labelMainColor.Location = new Point(5, 0);
|
||||
labelMainColor.Name = "labelMainColor";
|
||||
labelMainColor.Size = new Size(165, 50);
|
||||
labelMainColor.TabIndex = 10;
|
||||
labelMainColor.Text = "Main Color";
|
||||
labelMainColor.TextAlign = ContentAlignment.MiddleCenter;
|
||||
labelMainColor.DragDrop += LabelMainColor_DragDrop;
|
||||
labelMainColor.DragEnter += LabelColor_DragEnter;
|
||||
//
|
||||
// labelOptionalColor
|
||||
//
|
||||
labelOptionalColor.AllowDrop = true;
|
||||
labelOptionalColor.BorderStyle = BorderStyle.FixedSingle;
|
||||
labelOptionalColor.Font = new Font("Segoe UI", 15.75F, FontStyle.Regular, GraphicsUnit.Point);
|
||||
labelOptionalColor.Location = new Point(180, 0);
|
||||
labelOptionalColor.Name = "labelOptionalColor";
|
||||
labelOptionalColor.Size = new Size(165, 50);
|
||||
labelOptionalColor.TabIndex = 9;
|
||||
labelOptionalColor.Text = "Optional Color";
|
||||
labelOptionalColor.TextAlign = ContentAlignment.MiddleCenter;
|
||||
labelOptionalColor.DragDrop += LabelOptionalColor_DragDrop;
|
||||
labelOptionalColor.DragEnter += LabelColor_DragEnter;
|
||||
//
|
||||
// pictureBoxObject
|
||||
//
|
||||
pictureBoxObject.Location = new Point(5, 55);
|
||||
pictureBoxObject.Name = "pictureBoxObject";
|
||||
pictureBoxObject.Size = new Size(340, 120);
|
||||
pictureBoxObject.TabIndex = 1;
|
||||
pictureBoxObject.TabStop = false;
|
||||
//
|
||||
// buttonAdd
|
||||
//
|
||||
buttonAdd.Location = new Point(465, 205);
|
||||
buttonAdd.Name = "buttonAdd";
|
||||
buttonAdd.Size = new Size(170, 40);
|
||||
buttonAdd.TabIndex = 9;
|
||||
buttonAdd.Text = "Add";
|
||||
buttonAdd.UseVisualStyleBackColor = true;
|
||||
buttonAdd.Click += buttonAdd_Click;
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
buttonCancel.Location = new Point(645, 205);
|
||||
buttonCancel.Name = "buttonCancel";
|
||||
buttonCancel.Size = new Size(170, 40);
|
||||
buttonCancel.TabIndex = 10;
|
||||
buttonCancel.Text = "Cancel";
|
||||
buttonCancel.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// FormShipConfig
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(824, 251);
|
||||
Controls.Add(buttonCancel);
|
||||
Controls.Add(buttonAdd);
|
||||
Controls.Add(panelObject);
|
||||
Controls.Add(groupBoxParameters);
|
||||
Name = "FormShipConfig";
|
||||
Text = "FormShipConfig";
|
||||
groupBoxParameters.ResumeLayout(false);
|
||||
groupBoxParameters.PerformLayout();
|
||||
groupBoxColors.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 groupBoxParameters;
|
||||
private Label labelAdvancedObject;
|
||||
private Label labelSimpleObject;
|
||||
private GroupBox groupBoxColors;
|
||||
private Panel panelGray;
|
||||
private Panel panelWhite;
|
||||
private Panel panelPurple;
|
||||
private Panel panelBlack;
|
||||
private Panel panelYellow;
|
||||
private Panel panelGreen;
|
||||
private Panel panelRed;
|
||||
private Panel panelBlue;
|
||||
private CheckBox checkBoxFuelCompartment;
|
||||
private CheckBox checkBoxPipes;
|
||||
private NumericUpDown numericUpDownWeight;
|
||||
private NumericUpDown numericUpDownSpeed;
|
||||
private Label labelWeight;
|
||||
private Label labelSpeed;
|
||||
private Panel panelObject;
|
||||
private Label labelMainColor;
|
||||
private Label labelOptionalColor;
|
||||
private PictureBox pictureBoxObject;
|
||||
private Button buttonAdd;
|
||||
private Button buttonCancel;
|
||||
}
|
||||
}
|
131
ProjectWarmlyShip/ProjectWarmlyShip/FormShipConfig.cs
Normal file
131
ProjectWarmlyShip/ProjectWarmlyShip/FormShipConfig.cs
Normal file
@ -0,0 +1,131 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using ProjectWarmlyShip.Entities;
|
||||
using ProjectWarmlyShip.DrawingObjects;
|
||||
using static System.Windows.Forms.DataFormats;
|
||||
|
||||
namespace ProjectWarmlyShip
|
||||
{
|
||||
public partial class FormShipConfig : Form
|
||||
{
|
||||
DrawingShip? _ship = null;
|
||||
private event Action<DrawingShip> EventAddShip;
|
||||
public FormShipConfig()
|
||||
{
|
||||
InitializeComponent();
|
||||
panelBlack.MouseDown += PanelColor_MouseDown;
|
||||
panelPurple.MouseDown += PanelColor_MouseDown;
|
||||
panelGray.MouseDown += PanelColor_MouseDown;
|
||||
panelGreen.MouseDown += PanelColor_MouseDown;
|
||||
panelRed.MouseDown += PanelColor_MouseDown;
|
||||
panelWhite.MouseDown += PanelColor_MouseDown;
|
||||
panelYellow.MouseDown += PanelColor_MouseDown;
|
||||
panelBlue.MouseDown += PanelColor_MouseDown;
|
||||
buttonCancel.Click += (object sender, EventArgs a) => Close();
|
||||
}
|
||||
private void DrawShip()
|
||||
{
|
||||
Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height);
|
||||
Graphics gr = Graphics.FromImage(bmp);
|
||||
_ship?.SetPosition(5, 5);
|
||||
_ship?.DrawTrasport(gr);
|
||||
pictureBoxObject.Image = bmp;
|
||||
}
|
||||
public void AddEvent(Action<DrawingShip> ev)
|
||||
{
|
||||
if (EventAddShip == null)
|
||||
{
|
||||
EventAddShip = ev;
|
||||
}
|
||||
else
|
||||
{
|
||||
EventAddShip += ev;
|
||||
}
|
||||
}
|
||||
private void LabelObject_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
(sender as Label)?.DoDragDrop((sender as Label)?.Name, DragDropEffects.Move | DragDropEffects.Copy);
|
||||
}
|
||||
private void PanelObject_DragEnter(object sender, DragEventArgs e)
|
||||
{
|
||||
if (e.Data?.GetDataPresent(DataFormats.Text) ?? false)
|
||||
{
|
||||
e.Effect = DragDropEffects.Copy;
|
||||
}
|
||||
else
|
||||
{
|
||||
e.Effect = DragDropEffects.None;
|
||||
}
|
||||
}
|
||||
private void panelObject_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
|
||||
FormShipCollection form = new FormShipCollection();
|
||||
switch (e.Data?.GetData(DataFormats.Text).ToString())
|
||||
{
|
||||
case "labelSimpleObject":
|
||||
labelOptionalColor.AllowDrop = false;
|
||||
|
||||
_ship = new DrawingShip((int)numericUpDownSpeed.Value,
|
||||
(int)numericUpDownWeight.Value, Color.White,
|
||||
form.GetWidth(), form.GetHeight());
|
||||
break;
|
||||
case "labelAdvancedObject":
|
||||
labelOptionalColor.AllowDrop = true;
|
||||
|
||||
_ship = new DrawingWarmlyShip((int)numericUpDownSpeed.Value,
|
||||
(int)numericUpDownWeight.Value, Color.White, Color.Black,
|
||||
checkBoxPipes.Checked, checkBoxFuelCompartment.Checked,
|
||||
form.GetWidth(), form.GetHeight());
|
||||
break;
|
||||
}
|
||||
DrawShip();
|
||||
}
|
||||
private void PanelColor_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
(sender as Panel)?.DoDragDrop((sender as Panel)?.BackColor, DragDropEffects.Move | DragDropEffects.Copy);
|
||||
}
|
||||
private void LabelColor_DragEnter(object sender, DragEventArgs e)
|
||||
{
|
||||
if (e.Data.GetDataPresent(typeof(Color)))
|
||||
{
|
||||
e.Effect = DragDropEffects.Copy;
|
||||
}
|
||||
else
|
||||
{
|
||||
e.Effect = DragDropEffects.None;
|
||||
}
|
||||
}
|
||||
private void LabelMainColor_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
var color = e.Data.GetData(typeof(Color));
|
||||
if (_ship != null && color != null)
|
||||
{
|
||||
_ship.EntityShip.MainColor = (Color)color;
|
||||
DrawShip();
|
||||
}
|
||||
}
|
||||
private void LabelOptionalColor_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
var color = e.Data.GetData(typeof(Color));
|
||||
|
||||
if (_ship != null && color != null && _ship.EntityShip is EntityWarmlyShip entityWarmlyShip)
|
||||
{
|
||||
entityWarmlyShip.OptionalColor = (Color)color;
|
||||
DrawShip();
|
||||
}
|
||||
}
|
||||
private void buttonAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
EventAddShip?.Invoke(_ship);
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
60
ProjectWarmlyShip/ProjectWarmlyShip/FormShipConfig.resx
Normal file
60
ProjectWarmlyShip/ProjectWarmlyShip/FormShipConfig.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>
|
Loading…
Reference in New Issue
Block a user