файлы лабораторной
This commit is contained in:
parent
ec901ec714
commit
a29254945d
@ -1,4 +1,15 @@
|
|||||||
using ProjectLainer.DrawningObjects;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Data;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Reflection.Metadata.Ecma335;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
using ProjectLainer.DrawningObjects;
|
||||||
using ProjectLainer.Generics;
|
using ProjectLainer.Generics;
|
||||||
using ProjectLainer.MovementStrategy;
|
using ProjectLainer.MovementStrategy;
|
||||||
|
|
||||||
@ -10,26 +21,24 @@ namespace ProjectLainer
|
|||||||
public FormLainerCollection()
|
public FormLainerCollection()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
_storage = new LainersGenericStorage(pictureBoxCollection.Width,
|
_storage = new LainersGenericStorage(pictureBoxCollection.Width, pictureBoxCollection.Height);
|
||||||
pictureBoxCollection.Height);
|
|
||||||
}
|
}
|
||||||
private void ReloadObjects()
|
private void ReloadObjects()
|
||||||
{
|
{
|
||||||
int index = listBoxStorages.SelectedIndex;
|
int index = listBoxStorages.SelectedIndex;
|
||||||
listBoxStorages.Items.Clear();
|
listBoxStorages.Items.Clear();
|
||||||
|
for (int i = 0; i < _storage.Keys.Count; i++)
|
||||||
foreach (string key in _storage.Keys)
|
|
||||||
{
|
{
|
||||||
listBoxStorages.Items.Add(key);
|
listBoxStorages.Items.Add(_storage.Keys[i]);
|
||||||
if (listBoxStorages.Items.Count > 0 && (index == -1 || index >= listBoxStorages.Items.Count))
|
}
|
||||||
{
|
if (listBoxStorages.Items.Count > 0 && (index == -1 || index >= listBoxStorages.Items.Count))
|
||||||
listBoxStorages.SelectedIndex = 0;
|
{
|
||||||
}
|
listBoxStorages.SelectedIndex = 0;
|
||||||
else if (listBoxStorages.Items.Count > 0 && index > -1 && index < listBoxStorages.Items.Count)
|
}
|
||||||
{
|
else if (listBoxStorages.Items.Count > 0 && index > -1 && index < listBoxStorages.Items.Count)
|
||||||
listBoxStorages.SelectedIndex = index;
|
{
|
||||||
}
|
listBoxStorages.SelectedIndex = index;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void ButtonAddObject_Click(object sender, EventArgs e)
|
private void ButtonAddObject_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
@ -66,19 +75,9 @@ namespace ProjectLainer
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
LainerForm form = new();
|
var formLinerConfig = new FormLainerConfig();
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
formLinerConfig.AddEvent(AddLainer);
|
||||||
{
|
formLinerConfig.Show();
|
||||||
if (obj + form.SelectedLainer)
|
|
||||||
{
|
|
||||||
MessageBox.Show("Объект добавлен");
|
|
||||||
pictureBoxCollection.Image = obj.ShowLainers();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
MessageBox.Show("Не удалось добавить объект");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
private void ButtonRemove_Click(object sender, EventArgs e)
|
private void ButtonRemove_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
@ -86,8 +85,7 @@ namespace ProjectLainer
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var obj = _storage[listBoxStorages.SelectedItem.ToString() ??
|
var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? string.Empty];
|
||||||
string.Empty];
|
|
||||||
if (obj == null)
|
if (obj == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@ -126,5 +124,26 @@ namespace ProjectLainer
|
|||||||
{
|
{
|
||||||
pictureBoxCollection.Image = _storage[listBoxStorages.SelectedItem?.ToString() ?? string.Empty]?.ShowLainers();
|
pictureBoxCollection.Image = _storage[listBoxStorages.SelectedItem?.ToString() ?? string.Empty]?.ShowLainers();
|
||||||
}
|
}
|
||||||
|
private void AddLainer(DrawingEntity lainer)
|
||||||
|
{
|
||||||
|
if (listBoxStorages.SelectedIndex == -1)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var obj = _storage[listBoxStorages.SelectedItem.ToString() ?? string.Empty];
|
||||||
|
if (obj == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (obj + lainer)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Объект добавлен");
|
||||||
|
pictureBoxCollection.Image = obj.ShowLainers();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageBox.Show("Не удалось добавить объект");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
12
lainer/Lainer1/LainerDelegate.cs
Normal file
12
lainer/Lainer1/LainerDelegate.cs
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using ProjectLainer.DrawningObjects;
|
||||||
|
|
||||||
|
namespace Lainers
|
||||||
|
{
|
||||||
|
public delegate void LainerDelegate(DrawingEntity car);
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user