HOME преди 1 година
родител
ревизия
a0a8b407a5
променени са 1 файла, в които са добавени 27 реда и са изтрити 6 реда
  1. 27 6
      BsWidget/MainForm.cs

+ 27 - 6
BsWidget/MainForm.cs

@@ -135,8 +135,7 @@ internal class MainForm : BaseForm
         _pcTimer?.Start();
 
 #if DEBUG
-        Task.Run(Function);
-
+        //Task.Run(Function);
 #endif
     }
 
@@ -162,7 +161,11 @@ internal class MainForm : BaseForm
     protected override void OnMouseDoubleClick(MouseEventArgs e)
     {
         base.OnMouseDoubleClick(e);
+#if DEBUG
+        _queue.Add(UpdateFlags.RefreshAll);
+#else
         _queue.Add(UpdateFlags.ClearAll);
+#endif
     }
 
     protected override void OnShown(EventArgs e)
@@ -512,6 +515,8 @@ internal class MainForm : BaseForm
                     var calPts = new List<PointF>();
                     var cpsPts = new List<PointF>();
 
+                    var lastPeak = -1;
+                    var peaks = new List<Tuple<int, float>>();
                     for (var i = 0; i < items.Length; i++)
                     {
                         var item = items[i];
@@ -526,13 +531,29 @@ internal class MainForm : BaseForm
                         if (i > 0 && i < items.Length - 1)
                         {
                             var prevItem = items[i - 1];
-                            var nextItems = items.Skip(i + 1).Take(10).ToArray();
-                            if (prevItem.HitsPerSecond < item.HitsPerSecond && nextItems.All(p => p.HitsPerSecond < item.HitsPerSecond))
+                            var nextItem = items[i + 1];
+                            if (prevItem.HitsPerSecond <= item.HitsPerSecond && item.HitsPerSecond > nextItem.HitsPerSecond)
                             {
                                 //peak detected
-                                g.DrawStringWithRoundedRect(item.HitsPerSecond + "", _smallFont, pointX, chBottom, Brushes.Black, Brushes.Yellow, 2);
+                                var peak = item.HitsPerSecond;
+                                if (peak != lastPeak)
+                                {
+                                    peaks.Add(new Tuple<int, float>(peak, pointX));
+                                    lastPeak = peak;
+                                }
+                            }
+                            else
+                            {
+                                if (peaks.Count > 0 && peaks.Last().Item2 < pointX - 15)
+                                {
+                                    var p = peaks.OrderByDescending(p => p.Item1).First();
+                                    g.DrawStringWithRoundedRect(p.Item1 + "", _smallFont, p.Item2, chBottom, Brushes.Black, Brushes.Yellow, margin / 2.0f);
+                                    peaks.Clear();
+                                }
+
                             }
                         }
+
                     }
 
                     g.DrawLines(scorePen, scorePts.ToArray());
@@ -576,7 +597,7 @@ internal class MainForm : BaseForm
             x += sz.Width + margin * 2;
 
             sz = g.DrawStringWithOutline($"{CurrentHitsPerSecond}", Font, x, y, Color.Black, Color.White);
-            g.DrawStringWithOutline($"{CurrentHitsPerSecond} max", Font, x, y + 50, Color.Black, Color.White);
+            g.DrawStringWithOutline($"{MaxHitsPerSecond} max", Font, x, y + 50, Color.Black, Color.White);
             x += sz.Width + margin * 2;
 
             sz = g.DrawStringWithRoundedRectPerf("HIT / SEC", _smallFont, x, y + margin * 1.5f, Brushes.Black,