- Visual C++源码
- Visual Basic源码
- C++ Builder源码
- Java源码
- Delphi源码
- C/C++源码
- PHP源码
- Perl源码
- Python源码
- Asm源码
- Pascal源码
- Borland C++源码
- Others源码
- SQL源码
- VBScript源码
- JavaScript源码
- ASP/ASPX源码
- C#源码
- Flash/ActionScript源码
- matlab源码
- PowerBuilder源码
- LabView源码
- Flex源码
- MathCAD源码
- VBA源码
- IDL源码
- Lisp/Scheme源码
- VHDL源码
- Objective-C源码
- Fortran源码
- tcl/tk源码
- QT源码
- using System;
- using System.Drawing;
- using System.Collections;
- using System.ComponentModel;
- using System.Windows.Forms;
- using System.Data;
- namespace EventListener
- {
- /// <summary>
- /// Summary description for Form1.
- /// </summary>
- public class EventListenerForm : System.Windows.Forms.Form
- {
- private System.Windows.Forms.ListBox listBoxEvents;
- private System.Windows.Forms.Button buttonExit;
- private System.Diagnostics.EventLog eventLogQuote;
- /// <summary>
- /// Required designer variable.
- /// </summary>
- private System.ComponentModel.Container components = null;
- public EventListenerForm()
- {
- //
- // Required for Windows Form Designer support
- //
- InitializeComponent();
- //
- // TODO: Add any constructor code after InitializeComponent call
- //
- }
- /// <summary>
- /// Clean up any resources being used.
- /// </summary>
- protected override void Dispose( bool disposing )
- {
- if( disposing )
- {
- if (components != null)
- {
- components.Dispose();
- }
- }
- base.Dispose( disposing );
- }
- #region Windows Form Designer generated code
- /// <summary>
- /// Required method for Designer support - do not modify
- /// the contents of this method with the code editor.
- /// </summary>
- private void InitializeComponent()
- {
- this.listBoxEvents = new System.Windows.Forms.ListBox();
- this.buttonExit = new System.Windows.Forms.Button();
- this.eventLogQuote = new System.Diagnostics.EventLog();
- ((System.ComponentModel.ISupportInitialize)(this.eventLogQuote)).BeginInit();
- this.SuspendLayout();
- //
- // listBoxEvents
- //
- this.listBoxEvents.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
- | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.listBoxEvents.Location = new System.Drawing.Point(8, 16);
- this.listBoxEvents.Name = "listBoxEvents";
- this.listBoxEvents.Size = new System.Drawing.Size(280, 160);
- this.listBoxEvents.TabIndex = 0;
- //
- // buttonExit
- //
- this.buttonExit.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
- this.buttonExit.Location = new System.Drawing.Point(104, 192);
- this.buttonExit.Name = "buttonExit";
- this.buttonExit.TabIndex = 1;
- this.buttonExit.Text = "Exit";
- this.buttonExit.Click += new System.EventHandler(this.buttonExit_Click);
- //
- // eventLogQuote
- //
- this.eventLogQuote.EnableRaisingEvents = true;
- this.eventLogQuote.Log = "Application";
- this.eventLogQuote.Source = "QuoteService";
- this.eventLogQuote.SynchronizingObject = this;
- this.eventLogQuote.EntryWritten += new System.Diagnostics.EntryWrittenEventHandler(this.OnEntryWritten);
- //
- // EventListenerForm
- //
- this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
- this.ClientSize = new System.Drawing.Size(296, 221);
- this.Controls.Add(this.buttonExit);
- this.Controls.Add(this.listBoxEvents);
- this.Name = "EventListenerForm";
- this.Text = "Quote Service Event Listener";
- ((System.ComponentModel.ISupportInitialize)(this.eventLogQuote)).EndInit();
- this.ResumeLayout(false);
- }
- #endregion
- /// <summary>
- /// The main entry point for the application.
- /// </summary>
- [STAThread]
- static void Main()
- {
- Application.Run(new EventListenerForm());
- }
- private void OnEntryWritten(object sender, System.Diagnostics.EntryWrittenEventArgs e)
- {
- DateTime time = e.Entry.TimeGenerated;
- string message = e.Entry.Message;
- listBoxEvents.Items.Add(time + " " + message);
- }
- private void buttonExit_Click(object sender, System.EventArgs e)
- {
- Application.Exit();
- }
- }
- }