A
Anders Eriksson
I have an application that has a dataclass which have an event for error
messages
// Event handler for passing error messages to GUI
public delegate void ErrorMsgHandler(object Sender, ErrorMsgArgs e);
public event ErrorMsgHandler ErrorMsgEvent;
public class ErrorMsgArgs : EventArgs
{
/// <summary>
/// Initializes a new instance of the <see cref="ErrorMsgArgs"/> class.
/// </summary>
/// <param name="s">The s.</param>
public ErrorMsgArgs(string s) { Text = s; }
/// <summary>
/// Gets the text.
/// </summary>
public String Text { get; private set; } // readonly
}
private void RaiseErrorMsgEvent(string msg)
{
// Raise the event by using the () operator.
if (ErrorMsgEvent != null)
ErrorMsgEvent(this, new ErrorMsgArgs(msg));
}
This worked perfectly when I used the GUI class(WinForm or WPF) to
connect to the ErrorMsgEvent
le.ErrorMsgEvent += new LEngine.ErrorMsgHandler(le_ErrorMsgEvent);
le is the object that contains the event...
I have now put a class between the dataclass and the GUI class, it's
called DCMarkerScript. This so that the GUI class don't access the data
directly.
How do I forward the ErrorMsgEvent from the dataclass via the
DCMarkerScript class to the GUI Class?
// Anders
messages
// Event handler for passing error messages to GUI
public delegate void ErrorMsgHandler(object Sender, ErrorMsgArgs e);
public event ErrorMsgHandler ErrorMsgEvent;
public class ErrorMsgArgs : EventArgs
{
/// <summary>
/// Initializes a new instance of the <see cref="ErrorMsgArgs"/> class.
/// </summary>
/// <param name="s">The s.</param>
public ErrorMsgArgs(string s) { Text = s; }
/// <summary>
/// Gets the text.
/// </summary>
public String Text { get; private set; } // readonly
}
private void RaiseErrorMsgEvent(string msg)
{
// Raise the event by using the () operator.
if (ErrorMsgEvent != null)
ErrorMsgEvent(this, new ErrorMsgArgs(msg));
}
This worked perfectly when I used the GUI class(WinForm or WPF) to
connect to the ErrorMsgEvent
le.ErrorMsgEvent += new LEngine.ErrorMsgHandler(le_ErrorMsgEvent);
le is the object that contains the event...
I have now put a class between the dataclass and the GUI class, it's
called DCMarkerScript. This so that the GUI class don't access the data
directly.
How do I forward the ErrorMsgEvent from the dataclass via the
DCMarkerScript class to the GUI Class?
// Anders