private void updateList() { lvLessons.Items.Clear(); for (int i = 0; i < FileLesson.Index; i++) { string[] lines = FileLesson.getLine(i); ListViewItem item = new ListViewItem(lines); if (i % 2 == 0) { item.BackColor = Color.FromArgb(100, 166, 186); } lvLessons.Items.Add(item); } }
private void btnSave_Click(object sender, EventArgs e) { btnCalculate_Click(sender, e); lessonForm lessonForm = new lessonForm(); lessonForm.txtGrade.Text = lblGrade.Text; lessonForm.txtLetter.Text = lblLetterGrade.Text; if (lessonForm.ShowDialog() == DialogResult.OK) { string name = lessonForm.txtLessonName.Text.Trim(); string letter = getLetterGrade(averageGrade); FileLesson.writeLesson(name, averageGrade, letter); } }
private void toolClearAll_Click(object sender, EventArgs e) { if (FileLesson.Index == 0) { return; } if (MessageBox.Show("Are you sure you want to remove all lessons?", "Warning", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning) == DialogResult.Yes) { foreach (ListViewItem item in lvLessons.Items) { FileLesson.removeLesson(item.Index); lvLessons.Items.Remove(item); } } }
private void toolAddLesson_Click(object sender, EventArgs e) { lessonForm lessonForm = new lessonForm(); lessonForm.txtGrade.Enabled = true; lessonForm.txtGrade.TabStop = true; lessonForm.txtGrade.ReadOnly = false; if (lessonForm.ShowDialog() == DialogResult.OK) { string name = lessonForm.txtLessonName.Text.Trim(); double grade = double.Parse(lessonForm.txtGrade.Text.Trim()); string letter = lessonForm.txtLetter.Text; FileLesson.writeLesson(name, grade, letter); } updateList(); }
private void toolDeleteLesson_Click(object sender, EventArgs e) { int selectedCount = lvLessons.SelectedIndices.Count; if (selectedCount <= 0) { return; } if (MessageBox.Show("Are you sure you want to remove selected (" + selectedCount + ") lessons?", "Warning", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning) == DialogResult.Yes) { foreach (ListViewItem item in lvLessons.SelectedItems) { FileLesson.removeLesson(item.Index); lvLessons.Items.Remove(item); } } }
private void mainForm_Load(object sender, EventArgs e) { #region Dynamic RoundButtons added to panels btnAddRow.Click += BtnAddRow_Click; panelAddRow.Controls.Add(btnAddRow); btnRemoveRow.Click += BtnRemoveRow_Click; panelRemoveRow.Controls.Add(btnRemoveRow); btnResetValue.Click += BtnResetValues_Click; panelResetValue.Controls.Add(btnResetValue); #endregion #region Tab Index tabIndex = nmrWeight2.TabIndex; panelAddRow.TabIndex = 1 + tabIndex; panelRemoveRow.TabIndex = 2 + tabIndex; panelResetValue.TabIndex = 3 + tabIndex; btnCalculate.TabIndex = 4 + tabIndex; btnSave.TabIndex = 5 + tabIndex; #endregion FileLesson.checkFiles(); }