доделаю
This commit is contained in:
parent
d4ccb9c74a
commit
a50b38a592
@ -25,8 +25,6 @@ namespace HoistingCrane.CollectionGenericObjects
|
||||
/// <param name="collectionType">тип коллекции</param>
|
||||
public void AddCollection(string name, CollectionType collectionType)
|
||||
{
|
||||
// TODO проверка, что name не пустой и нет в словаре записи с таким ключом
|
||||
// TODO Прописать логику для добавления
|
||||
if (!string.IsNullOrEmpty(name) && !Keys.Contains(name))
|
||||
{
|
||||
if(collectionType == CollectionType.Massive)
|
||||
@ -45,13 +43,9 @@ namespace HoistingCrane.CollectionGenericObjects
|
||||
/// <param name="name">Название коллекции</param>
|
||||
public void DelCollection(string name)
|
||||
{
|
||||
// TODO Прописать логику для удаления коллекции
|
||||
|
||||
if(Keys.Contains(name))
|
||||
{
|
||||
if (dict.ContainsKey(name))
|
||||
dict.Remove(name);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Доступ к коллекции
|
||||
/// </summary>
|
||||
@ -61,12 +55,8 @@ namespace HoistingCrane.CollectionGenericObjects
|
||||
{
|
||||
get
|
||||
{
|
||||
// TODO Продумать логику получения объекта
|
||||
if (dict.TryGetValue(name, out ICollectionGenericObjects<T>? result))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
return null;
|
||||
if (name == null || !dict.ContainsKey(name)) { return null; }
|
||||
return dict[name];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -221,9 +221,9 @@
|
||||
buttonCreateHoistingCrane.Name = "buttonCreateHoistingCrane";
|
||||
buttonCreateHoistingCrane.Size = new Size(192, 22);
|
||||
buttonCreateHoistingCrane.TabIndex = 0;
|
||||
buttonCreateHoistingCrane.Text = "Добавить подъемный кран";
|
||||
buttonCreateHoistingCrane.Text = "Добавить транспорт";
|
||||
buttonCreateHoistingCrane.UseVisualStyleBackColor = true;
|
||||
|
||||
buttonCreateHoistingCrane.Click += buttonCreateHoistingCrane_Click;
|
||||
//
|
||||
// pictureBox
|
||||
//
|
||||
|
@ -74,20 +74,13 @@ namespace HoistingCrane
|
||||
return color;
|
||||
}
|
||||
|
||||
private void buttonCreateTrackedVehicle_Click(object sender, EventArgs e)
|
||||
{
|
||||
FormCarConfig form = new();
|
||||
form.Show();
|
||||
form.AddEvent(SetCar);
|
||||
}
|
||||
|
||||
private void SetCar(DrawningTrackedVehicle car)
|
||||
{
|
||||
if(_company == null || car == null)
|
||||
if (_company == null || car == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if((_company + car) != -1)
|
||||
if ((_company + car) != -1)
|
||||
{
|
||||
MessageBox.Show("Объект добавлен");
|
||||
pictureBox.Image = _company.Show();
|
||||
@ -225,6 +218,13 @@ namespace HoistingCrane
|
||||
panelStorage.Enabled = true;
|
||||
RerfreshListBoxItems();
|
||||
}
|
||||
|
||||
private void buttonCreateHoistingCrane_Click(object sender, EventArgs e)
|
||||
{
|
||||
FormCarConfig form = new();
|
||||
form.AddEvent(SetCar);
|
||||
form.Show();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -263,7 +263,8 @@
|
||||
labelAdditionalColor.TabIndex = 10;
|
||||
labelAdditionalColor.Text = "Доп. цвет";
|
||||
labelAdditionalColor.TextAlign = ContentAlignment.MiddleCenter;
|
||||
labelAdditionalColor.DragEnter += labelColors_DragEnter;
|
||||
labelAdditionalColor.DragDrop += labelAdditionalColor_DragDrop;
|
||||
labelAdditionalColor.DragEnter += labelAdditionalColor_DragEnter;
|
||||
//
|
||||
// labelBodyColor
|
||||
//
|
||||
@ -274,7 +275,8 @@
|
||||
labelBodyColor.TabIndex = 9;
|
||||
labelBodyColor.Text = "Цвет";
|
||||
labelBodyColor.TextAlign = ContentAlignment.MiddleCenter;
|
||||
labelBodyColor.DragEnter += labelColors_DragEnter;
|
||||
labelBodyColor.DragDrop += labelBodyColor_DragDrop;
|
||||
labelBodyColor.DragEnter += labelBodyColor_DragEnter;
|
||||
//
|
||||
// pictureBoxObject
|
||||
//
|
||||
@ -302,7 +304,6 @@
|
||||
buttonCancel.TabIndex = 2;
|
||||
buttonCancel.Text = "Отмена";
|
||||
buttonCancel.UseVisualStyleBackColor = true;
|
||||
|
||||
//
|
||||
// FormCarConfig
|
||||
//
|
||||
|
@ -10,6 +10,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using static System.Windows.Forms.VisualStyles.VisualStyleElement.TrackBar;
|
||||
|
||||
namespace HoistingCrane
|
||||
{
|
||||
@ -19,6 +20,7 @@ namespace HoistingCrane
|
||||
private event CarDelegate? _carDelegate;
|
||||
public FormCarConfig()
|
||||
{
|
||||
InitializeComponent();
|
||||
panelColorRed.MouseDown += panel_MouseDown;
|
||||
panelColorBlue.MouseDown += panel_MouseDown;
|
||||
panelColorGreen.MouseDown += panel_MouseDown;
|
||||
@ -28,45 +30,53 @@ namespace HoistingCrane
|
||||
panelColorGray.MouseDown += panel_MouseDown;
|
||||
panelColorPurple.MouseDown += panel_MouseDown;
|
||||
buttonCancel.Click += (sender, e) => Close();
|
||||
|
||||
InitializeComponent();
|
||||
}
|
||||
/// <summary>
|
||||
/// Привязка метода к событию
|
||||
/// </summary>
|
||||
/// <param name="carDelegate"></param>
|
||||
public void AddEvent(CarDelegate carDelegate)
|
||||
{
|
||||
_carDelegate += carDelegate;
|
||||
}
|
||||
/// <summary>
|
||||
/// Отрисовка объекта
|
||||
/// </summary>
|
||||
private void DrawObject()
|
||||
{
|
||||
Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height);
|
||||
Graphics gr = Graphics.FromImage(bmp);
|
||||
car?.SetPictureSize(pictureBoxObject.Width, pictureBoxObject.Height);
|
||||
car?.SetPosition(5, 5);
|
||||
car?.SetPosition(25, 25);
|
||||
car?.DrawTransport(gr);
|
||||
pictureBoxObject.Image = bmp;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Передаем информацию при нажатии на Label
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void labelObject_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
var label = sender as Label;
|
||||
label?.DoDragDrop(label.Name, DragDropEffects.Move);
|
||||
label?.DoDragDrop(label.Name, DragDropEffects.Copy);
|
||||
(sender as Label)?.DoDragDrop((sender as Label)?.Name ?? string.Empty, DragDropEffects.Move | DragDropEffects.Copy);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Проверка получаемой информации (ее типа на соответствие требуемому)
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void panel_DragEnter(object sender, DragEventArgs e)
|
||||
{
|
||||
if (e.Data?.GetDataPresent(DataFormats.Text) ?? false)
|
||||
{
|
||||
e.Effect = DragDropEffects.Copy;
|
||||
e.Effect = e.Data?.GetDataPresent(DataFormats.Text) ?? false ? DragDropEffects.Copy : DragDropEffects.None;
|
||||
}
|
||||
else
|
||||
{
|
||||
e.Effect = DragDropEffects.None;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Действия при приеме перетаскиваемой информации
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void panel_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
switch (e.Data?.GetData(DataFormats.Text)?.ToString())
|
||||
switch (e.Data?.GetData(DataFormats.Text).ToString())
|
||||
{
|
||||
case "labelSimpleObject":
|
||||
car = new DrawningTrackedVehicle((int)numericUpDownSpeed.Value, (double)numericUpDownWeight.Value, Color.White);
|
||||
@ -78,35 +88,20 @@ namespace HoistingCrane
|
||||
}
|
||||
DrawObject();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Передаем информацию при нажатии на Panel
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void panel_MouseDown(object? sender, MouseEventArgs e)
|
||||
{
|
||||
var color = sender as Label;
|
||||
color?.DoDragDrop(color.BackColor, DragDropEffects.Move);
|
||||
color?.DoDragDrop(color.BackColor, DragDropEffects.Copy);
|
||||
(sender as Panel)?.DoDragDrop((sender as Panel)?.BackColor ?? Color.White, DragDropEffects.Move | DragDropEffects.Copy);
|
||||
}
|
||||
|
||||
// TODO Реализовать логику смены цветов: основного и дополнительного (для продвинутого объекта)
|
||||
private void labelColors_DragEnter(object sender, DragEventArgs e)
|
||||
{
|
||||
var label = (String)sender;
|
||||
Color newColor = (Color)e.Data.GetData(typeof(Color).ToString());
|
||||
switch (label)
|
||||
{
|
||||
case "labelBodyColor":
|
||||
car?.EntityTrackedVehicle?.SetBodyColor(newColor);
|
||||
DrawObject();
|
||||
break;
|
||||
case "labelAdditionalColor":
|
||||
if (car is DrawningHoistingCrane)
|
||||
{
|
||||
(car.EntityTrackedVehicle as EntityHoistingCrane).SetAdditionalColor(newColor);
|
||||
DrawObject();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Передача объекта
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void buttonAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (car != null)
|
||||
@ -115,8 +110,67 @@ namespace HoistingCrane
|
||||
Close();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Прорисовка основным цветом
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void labelBodyColor_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
if (car != null)
|
||||
{
|
||||
car.EntityTrackedVehicle?.SetBodyColor((Color)e.Data.GetData(typeof(Color)));
|
||||
DrawObject();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Передача основного цвета
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void labelBodyColor_DragEnter(object sender, DragEventArgs e)
|
||||
{
|
||||
if (e.Data.GetDataPresent(typeof(Color)))
|
||||
{
|
||||
e.Effect = DragDropEffects.Copy;
|
||||
}
|
||||
else
|
||||
{
|
||||
e.Effect = DragDropEffects.None;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Прорисовка основным цветом
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void labelAdditionalColor_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
if (car?.EntityTrackedVehicle is EntityHoistingCrane entityHoistingCrane)
|
||||
{
|
||||
entityHoistingCrane.SetAdditionalColor((Color)e.Data.GetData(typeof(Color)));
|
||||
}
|
||||
DrawObject();
|
||||
}
|
||||
/// <summary>
|
||||
/// Передача дополнительного цвета
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void labelAdditionalColor_DragEnter(object sender, DragEventArgs e)
|
||||
{
|
||||
if (car is DrawningHoistingCrane)
|
||||
{
|
||||
if (e.Data.GetDataPresent(typeof(Color)))
|
||||
{
|
||||
e.Effect = DragDropEffects.Copy;
|
||||
}
|
||||
else
|
||||
{
|
||||
e.Effect = DragDropEffects.None;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user