diff --git a/src/AddIns/Misc/Profiler/Frontend/AddIn/Src/Dialogs/ProfilerControlWindow.xaml b/src/AddIns/Misc/Profiler/Frontend/AddIn/Src/Dialogs/ProfilerControlWindow.xaml index 9472efd7b7..37813f4e16 100644 --- a/src/AddIns/Misc/Profiler/Frontend/AddIn/Src/Dialogs/ProfilerControlWindow.xaml +++ b/src/AddIns/Misc/Profiler/Frontend/AddIn/Src/Dialogs/ProfilerControlWindow.xaml @@ -11,7 +11,7 @@ - + - + \ No newline at end of file diff --git a/src/AddIns/Misc/Profiler/Frontend/Controls/ExtendedTimeLineControl.xaml.cs b/src/AddIns/Misc/Profiler/Frontend/Controls/ExtendedTimeLineControl.xaml.cs index ec41272a17..48fcb4af07 100644 --- a/src/AddIns/Misc/Profiler/Frontend/Controls/ExtendedTimeLineControl.xaml.cs +++ b/src/AddIns/Misc/Profiler/Frontend/Controls/ExtendedTimeLineControl.xaml.cs @@ -59,9 +59,7 @@ namespace ICSharpCode.Profiler.Controls protected virtual void OnRangeChanged(RangeEventArgs e) { if (RangeChanged != null) - { RangeChanged(this, e); - } } void Update() @@ -83,9 +81,10 @@ namespace ICSharpCode.Profiler.Controls this.minLabel.Text = (selectedPerformanceCounter.MinValue ?? (values.Any() ? values.Min() : 0)).ToString("0"); this.unitLabel.Text = this.timeLine.Unit = selectedPerformanceCounter.Unit; + this.timeLine.Format = selectedPerformanceCounter.Format; for (int i = 0; i < values.Length; i++) - segments.Add(new TimeLineSegment() { Value = values[i], TimeOffset = 0, DisplayMarker = markers[i] }); + segments.Add(new TimeLineSegment() { Value = values[i], TimeOffset = 0, DisplayMarker = markers[i], Events = provider.GetEventDataEntries(i) }); this.timeLine.ValuesList.AddRange(segments); } diff --git a/src/AddIns/Misc/Profiler/Frontend/Controls/TimeLineControl.cs b/src/AddIns/Misc/Profiler/Frontend/Controls/TimeLineControl.cs index 29a0ad306c..b5eb17aaa8 100644 --- a/src/AddIns/Misc/Profiler/Frontend/Controls/TimeLineControl.cs +++ b/src/AddIns/Misc/Profiler/Frontend/Controls/TimeLineControl.cs @@ -6,8 +6,8 @@ // using System; -using System.Collections.Generic; using System.Collections.ObjectModel; +using System.Collections.Generic; using System.Diagnostics; using System.Windows; using System.Windows.Controls; @@ -16,12 +16,15 @@ using System.Windows.Input; using System.Windows.Media; using System.Windows.Threading; +using ICSharpCode.Profiler.Controller.Data; + namespace ICSharpCode.Profiler.Controls { public class TimeLineSegment { public float Value { get; set; } public bool DisplayMarker { get; set; } public long TimeOffset { get; set; } + public EventDataEntry[] Events { get; set; } } public class TimeLineControl : FrameworkElement @@ -46,6 +49,8 @@ namespace ICSharpCode.Profiler.Controls public string Unit { get; set; } + public string Format { get; set; } + public int SelectedEndIndex { get { return selectedEndIndex; } @@ -86,12 +91,6 @@ namespace ICSharpCode.Profiler.Controls return new Size(Math.Max(this.pieceWidth * this.valuesList.Count + 1, calculatedSize.Width), calculatedSize.Height + 10); } - protected override void OnToolTipOpening(ToolTipEventArgs e) - { - Console.WriteLine("tooltip"); - base.OnToolTipOpening(e); - } - const int offset = 0; const int offsetFromTop = 40; @@ -117,6 +116,7 @@ namespace ICSharpCode.Profiler.Controls for (int i = 0; i < this.valuesList.Count; i++) { double x = this.pieceWidth / 2.0 + this.pieceWidth * i; + // TODO : support MinValues other than 0 double y = offsetFromTop + (maxHeight - maxHeight * (this.valuesList[i].Value / this.MaxValue)); points.Add(new Point(x, y)); @@ -134,24 +134,39 @@ namespace ICSharpCode.Profiler.Controls Brush b = new LinearGradientBrush(Colors.Red, Colors.Orange, 90); - drawingContext.DrawRectangle(Brushes.White, new Pen(Brushes.White, 1), new Rect(new Point(0, offsetFromTop), this.RenderSize)); + drawingContext.DrawRectangle(Brushes.White, new Pen(Brushes.White, 1), new Rect(new Point(0, 0), this.RenderSize)); var p = new Pen(Brushes.DarkRed, 2); - drawingContext.DrawGeometry(b, new Pen(b, 3), geometry); + drawingContext.DrawGeometry(b, new Pen(b, 1), geometry); for (int i = 0; i < this.valuesList.Count; i++) { if (this.valuesList[i].DisplayMarker) drawingContext.DrawLine(p, new Point(pieceWidth * i, offsetFromTop), new Point(pieceWidth * i, this.RenderSize.Height)); + + var events = this.valuesList[i].Events; + + if (events != null && events.Length > 0) { + foreach (EventDataEntry @event in events) { + drawingContext.DrawRectangle( + Brushes.Red, + new Pen(Brushes.Red, 1), + new Rect( + new Point(@event.DataSetId * pieceWidth, 25), + new Point(@event.DataSetId * pieceWidth + pieceWidth, 35) + ) + ); + } + } } drawingContext.DrawRectangle( new SolidColorBrush(Color.FromArgb(64, Colors.Blue.R, Colors.Blue.G, Colors.Blue.B)), new Pen(Brushes.Blue, 1), new Rect( - new Point(Math.Min(this.selectedStartIndex, this.selectedEndIndex) * pieceWidth + offset, 0), - new Point(Math.Max(this.selectedStartIndex, this.selectedEndIndex) * pieceWidth + offset + pieceWidth, this.RenderSize.Height - offset) + new Point(Math.Min(this.selectedStartIndex, this.selectedEndIndex) * pieceWidth + offset, offsetFromTop), + new Point(Math.Max(this.selectedStartIndex, this.selectedEndIndex) * pieceWidth + offset + pieceWidth, this.RenderSize.Height) ) ); } @@ -191,7 +206,8 @@ namespace ICSharpCode.Profiler.Controls void HandleMovement(MouseEventArgs e) { bool valid; - int index = TransformToIndex(e.GetPosition(this), out valid); + Point pos = e.GetPosition(this); + int index = TransformToIndex(pos, out valid); if (e.LeftButton == MouseButtonState.Pressed) { this.selectedEndIndex = index; @@ -199,7 +215,12 @@ namespace ICSharpCode.Profiler.Controls this.InvalidateVisual(); } else if (tooltip == null && valid) { tooltip = new ToolTip(); - tooltip.Content = "Value: " + this.valuesList[index].Value.ToString("0.00") + " " + this.Unit; + if (pos.Y < 20) + tooltip.Content = "Time: "; + else if (pos.Y < 40) + tooltip.Content = "Event: "; + else + tooltip.Content = "Value: " + this.valuesList[index].Value.ToString(this.Format) + " " + this.Unit; tooltip .IsOpen = true; } }