diff --git a/SequenceEditor/Surface.cs b/SequenceEditor/Surface.cs index a5b14157fb..c5e5de29a3 100644 --- a/SequenceEditor/Surface.cs +++ b/SequenceEditor/Surface.cs @@ -19,6 +19,15 @@ namespace SequenceEditor Dictionary> items = new Dictionary>(); + Point mousePos; + + protected override void OnMouseMove(MouseEventArgs e) + { + base.OnMouseMove(e); + mousePos = e.Location; + Invalidate(); + } + protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); @@ -26,6 +35,23 @@ namespace SequenceEditor var x = 0; var y = 0; + Point? toolPoint = null; + string toolText = ""; + + if (items.Count > 0) + { + foreach (var shp in items) + { + var sel = shp.Value.FirstOrDefault(a => a.Value.Contains(mousePos)); + if (!sel.Value.IsEmpty) + { + e.Graphics.FillRectangle(Brushes.Silver, sel.Value); + toolPoint = new Point(sel.Value.Left, sel.Value.Bottom); + toolText = sel.Key.ToString(); + } + } + } + items.Clear(); foreach (var shp in Program.Shps) @@ -78,6 +104,13 @@ namespace SequenceEditor seqid = ++seqid % brushes.Length; } + + if (toolPoint.HasValue) + { + var size = e.Graphics.MeasureString(toolText, Font); + e.Graphics.FillRectangle(Brushes.Silver, toolPoint.Value.X, toolPoint.Value.Y, size.Width, size.Height); + e.Graphics.DrawString(toolText, Font, Brushes.Black, toolPoint.Value.X, toolPoint.Value.Y); + } } } }