Изменения
This commit is contained in:
parent
a51a6a2102
commit
d9f1f47750
@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Reflection.PortableExecutable;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
@ -52,5 +53,15 @@ namespace WarmlyShip
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SetDopColor(Color color)
|
||||||
|
{
|
||||||
|
Ship = Ship as EntityLiner;
|
||||||
|
if (Ship is not null)
|
||||||
|
{
|
||||||
|
Ship = new EntityLiner(Ship.Speed, Ship.Weight, Ship.BodyColor,
|
||||||
|
color, (Ship as EntityLiner).SwimmingPool, (Ship as EntityLiner).DopDeck);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Reflection.PortableExecutable;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
@ -199,5 +200,20 @@ namespace WarmlyShip
|
|||||||
{
|
{
|
||||||
return (_startPosX, _startPosY, _startPosX + _shipWidth, _startPosY + _shipHeight);
|
return (_startPosX, _startPosY, _startPosX + _shipWidth, _startPosY + _shipHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public virtual void SetBaseColor(Color color)
|
||||||
|
{
|
||||||
|
if (Ship is EntityLiner)
|
||||||
|
{
|
||||||
|
Ship = (EntityLiner)Ship;
|
||||||
|
if (Ship is not null)
|
||||||
|
{
|
||||||
|
Ship = new EntityLiner(Ship.Speed, Ship.Weight, color, (Ship as EntityLiner).DopColor, (Ship as EntityLiner).SwimmingPool, (Ship as EntityLiner).DopDeck);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Ship = new EntityShip(Ship.Speed, Ship.Weight, color);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
44
WarmlyShip/WarmlyShip/FormLinerConfig.Designer.cs
generated
44
WarmlyShip/WarmlyShip/FormLinerConfig.Designer.cs
generated
@ -48,8 +48,8 @@
|
|||||||
this.labelSpeed = new System.Windows.Forms.Label();
|
this.labelSpeed = new System.Windows.Forms.Label();
|
||||||
this.pictureBoxObject = new System.Windows.Forms.PictureBox();
|
this.pictureBoxObject = new System.Windows.Forms.PictureBox();
|
||||||
this.panelObject = new System.Windows.Forms.Panel();
|
this.panelObject = new System.Windows.Forms.Panel();
|
||||||
this.button2 = new System.Windows.Forms.Button();
|
this.buttonCancel = new System.Windows.Forms.Button();
|
||||||
this.button1 = new System.Windows.Forms.Button();
|
this.buttonAdd = new System.Windows.Forms.Button();
|
||||||
this.labelDopColor = new System.Windows.Forms.Label();
|
this.labelDopColor = new System.Windows.Forms.Label();
|
||||||
this.labelBaseColor = new System.Windows.Forms.Label();
|
this.labelBaseColor = new System.Windows.Forms.Label();
|
||||||
this.groupBoxConfig.SuspendLayout();
|
this.groupBoxConfig.SuspendLayout();
|
||||||
@ -252,8 +252,8 @@
|
|||||||
// panelObject
|
// panelObject
|
||||||
//
|
//
|
||||||
this.panelObject.AllowDrop = true;
|
this.panelObject.AllowDrop = true;
|
||||||
this.panelObject.Controls.Add(this.button2);
|
this.panelObject.Controls.Add(this.buttonCancel);
|
||||||
this.panelObject.Controls.Add(this.button1);
|
this.panelObject.Controls.Add(this.buttonAdd);
|
||||||
this.panelObject.Controls.Add(this.labelDopColor);
|
this.panelObject.Controls.Add(this.labelDopColor);
|
||||||
this.panelObject.Controls.Add(this.labelBaseColor);
|
this.panelObject.Controls.Add(this.labelBaseColor);
|
||||||
this.panelObject.Controls.Add(this.pictureBoxObject);
|
this.panelObject.Controls.Add(this.pictureBoxObject);
|
||||||
@ -265,23 +265,24 @@
|
|||||||
this.panelObject.DragEnter += new System.Windows.Forms.DragEventHandler(this.PanelObject_DragEnter);
|
this.panelObject.DragEnter += new System.Windows.Forms.DragEventHandler(this.PanelObject_DragEnter);
|
||||||
this.panelObject.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown);
|
this.panelObject.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PanelColor_MouseDown);
|
||||||
//
|
//
|
||||||
// button2
|
// buttonCancel
|
||||||
//
|
//
|
||||||
this.button2.Location = new System.Drawing.Point(112, 159);
|
this.buttonCancel.Location = new System.Drawing.Point(112, 159);
|
||||||
this.button2.Name = "button2";
|
this.buttonCancel.Name = "buttonCancel";
|
||||||
this.button2.Size = new System.Drawing.Size(75, 23);
|
this.buttonCancel.Size = new System.Drawing.Size(75, 23);
|
||||||
this.button2.TabIndex = 5;
|
this.buttonCancel.TabIndex = 5;
|
||||||
this.button2.Text = "Отмена";
|
this.buttonCancel.Text = "Отмена";
|
||||||
this.button2.UseVisualStyleBackColor = true;
|
this.buttonCancel.UseVisualStyleBackColor = true;
|
||||||
//
|
//
|
||||||
// button1
|
// buttonAdd
|
||||||
//
|
//
|
||||||
this.button1.Location = new System.Drawing.Point(31, 159);
|
this.buttonAdd.Location = new System.Drawing.Point(31, 159);
|
||||||
this.button1.Name = "button1";
|
this.buttonAdd.Name = "buttonAdd";
|
||||||
this.button1.Size = new System.Drawing.Size(75, 23);
|
this.buttonAdd.Size = new System.Drawing.Size(75, 23);
|
||||||
this.button1.TabIndex = 4;
|
this.buttonAdd.TabIndex = 4;
|
||||||
this.button1.Text = "Добавить";
|
this.buttonAdd.Text = "Добавить";
|
||||||
this.button1.UseVisualStyleBackColor = true;
|
this.buttonAdd.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonAdd.Click += new System.EventHandler(this.ButtonOk_Click);
|
||||||
//
|
//
|
||||||
// labelDopColor
|
// labelDopColor
|
||||||
//
|
//
|
||||||
@ -293,6 +294,8 @@
|
|||||||
this.labelDopColor.TabIndex = 3;
|
this.labelDopColor.TabIndex = 3;
|
||||||
this.labelDopColor.Text = "Доп.цвет";
|
this.labelDopColor.Text = "Доп.цвет";
|
||||||
this.labelDopColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
this.labelDopColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||||
|
this.labelDopColor.DragDrop += new System.Windows.Forms.DragEventHandler(this.LabelDopColor_DragDrop);
|
||||||
|
this.labelDopColor.DragEnter += new System.Windows.Forms.DragEventHandler(this.LabelBaseColor_DragEnter);
|
||||||
//
|
//
|
||||||
// labelBaseColor
|
// labelBaseColor
|
||||||
//
|
//
|
||||||
@ -304,6 +307,7 @@
|
|||||||
this.labelBaseColor.TabIndex = 2;
|
this.labelBaseColor.TabIndex = 2;
|
||||||
this.labelBaseColor.Text = "Цвет";
|
this.labelBaseColor.Text = "Цвет";
|
||||||
this.labelBaseColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
this.labelBaseColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||||
|
this.labelBaseColor.DragDrop += new System.Windows.Forms.DragEventHandler(this.LabelBaseColor_DragDrop);
|
||||||
this.labelBaseColor.DragEnter += new System.Windows.Forms.DragEventHandler(this.LabelBaseColor_DragEnter);
|
this.labelBaseColor.DragEnter += new System.Windows.Forms.DragEventHandler(this.LabelBaseColor_DragEnter);
|
||||||
//
|
//
|
||||||
// FormLinerConfig
|
// FormLinerConfig
|
||||||
@ -350,7 +354,7 @@
|
|||||||
private Panel panelObject;
|
private Panel panelObject;
|
||||||
private Label labelDopColor;
|
private Label labelDopColor;
|
||||||
private Label labelBaseColor;
|
private Label labelBaseColor;
|
||||||
private Button button2;
|
private Button buttonCancel;
|
||||||
private Button button1;
|
private Button buttonAdd;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
@ -18,7 +19,7 @@ namespace WarmlyShip
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Переменная-выбранная машина
|
/// Переменная-выбранная машина
|
||||||
/// </summary>
|
/// </summary>
|
||||||
DrawningShip _ship = null;
|
DrawningShip _liner = null;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Событие
|
/// Событие
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -38,8 +39,7 @@ namespace WarmlyShip
|
|||||||
panelYellow.MouseDown += PanelColor_MouseDown;
|
panelYellow.MouseDown += PanelColor_MouseDown;
|
||||||
panelBlue.MouseDown += PanelColor_MouseDown;
|
panelBlue.MouseDown += PanelColor_MouseDown;
|
||||||
|
|
||||||
// TODO buttonCancel.Click with lambda
|
buttonCancel.Click += (sender, e) => Close();
|
||||||
|
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Отрисовать машину
|
/// Отрисовать машину
|
||||||
@ -48,8 +48,8 @@ namespace WarmlyShip
|
|||||||
{
|
{
|
||||||
Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height);
|
Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height);
|
||||||
Graphics gr = Graphics.FromImage(bmp);
|
Graphics gr = Graphics.FromImage(bmp);
|
||||||
_ship?.SetPosition(5, 5, pictureBoxObject.Width, pictureBoxObject.Height);
|
_liner?.SetPosition(5, 5, pictureBoxObject.Width, pictureBoxObject.Height);
|
||||||
_ship?.DrawTransport(gr);
|
_liner?.DrawTransport(gr);
|
||||||
pictureBoxObject.Image = bmp;
|
pictureBoxObject.Image = bmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,11 +103,11 @@ namespace WarmlyShip
|
|||||||
switch (e.Data.GetData(DataFormats.Text).ToString())
|
switch (e.Data.GetData(DataFormats.Text).ToString())
|
||||||
{
|
{
|
||||||
case "labelSimpleObject":
|
case "labelSimpleObject":
|
||||||
_ship = new DrawningShip((int)numericUpDownSpeed.Value,
|
_liner = new DrawningShip((int)numericUpDownSpeed.Value,
|
||||||
(int)numericUpDownWeight.Value, Color.White);
|
(int)numericUpDownWeight.Value, Color.White);
|
||||||
break;
|
break;
|
||||||
case "labelModifiedObject":
|
case "labelModifiedObject":
|
||||||
_ship = new DrawningLiner((int)numericUpDownSpeed.Value,
|
_liner = new DrawningLiner((int)numericUpDownSpeed.Value,
|
||||||
(int)numericUpDownWeight.Value, Color.White, Color.Black,
|
(int)numericUpDownWeight.Value, Color.White, Color.Black,
|
||||||
checkBoxSwimmingPool.Checked, checkBoxDopDeck.Checked);
|
checkBoxSwimmingPool.Checked, checkBoxDopDeck.Checked);
|
||||||
break;
|
break;
|
||||||
@ -147,7 +147,11 @@ namespace WarmlyShip
|
|||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
private void LabelBaseColor_DragDrop(object sender, DragEventArgs e)
|
private void LabelBaseColor_DragDrop(object sender, DragEventArgs e)
|
||||||
{
|
{
|
||||||
// TODO Call method from object _car and set color
|
if (_liner != null)
|
||||||
|
{
|
||||||
|
_liner.SetBaseColor((Color)e.Data.GetData(typeof(Color)));
|
||||||
|
DrawLiner();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Принимаем дополнительный цвет
|
/// Принимаем дополнительный цвет
|
||||||
@ -156,7 +160,13 @@ namespace WarmlyShip
|
|||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
private void LabelDopColor_DragDrop(object sender, DragEventArgs e)
|
private void LabelDopColor_DragDrop(object sender, DragEventArgs e)
|
||||||
{
|
{
|
||||||
// TODO Call method from object _car if _car is DrawningSportCar and set dop color
|
if (_liner is DrawningLiner)
|
||||||
|
{
|
||||||
|
var liner = _liner as DrawningLiner;
|
||||||
|
liner.SetDopColor((Color)e.Data.GetData(typeof(Color)));
|
||||||
|
|
||||||
|
}
|
||||||
|
DrawLiner();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -166,7 +176,7 @@ namespace WarmlyShip
|
|||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
private void ButtonOk_Click(object sender, EventArgs e)
|
private void ButtonOk_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
EventAddShip?.Invoke(_ship);
|
EventAddShip?.Invoke(_liner);
|
||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,12 +113,27 @@ namespace WarmlyShip
|
|||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
private void ButtonAddShip_Click(object sender, EventArgs e)
|
private void ButtonAddShip_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var formCarConfig = new FormLinerConfig();
|
var formLinerConfig = new FormLinerConfig();
|
||||||
// TODO Call method AddEvent from formCarConfig
|
formLinerConfig.AddEvent(new(AddShip));
|
||||||
formCarConfig.Show();
|
formLinerConfig.Show();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void AddShip(DrawningShip liner)
|
||||||
|
{
|
||||||
|
if (listBoxMaps.SelectedIndex == -1)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Перед добавлением объекта необходимо создать карту");
|
||||||
|
}
|
||||||
|
else if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] + new DrawningObjectShip(liner) != -1)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Объект добавлен");
|
||||||
|
pictureBox1.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageBox.Show("Не удалось добавить объект");
|
||||||
|
}
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Удаление объекта
|
/// Удаление объекта
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
Loading…
Reference in New Issue
Block a user