private void InitializeLabels() { foreach (var name in trueNames) { AddNameToPnlNames(name); } foreach (var pupil in pupils) { PupilLabel label = new PupilLabel(); label.Font = new System.Drawing.Font("Montserrat", 10F); label.AutoSize = true; label.pupil = pupil; if (pupil.TrueName == null) { AddToPupilLabel(label); } else { var lblTrueNme = namesLabels.FirstOrDefault(x => x.Text == pupil.TrueName); if (lblTrueNme != null) { MarkNameAsUsed(lblTrueNme); } AddToReadyLabel(label); } } FoundRightNames(); ArrangeLabel(); }
private void AddTrueName(PupilLabel pupilLabel, Label lblName) { if (pupilLabel != null) { pupilLabel.pupil.TrueName = lblName.Text; pupilsLabels.Remove(pupilLabel); MarkNameAsUsed(lblName); AddToReadyLabel(pupilLabel); ArrangeLabel(); } }
private void FoundRightNames() { for (int i = pupilsLabels.Count - 1; i >= 0; i--) { for (int j = namesLabels.Count - 1; j >= 0; j--) { PupilLabel pupilLabel = (PupilLabel)pupilsLabels[i]; if (IsTheSameName(pupilLabel.pupil, namesLabels[j].Text)) { AddTrueName(pupilLabel, namesLabels[j]); } } } }
private void Label_DoubleClick(object sender, EventArgs e) { try { PupilLabel label = (PupilLabel)sender; AddNameToPnlNames(label.pupil.TrueName); readyLabels.Remove(label); label.pupil.TrueName = null; AddToPupilLabel(label); ArrangeLabel(); } catch (Exception) { throw new Exception("Instead PupilLabel has been got something else"); } }
private void AddToReadyLabel(PupilLabel label) { readyLabels.Add(label); label.Text = String.Format($"{label.pupil.FirstName} {label.pupil.LastName}: {label.pupil.TrueName}"); label.DoubleClick += Label_DoubleClick; }
private void AddToPupilLabel(PupilLabel label) { pupilsLabels.Add(label); label.Text = String.Format($"{label.pupil.FirstName} {label.pupil.LastName} {label.pupil.Email}"); }