[longomatch] Fix menus not being shown from the timeline



commit bb5311e8546f4d37aa5a3282792da972d9798590
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date:   Fri Apr 10 17:00:27 2015 +0200

    Fix menus not being shown from the timeline

 LongoMatch.Drawing/Widgets/PlaysTimeline.cs |   28 ++++++++++----------------
 1 files changed, 11 insertions(+), 17 deletions(-)
---
diff --git a/LongoMatch.Drawing/Widgets/PlaysTimeline.cs b/LongoMatch.Drawing/Widgets/PlaysTimeline.cs
index d97ea9f..cbbef9d 100644
--- a/LongoMatch.Drawing/Widgets/PlaysTimeline.cs
+++ b/LongoMatch.Drawing/Widgets/PlaysTimeline.cs
@@ -243,26 +243,15 @@ namespace LongoMatch.Drawing.Widgets
                        }
                }
 
-               void ShowPlaysMenu (Point coords)
+               void ShowPlaysMenu (Point coords, CategoryTimeline catTimeline)
                {
                        EventType ev = null;
                        List<TimelineEvent> plays;
                        
                        plays = Selections.Select (p => (p.Drawable as PlayObject).Play).ToList ();
-                       
-                       foreach (EventType evType in eventsTimelines.Keys) {
-                               TimelineObject tl;
-
-                               tl = eventsTimelines [evType];
-                               if (!tl.Visible)
-                                       continue;
-                               if (coords.Y >= tl.OffsetY && coords.Y < tl.OffsetY + tl.Height) {
-                                       ev = evType;
-                                       break;
-                               }
-                       }
-                       
-                       if ((ev != null || plays.Count > 0) && ShowMenuEvent != null) {
+
+                       ev = eventsTimelines.GetKeyByValue (catTimeline);
+                       if (ev != null && ShowMenuEvent != null) {
                                ShowMenuEvent (plays, ev, Utils.PosToTime (coords, SecondsPerPixel));
                        }
                }
@@ -305,8 +294,13 @@ namespace LongoMatch.Drawing.Widgets
 
                protected override void ShowMenu (Point coords)
                {
-                       if (Selections.Count >= 1 && Selections.Last ().Drawable is PlayObject) {
-                               ShowPlaysMenu (coords);
+                       CategoryTimeline catTimeline = eventsTimelines.Values.Where (
+                                                              t => t.Visible &&
+                                                              coords.Y >= t.OffsetY &&
+                                                              coords.Y < t.OffsetY + 
t.Height).FirstOrDefault (); 
+
+                       if (catTimeline != null) {
+                               ShowPlaysMenu (coords, catTimeline);
                        } else {
                                ShowTimersMenu (coords);
                        }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]