Compare commits
23 Commits
21e126ef09
...
c4ee67ab56
Author | SHA1 | Date | |
---|---|---|---|
|
c4ee67ab56 | ||
|
c4546990f8 | ||
|
8d7324d52e | ||
|
f51c2c348f | ||
|
08c1734614 | ||
|
ad565c92f3 | ||
|
f6f705c9f2 | ||
|
7f4d7dfdce | ||
04c45def82 | |||
592fd5bea5 | |||
|
21f4acf2d5 | ||
|
0a9f5bcbb6 | ||
|
052b9929c1 | ||
|
4de1bca002 | ||
|
f57496c459 | ||
ff1e1066b6 | |||
5f5f61f51b | |||
|
50146d6d1b | ||
|
92f30977af | ||
|
feea0da22b | ||
4eeaacde4b | |||
|
681e60fbd6 | ||
dc01587054 |
@ -1,5 +1,4 @@
|
|||||||
using HoistingCrane.Drawning;
|
using HoistingCrane.Drawning;
|
||||||
using System;
|
|
||||||
namespace HoistingCrane.CollectionGenericObjects
|
namespace HoistingCrane.CollectionGenericObjects
|
||||||
{
|
{
|
||||||
public abstract class AbstractCompany
|
public abstract class AbstractCompany
|
||||||
@ -48,7 +47,7 @@ namespace HoistingCrane.CollectionGenericObjects
|
|||||||
}
|
}
|
||||||
public static DrawningTrackedVehicle operator -(AbstractCompany company, int position)
|
public static DrawningTrackedVehicle operator -(AbstractCompany company, int position)
|
||||||
{
|
{
|
||||||
return company.arr?.Remove(position) ?? null;
|
return company.arr?.Remove(position);
|
||||||
}
|
}
|
||||||
|
|
||||||
public DrawningTrackedVehicle? GetRandomObject()
|
public DrawningTrackedVehicle? GetRandomObject()
|
||||||
@ -75,7 +74,6 @@ namespace HoistingCrane.CollectionGenericObjects
|
|||||||
}
|
}
|
||||||
return bitmap;
|
return bitmap;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Вывод заднего фона
|
/// Вывод заднего фона
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -1,7 +1,4 @@
|
|||||||
using HoistingCrane.Drawning;
|
using HoistingCrane.Drawning;
|
||||||
using System;
|
|
||||||
using System.Collections.Specialized;
|
|
||||||
|
|
||||||
namespace HoistingCrane.CollectionGenericObjects
|
namespace HoistingCrane.CollectionGenericObjects
|
||||||
{
|
{
|
||||||
public class Garage : AbstractCompany
|
public class Garage : AbstractCompany
|
||||||
@ -23,7 +20,6 @@ namespace HoistingCrane.CollectionGenericObjects
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void SetObjectsPosition()
|
protected override void SetObjectsPosition()
|
||||||
{
|
{
|
||||||
int countWidth = pictureWidth / _placeSizeWidth;
|
int countWidth = pictureWidth / _placeSizeWidth;
|
||||||
@ -39,7 +35,7 @@ namespace HoistingCrane.CollectionGenericObjects
|
|||||||
arr?.Get(i)?.SetPictureSize(pictureWidth, pictureHeight);
|
arr?.Get(i)?.SetPictureSize(pictureWidth, pictureHeight);
|
||||||
arr?.Get(i)?.SetPosition(_placeSizeWidth * currentPosWidth + 25, _placeSizeHeight * currentPosHeight + 15);
|
arr?.Get(i)?.SetPosition(_placeSizeWidth * currentPosWidth + 25, _placeSizeHeight * currentPosHeight + 15);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentPosWidth > 0)
|
if (currentPosWidth > 0)
|
||||||
currentPosWidth--;
|
currentPosWidth--;
|
||||||
else
|
else
|
||||||
@ -54,5 +50,6 @@ namespace HoistingCrane.CollectionGenericObjects
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
using System;
|
namespace HoistingCrane.CollectionGenericObjects
|
||||||
namespace HoistingCrane.CollectionGenericObjects
|
|
||||||
{
|
{
|
||||||
public interface ICollectionGenericObjects<T>
|
public interface ICollectionGenericObjects<T>
|
||||||
where T: class
|
where T: class
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.CodeDom.Compiler;
|
using System.CodeDom.Compiler;
|
||||||
|
using System.Windows.Forms.VisualStyles;
|
||||||
|
|
||||||
namespace HoistingCrane.CollectionGenericObjects
|
namespace HoistingCrane.CollectionGenericObjects
|
||||||
{
|
{
|
||||||
@ -44,19 +45,14 @@ namespace HoistingCrane.CollectionGenericObjects
|
|||||||
|
|
||||||
public T? Get(int position)
|
public T? Get(int position)
|
||||||
{
|
{
|
||||||
// TODO проверка позиции
|
|
||||||
if (position >= Count || position < 0) return null;
|
if (position >= Count || position < 0) return null;
|
||||||
return list[position];
|
return list[position];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public int Insert(T obj)
|
public int Insert(T obj)
|
||||||
{
|
{
|
||||||
// TODO проверка, что не превышено максимальное количество элементов
|
if (Count == _maxCount)
|
||||||
// TODO вставка в конец набора
|
{
|
||||||
if (Count == _maxCount)
|
return -1;
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
list.Add(obj);
|
list.Add(obj);
|
||||||
return Count;
|
return Count;
|
||||||
@ -64,21 +60,16 @@ namespace HoistingCrane.CollectionGenericObjects
|
|||||||
|
|
||||||
public int Insert(T obj, int position)
|
public int Insert(T obj, int position)
|
||||||
{
|
{
|
||||||
// TODO проверка, что не превышено максимальное количество элементов
|
|
||||||
// TODO проверка позиции
|
|
||||||
// TODO вставка по позиции
|
|
||||||
if (position < 0 || position >= Count || Count == _maxCount)
|
if (position < 0 || position >= Count || Count == _maxCount)
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
list.Insert(position, obj);
|
list.Insert(position, obj);
|
||||||
return position;
|
return position;
|
||||||
}
|
}
|
||||||
public T? Remove(int position)
|
public T? Remove(int position)
|
||||||
{
|
{
|
||||||
// TODO проверка позиции
|
if(position >= 0 && position < list.Count)
|
||||||
// TODO удаление объекта из списка
|
|
||||||
if (position >= 0 && position < list.Count)
|
|
||||||
{
|
{
|
||||||
T? temp = list[position];
|
T? temp = list[position];
|
||||||
list.RemoveAt(position);
|
list.RemoveAt(position);
|
||||||
|
@ -11,7 +11,7 @@ namespace HoistingCrane.CollectionGenericObjects
|
|||||||
}
|
}
|
||||||
public int Count
|
public int Count
|
||||||
{
|
{
|
||||||
get { return arr.Length; }
|
get { return arr.Length; }
|
||||||
}
|
}
|
||||||
public int MaxCount
|
public int MaxCount
|
||||||
{
|
{
|
||||||
@ -61,28 +61,33 @@ namespace HoistingCrane.CollectionGenericObjects
|
|||||||
|
|
||||||
public int Insert(T obj, int position)
|
public int Insert(T obj, int position)
|
||||||
{
|
{
|
||||||
//todo Проверка позиции
|
|
||||||
if (position < 0 || position > Count)
|
if (position < 0 || position >= Count)
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (arr[position] == null)
|
int copyPos = position - 1;
|
||||||
|
|
||||||
|
while (position < Count)
|
||||||
{
|
{
|
||||||
arr[position] = obj;
|
if (arr[position] == null)
|
||||||
return position;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (Insert(obj, position + 1) != -1)
|
|
||||||
{
|
|
||||||
return position;
|
|
||||||
}
|
|
||||||
if (Insert(obj, position - 1) != -1)
|
|
||||||
{
|
{
|
||||||
|
arr[position] = obj;
|
||||||
return position;
|
return position;
|
||||||
}
|
}
|
||||||
|
position++;
|
||||||
}
|
}
|
||||||
|
while (copyPos > 0)
|
||||||
|
{
|
||||||
|
if (arr[copyPos] == null)
|
||||||
|
{
|
||||||
|
arr[copyPos] = obj;
|
||||||
|
return copyPos;
|
||||||
|
}
|
||||||
|
copyPos--;
|
||||||
|
}
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,17 +41,12 @@ namespace HoistingCrane.CollectionGenericObjects
|
|||||||
/// <param name="collectionType">тип коллекции</param>
|
/// <param name="collectionType">тип коллекции</param>
|
||||||
public void AddCollection(string name, CollectionType collectionType)
|
public void AddCollection(string name, CollectionType collectionType)
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrEmpty(name) && !Keys.Contains(name))
|
if (dict.ContainsKey(name)) return;
|
||||||
{
|
if (collectionType == CollectionType.None) return;
|
||||||
if(collectionType == CollectionType.Massive)
|
else if (collectionType == CollectionType.Massive)
|
||||||
{
|
dict[name] = new MassivGenericObjects<T>();
|
||||||
dict.Add(name, new MassivGenericObjects<T> ());
|
else if (collectionType == CollectionType.List)
|
||||||
}
|
dict[name] = new ListGenericObjects<T>();
|
||||||
if(collectionType == CollectionType.List)
|
|
||||||
{
|
|
||||||
dict.Add(name, new ListGenericObjects<T> ());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Удаление коллекции
|
/// Удаление коллекции
|
||||||
@ -59,8 +54,10 @@ namespace HoistingCrane.CollectionGenericObjects
|
|||||||
/// <param name="name">Название коллекции</param>
|
/// <param name="name">Название коллекции</param>
|
||||||
public void DelCollection(string name)
|
public void DelCollection(string name)
|
||||||
{
|
{
|
||||||
if (dict.ContainsKey(name))
|
if (Keys.Contains(name))
|
||||||
|
{
|
||||||
dict.Remove(name);
|
dict.Remove(name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Доступ к коллекции
|
/// Доступ к коллекции
|
||||||
@ -71,8 +68,9 @@ namespace HoistingCrane.CollectionGenericObjects
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (name == null || !dict.ContainsKey(name)) { return null; }
|
if (dict.ContainsKey(name))
|
||||||
return dict[name];
|
return dict[name];
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -197,5 +195,6 @@ namespace HoistingCrane.CollectionGenericObjects
|
|||||||
_ => null,
|
_ => null,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -247,4 +247,4 @@ namespace HoistingCrane
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -45,7 +45,6 @@ namespace HoistingCrane
|
|||||||
{
|
{
|
||||||
_carDelegate += carDelegate;
|
_carDelegate += carDelegate;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Отрисовка объекта
|
/// Отрисовка объекта
|
||||||
@ -105,6 +104,7 @@ namespace HoistingCrane
|
|||||||
{
|
{
|
||||||
(sender as Panel)?.DoDragDrop((sender as Panel)?.BackColor ?? Color.White, DragDropEffects.Move | DragDropEffects.Copy);
|
(sender as Panel)?.DoDragDrop((sender as Panel)?.BackColor ?? Color.White, DragDropEffects.Move | DragDropEffects.Copy);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Передача объекта
|
/// Передача объекта
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -118,6 +118,7 @@ namespace HoistingCrane
|
|||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Прорисовка основным цветом
|
/// Прорисовка основным цветом
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -47,7 +47,6 @@
|
|||||||
FieldWidth = width;
|
FieldWidth = width;
|
||||||
FieldHeight = height;
|
FieldHeight = height;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Шаг перемещения
|
/// Шаг перемещения
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -119,7 +118,6 @@
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
protected abstract bool IsTargetDestination();
|
protected abstract bool IsTargetDestination();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Попытка перемещения в требуемом направлении
|
/// Попытка перемещения в требуемом направлении
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
namespace HoistingCrane.MovementStrategy
|
using System.Configuration;
|
||||||
|
|
||||||
|
namespace HoistingCrane.MovementStrategy
|
||||||
{
|
{
|
||||||
public class MoveToBorder : AbstractStrategy
|
public class MoveToBorder : AbstractStrategy
|
||||||
{
|
{
|
||||||
@ -12,7 +14,6 @@
|
|||||||
|
|
||||||
return objParams.RightBorder + GetStep() >= FieldWidth && objParams.DownBorder + GetStep() >= FieldHeight;
|
return objParams.RightBorder + GetStep() >= FieldWidth && objParams.DownBorder + GetStep() >= FieldHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void MoveToTarget()
|
protected override void MoveToTarget()
|
||||||
{
|
{
|
||||||
ObjectParameters? objParams = GetObjectParameters;
|
ObjectParameters? objParams = GetObjectParameters;
|
||||||
|
Loading…
Reference in New Issue
Block a user