public void СustomText(string text, Color color, FontStyle fontStyle) { if (!IsClosed) { Invoke(new Action(() => { RTBoxLog.AppendText(text, color, fontStyle); })); } }
private void BTSaveLog_Click(object sender, EventArgs e) { try { using var saveDialog = new SaveFileDialog { FileName = $"Табель ОТИЗ ({DateTime.Now:dd.MM.yyyy hh.mm.ss})", Filter = "Текст RTF(*.rtf)|*.rtf", DefaultExt = "rtf" }; if (saveDialog.ShowDialog() == DialogResult.OK) { RTBoxLog.SaveFile(saveDialog.FileName, RichTextBoxStreamType.RichText); MessageBox.Show(this, "Файл сохранен.", "Выполнено", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { MessageBox.Show(this, $"Ошибка сохранения:\r\n{ex.Message}", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } }