// init the properties data of the panel Lesson private void initPanelLessonData(ref PanelLsn p, Lesson lsn) { if (lsn == null) { return; } if (p == null) { p = new PanelLsn(); } p.lsn = lsn; int dayIndex = Array.IndexOf(DAYS, lsn.getFullDay()); if (dayIndex >= 0) { p.Width = (days[dayIndex].Width - 1); } p.Height = (hours[lsn.end - START_HOUR].Location.Y + hours[lsn.end - START_HOUR].Height) - (hours[lsn.start - START_HOUR].Location.Y + hours[lsn.start - START_HOUR].Height) - 2 * THICKNESS_HR_SEPERADE; p.RightToLeft = RightToLeft.Yes; p.Location = new Point(days[dayIndex].Location.X + 1, (hours[lsn.start - START_HOUR].Location.Y) + 1); // round edges panel p.Region = System.Drawing.Region.FromHrgn(CreateRoundRectRgn(0, 0, p.Width, p.Height, 20, 20)); // the content lables Label[] lbl_lessons = new Label[3]; // name+type, lecturer, className//GrowLabel[] lbl_lessons = new GrowLabel[3]; // name+type, lecturer, className for (int k = 0; k < lbl_lessons.Length; k++) { lbl_lessons[k] = new GrowLabel(); lbl_lessons[k].AutoSize = false; lbl_lessons[k].Height = p.Height / 3; lbl_lessons[k].Width = p.Width; lbl_lessons[k].BackColor = Color.Transparent; lbl_lessons[k].TextAlign = ContentAlignment.MiddleCenter; int size = 10; switch (lsn.weekHour) { case 1: size = 9; break; case 2: size = 11; break; case 3: size = 11; break; case 4: size = 11; break; case 5: size = 11; break; default: size = 13; break; } lbl_lessons[k].Font = new Font(FONT_TEXT, size); switch (k) { case 0: // course name lbl_lessons[k].Text = lsn.type + "-" + lsn.courseName; lbl_lessons[k].Location = new Point(0, 0); lbl_lessons[k].TextAlign = ContentAlignment.MiddleCenter; lbl_lessons[k].Font = new Font(lbl_lessons[k].Font, FontStyle.Underline | FontStyle.Bold); break; case 1: // lecturer name lbl_lessons[k].Text = lsn.lecturer; lbl_lessons[k].Location = new Point(0, p.Height / 2 - lbl_lessons[k].Height / 2); break; case 2: // class name lbl_lessons[k].Text = "כיתה: " + lsn.className; lbl_lessons[k].Location = new Point(0, p.Height - lbl_lessons[k].Height); break; default: break; } if (!lbl_lessons[k].Text.Equals("")) { if (lbl_lessons[k].Width != days[dayIndex].Width - 1) { if (lsn.weekHour == 1 || lsn.weekHour == 2) { if (k == 0 || k == 2) { p.Controls.Add(lbl_lessons[k]); } } else { p.Controls.Add(lbl_lessons[k]); } } else { if (lsn.weekHour == 1 && k != 1) { p.Controls.Add(lbl_lessons[k]); } else if (lsn.weekHour > 1) { p.Controls.Add(lbl_lessons[k]); } } } p.BringToFront(); for (int i = 0; i < cards.Length; i++) { if (cards[i].getCourseName().Equals(lsn.courseName)) { p.BackColor = cards[i].getCard().BackColor; break; } } } p.Tag = lsn.courseName + " " + lsn.type.Substring(0, 1); }
// Mock data for display and debug private void mockLessons() { lessons = new LessonList(); lessons = new LessonList(5); lessons[0] = new Lesson(); lessons[0].courseName = "קומפילציה"; lessons[0].lecturer = "אלכס צורקין"; lessons[0].number = 1; lessons[0].className = "F201"; lessons[0].day = "א"; lessons[0].end = 12; lessons[0].start = 10; lessons[0].type = "ה"; lessons[0].weekHour = 2; lessons[0].year = 2; lessons[1] = new Lesson(); lessons[1].courseName = "קומפילציה"; lessons[1].lecturer = "אלכס צורקין"; lessons[1].number = 2; lessons[1].className = "F201"; lessons[1].day = "ב"; lessons[1].end = 13; lessons[1].start = 12; lessons[1].type = "ה"; lessons[1].weekHour = 1; lessons[1].year = 2; lessons[2] = new Lesson(); lessons[2].courseName = "בדיקות"; lessons[2].lecturer = "אבישי"; lessons[2].number = 1; lessons[2].className = "S100"; lessons[2].day = "ב"; lessons[2].end = 20; lessons[2].start = 17; lessons[2].type = "מ"; lessons[2].weekHour = 3; lessons[2].year = 2; lessons[3] = new Lesson(); lessons[3].courseName = "אלגוריתמים 2"; lessons[3].lecturer = "נטליה ונטיק"; lessons[3].number = 1; lessons[3].className = "S202"; lessons[3].day = "ג"; lessons[3].end = 12; lessons[3].start = 8; lessons[3].type = "מ"; lessons[3].weekHour = 4; lessons[3].year = 4; lessons[4] = new Lesson(); lessons[4].courseName = "אלגוריתמים 2"; lessons[4].lecturer = "בוריס"; lessons[4].number = 1; lessons[4].className = "כלניות"; lessons[4].day = "ד"; lessons[4].end = 18; lessons[4].start = 13; lessons[4].type = "ת"; lessons[4].weekHour = 5; lessons[4].year = 4; }