Compare commits
2 Commits
9eb2688a38
...
3cfd932bc1
Author | SHA1 | Date | |
---|---|---|---|
3cfd932bc1 | |||
ea5e9c0244 |
11
AccordionBus/AccordionBus/BusDelegate.cs
Normal file
11
AccordionBus/AccordionBus/BusDelegate.cs
Normal file
@ -0,0 +1,11 @@
|
||||
using AccordionBus.Drawnings;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AccordionBus
|
||||
{
|
||||
public delegate void BusDelegate(DrawningBus bus);
|
||||
}
|
@ -29,14 +29,14 @@ namespace AccordionBus.CollectionGenericObjects
|
||||
_collection.SetMaxCount = GetMaxCount;
|
||||
}
|
||||
|
||||
public static bool operator +(AbstractCompany company, DrawningBus bus)
|
||||
public static int operator +(AbstractCompany company, DrawningBus bus)
|
||||
{
|
||||
return company._collection?.Insert(bus) ?? false;
|
||||
return company._collection.Insert(bus);
|
||||
}
|
||||
|
||||
public static bool operator -(AbstractCompany company, int position)
|
||||
public static DrawningBus? operator -(AbstractCompany company, int position)
|
||||
{
|
||||
return company._collection?.Remove(position) ?? false;
|
||||
return company._collection.Remove(position);
|
||||
}
|
||||
|
||||
public DrawningBus? GetRandomObject()
|
||||
@ -52,10 +52,10 @@ namespace AccordionBus.CollectionGenericObjects
|
||||
DrawBackground(graphics);
|
||||
|
||||
|
||||
for (int i = 0; i < (_collection?.Count ?? 0); i++)
|
||||
for (int i = 0; i < (_collection?.MaxCount ?? 0); i++)
|
||||
{
|
||||
DrawningBus? obj = _collection?.Get(i);
|
||||
SetObjectPosition(i, _collection?.Count ?? 0, obj);
|
||||
SetObjectPosition(i, _collection?.MaxCount ?? 0, obj);
|
||||
obj?.DrawTransport(graphics);
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AccordionBus.CollectionGenericObjects
|
||||
{
|
||||
public enum CollectionType
|
||||
{
|
||||
None = 0,
|
||||
|
||||
Massive = 1,
|
||||
|
||||
List = 2
|
||||
}
|
||||
}
|
@ -12,7 +12,7 @@ namespace AccordionBus.CollectionGenericObjects
|
||||
/// <summary>
|
||||
/// кол-во элем
|
||||
/// </summary>
|
||||
int Count { get; }
|
||||
int MaxCount { get; }
|
||||
/// <summary>
|
||||
/// установить макс элем
|
||||
/// </summary>
|
||||
@ -22,20 +22,20 @@ namespace AccordionBus.CollectionGenericObjects
|
||||
/// </summary>
|
||||
/// <param name="obj">добавляемый объект</param>
|
||||
/// <returns></returns>
|
||||
bool Insert(T obj);
|
||||
int Insert(T obj);
|
||||
/// <summary>
|
||||
/// вставить по позиции
|
||||
/// </summary>
|
||||
/// <param name="obj">добавляемый объект</param>
|
||||
/// <param name="position">индекс</param>
|
||||
/// <returns></returns>
|
||||
bool Insert(T obj, int position);
|
||||
int Insert(T obj, int position);
|
||||
/// <summary>
|
||||
/// удаление
|
||||
/// </summary>
|
||||
/// <param name="position">индекс</param>
|
||||
/// <returns></returns>
|
||||
bool Remove(int position);
|
||||
T? Remove(int position);
|
||||
/// <summary>
|
||||
/// получение объекта по позиции
|
||||
/// </summary>
|
||||
|
@ -0,0 +1,57 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AccordionBus.CollectionGenericObjects
|
||||
{
|
||||
public class ListGenericObjects<T> : ICollectionGenericObjects<T>
|
||||
where T : class
|
||||
{
|
||||
|
||||
private readonly List<T?> _collection;
|
||||
|
||||
private int _maxCount;
|
||||
public int MaxCount => _maxCount;
|
||||
|
||||
public int SetMaxCount { set { if (value > 0) _maxCount = value; } }
|
||||
|
||||
public ListGenericObjects()
|
||||
{
|
||||
_collection = new();
|
||||
}
|
||||
|
||||
public T? Get(int position)
|
||||
{
|
||||
if (position < 0 || position >= _collection.Count || _collection == null || _collection.Count == 0) return null;
|
||||
|
||||
return _collection[position];
|
||||
}
|
||||
|
||||
public int Insert(T obj)
|
||||
{
|
||||
if (_collection == null || _collection.Count == _maxCount) return -1;
|
||||
|
||||
_collection.Add(obj);
|
||||
return _collection.Count - 1;
|
||||
}
|
||||
|
||||
public int Insert(T obj, int position)
|
||||
{
|
||||
if (_collection == null || position < 0 || position > _maxCount) return -1;
|
||||
|
||||
_collection.Insert(position, obj);
|
||||
return position;
|
||||
}
|
||||
|
||||
public T? Remove(int position)
|
||||
{
|
||||
if (_collection == null || position < 0 || position >= _collection.Count) return null;
|
||||
|
||||
T? obj = _collection[position];
|
||||
_collection[position] = null;
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
}
|
@ -11,9 +11,9 @@ namespace AccordionBus.CollectionGenericObjects
|
||||
{
|
||||
private T?[] _collection;
|
||||
|
||||
public int Count => _collection.Length;
|
||||
public int MaxCount => _collection.Length;
|
||||
|
||||
public int SetMaxCount { set { if (value > 0) { _collection = new T?[value]; } } }
|
||||
public int SetMaxCount { set { if (value > 0 && MaxCount == 0) { _collection = new T?[value]; } } }
|
||||
|
||||
public MassiveGenericObjects()
|
||||
{
|
||||
@ -26,27 +26,27 @@ namespace AccordionBus.CollectionGenericObjects
|
||||
return _collection[position];
|
||||
}
|
||||
|
||||
public bool Insert(T obj)
|
||||
public int Insert(T obj)
|
||||
{
|
||||
for (int i = 0; i < _collection.Length; i++)
|
||||
{
|
||||
if (_collection[i] == null)
|
||||
{
|
||||
_collection[i] = obj;
|
||||
return true;
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return -1;
|
||||
}
|
||||
|
||||
public bool Insert(T obj, int position)
|
||||
public int Insert(T obj, int position)
|
||||
{
|
||||
if (position < 0 || position >= _collection.Length) { return false; }
|
||||
if (position < 0 || position >= _collection.Length) { return -1; }
|
||||
|
||||
if (_collection[position] == null)
|
||||
{
|
||||
_collection[position] = obj;
|
||||
return true;
|
||||
return position;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -55,7 +55,7 @@ namespace AccordionBus.CollectionGenericObjects
|
||||
if (_collection[i] == null)
|
||||
{
|
||||
_collection[i] = obj;
|
||||
return true;
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
@ -64,19 +64,20 @@ namespace AccordionBus.CollectionGenericObjects
|
||||
if (_collection[i] == null)
|
||||
{
|
||||
_collection[i] = obj;
|
||||
return true;
|
||||
return i;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return -1;
|
||||
}
|
||||
|
||||
public bool Remove(int position)
|
||||
public T? Remove(int position)
|
||||
{
|
||||
if (position < 0 || position >= _collection.Length) { return false;}
|
||||
if (position < 0 || position >= _collection.Length) { return null;}
|
||||
|
||||
T? obj = _collection[position];
|
||||
_collection[position] = null;
|
||||
return true;
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,50 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.NetworkInformation;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AccordionBus.CollectionGenericObjects
|
||||
{
|
||||
public class StorageCollection<T>
|
||||
where T: class
|
||||
{
|
||||
private Dictionary<string, ICollectionGenericObjects<T>> _storage;
|
||||
|
||||
public List<string> Keys => _storage.Keys.ToList();
|
||||
|
||||
public StorageCollection()
|
||||
{
|
||||
_storage = new Dictionary<string, ICollectionGenericObjects<T>>();
|
||||
}
|
||||
|
||||
public void AddCollection(string name, CollectionType collectionType)
|
||||
{
|
||||
if (_storage.ContainsKey(name) || name == "") return;
|
||||
|
||||
if (collectionType == CollectionType.Massive)
|
||||
{
|
||||
_storage[name] = new MassiveGenericObjects<T>();
|
||||
}
|
||||
else
|
||||
{
|
||||
_storage[name] = new ListGenericObjects<T>();
|
||||
}
|
||||
}
|
||||
|
||||
public void DelCollection(string name)
|
||||
{
|
||||
_storage.Remove(name);
|
||||
}
|
||||
|
||||
public ICollectionGenericObjects<T>? this[string name]
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!_storage.ContainsKey(name)) return null;
|
||||
return _storage[name];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -19,13 +19,14 @@ namespace AccordionBus.Drawnings
|
||||
/// <param name="weight"></param>
|
||||
/// <param name="bodyColor"></param>
|
||||
/// <param name="additionalColor"></param>
|
||||
/// <param name="onePart"></param>
|
||||
/// <param name="hatch"></param>
|
||||
/// <param name="fiveDoors"></param>
|
||||
public DrawningAccordionBus(int speed, double weight, Color bodyColor, Color
|
||||
additionalColor, bool onePart, bool fiveDoors): base(130, 20)
|
||||
additionalColor, bool hatch, bool fiveDoors): base(130, 20)
|
||||
{
|
||||
EntityBus = new EntityAccordionBus(speed, weight, bodyColor, additionalColor, onePart, fiveDoors);
|
||||
EntityBus = new EntityAccordionBus(speed, weight, bodyColor, additionalColor, hatch, fiveDoors);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Отрисовка транспорта
|
||||
/// </summary>
|
||||
@ -40,60 +41,66 @@ namespace AccordionBus.Drawnings
|
||||
|
||||
base.DrawTransport(g);
|
||||
|
||||
if (!accordionBus.OnePart)
|
||||
Pen pen = new(Color.Black);
|
||||
Brush brWhite = new SolidBrush(Color.White);
|
||||
Brush br = new SolidBrush(accordionBus.BodyColor);
|
||||
Brush brBlue = new SolidBrush(Color.LightBlue);
|
||||
Brush additionalBrush = new SolidBrush(accordionBus.AdditionalColor);
|
||||
//корпус
|
||||
g.FillRectangle(br, _startPosX.Value + 70, _startPosY.Value, 60, 15);
|
||||
g.DrawRectangle(pen, _startPosX.Value + 70, _startPosY.Value, 60, 15);
|
||||
|
||||
//колёса
|
||||
g.FillEllipse(brWhite, _startPosX.Value + 75, _startPosY.Value + 10, 10, 10);
|
||||
g.FillEllipse(brWhite, _startPosX.Value + 110, _startPosY.Value + 10, 10, 10);
|
||||
g.DrawEllipse(pen, _startPosX.Value + 110, _startPosY.Value + 10, 10, 10);
|
||||
g.DrawEllipse(pen, _startPosX.Value + 75, _startPosY.Value + 10, 10, 10);
|
||||
|
||||
//стёкла
|
||||
g.FillRectangle(brBlue, _startPosX.Value + 72, _startPosY.Value + 3, 5, 5);
|
||||
g.DrawRectangle(pen, _startPosX.Value + 72, _startPosY.Value + 3, 5, 5);
|
||||
g.FillRectangle(brBlue, _startPosX.Value + 82, _startPosY.Value + 3, 5, 5);
|
||||
g.DrawRectangle(pen, _startPosX.Value + 82, _startPosY.Value + 3, 5, 5);
|
||||
g.FillRectangle(brBlue, _startPosX.Value + 92, _startPosY.Value + 3, 5, 5);
|
||||
g.DrawRectangle(pen, _startPosX.Value + 92, _startPosY.Value + 3, 5, 5);
|
||||
g.FillRectangle(brBlue, _startPosX.Value + 102, _startPosY.Value + 3, 5, 5);
|
||||
g.DrawRectangle(pen, _startPosX.Value + 102, _startPosY.Value + 3, 5, 5);
|
||||
g.FillRectangle(brBlue, _startPosX.Value + 112, _startPosY.Value + 3, 5, 5);
|
||||
g.DrawRectangle(pen, _startPosX.Value + 112, _startPosY.Value + 3, 5, 5);
|
||||
|
||||
//гормошка
|
||||
g.DrawLine(pen, _startPosX.Value + 60, _startPosY.Value, _startPosX.Value + 62, _startPosY.Value + 3);
|
||||
g.DrawLine(pen, _startPosX.Value + 62, _startPosY.Value + 3, _startPosX.Value + 65, _startPosY.Value);
|
||||
g.DrawLine(pen, _startPosX.Value + 65, _startPosY.Value, _startPosX.Value + 67, _startPosY.Value + 3);
|
||||
g.DrawLine(pen, _startPosX.Value + 67, _startPosY.Value + 3, _startPosX.Value + 70, _startPosY.Value);
|
||||
g.DrawLine(pen, _startPosX.Value + 60, _startPosY.Value + 15, _startPosX.Value + 62, _startPosY.Value + 12);
|
||||
g.DrawLine(pen, _startPosX.Value + 62, _startPosY.Value + 12, _startPosX.Value + 65, _startPosY.Value + 15);
|
||||
g.DrawLine(pen, _startPosX.Value + 65, _startPosY.Value + 15, _startPosX.Value + 67, _startPosY.Value + 12);
|
||||
g.DrawLine(pen, _startPosX.Value + 67, _startPosY.Value + 12, _startPosX.Value + 70, _startPosY.Value + 15);
|
||||
g.DrawLine(pen, _startPosX.Value + 62, _startPosY.Value + 3, _startPosX.Value + 62, _startPosY.Value + 12);
|
||||
g.DrawLine(pen, _startPosX.Value + 67, _startPosY.Value + 3, _startPosX.Value + 67, _startPosY.Value + 12);
|
||||
g.DrawLine(pen, _startPosX.Value + 65, _startPosY.Value, _startPosX.Value + 65, _startPosY.Value + 15);
|
||||
|
||||
//двери
|
||||
g.FillRectangle(additionalBrush, _startPosX.Value + 123, _startPosY.Value + 5, 5, 10);
|
||||
g.DrawRectangle(pen, _startPosX.Value + 123, _startPosY.Value + 5, 5, 10);
|
||||
if (accordionBus.FiveDoors)
|
||||
{
|
||||
Pen pen = new(Color.Black);
|
||||
Brush brWhite = new SolidBrush(Color.White);
|
||||
Brush br = new SolidBrush(accordionBus.BodyColor);
|
||||
Brush brBlue = new SolidBrush(Color.LightBlue);
|
||||
Brush additionalBrush = new SolidBrush(accordionBus.AdditionalColor);
|
||||
//корпус
|
||||
g.FillRectangle(br, _startPosX.Value + 70, _startPosY.Value, 60, 15);
|
||||
g.DrawRectangle(pen, _startPosX.Value + 70, _startPosY.Value, 60, 15);
|
||||
g.FillRectangle(additionalBrush, _startPosX.Value + 87, _startPosY.Value + 9, 21, 5);
|
||||
g.DrawRectangle(pen, _startPosX.Value + 87, _startPosY.Value + 9, 21, 5);
|
||||
g.FillRectangle(additionalBrush, _startPosX.Value + 53, _startPosY.Value + 5, 5, 10);
|
||||
g.DrawRectangle(pen, _startPosX.Value + 53, _startPosY.Value + 5, 5, 10);
|
||||
g.FillRectangle(additionalBrush, _startPosX.Value + 27, _startPosY.Value + 9, 11, 5);
|
||||
g.DrawRectangle(pen, _startPosX.Value + 27, _startPosY.Value + 9, 11, 5);
|
||||
}
|
||||
|
||||
//колёса
|
||||
g.FillEllipse(brWhite, _startPosX.Value + 75, _startPosY.Value + 10, 10, 10);
|
||||
g.FillEllipse(brWhite, _startPosX.Value + 110, _startPosY.Value + 10, 10, 10);
|
||||
g.DrawEllipse(pen, _startPosX.Value + 110, _startPosY.Value + 10, 10, 10);
|
||||
g.DrawEllipse(pen, _startPosX.Value + 75, _startPosY.Value + 10, 10, 10);
|
||||
|
||||
//стёкла
|
||||
g.FillRectangle(brBlue, _startPosX.Value + 72, _startPosY.Value + 3, 5, 5);
|
||||
g.DrawRectangle(pen, _startPosX.Value + 72, _startPosY.Value + 3, 5, 5);
|
||||
g.FillRectangle(brBlue, _startPosX.Value + 82, _startPosY.Value + 3, 5, 5);
|
||||
g.DrawRectangle(pen, _startPosX.Value + 82, _startPosY.Value + 3, 5, 5);
|
||||
g.FillRectangle(brBlue, _startPosX.Value + 92, _startPosY.Value + 3, 5, 5);
|
||||
g.DrawRectangle(pen, _startPosX.Value + 92, _startPosY.Value + 3, 5, 5);
|
||||
g.FillRectangle(brBlue, _startPosX.Value + 102, _startPosY.Value + 3, 5, 5);
|
||||
g.DrawRectangle(pen, _startPosX.Value + 102, _startPosY.Value + 3, 5, 5);
|
||||
g.FillRectangle(brBlue, _startPosX.Value + 112, _startPosY.Value + 3, 5, 5);
|
||||
g.DrawRectangle(pen, _startPosX.Value + 112, _startPosY.Value + 3, 5, 5);
|
||||
|
||||
//гормошка
|
||||
g.DrawLine(pen, _startPosX.Value + 60, _startPosY.Value, _startPosX.Value + 62, _startPosY.Value + 3);
|
||||
g.DrawLine(pen, _startPosX.Value + 62, _startPosY.Value + 3, _startPosX.Value + 65, _startPosY.Value);
|
||||
g.DrawLine(pen, _startPosX.Value + 65, _startPosY.Value, _startPosX.Value + 67, _startPosY.Value + 3);
|
||||
g.DrawLine(pen, _startPosX.Value + 67, _startPosY.Value + 3, _startPosX.Value + 70, _startPosY.Value);
|
||||
g.DrawLine(pen, _startPosX.Value + 60, _startPosY.Value + 15, _startPosX.Value + 62, _startPosY.Value + 12);
|
||||
g.DrawLine(pen, _startPosX.Value + 62, _startPosY.Value + 12, _startPosX.Value + 65, _startPosY.Value + 15);
|
||||
g.DrawLine(pen, _startPosX.Value + 65, _startPosY.Value + 15, _startPosX.Value + 67, _startPosY.Value + 12);
|
||||
g.DrawLine(pen, _startPosX.Value + 67, _startPosY.Value + 12, _startPosX.Value + 70, _startPosY.Value + 15);
|
||||
g.DrawLine(pen, _startPosX.Value + 62, _startPosY.Value + 3, _startPosX.Value + 62, _startPosY.Value + 12);
|
||||
g.DrawLine(pen, _startPosX.Value + 67, _startPosY.Value + 3, _startPosX.Value + 67, _startPosY.Value + 12);
|
||||
g.DrawLine(pen, _startPosX.Value + 65, _startPosY.Value, _startPosX.Value + 65, _startPosY.Value + 15);
|
||||
|
||||
//двери
|
||||
g.FillRectangle(additionalBrush, _startPosX.Value + 123, _startPosY.Value + 5, 5, 10);
|
||||
g.DrawRectangle(pen, _startPosX.Value + 123, _startPosY.Value + 5, 5, 10);
|
||||
if (accordionBus.FiveDoors)
|
||||
{
|
||||
g.FillRectangle(additionalBrush, _startPosX.Value + 87, _startPosY.Value + 9, 21, 5);
|
||||
g.DrawRectangle(pen, _startPosX.Value + 87, _startPosY.Value + 9, 21, 5);
|
||||
g.FillRectangle(additionalBrush, _startPosX.Value + 53, _startPosY.Value + 5, 5, 10);
|
||||
g.DrawRectangle(pen, _startPosX.Value + 53, _startPosY.Value + 5, 5, 10);
|
||||
g.FillRectangle(additionalBrush, _startPosX.Value + 27, _startPosY.Value + 9, 11, 5);
|
||||
g.DrawRectangle(pen, _startPosX.Value + 27, _startPosY.Value + 9, 11, 5);
|
||||
}
|
||||
//люки
|
||||
if (accordionBus.Hatch)
|
||||
{
|
||||
g.FillRectangle(additionalBrush, _startPosX.Value + 10, _startPosY.Value - 3, 10, 3);
|
||||
g.FillRectangle(additionalBrush, _startPosX.Value + 90, _startPosY.Value - 3, 10, 3);
|
||||
g.DrawRectangle(pen, _startPosX.Value + 10, _startPosY.Value - 3, 10, 3);
|
||||
g.DrawRectangle(pen, _startPosX.Value + 90, _startPosY.Value - 3, 10, 3);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -68,6 +68,7 @@ namespace AccordionBus.Drawnings
|
||||
_startPosX = null;
|
||||
_startPosY = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Конструктор границ объекта
|
||||
/// </summary>
|
||||
|
@ -18,7 +18,7 @@ namespace AccordionBus.Entities
|
||||
/// <summary>
|
||||
/// Одна часть
|
||||
/// </summary>
|
||||
public bool OnePart { get; set; }
|
||||
public bool Hatch { get; set; }
|
||||
/// <summary>
|
||||
/// 5 дверей
|
||||
/// </summary>
|
||||
@ -30,14 +30,20 @@ namespace AccordionBus.Entities
|
||||
/// <param name="weight">вес</param>
|
||||
/// <param name="bodyColor">Основной цвет</param>
|
||||
/// <param name="additionalColor">Дополнительный цвет</param>
|
||||
/// <param name="onePart">1 часть</param>
|
||||
/// <param name="hatch">1 часть</param>
|
||||
/// <param name="fiveDoors">5 дверей</param>
|
||||
public EntityAccordionBus(int speed, double weight, Color bodyColor,
|
||||
Color additionalColor, bool onePart, bool fiveDoors) : base(speed, weight, bodyColor)
|
||||
Color additionalColor, bool hatch, bool fiveDoors) : base(speed, weight, bodyColor)
|
||||
{
|
||||
AdditionalColor = additionalColor;
|
||||
OnePart = onePart;
|
||||
Hatch = hatch;
|
||||
FiveDoors = fiveDoors;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Новый дополнительный цвет
|
||||
/// </summary>
|
||||
/// <param name="color"></param>
|
||||
public void SetAdditionalColor(Color color) { AdditionalColor = color; }
|
||||
}
|
||||
}
|
||||
|
@ -14,15 +14,15 @@ namespace AccordionBus.Entities
|
||||
/// <summary>
|
||||
/// Скорость
|
||||
/// </summary>
|
||||
public int Speed { get; set; }
|
||||
public int Speed { get; private set; }
|
||||
/// <summary>
|
||||
/// Вес
|
||||
/// </summary>
|
||||
public double Weight { get; set; }
|
||||
public double Weight { get; private set; }
|
||||
/// <summary>
|
||||
/// Основной цвет
|
||||
/// </summary>
|
||||
public Color BodyColor { get; set; }
|
||||
public Color BodyColor { get; private set; }
|
||||
/// <summary>
|
||||
/// Шаг
|
||||
/// </summary>
|
||||
@ -39,5 +39,11 @@ namespace AccordionBus.Entities
|
||||
Weight = weight;
|
||||
BodyColor = bodyColor;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Новый основной цвет
|
||||
/// </summary>
|
||||
/// <param name="color"></param>
|
||||
public void SetBodyColor(Color color) { BodyColor = color; }
|
||||
}
|
||||
}
|
||||
|
233
AccordionBus/AccordionBus/FormBusCollection.Designer.cs
generated
233
AccordionBus/AccordionBus/FormBusCollection.Designer.cs
generated
@ -29,38 +29,173 @@
|
||||
private void InitializeComponent()
|
||||
{
|
||||
groupBoxTools = new GroupBox();
|
||||
buttonCreateCompany = new Button();
|
||||
comboBoxSelectedCompany = new ComboBox();
|
||||
panelStorage = new Panel();
|
||||
buttonCollectionDel = new Button();
|
||||
listBoxCollection = new ListBox();
|
||||
buttonCollectionAdd = new Button();
|
||||
radioButtonList = new RadioButton();
|
||||
radioButtonMassive = new RadioButton();
|
||||
textBoxCollectionName = new TextBox();
|
||||
labelCollectionName = new Label();
|
||||
panelTools = new Panel();
|
||||
buttonAddBus = new Button();
|
||||
buttonRefresh = new Button();
|
||||
maskedTextBox = new MaskedTextBox();
|
||||
buttonGoToCheck = new Button();
|
||||
buttonRemoveBus = new Button();
|
||||
maskedTextBox = new MaskedTextBox();
|
||||
buttonAddAccordionBus = new Button();
|
||||
buttonAddBus = new Button();
|
||||
comboBoxSelectedCompany = new ComboBox();
|
||||
pictureBox = new PictureBox();
|
||||
groupBoxTools.SuspendLayout();
|
||||
panelStorage.SuspendLayout();
|
||||
panelTools.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBox).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// groupBoxTools
|
||||
//
|
||||
groupBoxTools.Controls.Add(buttonRefresh);
|
||||
groupBoxTools.Controls.Add(buttonGoToCheck);
|
||||
groupBoxTools.Controls.Add(buttonRemoveBus);
|
||||
groupBoxTools.Controls.Add(maskedTextBox);
|
||||
groupBoxTools.Controls.Add(buttonAddAccordionBus);
|
||||
groupBoxTools.Controls.Add(buttonAddBus);
|
||||
groupBoxTools.Controls.Add(buttonCreateCompany);
|
||||
groupBoxTools.Controls.Add(comboBoxSelectedCompany);
|
||||
groupBoxTools.Controls.Add(panelStorage);
|
||||
groupBoxTools.Controls.Add(panelTools);
|
||||
groupBoxTools.Dock = DockStyle.Right;
|
||||
groupBoxTools.Location = new Point(948, 0);
|
||||
groupBoxTools.Name = "groupBoxTools";
|
||||
groupBoxTools.Size = new Size(234, 653);
|
||||
groupBoxTools.Size = new Size(234, 753);
|
||||
groupBoxTools.TabIndex = 0;
|
||||
groupBoxTools.TabStop = false;
|
||||
groupBoxTools.Text = "Инструменты";
|
||||
//
|
||||
// buttonCreateCompany
|
||||
//
|
||||
buttonCreateCompany.Location = new Point(12, 361);
|
||||
buttonCreateCompany.Name = "buttonCreateCompany";
|
||||
buttonCreateCompany.Size = new Size(207, 29);
|
||||
buttonCreateCompany.TabIndex = 7;
|
||||
buttonCreateCompany.Text = "Создать компанию";
|
||||
buttonCreateCompany.UseVisualStyleBackColor = true;
|
||||
buttonCreateCompany.Click += buttonCreateCompany_Click;
|
||||
//
|
||||
// comboBoxSelectedCompany
|
||||
//
|
||||
comboBoxSelectedCompany.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||
comboBoxSelectedCompany.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
comboBoxSelectedCompany.FormattingEnabled = true;
|
||||
comboBoxSelectedCompany.Items.AddRange(new object[] { "Станция" });
|
||||
comboBoxSelectedCompany.Location = new Point(12, 327);
|
||||
comboBoxSelectedCompany.Name = "comboBoxSelectedCompany";
|
||||
comboBoxSelectedCompany.Size = new Size(207, 28);
|
||||
comboBoxSelectedCompany.TabIndex = 0;
|
||||
comboBoxSelectedCompany.SelectedIndexChanged += comboBoxSelectedCompany_SelectedIndexChanged;
|
||||
//
|
||||
// panelStorage
|
||||
//
|
||||
panelStorage.Controls.Add(buttonCollectionDel);
|
||||
panelStorage.Controls.Add(listBoxCollection);
|
||||
panelStorage.Controls.Add(buttonCollectionAdd);
|
||||
panelStorage.Controls.Add(radioButtonList);
|
||||
panelStorage.Controls.Add(radioButtonMassive);
|
||||
panelStorage.Controls.Add(textBoxCollectionName);
|
||||
panelStorage.Controls.Add(labelCollectionName);
|
||||
panelStorage.Dock = DockStyle.Top;
|
||||
panelStorage.Location = new Point(3, 23);
|
||||
panelStorage.Name = "panelStorage";
|
||||
panelStorage.Size = new Size(228, 291);
|
||||
panelStorage.TabIndex = 8;
|
||||
//
|
||||
// buttonCollectionDel
|
||||
//
|
||||
buttonCollectionDel.Location = new Point(9, 241);
|
||||
buttonCollectionDel.Name = "buttonCollectionDel";
|
||||
buttonCollectionDel.Size = new Size(207, 29);
|
||||
buttonCollectionDel.TabIndex = 6;
|
||||
buttonCollectionDel.Text = "Удалить коллекцию";
|
||||
buttonCollectionDel.UseVisualStyleBackColor = true;
|
||||
buttonCollectionDel.Click += buttonCollectionDel_Click;
|
||||
//
|
||||
// listBoxCollection
|
||||
//
|
||||
listBoxCollection.FormattingEnabled = true;
|
||||
listBoxCollection.Location = new Point(9, 131);
|
||||
listBoxCollection.Name = "listBoxCollection";
|
||||
listBoxCollection.Size = new Size(207, 104);
|
||||
listBoxCollection.TabIndex = 5;
|
||||
//
|
||||
// buttonCollectionAdd
|
||||
//
|
||||
buttonCollectionAdd.Location = new Point(9, 96);
|
||||
buttonCollectionAdd.Name = "buttonCollectionAdd";
|
||||
buttonCollectionAdd.Size = new Size(207, 29);
|
||||
buttonCollectionAdd.TabIndex = 4;
|
||||
buttonCollectionAdd.Text = "Добавить коллекцию";
|
||||
buttonCollectionAdd.UseVisualStyleBackColor = true;
|
||||
buttonCollectionAdd.Click += buttonCollectionAdd_Click;
|
||||
//
|
||||
// radioButtonList
|
||||
//
|
||||
radioButtonList.AutoSize = true;
|
||||
radioButtonList.Location = new Point(125, 66);
|
||||
radioButtonList.Name = "radioButtonList";
|
||||
radioButtonList.Size = new Size(80, 24);
|
||||
radioButtonList.TabIndex = 3;
|
||||
radioButtonList.TabStop = true;
|
||||
radioButtonList.Text = "Список";
|
||||
radioButtonList.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// radioButtonMassive
|
||||
//
|
||||
radioButtonMassive.AutoSize = true;
|
||||
radioButtonMassive.Location = new Point(22, 66);
|
||||
radioButtonMassive.Name = "radioButtonMassive";
|
||||
radioButtonMassive.Size = new Size(82, 24);
|
||||
radioButtonMassive.TabIndex = 2;
|
||||
radioButtonMassive.TabStop = true;
|
||||
radioButtonMassive.Text = "Массив";
|
||||
radioButtonMassive.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// textBoxCollectionName
|
||||
//
|
||||
textBoxCollectionName.Location = new Point(9, 33);
|
||||
textBoxCollectionName.Name = "textBoxCollectionName";
|
||||
textBoxCollectionName.Size = new Size(207, 27);
|
||||
textBoxCollectionName.TabIndex = 1;
|
||||
//
|
||||
// labelCollectionName
|
||||
//
|
||||
labelCollectionName.AutoSize = true;
|
||||
labelCollectionName.Location = new Point(40, 10);
|
||||
labelCollectionName.Name = "labelCollectionName";
|
||||
labelCollectionName.Size = new Size(155, 20);
|
||||
labelCollectionName.TabIndex = 0;
|
||||
labelCollectionName.Text = "Название коллекции";
|
||||
//
|
||||
// panelTools
|
||||
//
|
||||
panelTools.Controls.Add(buttonAddBus);
|
||||
panelTools.Controls.Add(buttonRefresh);
|
||||
panelTools.Controls.Add(maskedTextBox);
|
||||
panelTools.Controls.Add(buttonGoToCheck);
|
||||
panelTools.Controls.Add(buttonRemoveBus);
|
||||
panelTools.Dock = DockStyle.Bottom;
|
||||
panelTools.Enabled = false;
|
||||
panelTools.Location = new Point(3, 396);
|
||||
panelTools.Name = "panelTools";
|
||||
panelTools.Size = new Size(228, 354);
|
||||
panelTools.TabIndex = 7;
|
||||
//
|
||||
// buttonAddBus
|
||||
//
|
||||
buttonAddBus.Location = new Point(9, 13);
|
||||
buttonAddBus.Name = "buttonAddBus";
|
||||
buttonAddBus.Size = new Size(207, 54);
|
||||
buttonAddBus.TabIndex = 1;
|
||||
buttonAddBus.Text = "Добавить автобус";
|
||||
buttonAddBus.UseVisualStyleBackColor = true;
|
||||
buttonAddBus.Click += buttonAddBus_Click;
|
||||
//
|
||||
// buttonRefresh
|
||||
//
|
||||
buttonRefresh.Location = new Point(15, 554);
|
||||
buttonRefresh.Location = new Point(9, 286);
|
||||
buttonRefresh.Name = "buttonRefresh";
|
||||
buttonRefresh.Size = new Size(207, 54);
|
||||
buttonRefresh.TabIndex = 6;
|
||||
@ -68,9 +203,18 @@
|
||||
buttonRefresh.UseVisualStyleBackColor = true;
|
||||
buttonRefresh.Click += buttonRefresh_Click;
|
||||
//
|
||||
// maskedTextBox
|
||||
//
|
||||
maskedTextBox.Location = new Point(9, 133);
|
||||
maskedTextBox.Mask = "00";
|
||||
maskedTextBox.Name = "maskedTextBox";
|
||||
maskedTextBox.Size = new Size(207, 27);
|
||||
maskedTextBox.TabIndex = 3;
|
||||
maskedTextBox.ValidatingType = typeof(int);
|
||||
//
|
||||
// buttonGoToCheck
|
||||
//
|
||||
buttonGoToCheck.Location = new Point(15, 443);
|
||||
buttonGoToCheck.Location = new Point(9, 226);
|
||||
buttonGoToCheck.Name = "buttonGoToCheck";
|
||||
buttonGoToCheck.Size = new Size(207, 54);
|
||||
buttonGoToCheck.TabIndex = 5;
|
||||
@ -80,7 +224,7 @@
|
||||
//
|
||||
// buttonRemoveBus
|
||||
//
|
||||
buttonRemoveBus.Location = new Point(15, 310);
|
||||
buttonRemoveBus.Location = new Point(9, 166);
|
||||
buttonRemoveBus.Name = "buttonRemoveBus";
|
||||
buttonRemoveBus.Size = new Size(207, 54);
|
||||
buttonRemoveBus.TabIndex = 4;
|
||||
@ -88,53 +232,12 @@
|
||||
buttonRemoveBus.UseVisualStyleBackColor = true;
|
||||
buttonRemoveBus.Click += buttonRemoveBus_Click;
|
||||
//
|
||||
// maskedTextBox
|
||||
//
|
||||
maskedTextBox.Location = new Point(15, 277);
|
||||
maskedTextBox.Mask = "00";
|
||||
maskedTextBox.Name = "maskedTextBox";
|
||||
maskedTextBox.Size = new Size(207, 27);
|
||||
maskedTextBox.TabIndex = 3;
|
||||
maskedTextBox.ValidatingType = typeof(int);
|
||||
//
|
||||
// buttonAddAccordionBus
|
||||
//
|
||||
buttonAddAccordionBus.Location = new Point(15, 155);
|
||||
buttonAddAccordionBus.Name = "buttonAddAccordionBus";
|
||||
buttonAddAccordionBus.Size = new Size(207, 54);
|
||||
buttonAddAccordionBus.TabIndex = 2;
|
||||
buttonAddAccordionBus.Text = "Добавить автобус с гормошкой";
|
||||
buttonAddAccordionBus.UseVisualStyleBackColor = true;
|
||||
buttonAddAccordionBus.Click += buttonAddAccordionBus_Click;
|
||||
//
|
||||
// buttonAddBus
|
||||
//
|
||||
buttonAddBus.Location = new Point(15, 95);
|
||||
buttonAddBus.Name = "buttonAddBus";
|
||||
buttonAddBus.Size = new Size(207, 54);
|
||||
buttonAddBus.TabIndex = 1;
|
||||
buttonAddBus.Text = "Добавить автобус";
|
||||
buttonAddBus.UseVisualStyleBackColor = true;
|
||||
buttonAddBus.Click += buttonAddBus_Click;
|
||||
//
|
||||
// comboBoxSelectedCompany
|
||||
//
|
||||
comboBoxSelectedCompany.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||
comboBoxSelectedCompany.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
comboBoxSelectedCompany.FormattingEnabled = true;
|
||||
comboBoxSelectedCompany.Items.AddRange(new object[] { "Станция" });
|
||||
comboBoxSelectedCompany.Location = new Point(15, 40);
|
||||
comboBoxSelectedCompany.Name = "comboBoxSelectedCompany";
|
||||
comboBoxSelectedCompany.Size = new Size(207, 28);
|
||||
comboBoxSelectedCompany.TabIndex = 0;
|
||||
comboBoxSelectedCompany.SelectedIndexChanged += comboBoxSelectedCompany_SelectedIndexChanged;
|
||||
//
|
||||
// pictureBox
|
||||
//
|
||||
pictureBox.Dock = DockStyle.Fill;
|
||||
pictureBox.Location = new Point(0, 0);
|
||||
pictureBox.Name = "pictureBox";
|
||||
pictureBox.Size = new Size(948, 653);
|
||||
pictureBox.Size = new Size(948, 753);
|
||||
pictureBox.TabIndex = 1;
|
||||
pictureBox.TabStop = false;
|
||||
//
|
||||
@ -142,14 +245,17 @@
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(1182, 653);
|
||||
ClientSize = new Size(1182, 753);
|
||||
Controls.Add(pictureBox);
|
||||
Controls.Add(groupBoxTools);
|
||||
Name = "FormBusCollection";
|
||||
StartPosition = FormStartPosition.CenterScreen;
|
||||
Text = "Коллекция автобусов";
|
||||
groupBoxTools.ResumeLayout(false);
|
||||
groupBoxTools.PerformLayout();
|
||||
panelStorage.ResumeLayout(false);
|
||||
panelStorage.PerformLayout();
|
||||
panelTools.ResumeLayout(false);
|
||||
panelTools.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBox).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
@ -159,11 +265,20 @@
|
||||
private GroupBox groupBoxTools;
|
||||
private ComboBox comboBoxSelectedCompany;
|
||||
private Button buttonAddBus;
|
||||
private Button buttonAddAccordionBus;
|
||||
private PictureBox pictureBox;
|
||||
private Button buttonRemoveBus;
|
||||
private MaskedTextBox maskedTextBox;
|
||||
private Button buttonRefresh;
|
||||
private Button buttonGoToCheck;
|
||||
private Panel panelTools;
|
||||
private Panel panelStorage;
|
||||
private Label labelCollectionName;
|
||||
private RadioButton radioButtonMassive;
|
||||
private TextBox textBoxCollectionName;
|
||||
private RadioButton radioButtonList;
|
||||
private Button buttonCollectionAdd;
|
||||
private Button buttonCollectionDel;
|
||||
private ListBox listBoxCollection;
|
||||
private Button buttonCreateCompany;
|
||||
}
|
||||
}
|
@ -15,47 +15,35 @@ namespace AccordionBus
|
||||
{
|
||||
public partial class FormBusCollection : Form
|
||||
{
|
||||
private AbstractCompany? _company;
|
||||
private StorageCollection<DrawningBus> _storageCollection;
|
||||
|
||||
private AbstractCompany? _company = null;
|
||||
|
||||
public FormBusCollection()
|
||||
{
|
||||
InitializeComponent();
|
||||
_storageCollection = new StorageCollection<DrawningBus>();
|
||||
}
|
||||
|
||||
private void comboBoxSelectedCompany_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
switch (comboBoxSelectedCompany.Text)
|
||||
{
|
||||
case "Станция":
|
||||
_company = new BusStation(pictureBox.Width, pictureBox.Height, new MassiveGenericObjects<DrawningBus>());
|
||||
pictureBox.Image = _company.Show();
|
||||
break;
|
||||
}
|
||||
panelTools.Enabled = false;
|
||||
}
|
||||
|
||||
private void CreateObject(string type)
|
||||
private void buttonAddBus_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_company == null) return;
|
||||
FormBusConfig form = new FormBusConfig();
|
||||
form.Show();
|
||||
form.AddEvent(SetCar);
|
||||
}
|
||||
|
||||
Random random = new();
|
||||
DrawningBus _drawningBus;
|
||||
switch (type)
|
||||
{
|
||||
case nameof(DrawningBus):
|
||||
_drawningBus = new DrawningBus(random.Next(100, 300), random.Next(1000, 3000), GetColor(random));
|
||||
_drawningBus.SetPictureSize(pictureBox.Width, pictureBox.Height);
|
||||
break;
|
||||
case nameof(DrawningAccordionBus):
|
||||
_drawningBus = new DrawningAccordionBus(random.Next(100, 300), random.Next(1000, 3000),
|
||||
GetColor(random), GetColor(random),
|
||||
Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)));
|
||||
_drawningBus.SetPictureSize(pictureBox.Width, pictureBox.Height);
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
private void SetCar(DrawningBus bus)
|
||||
{
|
||||
if (_company == null || bus == null) return;
|
||||
|
||||
if (_company + _drawningBus)
|
||||
bus.SetPictureSize(pictureBox.Width, pictureBox.Height);
|
||||
|
||||
if (_company + bus != -1)
|
||||
{
|
||||
MessageBox.Show("Объект добавлен");
|
||||
pictureBox.Image = _company.Show();
|
||||
@ -66,30 +54,15 @@ namespace AccordionBus
|
||||
}
|
||||
}
|
||||
|
||||
private static Color GetColor(Random rnd)
|
||||
{
|
||||
Color color = Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256));
|
||||
ColorDialog dialog = new();
|
||||
if (dialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
color = dialog.Color;
|
||||
}
|
||||
|
||||
return color;
|
||||
}
|
||||
|
||||
private void buttonAddBus_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningBus));
|
||||
|
||||
private void buttonAddAccordionBus_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningAccordionBus));
|
||||
|
||||
private void buttonRemoveBus_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_company == null || string.IsNullOrEmpty(maskedTextBox.Text)) return;
|
||||
|
||||
if (MessageBox.Show("Удалить объект?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) return;
|
||||
if (MessageBox.Show("Удалить объект?", "Удаление",
|
||||
MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) return;
|
||||
|
||||
int pos = Convert.ToInt32(maskedTextBox.Text);
|
||||
if (_company - pos)
|
||||
if (_company - pos is DrawningBus)
|
||||
{
|
||||
MessageBox.Show("Объект удалён");
|
||||
pictureBox.Image = _company.Show();
|
||||
@ -106,7 +79,7 @@ namespace AccordionBus
|
||||
|
||||
DrawningBus? bus = null;
|
||||
int counter = 100;
|
||||
while (bus == null || counter > 0)
|
||||
while (bus == null && counter > 0)
|
||||
{
|
||||
bus = _company.GetRandomObject();
|
||||
counter--;
|
||||
@ -119,6 +92,7 @@ namespace AccordionBus
|
||||
SetBus = bus
|
||||
};
|
||||
form.ShowDialog();
|
||||
bus.SetPictureSize(pictureBox.Width, pictureBox.Height);
|
||||
}
|
||||
|
||||
private void buttonRefresh_Click(object sender, EventArgs e)
|
||||
@ -127,5 +101,79 @@ namespace AccordionBus
|
||||
|
||||
pictureBox.Image = _company.Show();
|
||||
}
|
||||
|
||||
private void buttonCollectionAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(textBoxCollectionName.Text) || (!radioButtonMassive.Checked && !radioButtonList.Checked))
|
||||
{
|
||||
MessageBox.Show("Не все данные заполнены", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
CollectionType collectionType = CollectionType.None;
|
||||
if (radioButtonMassive.Checked) collectionType = CollectionType.Massive;
|
||||
else if (radioButtonList.Checked) collectionType = CollectionType.List;
|
||||
|
||||
_storageCollection.AddCollection(textBoxCollectionName.Text, collectionType);
|
||||
textBoxCollectionName.Text = "";
|
||||
RefreshListBoxItems();
|
||||
}
|
||||
|
||||
private void buttonCollectionDel_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (listBoxCollection.SelectedItem == null) return;
|
||||
|
||||
if (MessageBox.Show("Вы действительно хотите удалить выбранный элемент?",
|
||||
"Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||
{
|
||||
_storageCollection.DelCollection(listBoxCollection.SelectedItem.ToString());
|
||||
RefreshListBoxItems();
|
||||
MessageBox.Show("Компания удалена");
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Не удалось удалить компанию");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void buttonCreateCompany_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (listBoxCollection.SelectedIndex < 0)
|
||||
{
|
||||
MessageBox.Show("Компания не выбрана");
|
||||
return;
|
||||
}
|
||||
|
||||
ICollectionGenericObjects<DrawningBus?> collection = _storageCollection[listBoxCollection.SelectedItem?.ToString() ?? string.Empty];
|
||||
if (collection == null)
|
||||
{
|
||||
MessageBox.Show("Компания не инициализирована");
|
||||
return;
|
||||
}
|
||||
|
||||
switch (comboBoxSelectedCompany.Text)
|
||||
{
|
||||
case "Станция":
|
||||
_company = new BusStation(pictureBox.Width, pictureBox.Height, collection);
|
||||
pictureBox.Image = _company.Show();
|
||||
break;
|
||||
}
|
||||
|
||||
panelTools.Enabled = true;
|
||||
}
|
||||
|
||||
private void RefreshListBoxItems()
|
||||
{
|
||||
listBoxCollection.Items.Clear();
|
||||
for (int i =0; i < _storageCollection.Keys?.Count; i++)
|
||||
{
|
||||
string? colName = _storageCollection.Keys?[i];
|
||||
if (!string.IsNullOrEmpty(colName))
|
||||
{
|
||||
listBoxCollection.Items.Add(colName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
368
AccordionBus/AccordionBus/FormBusConfig.Designer.cs
generated
Normal file
368
AccordionBus/AccordionBus/FormBusConfig.Designer.cs
generated
Normal file
@ -0,0 +1,368 @@
|
||||
namespace AccordionBus
|
||||
{
|
||||
partial class FormBusConfig
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
groupBoxConfig = new GroupBox();
|
||||
groupBoxColor = new GroupBox();
|
||||
panelPurple = new Panel();
|
||||
panelBlack = new Panel();
|
||||
panelGray = new Panel();
|
||||
panelWhite = new Panel();
|
||||
panelYellow = new Panel();
|
||||
panelBlue = new Panel();
|
||||
panelGreen = new Panel();
|
||||
panelRed = new Panel();
|
||||
checkBoxFiveDoors = new CheckBox();
|
||||
checkBoxHatch = new CheckBox();
|
||||
numericUpDownWeight = new NumericUpDown();
|
||||
labelWeight = new Label();
|
||||
numericUpDownSpeed = new NumericUpDown();
|
||||
labelSpeed = new Label();
|
||||
labelModifiedObject = new Label();
|
||||
labelSimpleObject = new Label();
|
||||
pictureBoxObject = new PictureBox();
|
||||
buttonAdd = new Button();
|
||||
buttonCancel = new Button();
|
||||
panelObject = new Panel();
|
||||
labelAdditionalColor = new Label();
|
||||
labelBodyColor = new Label();
|
||||
groupBoxConfig.SuspendLayout();
|
||||
groupBoxColor.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownWeight).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBoxObject).BeginInit();
|
||||
panelObject.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
// groupBoxConfig
|
||||
//
|
||||
groupBoxConfig.Controls.Add(groupBoxColor);
|
||||
groupBoxConfig.Controls.Add(checkBoxFiveDoors);
|
||||
groupBoxConfig.Controls.Add(checkBoxHatch);
|
||||
groupBoxConfig.Controls.Add(numericUpDownWeight);
|
||||
groupBoxConfig.Controls.Add(labelWeight);
|
||||
groupBoxConfig.Controls.Add(numericUpDownSpeed);
|
||||
groupBoxConfig.Controls.Add(labelSpeed);
|
||||
groupBoxConfig.Controls.Add(labelModifiedObject);
|
||||
groupBoxConfig.Controls.Add(labelSimpleObject);
|
||||
groupBoxConfig.Dock = DockStyle.Left;
|
||||
groupBoxConfig.Location = new Point(0, 0);
|
||||
groupBoxConfig.Name = "groupBoxConfig";
|
||||
groupBoxConfig.Size = new Size(493, 229);
|
||||
groupBoxConfig.TabIndex = 0;
|
||||
groupBoxConfig.TabStop = false;
|
||||
groupBoxConfig.Text = "Параметры";
|
||||
//
|
||||
// groupBoxColor
|
||||
//
|
||||
groupBoxColor.Controls.Add(panelPurple);
|
||||
groupBoxColor.Controls.Add(panelBlack);
|
||||
groupBoxColor.Controls.Add(panelGray);
|
||||
groupBoxColor.Controls.Add(panelWhite);
|
||||
groupBoxColor.Controls.Add(panelYellow);
|
||||
groupBoxColor.Controls.Add(panelBlue);
|
||||
groupBoxColor.Controls.Add(panelGreen);
|
||||
groupBoxColor.Controls.Add(panelRed);
|
||||
groupBoxColor.Location = new Point(221, 17);
|
||||
groupBoxColor.Name = "groupBoxColor";
|
||||
groupBoxColor.Size = new Size(262, 147);
|
||||
groupBoxColor.TabIndex = 8;
|
||||
groupBoxColor.TabStop = false;
|
||||
groupBoxColor.Text = "Цвета";
|
||||
//
|
||||
// panelPurple
|
||||
//
|
||||
panelPurple.AllowDrop = true;
|
||||
panelPurple.BackColor = Color.Purple;
|
||||
panelPurple.Location = new Point(205, 90);
|
||||
panelPurple.Name = "panelPurple";
|
||||
panelPurple.Size = new Size(35, 35);
|
||||
panelPurple.TabIndex = 6;
|
||||
//
|
||||
// panelBlack
|
||||
//
|
||||
panelBlack.AllowDrop = true;
|
||||
panelBlack.BackColor = Color.Black;
|
||||
panelBlack.Location = new Point(143, 90);
|
||||
panelBlack.Name = "panelBlack";
|
||||
panelBlack.Size = new Size(35, 35);
|
||||
panelBlack.TabIndex = 1;
|
||||
//
|
||||
// panelGray
|
||||
//
|
||||
panelGray.AllowDrop = true;
|
||||
panelGray.BackColor = Color.Gray;
|
||||
panelGray.Location = new Point(77, 90);
|
||||
panelGray.Name = "panelGray";
|
||||
panelGray.Size = new Size(35, 35);
|
||||
panelGray.TabIndex = 5;
|
||||
//
|
||||
// panelWhite
|
||||
//
|
||||
panelWhite.AllowDrop = true;
|
||||
panelWhite.BackColor = Color.White;
|
||||
panelWhite.Location = new Point(15, 90);
|
||||
panelWhite.Name = "panelWhite";
|
||||
panelWhite.Size = new Size(35, 35);
|
||||
panelWhite.TabIndex = 4;
|
||||
//
|
||||
// panelYellow
|
||||
//
|
||||
panelYellow.AllowDrop = true;
|
||||
panelYellow.BackColor = Color.Yellow;
|
||||
panelYellow.Location = new Point(205, 26);
|
||||
panelYellow.Name = "panelYellow";
|
||||
panelYellow.Size = new Size(35, 35);
|
||||
panelYellow.TabIndex = 3;
|
||||
//
|
||||
// panelBlue
|
||||
//
|
||||
panelBlue.AllowDrop = true;
|
||||
panelBlue.BackColor = Color.Blue;
|
||||
panelBlue.Location = new Point(143, 26);
|
||||
panelBlue.Name = "panelBlue";
|
||||
panelBlue.Size = new Size(35, 35);
|
||||
panelBlue.TabIndex = 2;
|
||||
//
|
||||
// panelGreen
|
||||
//
|
||||
panelGreen.AllowDrop = true;
|
||||
panelGreen.BackColor = Color.Green;
|
||||
panelGreen.Location = new Point(77, 26);
|
||||
panelGreen.Name = "panelGreen";
|
||||
panelGreen.Size = new Size(35, 35);
|
||||
panelGreen.TabIndex = 1;
|
||||
//
|
||||
// panelRed
|
||||
//
|
||||
panelRed.AllowDrop = true;
|
||||
panelRed.BackColor = Color.Red;
|
||||
panelRed.Location = new Point(15, 26);
|
||||
panelRed.Name = "panelRed";
|
||||
panelRed.Size = new Size(35, 35);
|
||||
panelRed.TabIndex = 0;
|
||||
//
|
||||
// checkBoxFiveDoors
|
||||
//
|
||||
checkBoxFiveDoors.AutoSize = true;
|
||||
checkBoxFiveDoors.Location = new Point(24, 160);
|
||||
checkBoxFiveDoors.Name = "checkBoxFiveDoors";
|
||||
checkBoxFiveDoors.Size = new Size(93, 24);
|
||||
checkBoxFiveDoors.TabIndex = 7;
|
||||
checkBoxFiveDoors.Text = "5 дверей";
|
||||
checkBoxFiveDoors.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// checkBoxOnePart
|
||||
//
|
||||
checkBoxHatch.AutoSize = true;
|
||||
checkBoxHatch.Location = new Point(24, 118);
|
||||
checkBoxHatch.Name = "checkBoxOnePart";
|
||||
checkBoxHatch.Size = new Size(69, 24);
|
||||
checkBoxHatch.TabIndex = 6;
|
||||
checkBoxHatch.Text = "Люки";
|
||||
checkBoxHatch.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// numericUpDownWeight
|
||||
//
|
||||
numericUpDownWeight.Location = new Point(94, 78);
|
||||
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(106, 27);
|
||||
numericUpDownWeight.TabIndex = 5;
|
||||
numericUpDownWeight.Value = new decimal(new int[] { 100, 0, 0, 0 });
|
||||
//
|
||||
// labelWeight
|
||||
//
|
||||
labelWeight.AutoSize = true;
|
||||
labelWeight.Location = new Point(12, 78);
|
||||
labelWeight.Name = "labelWeight";
|
||||
labelWeight.Size = new Size(36, 20);
|
||||
labelWeight.TabIndex = 4;
|
||||
labelWeight.Text = "Вес:";
|
||||
//
|
||||
// numericUpDownSpeed
|
||||
//
|
||||
numericUpDownSpeed.Location = new Point(94, 37);
|
||||
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(106, 27);
|
||||
numericUpDownSpeed.TabIndex = 3;
|
||||
numericUpDownSpeed.Value = new decimal(new int[] { 100, 0, 0, 0 });
|
||||
//
|
||||
// labelSpeed
|
||||
//
|
||||
labelSpeed.AutoSize = true;
|
||||
labelSpeed.Location = new Point(12, 37);
|
||||
labelSpeed.Name = "labelSpeed";
|
||||
labelSpeed.Size = new Size(76, 20);
|
||||
labelSpeed.TabIndex = 2;
|
||||
labelSpeed.Text = "Скорость:";
|
||||
//
|
||||
// labelModifiedObject
|
||||
//
|
||||
labelModifiedObject.AllowDrop = true;
|
||||
labelModifiedObject.BorderStyle = BorderStyle.FixedSingle;
|
||||
labelModifiedObject.Location = new Point(361, 176);
|
||||
labelModifiedObject.Name = "labelModifiedObject";
|
||||
labelModifiedObject.Size = new Size(122, 39);
|
||||
labelModifiedObject.TabIndex = 1;
|
||||
labelModifiedObject.Text = "Продвинутый";
|
||||
labelModifiedObject.TextAlign = ContentAlignment.MiddleCenter;
|
||||
labelModifiedObject.MouseDown += labelObject_MouseDown;
|
||||
//
|
||||
// labelSimpleObject
|
||||
//
|
||||
labelSimpleObject.AllowDrop = true;
|
||||
labelSimpleObject.BorderStyle = BorderStyle.FixedSingle;
|
||||
labelSimpleObject.Location = new Point(221, 176);
|
||||
labelSimpleObject.Name = "labelSimpleObject";
|
||||
labelSimpleObject.Size = new Size(122, 39);
|
||||
labelSimpleObject.TabIndex = 0;
|
||||
labelSimpleObject.Text = "Простой";
|
||||
labelSimpleObject.TextAlign = ContentAlignment.MiddleCenter;
|
||||
labelSimpleObject.MouseDown += labelObject_MouseDown;
|
||||
//
|
||||
// pictureBoxObject
|
||||
//
|
||||
pictureBoxObject.Location = new Point(16, 64);
|
||||
pictureBoxObject.Name = "pictureBoxObject";
|
||||
pictureBoxObject.Size = new Size(200, 100);
|
||||
pictureBoxObject.TabIndex = 1;
|
||||
pictureBoxObject.TabStop = false;
|
||||
//
|
||||
// buttonAdd
|
||||
//
|
||||
buttonAdd.Location = new Point(515, 186);
|
||||
buttonAdd.Name = "buttonAdd";
|
||||
buttonAdd.Size = new Size(94, 29);
|
||||
buttonAdd.TabIndex = 2;
|
||||
buttonAdd.Text = "Добавить";
|
||||
buttonAdd.UseVisualStyleBackColor = true;
|
||||
buttonAdd.Click += buttonAdd_Click;
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
buttonCancel.Location = new Point(621, 186);
|
||||
buttonCancel.Name = "buttonCancel";
|
||||
buttonCancel.Size = new Size(94, 29);
|
||||
buttonCancel.TabIndex = 3;
|
||||
buttonCancel.Text = "Отмена";
|
||||
buttonCancel.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// panelObject
|
||||
//
|
||||
panelObject.AllowDrop = true;
|
||||
panelObject.Controls.Add(labelAdditionalColor);
|
||||
panelObject.Controls.Add(labelBodyColor);
|
||||
panelObject.Controls.Add(pictureBoxObject);
|
||||
panelObject.Location = new Point(499, 0);
|
||||
panelObject.Name = "panelObject";
|
||||
panelObject.Size = new Size(226, 178);
|
||||
panelObject.TabIndex = 4;
|
||||
panelObject.DragDrop += panelObject_DragDrop;
|
||||
panelObject.DragEnter += panelObject_DragEnter;
|
||||
//
|
||||
// labelAdditionalColor
|
||||
//
|
||||
labelAdditionalColor.AllowDrop = true;
|
||||
labelAdditionalColor.BorderStyle = BorderStyle.FixedSingle;
|
||||
labelAdditionalColor.Location = new Point(128, 26);
|
||||
labelAdditionalColor.Name = "labelAdditionalColor";
|
||||
labelAdditionalColor.Size = new Size(88, 25);
|
||||
labelAdditionalColor.TabIndex = 3;
|
||||
labelAdditionalColor.Text = "Доп. цвет";
|
||||
labelAdditionalColor.TextAlign = ContentAlignment.MiddleCenter;
|
||||
labelAdditionalColor.DragDrop += labelAdditionalColor_DragDrop;
|
||||
labelAdditionalColor.DragEnter += labelColor_DragEnter;
|
||||
//
|
||||
// labelBodyColor
|
||||
//
|
||||
labelBodyColor.AllowDrop = true;
|
||||
labelBodyColor.BorderStyle = BorderStyle.FixedSingle;
|
||||
labelBodyColor.Location = new Point(16, 26);
|
||||
labelBodyColor.Name = "labelBodyColor";
|
||||
labelBodyColor.Size = new Size(94, 25);
|
||||
labelBodyColor.TabIndex = 2;
|
||||
labelBodyColor.Text = "Цвет";
|
||||
labelBodyColor.TextAlign = ContentAlignment.MiddleCenter;
|
||||
labelBodyColor.DragDrop += labelBodyColor_DragDrop;
|
||||
labelBodyColor.DragEnter += labelColor_DragEnter;
|
||||
//
|
||||
// FormBusConfig
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(737, 229);
|
||||
Controls.Add(panelObject);
|
||||
Controls.Add(buttonCancel);
|
||||
Controls.Add(buttonAdd);
|
||||
Controls.Add(groupBoxConfig);
|
||||
Name = "FormBusConfig";
|
||||
StartPosition = FormStartPosition.CenterScreen;
|
||||
Text = "Создание объекта";
|
||||
groupBoxConfig.ResumeLayout(false);
|
||||
groupBoxConfig.PerformLayout();
|
||||
groupBoxColor.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownWeight).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownSpeed).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBoxObject).EndInit();
|
||||
panelObject.ResumeLayout(false);
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private GroupBox groupBoxConfig;
|
||||
private Label labelSimpleObject;
|
||||
private Label labelModifiedObject;
|
||||
private Label labelSpeed;
|
||||
private Label labelWeight;
|
||||
private NumericUpDown numericUpDownSpeed;
|
||||
private NumericUpDown numericUpDownWeight;
|
||||
private CheckBox checkBoxHatch;
|
||||
private CheckBox checkBoxFiveDoors;
|
||||
private GroupBox groupBoxColor;
|
||||
private Panel panelRed;
|
||||
private Panel panelPurple;
|
||||
private Panel panelBlack;
|
||||
private Panel panelGray;
|
||||
private Panel panelWhite;
|
||||
private Panel panelYellow;
|
||||
private Panel panelBlue;
|
||||
private Panel panelGreen;
|
||||
private PictureBox pictureBoxObject;
|
||||
private Button buttonAdd;
|
||||
private Button buttonCancel;
|
||||
private Panel panelObject;
|
||||
private Label labelBodyColor;
|
||||
private Label labelAdditionalColor;
|
||||
}
|
||||
}
|
184
AccordionBus/AccordionBus/FormBusConfig.cs
Normal file
184
AccordionBus/AccordionBus/FormBusConfig.cs
Normal file
@ -0,0 +1,184 @@
|
||||
using AccordionBus.Drawnings;
|
||||
using AccordionBus.Entities;
|
||||
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;
|
||||
|
||||
namespace AccordionBus
|
||||
{
|
||||
public partial class FormBusConfig : Form
|
||||
{
|
||||
private DrawningBus _bus;
|
||||
|
||||
private event Action<DrawningBus> _busDelegate;
|
||||
|
||||
public FormBusConfig()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
panelRed.MouseDown += Panel_MouseDown;
|
||||
panelBlue.MouseDown += Panel_MouseDown;
|
||||
panelGreen.MouseDown += Panel_MouseDown;
|
||||
panelYellow.MouseDown += Panel_MouseDown;
|
||||
panelGray.MouseDown += Panel_MouseDown;
|
||||
panelBlack.MouseDown += Panel_MouseDown;
|
||||
panelWhite.MouseDown += Panel_MouseDown;
|
||||
panelPurple.MouseDown += Panel_MouseDown;
|
||||
|
||||
buttonCancel.Click += (sender, e) => Close();
|
||||
}
|
||||
|
||||
public void AddEvent(Action<DrawningBus> busDelegate)
|
||||
{
|
||||
_busDelegate += busDelegate;
|
||||
}
|
||||
|
||||
private void Panel_MouseDown(object? sender, MouseEventArgs e)
|
||||
{
|
||||
Panel panel = sender as Panel;
|
||||
panel.DoDragDrop(panel.Name, DragDropEffects.Copy);
|
||||
}
|
||||
|
||||
private void DrawObject()
|
||||
{
|
||||
if (_bus == null) return;
|
||||
|
||||
Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height);
|
||||
Graphics gr = Graphics.FromImage(bmp);
|
||||
_bus.SetPictureSize(pictureBoxObject.Width, pictureBoxObject.Height);
|
||||
_bus.SetPosition(5, 5);
|
||||
_bus.DrawTransport(gr);
|
||||
pictureBoxObject.Image = bmp;
|
||||
}
|
||||
|
||||
private void labelObject_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
Label label = sender as Label;
|
||||
label.DoDragDrop(label.Name, 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)
|
||||
{
|
||||
switch (e.Data?.GetData(DataFormats.Text)?.ToString())
|
||||
{
|
||||
case "labelSimpleObject":
|
||||
_bus = new DrawningBus((int)numericUpDownSpeed.Value, (double)numericUpDownWeight.Value, Color.White);
|
||||
break;
|
||||
case "labelModifiedObject":
|
||||
_bus = new DrawningAccordionBus((int)numericUpDownSpeed.Value, (double)numericUpDownWeight.Value, Color.White,
|
||||
Color.Black, checkBoxHatch.Checked, checkBoxFiveDoors.Checked);
|
||||
break;
|
||||
}
|
||||
|
||||
DrawObject();
|
||||
}
|
||||
|
||||
private void labelColor_DragEnter(object sender, DragEventArgs e)
|
||||
{
|
||||
if (e.Data?.GetDataPresent(DataFormats.Text) ?? false)
|
||||
{
|
||||
e.Effect = DragDropEffects.Copy;
|
||||
}
|
||||
else
|
||||
{
|
||||
e.Effect = DragDropEffects.None;
|
||||
}
|
||||
}
|
||||
|
||||
private void labelBodyColor_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
switch (e.Data?.GetData(DataFormats.Text)?.ToString())
|
||||
{
|
||||
case "panelRed":
|
||||
_bus.EntityBus.SetBodyColor(Color.Red);
|
||||
break;
|
||||
case "panelBlue":
|
||||
_bus.EntityBus.SetBodyColor(Color.Blue);
|
||||
break;
|
||||
case "panelGreen":
|
||||
_bus.EntityBus.SetBodyColor(Color.Green);
|
||||
break;
|
||||
case "panelYellow":
|
||||
_bus.EntityBus.SetBodyColor(Color.Yellow);
|
||||
break;
|
||||
case "panelWhite":
|
||||
_bus.EntityBus.SetBodyColor(Color.White);
|
||||
break;
|
||||
case "panelGray":
|
||||
_bus.EntityBus.SetBodyColor(Color.Gray);
|
||||
break;
|
||||
case "panelBlack":
|
||||
_bus.EntityBus.SetBodyColor(Color.Black);
|
||||
break;
|
||||
case "panelPurple":
|
||||
_bus.EntityBus.SetBodyColor(Color.Purple);
|
||||
break;
|
||||
}
|
||||
|
||||
DrawObject();
|
||||
}
|
||||
|
||||
private void labelAdditionalColor_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
if (_bus.EntityBus is EntityAccordionBus entityAccordionBus)
|
||||
{
|
||||
switch (e.Data?.GetData(DataFormats.Text)?.ToString())
|
||||
{
|
||||
case "panelRed":
|
||||
entityAccordionBus.SetAdditionalColor(Color.Red);
|
||||
break;
|
||||
case "panelBlue":
|
||||
entityAccordionBus.SetAdditionalColor(Color.Blue);
|
||||
break;
|
||||
case "panelGreen":
|
||||
entityAccordionBus.SetAdditionalColor(Color.Green);
|
||||
break;
|
||||
case "panelYellow":
|
||||
entityAccordionBus.SetAdditionalColor(Color.Yellow);
|
||||
break;
|
||||
case "panelWhite":
|
||||
entityAccordionBus.SetAdditionalColor(Color.White);
|
||||
break;
|
||||
case "panelGray":
|
||||
entityAccordionBus.SetAdditionalColor(Color.Gray);
|
||||
break;
|
||||
case "panelBlack":
|
||||
entityAccordionBus.SetAdditionalColor(Color.Black);
|
||||
break;
|
||||
case "panelPurple":
|
||||
entityAccordionBus.SetAdditionalColor(Color.Purple);
|
||||
break;
|
||||
}
|
||||
|
||||
DrawObject() ;
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_bus != null)
|
||||
{
|
||||
_busDelegate.Invoke(_bus);
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
120
AccordionBus/AccordionBus/FormBusConfig.resx
Normal file
120
AccordionBus/AccordionBus/FormBusConfig.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<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