Example #1
0
 		private void UpdateControl(LoggingEvent loggingEvent)
 		{
 			// There may be performance issues if the buffer gets too long
 			// So periodically clear the buffer
 			if (richTextBox.TextLength > maxTextLength)
 			{
 				richTextBox.Clear();
 				richTextBox.AppendText(string.Format("(Cleared log length max: {0})\n", maxTextLength));
 			}
 			
 			// look for a style mapping
 			LevelTextStyle selectedStyle = levelMapping.Lookup(loggingEvent.Level) as LevelTextStyle;
 			if (selectedStyle != null)
 			{
 				// set the colors of the text about to be appended
 				richTextBox.SelectionBackColor = selectedStyle.BackColor;
 				richTextBox.SelectionColor = selectedStyle.TextColor;
 				
 				// alter selection font as much as necessary
 				// missing settings are replaced by the font settings on the control
 				if (selectedStyle.Font != null)
 				{
 					// set Font Family, size and styles
 					richTextBox.SelectionFont = selectedStyle.Font;
 				}
 				else if (selectedStyle.PointSize > 0 && richTextBox.Font.SizeInPoints != selectedStyle.PointSize)
 				{
 					// use control's font family, set size and styles
 					float size = selectedStyle.PointSize > 0.0f ? selectedStyle.PointSize : richTextBox.Font.SizeInPoints;
 					richTextBox.SelectionFont = new Font(richTextBox.Font.FontFamily.Name, size, selectedStyle.FontStyle);
 				}
 				else if (richTextBox.Font.Style != selectedStyle.FontStyle)
 				{
 					// use control's font family and size, set styles
 					richTextBox.SelectionFont = new Font(richTextBox.Font, selectedStyle.FontStyle);
 				}
 			}
 			richTextBox.AppendText(RenderLoggingEvent(loggingEvent));
 		}
Example #2
0
 		public void AddMapping(LevelTextStyle mapping)
         {
             levelMapping.Add(mapping);
         }