Pregunta

I have a sample program from Aforge library. It uses a kind of logging system (I assume it is like a StringBuilder or something...).

In the samples, here and there I see something like:

IImageProcessingLog _log = new ImageProcessingLog();

//some code
_log.AddMessage("Image size: " + _bitmap.Width + " x " + _bitmap.Height);
//more codes and usage of `_log`

Clearly this is some sort of string. Later I want to dump all this data into a TextBox. I tried to do _log.ToString() but it just returns the object name.

Any idea how can I use this log feature?

Thanks

¿Fue útil?

Solución

The ImageProcessingLog class has a property called Messages. Messages is of type List<string>. So, to get all logged messages simply iterate the elements of the messages list.

TextBox tbMessages = ...;

ImageProcessingLog log = new ImageProcessingLog();

log.AddMessage(...);

foreach(string msg in log.Messages)
{
  tbMessages.Text += msg;      
}

Unfortunately the IImageProcessingLog interface does not have such a property. A possible workaround would be to create an adapter class/interface which wraps the ImageProcessingLog class.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top