namespace Devoid { using System; using System.ComponentModel; using System.Drawing; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Windows.Forms; public class frmLog : Form { private IContainer components = null; private TextBox txtLog; public frmLog() { this.InitializeComponent(); } public void Clear() { if (!base.InvokeRequired) { this.txtLog.Clear(); this.txtLog.AppendText("-- Devoid "); this.txtLog.AppendText(Assembly.GetExecutingAssembly().GetName().Version.ToString()); this.txtLog.AppendText("\r\n\r\n"); this.FlashWindow(); } } protected override void Dispose(bool disposing) { if (disposing && (this.components != null)) { this.components.Dispose(); } base.Dispose(disposing); } public void FlashWindow() { if (!this.Focused) { FlashWindow(base.Handle, true); } } [DllImport("user32.dll")] private static extern bool FlashWindow(IntPtr hwnd, bool bInvert); private void frmLog_FormClosing(object sender, FormClosingEventArgs e) { e.Cancel = true; this.Clear(); } private void frmLog_Load(object sender, EventArgs e) { this.Clear(); } private void InitializeComponent() { this.txtLog = new TextBox(); base.SuspendLayout(); this.txtLog.BackColor = SystemColors.Window; this.txtLog.Dock = DockStyle.Fill; this.txtLog.Location = new Point(0, 0); this.txtLog.Multiline = true; this.txtLog.Name = "txtLog"; this.txtLog.ReadOnly = true; this.txtLog.ScrollBars = ScrollBars.Vertical; this.txtLog.Size = new Size(0x252, 0x127); this.txtLog.TabIndex = 0; base.AutoScaleDimensions = new SizeF(6f, 13f); base.AutoScaleMode = AutoScaleMode.Font; base.ClientSize = new Size(0x252, 0x127); base.Controls.Add(this.txtLog); base.FormBorderStyle = FormBorderStyle.SizableToolWindow; base.Name = "frmLog"; this.Text = "M"; base.Load += new EventHandler(this.frmLog_Load); base.FormClosing += new FormClosingEventHandler(this.frmLog_FormClosing); base.ResumeLayout(false); base.PerformLayout(); } public void Log(string sText) { if (base.InvokeRequired) { base.BeginInvoke(new CrossThreadLogger(this.Log), new object[] { sText }); } else { this.txtLog.AppendText("-- ["); this.txtLog.AppendText(DateTime.Now.ToString()); this.txtLog.AppendText("] "); this.txtLog.AppendText(sText); this.txtLog.AppendText("\r\n"); this.FlashWindow(); } } private delegate void CrossThreadLogger(string Text); } }