Exemple #1
0
        private void addLessonToolStripMenuItem_Click(object sender, EventArgs e)
        {
            bool finalBefore = currentTT.IsFinalised();

            //ADD LESSON
            lessonView           = new AddLesson();
            lessonView.currentTT = currentTT;
            lessonView.ShowDialog();
            pb_mainView.Refresh();
            pb_homeworkView.Refresh();
            pb_staffView.Refresh();
            pb_roomView.Refresh();

            if (!finalBefore)
            {
                PopulateEditToolbar();
                SetStatusOfStructureForms(false); //This prevents the user from modifying the week/yeargroups/subjects/teachers etc. This will interfere with our project.
            }
        }
Exemple #2
0
        private void addLessonToolStripMenuItem_Click(object sender, EventArgs e)
        {
            bool finalBefore = currentTT.IsFinalised();

            //ADD LESSON
            lessonView = new AddLesson();
            lessonView.currentTT = currentTT;
            lessonView.ShowDialog();
            pb_mainView.Refresh();
            pb_homeworkView.Refresh();
            pb_staffView.Refresh();
            pb_roomView.Refresh();

            if (!finalBefore)
            {
                PopulateEditToolbar();
                SetStatusOfStructureForms(false); //This prevents the user from modifying the week/yeargroups/subjects/teachers etc. This will interfere with our project.
            }
        }
Exemple #3
0
        //private void DetectClickForMain(out int DayIndex, out int PeriodIndex, out int YearIndex, out int FormIndex,out Lesson selectedLesson,Rectangle cursor)
        //{
        //    DayIndex = -1;
        //    FormIndex = -1;
        //    YearIndex = -1;
        //    PeriodIndex = -1;
        //    selectedLesson = null;
        //    do
        //    {
        //        DayIndex++;
        //    } while ((DayIndex < currentTT.Week.Count - 1) && (!currentTT.Week[DayIndex].dayBounds.IntersectsWith(cursor)));
        //    Console.WriteLine("DayIndex: " + DayIndex);
        //    if (DayIndex >= currentTT.Week.Count) return;
        //    //if (!currentTT.Week[DayIndex].dayBounds.IntersectsWith(cursor)) return;
        //    do
        //    {
        //        PeriodIndex++;
        //    } while ((PeriodIndex < currentTT.Week[DayIndex].PeriodsInDay.Count - 1) && (!currentTT.Week[DayIndex].PeriodsInDay[PeriodIndex].periodBounds.IntersectsWith(cursor)));
        //    Console.WriteLine("Period Index: " + PeriodIndex);
        //    if (PeriodIndex >= currentTT.Week[DayIndex].PeriodsInDay.Count) return;
        //    // if (!currentTT.Week[DayIndex].PeriodsInDay[PeriodIndex].periodBounds.IntersectsWith(cursor)) return;
        //    do
        //    {
        //        YearIndex++;
        //    } while ((YearIndex < currentTT.Years.Count - 1) && (!currentTT.Years[YearIndex].yearBounds.IntersectsWith(cursor)));
        //    Console.WriteLine("Year Index: " + YearIndex);
        //    // if (!currentTT.Years[YearIndex].yearBounds.IntersectsWith(cursor)) return;
        //    if (YearIndex >= currentTT.Years.Count) return;
        //    do
        //    {
        //        FormIndex++;
        //    } while ((FormIndex < currentTT.Years[YearIndex].Forms.Count() - 1) && (!currentTT.Years[YearIndex].Forms[FormIndex].formBounds.IntersectsWith(cursor)));
        //    Console.WriteLine("Form Index: " + FormIndex);
        //    if (FormIndex >= currentTT.Years[YearIndex].Forms.Count()) return;
        //    try
        //    {
        //        selectedLesson = currentTT.mainTT[DayIndex][PeriodIndex][YearIndex][FormIndex];
        //    }
        //    catch
        //    {
        //    }
        //}
        private void pb_mainView_MouseClick(object sender, MouseEventArgs e)
        {
            //RENAME TO MouseUp.
            if (sw != null) sw.Stop();
            if (displayedItem != null)
            {
                displayedItem.selected = false;

            }
            if (!currentTT.IsFinalised()) return;
            Rectangle cursor = new Rectangle(e.X, e.Y, 1, 1);

            int YearIndex;
            int PeriodIndex;
            int DayIndex;
            int FormIndex;
            Lesson selectedLesson;
            DayIndex = -1;
            FormIndex = -1;
            YearIndex = -1;
            PeriodIndex = -1;
            selectedLesson = null;
            do
            {
                DayIndex++;
            } while ((DayIndex < currentTT.Week.Count - 1) && (!currentTT.Week[DayIndex].dayBounds.IntersectsWith(cursor)));
            //Console.WriteLine("DayIndex: " + DayIndex);
            if (DayIndex >= currentTT.Week.Count) return;
            //if (!currentTT.Week[DayIndex].dayBounds.IntersectsWith(cursor)) return;

            do
            {
                PeriodIndex++;
            } while ((PeriodIndex < currentTT.Week[DayIndex].PeriodsInDay.Count - 1) && (!currentTT.Week[DayIndex].PeriodsInDay[PeriodIndex].periodBounds.IntersectsWith(cursor)));
            //Console.WriteLine("Period Index: " + PeriodIndex);
            if (PeriodIndex >= currentTT.Week[DayIndex].PeriodsInDay.Count) return;

            // if (!currentTT.Week[DayIndex].PeriodsInDay[PeriodIndex].periodBounds.IntersectsWith(cursor)) return;

            do
            {
                YearIndex++;
            } while ((YearIndex < currentTT.Years.Count - 1) && (!currentTT.Years[YearIndex].yearBounds.IntersectsWith(cursor)));
            //Console.WriteLine("Year Index: " + YearIndex);
            // if (!currentTT.Years[YearIndex].yearBounds.IntersectsWith(cursor)) return;
            if (YearIndex >= currentTT.Years.Count) return;

            do
            {
                FormIndex++;
            } while ((FormIndex < currentTT.Years[YearIndex].Forms.Count() - 1) && (!currentTT.Years[YearIndex].Forms[FormIndex].formBounds.IntersectsWith(cursor)));
            //Console.WriteLine("Form Index: " + FormIndex);
            if (FormIndex >= currentTT.Years[YearIndex].Forms.Count()) return;

            try
            {
                selectedLesson = currentTT.mainTT[DayIndex][PeriodIndex][YearIndex][FormIndex];
            }
            catch
            {

            }

            if (mainViewMode == ClickMode.AddLessonViaMenu)
            {
                lessonView = new AddLesson();
                lessonView.currentTT = currentTT;
                lessonView.LoadData();
                lessonView.cb_day.SelectedIndex = DayIndex;

                lessonView.cb_periodStart.SelectedIndex = PeriodIndex;
                lessonView.cb_yearGroup.SelectedIndex = YearIndex;
                lessonView.cb_class.SelectedIndex = FormIndex;
                mainViewMode = ClickMode.Normal;
                lessonView.ShowDialog();

                pb_mainView.Refresh();
                lbl_status.Text = "Ready";
                return;
            }
            if (mainViewMode == ClickMode.InsertFromTray)
            {
                if (lv_tray.SelectedIndices.Count == 0)
                {
                    mainViewMode = ClickMode.Normal;
                    return;
                }
                currentTT.MoveFromTrayToMainTT(DayIndex, PeriodIndex, YearIndex, FormIndex, lv_tray.SelectedIndices[0]);
                mainViewMode = ClickMode.Normal;
                RefreshTrayItems();
                return;
            }
            else if (mainViewMode == ClickMode.FindStaff)
            {
                mainViewMode = ClickMode.Normal;
                lbl_status.Text = currentTT.FreeStaffCodes(Convert.ToByte(DayIndex), Convert.ToByte(PeriodIndex));

            }
            else if (mainViewMode == ClickMode.FindRooms) {
                mainViewMode = ClickMode.Normal;
                lbl_status.Text =  currentTT.FreeRoomCodes(Convert.ToByte(DayIndex), Convert.ToByte(PeriodIndex));

            }

            selectedLesson = currentTT.mainTT[DayIndex][PeriodIndex][YearIndex][FormIndex];

            if (mainViewMode == ClickMode.Move && sw.ElapsedMilliseconds > timeForMove)
            {

                //MessageBox.Show("Move: " + FormIndex + " " + YearIndex);
                if (displayedItem.locked)
                {
                    MessageBox.Show("One cannot move a locked lesson. To move it, please unlock the lesson.", "Lesson locking");
                    mainViewMode = ClickMode.Normal;
                    return;
                }

                bool ConditionA = (displayedItem.YearIndex != YearIndex);
                bool ConditionB = (displayedItem.PeriodIndex != PeriodIndex);
                bool ConditionC = (displayedItem.FormIndex != FormIndex);

                if (ConditionA) AddNodeToUndo(Event.MoveYear, displayedItem.YearIndex, YearIndex, displayedItem,false,ConditionB|ConditionC);
                if (ConditionB) AddNodeToUndo(Event.MovePeriod, displayedItem.PeriodIndex, PeriodIndex, displayedItem, ConditionA,ConditionC);

                if (ConditionC) AddNodeToUndo(Event.MoveForm, displayedItem.FormIndex, FormIndex,displayedItem, ConditionA | ConditionB,false);
                currentTT.MoveForms(displayedItem, Convert.ToByte(FormIndex));

                currentTT.MovePeriods(displayedItem, Convert.ToByte(PeriodIndex));
                currentTT.MoveYears(displayedItem, Convert.ToByte(YearIndex));

                mainViewMode = ClickMode.Normal;
                RefreshViews();
                displayedItem.selected = true;
                return;
            }

            if (selectedLesson == null)
            {
                displayedItem = null;
                pb_mainView.Refresh();
            }

            else
            {
                selectedLesson.selected = true;
                displayedItem = selectedLesson;;
                pb_mainView.Refresh();

                cb_year.SelectedIndex = YearIndex;
                cb_room.SelectedIndex = currentTT.GetIndexOfRoom(selectedLesson.RoomCode);
                cb_teacher.SelectedIndex = currentTT.GetIndexOfStaff(selectedLesson.TeacherAbbreviation);
                cb_subject.SelectedIndex = currentTT.GetIndexOfSubject(selectedLesson.SubjectAbbreviation);

                cb_homework.Text = Convert.ToString(selectedLesson.homeworkAmount);
                cb_form.Text = currentTT.Years[YearIndex].Forms[FormIndex].FormName;
                btn_invisible.Checked = selectedLesson.invisible;
                btn_locked.Checked = selectedLesson.locked;
            }
            mainViewMode = ClickMode.Normal;
        }
Exemple #4
0
        private void editLessonToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //edit lesson
            if (!currentTT.IsFinalised()) return;
            if (displayedItem == null) return;
            lessonView = new AddLesson();
            lessonView.currentTT = currentTT;
            lessonView.mode = AddLessonMode.Edit; //loads in editing mode.

            lessonView.LoadLesson(displayedItem);
            lessonView.ShowDialog();
            RefreshViews();
        }
Exemple #5
0
        private void pb_staffView_MouseClick(object sender, MouseEventArgs e)
        {
            //After adding the new feature, please be sure to update the system maintenance!!!

            if (sw != null) sw.Stop();
            if (displayedItem != null)
            {
                displayedItem.selected = false;
                btn_locked.Checked = false;
                btn_invisible.Checked = false;
            }

            //Console.WriteLine("");
            //Console.WriteLine("Click detected: ");
            Rectangle cursor = new Rectangle(e.X, e.Y, 1, 1);

            int DayIndex = -1;

            do
            {
                DayIndex++;
            } while ((DayIndex < currentTT.Week.Count - 1) && (!currentTT.Week[DayIndex].dayBounds.IntersectsWith(cursor)));
            //Console.WriteLine("DayIndex: " + DayIndex);
            if (DayIndex >= currentTT.Week.Count) return;
            //if (!currentTT.Week[DayIndex].dayBounds.IntersectsWith(cursor)) return;

            int PeriodIndex = -1;

            do
            {
                PeriodIndex++;
            } while ((PeriodIndex < currentTT.Week[DayIndex].PeriodsInDay.Count - 1) && (!currentTT.Week[DayIndex].PeriodsInDay[PeriodIndex].periodBounds.IntersectsWith(cursor)));
            //Console.WriteLine("Period Index: " + PeriodIndex);
            if (PeriodIndex >= currentTT.Week[DayIndex].PeriodsInDay.Count) return;

            // if (!currentTT.Week[DayIndex].PeriodsInDay[PeriodIndex].periodBounds.IntersectsWith(cursor)) return;

            int StaffIndex = -1;

            do
            {
                StaffIndex++;
            } while ((StaffIndex < currentTT.Staff.Count - 1) && (!currentTT.Staff[StaffIndex].staffBounds.IntersectsWith(cursor)));
            //Console.WriteLine("Staff Index: " + StaffIndex);
            // if (!currentTT.Years[YearIndex].yearBounds.IntersectsWith(cursor)) return;
            if (StaffIndex >= currentTT.Staff.Count) return;
            Lesson selectedLesson = null;
            try
            {
                selectedLesson = (Lesson)currentTT.staffTT[DayIndex][PeriodIndex][StaffIndex];
            }
            catch (Exception)
            {
                return;
            }
            //Console.WriteLine("Status: " + mainViewMode);
            if (mainViewMode == ClickMode.AddLessonViaMenu)
            {
                mainViewMode = ClickMode.Normal;
                lessonView = new AddLesson();
                lessonView.currentTT = currentTT;
                lessonView.LoadData();
                lessonView.cb_teacherCode.SelectedIndex = StaffIndex;
                lessonView.cb_day.SelectedIndex = DayIndex;
                lessonView.cb_periodStart.SelectedIndex = PeriodIndex;
                lessonView.ShowDialog();

                lbl_status.Text = "Ready";
                return;
            }

            if (mainViewMode == ClickMode.Move && sw.ElapsedMilliseconds > timeForMove)
            {
                if (displayedItem.locked)
                {
                    MessageBox.Show("One cannot move a locked lesson. To move it, please unlock the lesson.", "Lesson locking");
                    return;
                }
                bool ConditionA = (displayedItem.TeacherAbbreviation != currentTT.Staff[StaffIndex].TeacherAbbreviation);
                bool ConditionB = (displayedItem.PeriodIndex != PeriodIndex);
                bool eventAfter = ConditionA;

                if (ConditionA) AddNodeToUndo(Event.MoveStaff, currentTT.GetIndexOfStaff(displayedItem.TeacherAbbreviation), StaffIndex, displayedItem, false,ConditionB);
                if (ConditionB) AddNodeToUndo(Event.MovePeriod, displayedItem.PeriodIndex, PeriodIndex, displayedItem, eventAfter,false);

                currentTT.MoveTeacher(displayedItem, Convert.ToByte(StaffIndex));
                currentTT.MovePeriods(displayedItem, Convert.ToByte(PeriodIndex));

                mainViewMode = ClickMode.Normal;
                RefreshViews();
                displayedItem.selected = true;
                return;
            }
            if (selectedLesson == null) displayedItem = null;
            else
            {

                selectedLesson.selected = true;
                displayedItem = selectedLesson;
                pb_staffView.Refresh();

                cb_year.SelectedIndex = selectedLesson.YearIndex;
                cb_room.SelectedIndex = currentTT.GetIndexOfRoom(selectedLesson.RoomCode);
                cb_teacher.SelectedIndex = StaffIndex;
                cb_subject.SelectedIndex = currentTT.GetIndexOfSubject(selectedLesson.SubjectAbbreviation);
                btn_locked.Checked = selectedLesson.locked;
                btn_invisible.Checked = selectedLesson.invisible;

                if (selectedLesson.locked)
                {
                    editLessonToolStripMenuItem.Enabled = false; //we can't edit anything that's locked.

                }
                else
                {
                    editLessonToolStripMenuItem.Enabled = true;
                }

                cb_homework.Text = Convert.ToString(selectedLesson.homeworkAmount);
                cb_form.Text = currentTT.Years[selectedLesson.YearIndex].Forms[selectedLesson.FormIndex].FormName;
            }
            mainViewMode = ClickMode.Normal;
        }
Exemple #6
0
        private void pb_mainView_MouseClick(object sender, MouseEventArgs e)
        {
            if (displayedItem != null)
            {
                displayedItem.selected = false;
            }


            Rectangle cursor = new Rectangle(e.X, e.Y, 1, 1);

            int DayIndex = -1;

            do
            {
                DayIndex++;
            } while ((DayIndex < currentTT.Week.Count - 1) && (!currentTT.Week[DayIndex].dayBounds.IntersectsWith(cursor)));
            if (DayIndex >= currentTT.Week.Count)
            {
                return;
            }
            //if (!currentTT.Week[DayIndex].dayBounds.IntersectsWith(cursor)) return;

            int PeriodIndex = -1;

            do
            {
                PeriodIndex++;
            } while ((PeriodIndex < currentTT.Week[DayIndex].PeriodsInDay.Count - 1) && (!currentTT.Week[DayIndex].PeriodsInDay[PeriodIndex].periodBounds.IntersectsWith(cursor)));

            if (PeriodIndex >= currentTT.Week[DayIndex].PeriodsInDay.Count)
            {
                return;
            }

            // if (!currentTT.Week[DayIndex].PeriodsInDay[PeriodIndex].periodBounds.IntersectsWith(cursor)) return;

            int YearIndex = -1;

            do
            {
                YearIndex++;
            } while ((YearIndex < currentTT.Years.Count - 1) && (!currentTT.Years[YearIndex].yearBounds.IntersectsWith(cursor)));

            // if (!currentTT.Years[YearIndex].yearBounds.IntersectsWith(cursor)) return;
            if (YearIndex >= currentTT.Years.Count)
            {
                return;
            }
            int FormIndex = -1;

            do
            {
                FormIndex++;
            } while ((FormIndex < currentTT.Years[YearIndex].Forms.Count() - 1) && (!currentTT.Years[YearIndex].Forms[FormIndex].formBounds.IntersectsWith(cursor)));

            if (FormIndex >= currentTT.Years[YearIndex].Forms.Count())
            {
                return;
            }
            Lesson selectedLesson = null;

            try{
                selectedLesson = currentTT.mainTT[DayIndex][PeriodIndex][YearIndex][FormIndex];
            }
            catch
            {
            }
            if (addLessonViaMenu)
            {
                lessonView           = new AddLesson();
                lessonView.currentTT = currentTT;
                lessonView.LoadData();
                lessonView.cb_day.SelectedIndex = DayIndex;

                lessonView.cb_periodStart.SelectedIndex = PeriodIndex;
                lessonView.cb_yearGroup.SelectedIndex   = YearIndex;
                lessonView.cb_class.SelectedIndex       = FormIndex;
                lessonView.ShowDialog();
                addLessonViaMenu = false;
                pb_mainView.Refresh();
                lbl_status.Text = "Ready";
                return;
            }


            if (selectedLesson == null)
            {
                displayedItem = null;
                pb_mainView.Refresh();
            }

            else
            {
                selectedLesson.selected = true;
                displayedItem           = selectedLesson;
                pb_mainView.Refresh();

                cb_year.SelectedIndex    = YearIndex;
                cb_room.SelectedIndex    = currentTT.GetIndexOfRoom(selectedLesson.RoomCode);
                cb_teacher.SelectedIndex = currentTT.GetIndexOfStaff(selectedLesson.TeacherAbbreviation);
                cb_subject.SelectedIndex = currentTT.GetIndexOfSubject(selectedLesson.SubjectAbbreviation);


                cb_homework.Text = Convert.ToString(selectedLesson.homeworkAmount);
                cb_form.Text     = currentTT.Years[YearIndex].Forms[FormIndex].FormName;
            }
        }
Exemple #7
0
        private void pb_staffView_MouseClick(object sender, MouseEventArgs e)
        {
            if (displayedItem != null)
            {
                displayedItem.selected = false;

            }

            Rectangle cursor = new Rectangle(e.X, e.Y, 1, 1);

            int DayIndex = -1;

            do
            {
                DayIndex++;
            } while ((DayIndex < currentTT.Week.Count - 1) && (!currentTT.Week[DayIndex].dayBounds.IntersectsWith(cursor)));

            if (DayIndex >= currentTT.Week.Count) return;
            //if (!currentTT.Week[DayIndex].dayBounds.IntersectsWith(cursor)) return;

            int PeriodIndex = -1;

            do
            {
                PeriodIndex++;
            } while ((PeriodIndex < currentTT.Week[DayIndex].PeriodsInDay.Count - 1) && (!currentTT.Week[DayIndex].PeriodsInDay[PeriodIndex].periodBounds.IntersectsWith(cursor)));

            if (PeriodIndex >= currentTT.Week[DayIndex].PeriodsInDay.Count) return;

            // if (!currentTT.Week[DayIndex].PeriodsInDay[PeriodIndex].periodBounds.IntersectsWith(cursor)) return;

            int StaffIndex = -1;

            do
            {
                StaffIndex++;
            } while ((StaffIndex < currentTT.Staff.Count - 1) && (!currentTT.Staff[StaffIndex].staffBounds.IntersectsWith(cursor)));

            // if (!currentTT.Years[YearIndex].yearBounds.IntersectsWith(cursor)) return;
            if (StaffIndex >= currentTT.Staff.Count) return;
            Lesson selectedLesson = null;
            try
            {
                selectedLesson = (Lesson)currentTT.staffTT[DayIndex][PeriodIndex][StaffIndex];
            }
            catch (Exception)
            {
                return;
            }

            if (addLessonViaMenu == true)
            {
                lessonView = new AddLesson();
                lessonView.currentTT = currentTT;
                lessonView.LoadData();
                lessonView.cb_teacherCode.SelectedIndex = StaffIndex;
                lessonView.cb_day.SelectedIndex = DayIndex;
                lessonView.cb_periodStart.SelectedIndex = PeriodIndex;
                lessonView.ShowDialog();
                addLessonViaMenu = false;
                lbl_status.Text = "Ready";
                return;
            }

            if (selectedLesson == null) displayedItem = null;
            else
            {

                selectedLesson.selected = true;
                displayedItem = selectedLesson;
                pb_staffView.Refresh();

                cb_year.SelectedIndex = selectedLesson.YearIndex;
                cb_room.SelectedIndex = currentTT.GetIndexOfRoom(selectedLesson.RoomCode);
                cb_teacher.SelectedIndex = StaffIndex;
                cb_subject.SelectedIndex = currentTT.GetIndexOfSubject(selectedLesson.SubjectAbbreviation);

                cb_homework.Text = Convert.ToString(selectedLesson.homeworkAmount);
                cb_form.Text = currentTT.Years[selectedLesson.YearIndex].Forms[selectedLesson.FormIndex].FormName;
            }
        }