update
This commit is contained in:
47
TimetableDesigner.Core/BaseGroup.cs
Normal file
47
TimetableDesigner.Core/BaseGroup.cs
Normal file
@@ -0,0 +1,47 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace TimetableDesigner.Core
|
||||
{
|
||||
public abstract class BaseGroup : IUnit
|
||||
{
|
||||
#region FIELDS
|
||||
|
||||
private string _name;
|
||||
private string _shortName;
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region PROPERTIES
|
||||
|
||||
public string Name
|
||||
{
|
||||
get => _name;
|
||||
set => _name = value;
|
||||
}
|
||||
public string ShortName
|
||||
{
|
||||
get => _shortName;
|
||||
set => _shortName = value;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region CONSTRUCTORS
|
||||
|
||||
public BaseGroup()
|
||||
{
|
||||
_name = string.Empty;
|
||||
_shortName = string.Empty;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -6,14 +6,60 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace TimetableDesigner.Core
|
||||
{
|
||||
[Serializable]
|
||||
public class Class
|
||||
{
|
||||
#region FIELDS
|
||||
|
||||
private string _name;
|
||||
private Teacher? _teacher;
|
||||
private BaseGroup? _group;
|
||||
private Classroom? _classroom;
|
||||
private TimetableDay? _day;
|
||||
private TimetableSpan? _slot;
|
||||
private byte[] _color;
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region PROPERTIES
|
||||
|
||||
public string Name { get; set; }
|
||||
public Teacher? Teacher { get; set; }
|
||||
public IGroup? Group { get; set; }
|
||||
public Classroom? Classroom { get; set; }
|
||||
public string Name
|
||||
{
|
||||
get => _name;
|
||||
set => _name = value;
|
||||
}
|
||||
public Teacher? Teacher
|
||||
{
|
||||
get => _teacher;
|
||||
set => _teacher = value;
|
||||
}
|
||||
public BaseGroup? Group
|
||||
{
|
||||
get => _group;
|
||||
set => _group = value;
|
||||
}
|
||||
public Classroom? Classroom
|
||||
{
|
||||
get => _classroom;
|
||||
set => _classroom = value;
|
||||
}
|
||||
public TimetableDay? Day
|
||||
{
|
||||
get => _day;
|
||||
set => _day = value;
|
||||
}
|
||||
public TimetableSpan? Slot
|
||||
{
|
||||
get => _slot;
|
||||
set => _slot = value;
|
||||
}
|
||||
public byte[] Color
|
||||
{
|
||||
get => _color;
|
||||
set => _color = value;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -23,10 +69,13 @@ namespace TimetableDesigner.Core
|
||||
|
||||
public Class()
|
||||
{
|
||||
Name = string.Empty;
|
||||
Teacher = null;
|
||||
Group = null;
|
||||
Classroom = null;
|
||||
_name = string.Empty;
|
||||
_teacher = null;
|
||||
_group = null;
|
||||
_classroom = null;
|
||||
_day = null;
|
||||
_slot = null;
|
||||
_color = new byte[3] { 0xFA, 0x5A, 0x5A };
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -7,14 +7,48 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace TimetableDesigner.Core
|
||||
{
|
||||
public class Classroom
|
||||
[Serializable]
|
||||
public class Classroom : IUnit
|
||||
{
|
||||
#region FIELDS
|
||||
|
||||
private string _name;
|
||||
private string _shortName;
|
||||
private string _description;
|
||||
private bool _isCapacityLimited;
|
||||
private uint _capacity;
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region PROPERTIES
|
||||
|
||||
public string Name { get; set; }
|
||||
public string Description { get; set; }
|
||||
public bool IsCapacityLimited { get; set; }
|
||||
public uint Capacity { get; set; }
|
||||
public string Name
|
||||
{
|
||||
get => _name;
|
||||
set => _name = value;
|
||||
}
|
||||
public string ShortName
|
||||
{
|
||||
get => _shortName;
|
||||
set => _shortName = value;
|
||||
}
|
||||
public string Description
|
||||
{
|
||||
get => _description;
|
||||
set => _description = value;
|
||||
}
|
||||
public bool IsCapacityLimited
|
||||
{
|
||||
get => _isCapacityLimited;
|
||||
set => _isCapacityLimited = value;
|
||||
}
|
||||
public uint Capacity
|
||||
{
|
||||
get => _capacity;
|
||||
set => _capacity = value;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -24,10 +58,11 @@ namespace TimetableDesigner.Core
|
||||
|
||||
public Classroom()
|
||||
{
|
||||
Name = string.Empty;
|
||||
Description = string.Empty;
|
||||
IsCapacityLimited = false;
|
||||
Capacity = 1;
|
||||
_name = string.Empty;
|
||||
_shortName = string.Empty;
|
||||
_description = string.Empty;
|
||||
_isCapacityLimited = false;
|
||||
_capacity = 1;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -6,13 +6,26 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace TimetableDesigner.Core
|
||||
{
|
||||
public class Group : IGroup
|
||||
[Serializable]
|
||||
public class Group : BaseGroup
|
||||
{
|
||||
#region FIELDS
|
||||
|
||||
private string _description;
|
||||
private HashSet<Subgroup> _assignedSubgroups;
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region PROPERTIES
|
||||
|
||||
public string Name { get; set; }
|
||||
public string Description { get; set; }
|
||||
public ICollection<Subgroup> AssignedSubgroups { get; set; }
|
||||
public string Description
|
||||
{
|
||||
get => _description;
|
||||
set => _description = value;
|
||||
}
|
||||
public ICollection<Subgroup> AssignedSubgroups => _assignedSubgroups;
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -20,11 +33,10 @@ namespace TimetableDesigner.Core
|
||||
|
||||
#region CONSTRUCTORS
|
||||
|
||||
public Group()
|
||||
public Group() : base()
|
||||
{
|
||||
Name = string.Empty;
|
||||
Description = string.Empty;
|
||||
AssignedSubgroups = new HashSet<Subgroup>();
|
||||
_description = string.Empty;
|
||||
_assignedSubgroups = new HashSet<Subgroup>();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -6,7 +6,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace TimetableDesigner.Core
|
||||
{
|
||||
public interface IGroup
|
||||
public interface IUnit
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
@@ -9,17 +9,47 @@ namespace TimetableDesigner.Core
|
||||
[Serializable]
|
||||
public class Project
|
||||
{
|
||||
#region FIELDS
|
||||
|
||||
private Guid _guid;
|
||||
private string _name;
|
||||
private string _author;
|
||||
private string _description;
|
||||
private TimetableTemplate _timetableTemplate;
|
||||
private HashSet<Classroom> _classrooms;
|
||||
private HashSet<Teacher> _teachers;
|
||||
private HashSet<Group> _groups;
|
||||
private HashSet<Subgroup> _subgroups;
|
||||
private HashSet<Class> _classes;
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region PROPERTIES
|
||||
|
||||
public string Name { get; set; }
|
||||
public string Author { get; set; }
|
||||
public string Description { get; set; }
|
||||
public TimetableTemplate TimetableTemplate { get; set; }
|
||||
public ICollection<Classroom> Classrooms { get; set; }
|
||||
public ICollection<Teacher> Teachers { get; set; }
|
||||
public ICollection<Group> Groups { get; set; }
|
||||
public ICollection<Subgroup> Subgroups { get; set; }
|
||||
public ICollection<Class> Classes { get; set; }
|
||||
public Guid Guid => _guid;
|
||||
public string Name
|
||||
{
|
||||
get => _name;
|
||||
set => _name = value;
|
||||
}
|
||||
public string Author
|
||||
{
|
||||
get => _author;
|
||||
set => _author = value;
|
||||
}
|
||||
public string Description
|
||||
{
|
||||
get => _description;
|
||||
set => _description = value;
|
||||
}
|
||||
public TimetableTemplate TimetableTemplate => _timetableTemplate;
|
||||
public ICollection<Classroom> Classrooms => _classrooms;
|
||||
public ICollection<Teacher> Teachers => _teachers;
|
||||
public ICollection<Group> Groups => _groups;
|
||||
public ICollection<Subgroup> Subgroups => _subgroups;
|
||||
public ICollection<Class> Classes => _classes;
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -29,14 +59,16 @@ namespace TimetableDesigner.Core
|
||||
|
||||
public Project()
|
||||
{
|
||||
Name = string.Empty;
|
||||
Author = string.Empty;
|
||||
Description = string.Empty;
|
||||
TimetableTemplate = new TimetableTemplate();
|
||||
Classrooms = new HashSet<Classroom>();
|
||||
Teachers = new HashSet<Teacher>();
|
||||
Groups = new HashSet<Group>();
|
||||
Subgroups = new HashSet<Subgroup>();
|
||||
_guid = Guid.NewGuid();
|
||||
_name = string.Empty;
|
||||
_author = string.Empty;
|
||||
_description = string.Empty;
|
||||
_timetableTemplate = new TimetableTemplate();
|
||||
_classrooms = new HashSet<Classroom>();
|
||||
_teachers = new HashSet<Teacher>();
|
||||
_groups = new HashSet<Group>();
|
||||
_subgroups = new HashSet<Subgroup>();
|
||||
_classes = new HashSet<Class>();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -6,22 +6,13 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace TimetableDesigner.Core
|
||||
{
|
||||
public class Subgroup : IGroup
|
||||
[Serializable]
|
||||
public class Subgroup : BaseGroup
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
public string Name { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region CONSTRUCTORS
|
||||
|
||||
public Subgroup()
|
||||
{
|
||||
Name = string.Empty;
|
||||
}
|
||||
public Subgroup() : base()
|
||||
{ }
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
@@ -3,16 +3,42 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using TimetableDesigner.Customs;
|
||||
|
||||
namespace TimetableDesigner.Core
|
||||
{
|
||||
public class Teacher
|
||||
[Serializable]
|
||||
public class Teacher : IUnit
|
||||
{
|
||||
#region FIELDS
|
||||
|
||||
private string _name;
|
||||
private string _shortName;
|
||||
private string _description;
|
||||
private JsonSerializableDictionary<TimetableDay, TimetableSpanCollection> _availabilityHours;
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region PROPERTIES
|
||||
|
||||
public string Name { get; set; }
|
||||
public string Description { get; set; }
|
||||
public IDictionary<TimetableDay, TimetableSpanCollection> AvailabilityHours { get; set; }
|
||||
public string Name
|
||||
{
|
||||
get => _name;
|
||||
set => _name = value;
|
||||
}
|
||||
public string ShortName
|
||||
{
|
||||
get => _shortName;
|
||||
set => _shortName = value;
|
||||
}
|
||||
public string Description
|
||||
{
|
||||
get => _description;
|
||||
set => _description = value;
|
||||
}
|
||||
public IDictionary<TimetableDay, TimetableSpanCollection> AvailabilityHours => _availabilityHours;
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -22,9 +48,10 @@ namespace TimetableDesigner.Core
|
||||
|
||||
public Teacher()
|
||||
{
|
||||
Name = string.Empty;
|
||||
Description = string.Empty;
|
||||
AvailabilityHours = new Dictionary<TimetableDay, TimetableSpanCollection>();
|
||||
_name = string.Empty;
|
||||
_shortName = string.Empty;
|
||||
_description = string.Empty;
|
||||
_availabilityHours = new JsonSerializableDictionary<TimetableDay, TimetableSpanCollection>();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -9,9 +9,21 @@ namespace TimetableDesigner.Core
|
||||
[Serializable]
|
||||
public class TimetableDay
|
||||
{
|
||||
#region FIELDS
|
||||
|
||||
private string _name;
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region PROPERTIES
|
||||
|
||||
public string Name { get; set; }
|
||||
public string Name
|
||||
{
|
||||
get => _name;
|
||||
set => _name = value;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -20,8 +32,8 @@ namespace TimetableDesigner.Core
|
||||
#region CONSTRUCTORS
|
||||
|
||||
public TimetableDay(string name)
|
||||
{
|
||||
Name = name;
|
||||
{
|
||||
_name = name;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -6,4 +6,8 @@
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\TimetableDesigner.Customs\TimetableDesigner.Customs.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -1,14 +1,24 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace TimetableDesigner.Core
|
||||
{
|
||||
[Serializable]
|
||||
public class TimetableSpan
|
||||
{
|
||||
#region FIELDS
|
||||
|
||||
private TimeOnly _from;
|
||||
private TimeOnly _to;
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region PROPERTIES
|
||||
|
||||
public TimeOnly From { get; private set; }
|
||||
public TimeOnly To { get; private set; }
|
||||
public TimeOnly From => _from;
|
||||
public TimeOnly To => _to;
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -20,11 +30,11 @@ namespace TimetableDesigner.Core
|
||||
{
|
||||
if (to <= from)
|
||||
{
|
||||
throw new ArgumentException("\"to\" cannot be less or equal to \"from\"");
|
||||
throw new ArgumentException("Ending value (\"to\") of TimetableSpan have to be greater than starting value (\"from\")");
|
||||
}
|
||||
|
||||
From = from;
|
||||
To = to;
|
||||
_from = from;
|
||||
_to = to;
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -33,27 +43,33 @@ namespace TimetableDesigner.Core
|
||||
|
||||
#region PUBLIC METHODS
|
||||
|
||||
internal TimetableSpanCollision CheckCollision(TimetableSpan slot)
|
||||
public override bool Equals(object? obj) => obj is TimetableSpan slot && From == slot.From && To == slot.To;
|
||||
|
||||
public override int GetHashCode() => HashCode.Combine(From, To);
|
||||
|
||||
public override string? ToString() => $"{From} - {To}";
|
||||
|
||||
public TimetableSpanCollision CheckCollision(TimetableSpan slot)
|
||||
{
|
||||
if (slot.To <= this.From)
|
||||
{
|
||||
return TimetableSpanCollision.CheckedSlotBefore;
|
||||
}
|
||||
else if (this.To <= slot.From)
|
||||
else if (this.To <= slot.From)
|
||||
{
|
||||
return TimetableSpanCollision.CheckedSlotAfter;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.From < slot.From && slot.To < this.To)
|
||||
if (this.From <= slot.From && slot.To <= this.To)
|
||||
{
|
||||
return TimetableSpanCollision.CheckedSlotIn;
|
||||
}
|
||||
else if (this.From < slot.From && slot.From < this.To && this.To < slot.To)
|
||||
else if (this.From < slot.From && slot.From < this.To && this.To <= slot.To)
|
||||
{
|
||||
return TimetableSpanCollision.CheckedSlotFromIn;
|
||||
}
|
||||
else if (slot.From < this.From && this.From < slot.To && slot.To < this.To)
|
||||
else if (slot.From < this.From && this.From < slot.To && slot.To <= this.To)
|
||||
{
|
||||
return TimetableSpanCollision.CheckedSlotToIn;
|
||||
}
|
||||
@@ -64,12 +80,6 @@ namespace TimetableDesigner.Core
|
||||
}
|
||||
}
|
||||
|
||||
public override bool Equals(object? obj) => obj is TimetableSpan slot && From == slot.From && To == slot.To;
|
||||
|
||||
public override int GetHashCode() => HashCode.Combine(From, To);
|
||||
|
||||
public override string? ToString() => $"{From}-{To}";
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,11 +7,12 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace TimetableDesigner.Core
|
||||
{
|
||||
[Serializable]
|
||||
public class TimetableSpanCollection : ICollection<TimetableSpan>
|
||||
{
|
||||
#region FIELDS
|
||||
|
||||
private IList<TimetableSpan> _list;
|
||||
private List<TimetableSpan> _list;
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -20,7 +21,7 @@ namespace TimetableDesigner.Core
|
||||
#region PROPERTIES
|
||||
|
||||
public int Count => _list.Count;
|
||||
public bool IsReadOnly => _list.IsReadOnly;
|
||||
public bool IsReadOnly => ((ICollection<TimetableSpan>)_list).IsReadOnly;
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace TimetableDesigner.Core
|
||||
{
|
||||
internal enum TimetableSpanCollision
|
||||
public enum TimetableSpanCollision
|
||||
{
|
||||
CheckedSlotBefore,
|
||||
CheckedSlotAfter,
|
||||
|
||||
@@ -20,8 +20,8 @@ namespace TimetableDesigner.Core
|
||||
|
||||
#region PROPERTIES
|
||||
|
||||
public IEnumerable<TimetableDay> Days => _days;
|
||||
public IEnumerable<TimetableSpan> Slots => _slots;
|
||||
public ICollection<TimetableDay> Days => _days;
|
||||
public ICollection<TimetableSpan> Slots => _slots;
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -36,19 +36,5 @@ namespace TimetableDesigner.Core
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region PUBLIC METHODS
|
||||
|
||||
public void AddDay(TimetableDay name) => _days.Add(name);
|
||||
|
||||
public bool RemoveDay(TimetableDay day) => _days.Remove(day);
|
||||
|
||||
public void AddSlot(TimetableSpan slot) => _slots.Add(slot);
|
||||
|
||||
public bool RemoveSlot(TimetableSpan slot) => _slots.Remove(slot);
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user