private void listBoxGroups_SelectedIndexChanged(object sender, EventArgs e)
        {
            var selectedGroup = listBoxGroups.SelectedItem as Group;

            if (selectedGroup == null)
            {
                if (previouslySelectedGroup != null)
                {
                    UpdateGroup(previouslySelectedGroup);
                    previouslySelectedGroup = null;
                }

                listBoxSubjectsOfGroups.ClearSelected();
                numericUpDownStudents.Value = 0;
                groupName.Text = "";
                return;
            }

            previouslySelectedGroup = selectedGroup;

            listBoxSubjectsOfGroups.ClearSelected();
            foreach (var subject in selectedGroup.horarium)
            {
                var index = listBoxSubjectsOfGroups.Items.IndexOf(subject);
                listBoxSubjectsOfGroups.SetSelected(index, true);
            }

            numericUpDownStudents.Value = selectedGroup.size;
            groupName.Text = selectedGroup.name;
        }
 public IEnumerable<ScheduledTimeSlot> GetGroupProgram(Group group)
 {
     return Schedule.Where(s => s.groups.Contains(group));
 }
        private void UpdateGroup(Group group)
        {
            var subjects = new List<Subject>();
            foreach (Subject subject in listBoxSubjectsOfGroups.SelectedItems)
            {
                subjects.Add(subject);
            }

            group.horarium = subjects;
            group.name = groupName.Text;
            group.size = (uint) numericUpDownStudents.Value;

            RefreshGroups();
        }
 internal void AddGroup(Group group)
 {
     groups.Add(group);
     attendingPeopleCount += group.size;
 }