using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace IndianHealthService.ClinicalScheduling
{
///
/// This form displays the RPC Events found in RPCLogger
///
public partial class RPCLoggerView : Form
{
public RPCLoggerView()
{
InitializeComponent();
lstRPCEvents.BeginUpdate(); // Stop redrawing
foreach (var eventItem in CGDocumentManager.Current.RPCLogger.Logger) lstRPCEvents.Items.Add(eventItem); // Add the stuff
lstRPCEvents.EndUpdate(); // Draw Again
//We are interested in event HaveMoreData. Each time it happens, it means we have an extra item we need to add.
CGDocumentManager.Current.RPCLogger.HaveMoreData += new EventHandler(RPCLogger_HaveMoreData);
}
// Dummmy delegate for the method below to use in this.Invoke
delegate void dAny(object s, RPCLogger.EventToLog e);
///
/// Adds the new RPC event to Listbox
///
/// this is the RPCLogger Object. It's not used
/// That's the custom logged event.
void RPCLogger_HaveMoreData(object sender, RPCLogger.EventToLog e)
{
if (this.InvokeRequired)
{
dAny d = new dAny(this.RPCLogger_HaveMoreData);
this.Invoke(d, new object[] { sender, e });
return;
}
lstRPCEvents.Items.Add(e);
}
///
/// Puts the text of the event in the text box
///
/// useless
/// useless
private void lstRPCEvents_SelectedIndexChanged(object sender, EventArgs e)
{
RPCLogger.EventToLog l = lstRPCEvents.SelectedItem as RPCLogger.EventToLog;
if (l == null) return;
txtRPCEvent.Text = l.Lines + "\r\n" + l.Exception ?? "";
}
}
}