//example of receiving messagaes from the generics form private void OnGenericSend(object sender, ExampleEventArgs e) { txtConsole.Clear(); string message = "Sent Date: " + e.SendDate.ToLongDateString() + Environment.NewLine; message += e.SendMessage; txtConsole.Text = message; }
private void btnSendMessage_Click(object sender, EventArgs e) { if (txtMessage.Text.Length > 0) { ExampleEventArgs eArg = new ExampleEventArgs(); eArg.SendDate = DateTime.Now; eArg.SendMessage = txtMessage.Text; //now raise the event OnSendMessage(eArg); } }
//this is the method that is called in this form to raise the event! protected virtual void OnSendMessage(ExampleEventArgs e) { try { EventHandler <ExampleEventArgs> handler = SendMessage; if (handler != null) { handler(this, e); } }catch { } }
/// <summary> /// Raises the <see cref="E:ExampleProcessed" /> event. /// </summary> /// <param name="e">The <see cref="ExampleEventArgs"/> instance containing the event data.</param> void On_ExampleProcessed(ExampleEventArgs e) { this.InvokeAction(() => { var selectedNode = treeSpecs.SelectedNode; if (pbTestProgress.Value < pbTestProgress.Maximum) { pbTestProgress.Value++; } if (selectedNode != null && _allCurrentSpecNames != null) { var matchingExample = _allCurrentSpecNames.FirstOrDefault(t => t.Name == e.Example.UniqueName); if (matchingExample != null) { _testCount++; string resultType = e.Example.Exception != null ? ImageTypes.FAILED : ImageTypes.PASSED; matchingExample.ImageKey = matchingExample.SelectedImageKey = resultType; TraverseTillRoot(matchingExample, resultType); if (e.Example.Exception != null) { _failedCount++; var errorList = GetErrorItems(e.Example); errorList.ForEach(itm => lstErrors.Items.Add(itm)); var errorGroup = new ListViewGroup("Example: " + e.Example.Spec); errorGroup.Name = e.Example.UniqueName; lstErrors.Groups.Add(errorGroup); errorList.ForEach(itm => itm.Group = errorGroup); _exceptions.Add(e.Example.UniqueName, e.Example.Exception.ExampleException.StackTrace); } lblFileName.Text = string.Format("Running - {0}/{1}/{2}", selectedNode.Text, e.Example.Context.Name, e.Example.Spec); } } }); }