Код формы с лекциями

namespace Kursach

{public enum Modes { Lecture, ChooseLecture }

public partial class LecturesForm : Form

{

private ChoiseButtons buttons;

private DirectoryInfo[] lecturesDirectories;

private DirectoryInfo currentLectureDirectory;

private Point startPosition = new Point(5, 15);

private Size buttonSize = new Size(200, 30);

private int distance = 5;

private Modes currentMode;

public LecturesForm(string folderPath)

{

InitializeComponent();

buttons = new ChoiseButtons(ButtonTypes.RadioButton, startPosition.X, startPosition.Y, buttonSize.Width, buttonSize.Height, distance);

DirectoryInfo directory = new DirectoryInfo(folderPath);

lecturesDirectories = directory.GetDirectories();

foreach (DirectoryInfo lectureDirectory in lecturesDirectories)

{

groupBoxLectures.Controls.Add(buttons.AddNextButton(lectureDirectory.Name));

}

SetChooseLectureMode();

}

private void button1_Click(object sender, EventArgs e)

{

if (currentMode == Modes.ChooseLecture)

{

List<int> selected = buttons.GetSelected();

if (selected.Count == 0)

{

MessageBox.Show("Выберите лекцию!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Information);

return;

}

else

{

currentLectureDirectory = lecturesDirectories[selected[0]];

try

{

FileStream fileStream = new FileStream(currentLectureDirectory.FullName + "\\lecture", FileMode.Open);

StreamReader streamReader = new StreamReader(fileStream);

richTextBoxLecture.Text = streamReader.ReadToEnd();

streamReader.Close();

fileStream.Close();

}

catch

{

TestForm.ShowCriticalErrorMessage("Не найден файл с лекцией\nПриложение будет закрыто");

}

}

SetLecturesMode();

}

else

{

InitForm form = new InitForm();

if (form.ShowDialog() == DialogResult.OK)

{

new TestForm(currentLectureDirectory.FullName, currentLectureDirectory.Name, form.UserName, this).Show();

}

}

}

private void SetLecturesMode()

{

currentMode = Modes.Lecture;

buttonChoose.Text = "Тест";

richTextBoxLecture.Visible = true;

linkLabelResults.Visible = false;

groupBoxLectures.Visible = false;

richTextBoxLecture.Dock = DockStyle.Fill;

linkLabelBack.Visible = true;

this.MaximumSize = new Size();

this.MinimumSize = new Size();

this.Size = new Size(739, 419);

this.MaximizeBox = true;

this.Text = currentLectureDirectory.Name;

buttonChoose.Select();

}

private void SetChooseLectureMode()

{

currentMode = Modes.ChooseLecture;

linkLabelResults.Visible = true;

buttonChoose.Text = "Выбрать";

richTextBoxLecture.Visible = false;

groupBoxLectures.Visible = true;

linkLabelBack.Visible = false;

this.Text = "Выбор лекции";

this.MaximumSize = new Size(739, 419);

this.MinimumSize = new Size(739, 419);

this.Size = new Size(739, 419);

this.MaximizeBox = false;

}

private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)

{

SetChooseLectureMode();

}

private void LecturesForm_VisibleChanged(object sender, EventArgs e)

{

if (Visible == true)

{

SetChooseLectureMode();

}

}

private void linkLabel1_LinkClicked_1(object sender, LinkLabelLinkClickedEventArgs e)

{

new ResultsForm().ShowDialog();

}

private void panel2_Paint(object sender, PaintEventArgs e)

{

}

}

}