public override void doit() { _forUndoRedoList = new ArrayList(); ArrayList possibleRooms = _tsp.calculateAllAllowedRooms(_dropedCourse, _indexRow, _indexCol); IEnumerator puEnum = possibleRooms.GetEnumerator(); Room minCapacityRoom = null; for (int n = 0; n < possibleRooms.Count; n++) { puEnum.MoveNext(); Room room = (Room)puEnum.Current; if (n == 0) { minCapacityRoom = room; } else { if (room.getRoomCapacity() < minCapacityRoom.getRoomCapacity()) { minCapacityRoom = room; } } } _tsp.makeSubLabel(_dropedCourse, minCapacityRoom); EduProgram thisEP = (EduProgram)_dropedCourse.Parent; ArrayList [,] mytt = thisEP.getTimetable(); ArrayList lessonsInOneTimeSlot; if (mytt[_indexRow, _indexCol] == null) { lessonsInOneTimeSlot = new ArrayList(); } else { lessonsInOneTimeSlot = mytt[_indexRow, _indexCol]; } Object [] courseAndRoomPair = new Object[2]; courseAndRoomPair[0] = _dropedCourse; courseAndRoomPair[1] = minCapacityRoom; lessonsInOneTimeSlot.Add(courseAndRoomPair); mytt[_indexRow, _indexCol] = lessonsInOneTimeSlot; _forUndoRedoList.Add(courseAndRoomPair); if (_dropedCourse.getCoursesToHoldTogetherList().Count > 0) { foreach (Course courseHT in _dropedCourse.getCoursesToHoldTogetherList()) { EduProgram epHT = (EduProgram)courseHT.Parent; ArrayList [,] myttHT = epHT.getTimetable(); ArrayList lessonsInOneTimeSlotHT; if (myttHT[_indexRow, _indexCol] == null) { lessonsInOneTimeSlotHT = new ArrayList(); } else { lessonsInOneTimeSlotHT = myttHT[_indexRow, _indexCol]; } Object [] courseAndRoomPairHT = new Object[2]; courseAndRoomPairHT[0] = courseHT; courseAndRoomPairHT[1] = minCapacityRoom; lessonsInOneTimeSlotHT.Add(courseAndRoomPairHT); myttHT[_indexRow, _indexCol] = lessonsInOneTimeSlotHT; _tsp.makeSubLabel(courseHT, minCapacityRoom); _forUndoRedoList.Add(courseAndRoomPairHT); } } }
public override void doit() { _forUndoRedoList = new ArrayList(); //find all rooms which are possible //for this lection (capacity, are they free in the term,...) ArrayList possibleRooms = _tsp.calculateAllAllowedRooms(_dropedCourse, _tsp.getIndexRow(), _tsp.getIndexCol()); //i take the room which has the first bigger capacity than //the number of enrolled students for the course(s) that is draged IEnumerator prEnum = possibleRooms.GetEnumerator(); Room minCapacityRoom = null; for (int n = 0; n < possibleRooms.Count; n++) { prEnum.MoveNext(); Room room = (Room)prEnum.Current; if (n == 0) { minCapacityRoom = room; } else { if (room.getRoomCapacity() < minCapacityRoom.getRoomCapacity()) { minCapacityRoom = room; } } } _tsp.makeSubLabel(_dropedCourse, minCapacityRoom); EduProgram thisEP = (EduProgram)_dropedCourse.Parent; ArrayList [,] mytt = thisEP.getTimetable(); ArrayList lessonsInOneTimeSlot; if (mytt[_indexRow, _indexCol] == null) { lessonsInOneTimeSlot = new ArrayList(); } else { lessonsInOneTimeSlot = mytt[_indexRow, _indexCol]; } Object [] courseAndRoomPair = new Object[2]; courseAndRoomPair[0] = _dropedCourse; courseAndRoomPair[1] = minCapacityRoom; lessonsInOneTimeSlot.Add(courseAndRoomPair); mytt[_indexRow, _indexCol] = lessonsInOneTimeSlot; _forUndoRedoList.Add(courseAndRoomPair); if (_dropedCourse.getCoursesToHoldTogetherList().Count > 0) { foreach (Course courseHT in _dropedCourse.getCoursesToHoldTogetherList()) { EduProgram epHT = (EduProgram)courseHT.Parent; ArrayList [,] myttHT = epHT.getTimetable(); ArrayList lessonsInOneTimeSlotHT; if (myttHT[_indexRow, _indexCol] == null) { lessonsInOneTimeSlotHT = new ArrayList(); } else { lessonsInOneTimeSlotHT = myttHT[_indexRow, _indexCol]; } Object [] courseAndRoomPairHT = new Object[2]; courseAndRoomPairHT[0] = courseHT; courseAndRoomPairHT[1] = minCapacityRoom; lessonsInOneTimeSlotHT.Add(courseAndRoomPairHT); myttHT[_indexRow, _indexCol] = lessonsInOneTimeSlotHT; _forUndoRedoList.Add(courseAndRoomPairHT); } } }