# HG changeset patch # User cin # Date 1397689553 -14400 # Node ID d10034588e38cfa0c89d484914695cc6eca2b3dc # Parent 3ba6778ed3364554405562bae4c2ac3cd89c5b2f initial work on interactive logger diff -r 3ba6778ed336 -r d10034588e38 .hgignore --- a/.hgignore Wed Apr 16 00:33:09 2014 +0400 +++ b/.hgignore Thu Apr 17 03:05:53 2014 +0400 @@ -11,3 +11,5 @@ Implab.Fx.Test/bin/ Implab.Fx.Test/obj/ _ReSharper.Implab/ +Implab.Diagnostics.Interactive/bin/ +Implab.Diagnostics.Interactive/obj/ diff -r 3ba6778ed336 -r d10034588e38 Implab.Diagnostics.Interactive/Implab.Diagnostics.Interactive.csproj --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Implab.Diagnostics.Interactive/Implab.Diagnostics.Interactive.csproj Thu Apr 17 03:05:53 2014 +0400 @@ -0,0 +1,83 @@ + + + + + Debug + AnyCPU + {1DB7DB0C-8AA9-484B-A681-33AE94038391} + Library + Properties + Implab.Diagnostics.Interactive + Implab.Diagnostics.Interactive + v4.5 + 512 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + Form + + + TraceForm.cs + + + UserControl + + + TraceViewControl.cs + + + + + + {f550f1f8-8746-4ad0-9614-855f4c4b7f05} + Implab + + + + + TraceForm.cs + + + TraceViewControl.cs + + + + + \ No newline at end of file diff -r 3ba6778ed336 -r d10034588e38 Implab.Diagnostics.Interactive/InteractiveTracer.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Implab.Diagnostics.Interactive/InteractiveTracer.cs Thu Apr 17 03:05:53 2014 +0400 @@ -0,0 +1,55 @@ +using Implab.Parallels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace Implab.Diagnostics.Interactive +{ + public class InteractiveTracer: Disposable + { + TraceForm m_form; + SynchronizationContext m_syncGuiThread; + readonly IPromiseBase m_completed; + readonly Promise m_started = new Promise(); + + public InteractiveTracer() { + m_completed = AsyncPool.InvokeNewThread(() => { + GuiThread(); + return 0; + }); + + m_started.Join(); + } + + void GuiThread() { + m_form = new TraceForm(); // will create SynchronizationContext + m_syncGuiThread = SynchronizationContext.Current; + m_started.Resolve(); + Application.Run(); + } + + public void ShowForm() { + m_syncGuiThread.Post(x => m_form.Show(), null); + } + + public void HideForm() { + m_syncGuiThread.Post(x => m_form.Hide(), null); + } + + void Terminate() { + m_syncGuiThread.Post(x => Application.ExitThread(), null); + } + + protected override void Dispose(bool disposing) { + if (disposing) { + Terminate(); + m_completed.Join(); + } + base.Dispose(disposing); + } + } +} diff -r 3ba6778ed336 -r d10034588e38 Implab.Diagnostics.Interactive/Properties/AssemblyInfo.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Implab.Diagnostics.Interactive/Properties/AssemblyInfo.cs Thu Apr 17 03:05:53 2014 +0400 @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Implab.Diagnostics.Interactive")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Implab.Diagnostics.Interactive")] +[assembly: AssemblyCopyright("Copyright © 2014")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("1c156c51-4884-43b2-a823-d86313872e82")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff -r 3ba6778ed336 -r d10034588e38 Implab.Diagnostics.Interactive/TextStyle.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Implab.Diagnostics.Interactive/TextStyle.cs Thu Apr 17 03:05:53 2014 +0400 @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Implab.Diagnostics.Interactive { + class TextStyle { + public Color TextColor { + get; + set; + } + + public FontStyle FontStyle { + get; + set; + } + + public int PaddingLeft { + get; + set; + } + } +} diff -r 3ba6778ed336 -r d10034588e38 Implab.Diagnostics.Interactive/TraceForm.Designer.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Implab.Diagnostics.Interactive/TraceForm.Designer.cs Thu Apr 17 03:05:53 2014 +0400 @@ -0,0 +1,52 @@ +namespace Implab.Diagnostics.Interactive { + partial class TraceForm { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) { + if (disposing && (components != null)) { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() { + this.traceViewControl1 = new Implab.Diagnostics.Interactive.TraceViewControl(); + this.SuspendLayout(); + // + // traceViewControl1 + // + this.traceViewControl1.Location = new System.Drawing.Point(13, 13); + this.traceViewControl1.Name = "traceViewControl1"; + this.traceViewControl1.Size = new System.Drawing.Size(267, 248); + this.traceViewControl1.TabIndex = 0; + // + // TraceForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(292, 273); + this.Controls.Add(this.traceViewControl1); + this.Name = "TraceForm"; + this.Text = "TraceForm"; + this.ResumeLayout(false); + + } + + #endregion + + private TraceViewControl traceViewControl1; + } +} \ No newline at end of file diff -r 3ba6778ed336 -r d10034588e38 Implab.Diagnostics.Interactive/TraceForm.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Implab.Diagnostics.Interactive/TraceForm.cs Thu Apr 17 03:05:53 2014 +0400 @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace Implab.Diagnostics.Interactive { + public partial class TraceForm : Form { + public TraceForm() { + InitializeComponent(); + } + + protected override void OnFormClosing(FormClosingEventArgs e) { + base.OnFormClosing(e); + if (!e.Cancel && e.CloseReason == CloseReason.UserClosing) { + e.Cancel = true; + Hide(); + } + } + } +} diff -r 3ba6778ed336 -r d10034588e38 Implab.Diagnostics.Interactive/TraceForm.resx --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Implab.Diagnostics.Interactive/TraceForm.resx Thu Apr 17 03:05:53 2014 +0400 @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff -r 3ba6778ed336 -r d10034588e38 Implab.Diagnostics.Interactive/TraceViewControl.Designer.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Implab.Diagnostics.Interactive/TraceViewControl.Designer.cs Thu Apr 17 03:05:53 2014 +0400 @@ -0,0 +1,40 @@ +namespace Implab.Diagnostics.Interactive { + partial class TraceViewControl { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) { + if (disposing && (components != null)) { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() { + this.SuspendLayout(); + // + // TraceViewControl + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.BackColor = System.Drawing.SystemColors.Window; + this.Name = "TraceViewControl"; + this.ResumeLayout(false); + + } + + #endregion + } +} diff -r 3ba6778ed336 -r d10034588e38 Implab.Diagnostics.Interactive/TraceViewControl.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Implab.Diagnostics.Interactive/TraceViewControl.cs Thu Apr 17 03:05:53 2014 +0400 @@ -0,0 +1,55 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Data; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace Implab.Diagnostics.Interactive { + public partial class TraceViewControl : UserControl { + int m_maxEvents = 1000; + + string m_status = "ready"; + + readonly LinkedList m_events = new LinkedList(); + public TraceViewControl() { + InitializeComponent(); + + var ticks = Environment.TickCount; + + for (int i = 0; i < 1333; i++) { + AddViewItem(new TraceViewItem { + indent = i % 4, + message = String.Format("Auto generated {0}", i), + thread = 2, + timestamp = ticks + i*10 + }); + } + } + + public void AddViewItem(TraceViewItem item) { + m_events.AddLast(item); + if (m_events.Count > m_maxEvents) + m_events.RemoveFirst(); + } + + protected override void OnPaint(PaintEventArgs e) { + base.OnPaint(e); + + if (m_status != null) + e.Graphics.DrawString(m_status, DefaultFont, Brushes.Black, 0, 0); + + } + + protected override void OnMouseMove(MouseEventArgs e) { + base.OnMouseMove(e); + + m_status = String.Format("({0},{1})", e.X, e.Y); + Invalidate(); + } + + } +} diff -r 3ba6778ed336 -r d10034588e38 Implab.Diagnostics.Interactive/TraceViewControl.resx --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Implab.Diagnostics.Interactive/TraceViewControl.resx Thu Apr 17 03:05:53 2014 +0400 @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff -r 3ba6778ed336 -r d10034588e38 Implab.Diagnostics.Interactive/TraceViewItem.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Implab.Diagnostics.Interactive/TraceViewItem.cs Thu Apr 17 03:05:53 2014 +0400 @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Implab.Diagnostics.Interactive { + public struct TraceViewItem { + public string message; + public int timestamp; + public int indent; + public int thread; + } +} diff -r 3ba6778ed336 -r d10034588e38 Implab/Implab.csproj --- a/Implab/Implab.csproj Wed Apr 16 00:33:09 2014 +0400 +++ b/Implab/Implab.csproj Thu Apr 17 03:05:53 2014 +0400 @@ -52,7 +52,6 @@ - diff -r 3ba6778ed336 -r d10034588e38 Implab/ManagedPromise.cs --- a/Implab/ManagedPromise.cs Wed Apr 16 00:33:09 2014 +0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,11 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace Implab { - - /*public class ManagedPromise: Promise, ITaskController, IProgressNotifier { - - }*/ -} diff -r 3ba6778ed336 -r d10034588e38 Implab/Parallels/AsyncPool.cs --- a/Implab/Parallels/AsyncPool.cs Wed Apr 16 00:33:09 2014 +0400 +++ b/Implab/Parallels/AsyncPool.cs Thu Apr 17 03:05:53 2014 +0400 @@ -12,7 +12,7 @@ /// public static class AsyncPool { - public static Promise Invoke(Func func) { + public static IPromise Invoke(Func func) { var p = new Promise(); var caller = TraceContext.Snapshot(); @@ -28,7 +28,7 @@ return p; } - public static Promise InvokeNewThread(Func func) { + public static IPromise InvokeNewThread(Func func) { var p = new Promise(); var caller = TraceContext.Snapshot();