-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGroup.cs
95 lines (94 loc) · 2.35 KB
/
Group.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Drawing;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
namespace Organizer
{
[Serializable]
abstract class Group
{
protected List<Event> tasks = new List<Event>();
protected int priority;
protected String name;
protected Color color;
protected Image background;
protected static BinaryFormatter formatter = new BinaryFormatter();
public Group()
{
priority = 0;
name = "";
}
public Group(String name)
{
priority = 0;
this.name = name;
}
public void Add(Event t)
{
if (!tasks.Contains(t))
{
tasks.Add(t);
t.Group = this;
}
}
public void Remove(Event t)
{
tasks.Remove(t);
t.Group = null;
}
public Color Color
{
get { return color; }
set { color = value; }
}
public String Name
{
get { return name; }
set
{
if (value.Length == 0)
{
throw new Exception("Имя не должно быть пустым");
}
name = value;
}
}
public Image Background
{
get { return background; }
set { background = value; }
}
public Task[] GetTasks(DateTime date)
{
List<Task> res = new List<Task>();
foreach (Task t in tasks)
{
if (t.End > date)
{
res.Add(t);
}
}
return res.ToArray();
}
public List<Event> Tasks
{
get { return tasks; }
}
public void ShowTasks(System.Windows.Forms.DataGridView gridView)
{
Event tsk;
gridView.Rows.Clear();
for (int i = 0; i < tasks.Count; i++)
{
tsk = tasks[i];
gridView.Rows.Add(tsk.Name);
gridView.Rows[i].Tag = tsk;
}
gridView.Tag = this;
}
}
}