Open kip0x00 opened 1 day ago
I don't think it's necessary to update the font size via the Serilog sink. You could try the following to dynamically change the font size, assuming your RichTextBox is named richTextBox1
:
public void ChangeFontSize(int fontSize)
{
// Change existing text
richTextBox1.SelectAll();
richTextBox1.SelectionFont = new Font(richTextBox1.Font.FontFamily, fontSize);
// Change default font for new text
richTextBox1.Font = new Font(richTextBox1.Font.FontFamily, fontSize);
// Clear selection
richTextBox1.SelectionStart = richTextBox1.TextLength;
richTextBox1.SelectionLength = 0;
}
Does this work for you?
Thanks for the answer! Unfortunately, this does not work properly, I did about that, the problem is as follows: if you select an existing text and apply a new font size to it, it works:
RichTextBox Log.Select All();
richTextBoxLog.Selection Font = new Font(richTextBoxLog.Font.FontFamily, fontSize);
but further output continues with the previous font size, and if you do this:
richTextBoxLog.Font = new Font(richTextBoxLog.Font.FontFamily, fontSize);
that previous formatting breaks down (everything becomes monochrome) and further output also continues with the previous font size.
Hi! I tried your control, it's fantastic! Thank you for spending so much time and effort! I like everything so far, but I'm faced with one problem that I can't solve myself, I have very little programming experience. I needed to change the font size at any time during the operation of the program, just as, for example, I can change the number of lines displayed. Unfortunately, I have not been able to solve this problem. Could you help me with this? PS I'm sorry for my English.