почти 5
This commit is contained in:
@@ -220,6 +220,20 @@ namespace Catamaran.DrawningObjects
|
||||
SolidBrush brushBrown = new SolidBrush(Color.Brown);
|
||||
g.FillEllipse(brushBrown, _startPosX + 30, _startPosY + 60, 100, 40);
|
||||
}
|
||||
public void SetColor(Color color)
|
||||
{
|
||||
if (EntityCatamaran == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
EntityCatamaran.BodyColor = color;
|
||||
}
|
||||
|
||||
public void ChangePictureBoxSize(int pictureBoxWidth, int pictureBoxHeight)
|
||||
{
|
||||
_pictureWidth = pictureBoxWidth;
|
||||
_pictureHeight = pictureBoxHeight;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -84,6 +84,10 @@ namespace Catamaran.DrawningObjects
|
||||
g.DrawRectangle(pen, _startPosX + 70, _startPosY, 3, 85);
|
||||
}
|
||||
}
|
||||
public void SetAddColor(Color color)
|
||||
{
|
||||
((EntitySailCatamaran)EntityCatamaran).AdditionalColor = color;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace Catamaran.Entities
|
||||
/// <summary>
|
||||
/// Основной цвет
|
||||
/// </summary>
|
||||
public Color BodyColor { get; private set; }
|
||||
public Color BodyColor { get; set; }
|
||||
/// <summary>
|
||||
/// Шаг перемещения катамарана
|
||||
/// </summary>
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace Catamaran.Entities
|
||||
/// <summary>
|
||||
/// Дополнительный цвет (для опциональных элементов)
|
||||
/// </summary>
|
||||
public Color AdditionalColor { get; private set; }
|
||||
public Color AdditionalColor { get; set; }
|
||||
/// <summary>
|
||||
/// Признак (опция) наличия паруса
|
||||
/// </summary>
|
||||
|
||||
@@ -62,6 +62,30 @@ namespace Catamaran
|
||||
_storage.AddSet(textBoxStorageName.Text);
|
||||
ReloadObjects();
|
||||
}
|
||||
|
||||
private void AddCatamaran(DrawningCatamaran drawningCatamaran)
|
||||
{
|
||||
if (listBoxStorages.SelectedIndex == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var obj = _storage[listBoxStorages.SelectedItem.ToString() ??
|
||||
string.Empty];
|
||||
if (obj == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (obj + drawningCatamaran)
|
||||
{
|
||||
MessageBox.Show("Объект добавлен");
|
||||
pictureBoxCollection.Image = obj.ShowCatamarans();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Не удалось добавить объект");
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Выбор набора
|
||||
/// </summary>
|
||||
@@ -100,9 +124,19 @@ namespace Catamaran
|
||||
/// <param name="e"></param>
|
||||
private void ButtonAddCatamaran_Click(object sender, EventArgs e)
|
||||
{
|
||||
var formCarConfig = new FormCatamaranConfig();
|
||||
if (listBoxStorages.SelectedIndex == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? string.Empty];
|
||||
if (obj == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var formBoatConfig = new FormCatamaranConfig();
|
||||
// TODO Call method AddEvent from formCarConfig
|
||||
formCarConfig.Show();
|
||||
formBoatConfig.AddEvent(AddCatamaran);
|
||||
formBoatConfig.Show();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -324,9 +324,11 @@
|
||||
this.buttonOk.TabIndex = 11;
|
||||
this.buttonOk.Text = "Добавить";
|
||||
this.buttonOk.UseVisualStyleBackColor = true;
|
||||
this.buttonOk.Click += new System.EventHandler(this.ButtonOk_Click);
|
||||
//
|
||||
// labelAddColor
|
||||
//
|
||||
this.labelAddColor.AllowDrop = true;
|
||||
this.labelAddColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
this.labelAddColor.Font = new System.Drawing.Font("Segoe UI", 10.2F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||
this.labelAddColor.Location = new System.Drawing.Point(175, 22);
|
||||
@@ -335,9 +337,12 @@
|
||||
this.labelAddColor.TabIndex = 10;
|
||||
this.labelAddColor.Text = "Доп. цвет";
|
||||
this.labelAddColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
this.labelAddColor.DragDrop += new System.Windows.Forms.DragEventHandler(this.LabelColor_DragDrop);
|
||||
this.labelAddColor.DragEnter += new System.Windows.Forms.DragEventHandler(this.LabelColor_DragEnter);
|
||||
//
|
||||
// labelBodyColor
|
||||
//
|
||||
this.labelBodyColor.AllowDrop = true;
|
||||
this.labelBodyColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
this.labelBodyColor.Font = new System.Drawing.Font("Segoe UI", 10.2F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||
this.labelBodyColor.Location = new System.Drawing.Point(38, 22);
|
||||
@@ -346,6 +351,8 @@
|
||||
this.labelBodyColor.TabIndex = 9;
|
||||
this.labelBodyColor.Text = "Цвет";
|
||||
this.labelBodyColor.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
this.labelBodyColor.DragDrop += new System.Windows.Forms.DragEventHandler(this.LabelColor_DragDrop);
|
||||
this.labelBodyColor.DragEnter += new System.Windows.Forms.DragEventHandler(this.LabelColor_DragEnter);
|
||||
//
|
||||
// pictureBoxObject
|
||||
//
|
||||
|
||||
@@ -10,6 +10,8 @@ using System.Windows.Forms;
|
||||
|
||||
using Catamaran.DrawningObjects;
|
||||
using Catamaran.Entities;
|
||||
using Catamaran.Generics;
|
||||
using Catamaran.MovementStrategy;
|
||||
namespace Catamaran
|
||||
{
|
||||
/// <summary>
|
||||
@@ -18,13 +20,13 @@ namespace Catamaran
|
||||
public partial class FormCatamaranConfig : Form
|
||||
{
|
||||
/// <summary>
|
||||
/// Переменная-выбранная машина
|
||||
/// Переменная-выбранный катамаран
|
||||
/// </summary>
|
||||
DrawningCatamaran? _catamaran = null;
|
||||
/// <summary>
|
||||
/// Событие
|
||||
/// </summary>
|
||||
private event CatamaranDelegate? EventAddCatamaran;
|
||||
private event Action<DrawningCatamaran>? EventAddCatamaran;
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
@@ -43,7 +45,7 @@ namespace Catamaran
|
||||
buttonCancel.Click += (s, e) => Close();
|
||||
}
|
||||
/// <summary>
|
||||
/// Отрисовать машину
|
||||
/// Отрисовать катамаран
|
||||
/// </summary>
|
||||
private void DrawCatamaran()
|
||||
{
|
||||
@@ -53,17 +55,11 @@ namespace Catamaran
|
||||
_catamaran?.DrawTransport(gr);
|
||||
pictureBoxObject.Image = bmp;
|
||||
}
|
||||
|
||||
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(CatamaranDelegate ev)
|
||||
internal void AddEvent(Action<DrawningCatamaran> ev)
|
||||
{
|
||||
if (EventAddCatamaran == null)
|
||||
{
|
||||
@@ -74,6 +70,11 @@ namespace Catamaran
|
||||
EventAddCatamaran += ev;
|
||||
}
|
||||
}
|
||||
|
||||
private void PanelColor_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
(sender as Panel)?.DoDragDrop((sender as Panel)?.BackColor, DragDropEffects.Move | DragDropEffects.Copy);
|
||||
}
|
||||
/// <summary>
|
||||
/// Передаем информацию при нажатии на Label
|
||||
/// </summary>
|
||||
@@ -124,11 +125,40 @@ namespace Catamaran
|
||||
DrawCatamaran();
|
||||
}
|
||||
// TODO Реализовать логику смены цветов: основного и дополнительного (для продвинутого объекта)
|
||||
/// <summary>
|
||||
/// Добавление машины
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void LabelColor_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
if (_catamaran == null)
|
||||
return;
|
||||
switch (((Label)sender).Name)
|
||||
{
|
||||
case "labelColor":
|
||||
_catamaran.SetColor((Color)e.Data.GetData(typeof(Color)));
|
||||
break;
|
||||
case "labelAddColor":
|
||||
if (!(_catamaran is DrawningSailCatamaran))
|
||||
return;
|
||||
(_catamaran as DrawningSailCatamaran).SetAddColor((Color)e.Data.GetData(typeof(Color)));
|
||||
break;
|
||||
}
|
||||
DrawCatamaran();
|
||||
}
|
||||
private void LabelColor_DragEnter(object sender, DragEventArgs e)
|
||||
{
|
||||
if (e.Data?.GetDataPresent(typeof(Color)) ?? false)
|
||||
{
|
||||
e.Effect = DragDropEffects.Copy;
|
||||
}
|
||||
else
|
||||
{
|
||||
e.Effect = DragDropEffects.None;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Добавление машины
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonOk_Click(object sender, EventArgs e)
|
||||
{
|
||||
EventAddCatamaran?.Invoke(_catamaran);
|
||||
|
||||
Reference in New Issue
Block a user