private void init_lessonList() { // get amount of lesson in each category List <List <Lesson> > lessonsByTypes = null; int[] arrsLength = getAmountOfTypes(ref lessonsByTypes); int heightLableTitleGroup = 0; // init 3 groupBoxes for: groups = new Panel[lessonsByTypes.Count]; for (int i = 0; i < groups.Length; i++) { groups[i] = new Panel(); groups[i].AutoSize = false; groups[i].Width = WIDTH - 50; groups[i].Height = 25; groups[i].Anchor = AnchorStyles.Top | AnchorStyles.Right; groups[i].BackColor = Color.Transparent; groups[i].ForeColor = Color.Black; groups[i].Font = new Font(FONT_TEXT, FONT_SIZE_SUBTITLE); groups[i].RightToLeft = RightToLeft.Yes; Label l = new Label(); l.Width = groups[i].Width; l.Height = 20; l.Font = new Font(FONT_TEXT, FONT_SIZE_SUBTITLE, FontStyle.Underline); l.Text = TITLES[i]; l.Location = new Point(0, 2); heightLableTitleGroup = l.Location.Y + l.Height + 2; groups[i].Controls.Add(l); } lessonsLables = new LableEditable[lessonsByTypes.Count][][]; for (int i = 0; i < lessonsByTypes.Count; i++) { if (lessonsByTypes[i].Count > 0) { lessonsLables[i] = new LableEditable[lessonsByTypes[i].Count][]; for (int ii = 0; ii < lessonsLables[i].Length; ii++) { lessonsLables[i][ii] = new LableEditable[LABEL_TITLES.Length]; } } } // init the properties and data LINE_SUBTITLES = new Label[TITLES.Length - 1]; for (int i = 0; i < lessonsByTypes.Count; i++) { for (int s = 0; s < lessonsByTypes[i].Count; s++) { int widthOfAllTitles = 0; for (int a = LABEL_TITLES.Length - 1; a >= 0; a--) { switch (a) { case 0: // number lessonsLables[i][s][a] = new LableEditable(lessonsByTypes[i][s].number.ToString(), LABEL_TITLES[a]); lessonsLables[i][s][a].Width(W_CHAR); break; case 1: // lecturer lessonsLables[i][s][a] = new LableEditable(lessonsByTypes[i][s].lecturer, LABEL_TITLES[a]); lessonsLables[i][s][a].Width(W_LONG); break; case 2: // day lessonsLables[i][s][a] = new LableEditable(lessonsByTypes[i][s].getShortDay(), LABEL_TITLES[a]); lessonsLables[i][s][a].Width(W_SHORT); break; case 3: // end lessonsLables[i][s][a] = new LableEditable(lessonsByTypes[i][s].getEndHour(), LABEL_TITLES[a]); lessonsLables[i][s][a].Width(W_SHORT); break; case 4: // start lessonsLables[i][s][a] = new LableEditable(lessonsByTypes[i][s].getStartHour(), LABEL_TITLES[a]); lessonsLables[i][s][a].Width(W_SHORT); break; case 5: // hours lessonsLables[i][s][a] = new LableEditable(lessonsByTypes[i][s].weekHour.ToString(), LABEL_TITLES[a]); lessonsLables[i][s][a].Width(W_SHORT); break; case 6: // classes lessonsLables[i][s][a] = new LableEditable(lessonsByTypes[i][s].className, LABEL_TITLES[a]); lessonsLables[i][s][a].Width(W_MEDIUM); break; } widthOfAllTitles += lessonsLables[i][s][a].Width(); lessonsLables[i][s][a].label.BackColor = Color.Transparent; lessonsLables[i][s][a].textbox.BackColor = Color.WhiteSmoke; lessonsLables[i][s][a].ChangeState(); lessonsLables[i][s][a].Location(new Point(0, 0)); if (lessonsLables[i][s][3] != null && lessonsLables[i][s][4] != null && lessonsLables[i][s][5] != null) { lessonsLables[i][s][3].updateHoursInputRoles(lessonsLables[i][s][4], lessonsLables[i][s][3], lessonsLables[i][s][5]); lessonsLables[i][s][4].updateHoursInputRoles(lessonsLables[i][s][4], lessonsLables[i][s][3], lessonsLables[i][s][5]); } } for (int b = lessonsLables[i][s].Length - 1; b >= 0; b--) { int locX = 0; int locY = 0; locX = b == LABEL_TITLES.Length - 1 ? groups[i].Width - widthOfAllTitles - 100 : lessonsLables[i][s][b + 1].Location().X + lessonsLables[i][s][b + 1].Width() + COL_SPACE; locY = b < LABEL_TITLES.Length - 1 && s != 0 ? lessonsLables[i][s - 1][b + 1].Location().Y + HEIGHT_ROW_ITEM + 2 : heightLableTitleGroup; lessonsLables[i][s][b].Location(new Point(locX, locY)); lessonsLables[i][s][b].label.Invalidate(); lessonsLables[i][s][b].textbox.Invalidate(); } groups[i].Height = lessonsLables[i][s] == null ? heightLableTitleGroup + 10 : heightLableTitleGroup + 10 + (lessonsLables[i].Length) * (HEIGHT_ROW_ITEM + 2); } if (i == 0) { groups[i].Location = new Point(5, LINE_TITLE.Location.Y + LINE_TITLE.Height + 10); } else { groups[i].Location = new Point(5, LINE_SUBTITLES[i - 1].Location.Y + LINE_SUBTITLES[i - 1].Height + 2); } int j = i; if (j < LINE_SUBTITLES.Length) { LINE_SUBTITLES[j] = new Label(); if (PROP_PERSENR_HR_SEPERATION > 100 || PROP_PERSENR_HR_SEPERATION == 0) { PROP_PERSENR_HR_SEPERATION = 80; } LINE_SUBTITLES[j].Width = (int)((float)(PROP_PERSENR_HR_SEPERATION * 1.0 / 100) * WIDTH); LINE_SUBTITLES[j].Height = 1; LINE_SUBTITLES[j].Text = ""; LINE_SUBTITLES[j].BackColor = colors[id % colors.GetLength(0), 0]; int locX = ((WIDTH / 2) - (LINE_SUBTITLES[j].Width / 2)); int locY = groups[i].Location.Y + groups[i].Height + 5; LINE_SUBTITLES[j].Location = new Point(locX, locY); card.Controls.Add(LINE_SUBTITLES[j]); } card.Controls.Add(groups[i]); } // add seperation line to the next type lesson max_height = groups[groups.Length - 1].Location.Y + groups[groups.Length - 1].Height + 15; addAllLabelsToPanel(); }
public void updateHoursInputRoles(LableEditable start, LableEditable end, LableEditable hours) { if (role.Equals("סיום")) { textbox.KeyPress += ((sender, e) => { bool getTouch = false; TextBox tb = sender as TextBox; hourPress(sender, e, tb); TextBox t_end = this.textbox; TextBox t_start = start.textbox; TextBox t_hours = hours.textbox; if (!getTouch && t_end.Text.Length >= 3 && t_start.Text.Length > 0 && !t_start.Text.Equals(start.role)) { getTouch = true; if (t_start.Text.Length > 2 && t_end.Text.Length > 2) { int start_hours_num = Convert.ToInt32(t_start.Text.Substring(0, 2)); int end_hours_num = Convert.ToInt32(t_end.Text.Substring(0, 2)); if (end_hours_num - start_hours_num <= 0) { t_end.Text = ""; } else { t_hours.Text = (end_hours_num - start_hours_num).ToString(); t_hours.ForeColor = Color.Black; } } } else { getTouch = false; } }); } else if (role.Equals("התחלה")) { textbox.KeyPress += ((sender, e) => { bool getTouch = false; TextBox tb = sender as TextBox; hourPress(sender, e, tb); TextBox t_end = end.textbox; TextBox t_start = this.textbox; TextBox t_hours = hours.textbox; if (!getTouch && t_start.Text.Length >= 3 && t_end.Text.Length > 0 && !t_end.Text.Equals(end.role)) { getTouch = true; if (t_start.Text.Length > 2 && t_end.Text.Length > 2) { int start_hours_num = Convert.ToInt32(t_start.Text.Substring(0, 2)); int end_hours_num = Convert.ToInt32(t_end.Text.Substring(0, 2)); if (end_hours_num - start_hours_num <= 0) { t_start.Text = ""; } else { t_hours.Text = (end_hours_num - start_hours_num).ToString(); t_hours.ForeColor = Color.Black; } } } else { getTouch = false; } }); } }
private void init_title(string text, string txtyear) { year = new LableEditable("שנה - " + txtyear, "שנה"); year.Font(new Font(FONT_TEXT, FONT_SIZE_TITLE, FontStyle.Bold | FontStyle.Underline)); year.BackColor(Color.Transparent); year.ForeColor(Color.Black); year.Width(W_MEDIUM); year.Height(PROP_TITLE_HIEGHT); year.Location(new Point(WIDTH - 50 - year.Width(), 8)); year.ChangeState(); year.label.Click += ((sender, e) => { openCard = !openCard; if (openCard) { card.Height = max_height; card.Invalidate(); } else { card.Height = HIEGHT; card.Invalidate(); } panelCoursesList.reorderLocationCards_callback(); }); card.Controls.Add(year.label); card.Controls.Add(year.textbox); int width_edit_button = 5 + W_MEDIUM + COL_SPACE; title = new LableEditable(text, "שם הקורס"); title.Font(new Font(FONT_TEXT, FONT_SIZE_TITLE, FontStyle.Bold | FontStyle.Underline)); title.BackColor(Color.Transparent); title.ForeColor(Color.Black); title.Width(year.Location().X - width_edit_button - COL_SPACE); title.Height(PROP_TITLE_HIEGHT); title.Location(new Point(width_edit_button + 5, 8)); title.ChangeState(); title.label.Click += ((sender, e) => { openCard = !openCard; if (openCard) { card.Height = max_height; card.Invalidate(); } else { card.Height = HIEGHT; card.Invalidate(); } panelCoursesList.reorderLocationCards_callback(); }); card.Controls.Add(title.label); card.Controls.Add(title.textbox); LINE_TITLE.Width = WIDTH; LINE_TITLE.Height = 2; LINE_TITLE.Text = ""; LINE_TITLE.BackColor = colors[id % colors.GetLength(0), 0]; LINE_TITLE.Location = new Point(0, HIEGHT - LINE_TITLE.Height); card.Controls.Add(LINE_TITLE); }