[longomatch] Add support for event type hotkeys without tags



commit b9a4ddc4ebeb9b3ff5c44bf6b51bbb5160d402fc
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date:   Fri Oct 24 18:01:46 2014 +0200

    Add support for event type hotkeys without tags

 LongoMatch.Core/Interfaces/GUI/IGUIToolkit.cs    |    1 +
 LongoMatch.Drawing/CanvasObjects/CanvasObject.cs |    2 +-
 LongoMatch.GUI/Gui/GUIToolkit.cs                 |    4 ++
 LongoMatch.Services/Services/HotKeysManager.cs   |   39 ++++++++++++++++++----
 4 files changed, 38 insertions(+), 8 deletions(-)
---
diff --git a/LongoMatch.Core/Interfaces/GUI/IGUIToolkit.cs b/LongoMatch.Core/Interfaces/GUI/IGUIToolkit.cs
index 26568b1..9c4b76d 100644
--- a/LongoMatch.Core/Interfaces/GUI/IGUIToolkit.cs
+++ b/LongoMatch.Core/Interfaces/GUI/IGUIToolkit.cs
@@ -93,6 +93,7 @@ namespace LongoMatch.Core.Interfaces.GUI
 
                HotKey SelectHotkey (HotKey hotkey, object parent = null);
 
+               void Invoke (EventHandler handler);
        }
 }
 
diff --git a/LongoMatch.Drawing/CanvasObjects/CanvasObject.cs 
b/LongoMatch.Drawing/CanvasObjects/CanvasObject.cs
index b87c1cc..f69e23b 100644
--- a/LongoMatch.Drawing/CanvasObjects/CanvasObject.cs
+++ b/LongoMatch.Drawing/CanvasObjects/CanvasObject.cs
@@ -185,7 +185,7 @@ namespace LongoMatch.Drawing.CanvasObjects
                }
 
                public void Click () {
-                       ClickPressed (new Point (Position.X + Width / 2, Position.Y + Height / 2),
+                       ClickPressed (new Point (Position.X + 1, Position.Y + 1),
                                      ButtonModifier.None);
                        
                        ClickReleased ();
diff --git a/LongoMatch.GUI/Gui/GUIToolkit.cs b/LongoMatch.GUI/Gui/GUIToolkit.cs
index a0afbc0..1516e86 100644
--- a/LongoMatch.GUI/Gui/GUIToolkit.cs
+++ b/LongoMatch.GUI/Gui/GUIToolkit.cs
@@ -423,6 +423,10 @@ namespace LongoMatch.Gui
                        dialog.Destroy ();
                        return hotkey;
                }
+               
+               public void Invoke (EventHandler handler) {
+                       Gtk.Application.Invoke (handler);
+               }
        }
 }
 
diff --git a/LongoMatch.Services/Services/HotKeysManager.cs b/LongoMatch.Services/Services/HotKeysManager.cs
index 689a25b..4a0d578 100644
--- a/LongoMatch.Services/Services/HotKeysManager.cs
+++ b/LongoMatch.Services/Services/HotKeysManager.cs
@@ -32,6 +32,9 @@ namespace LongoMatch.Services
                Dictionary<HotKey, DashboardButton> dashboardHotkeys;
                IAnalysisWindow analysisWindow;
                Dashboard dashboard;
+               AnalysisEventButton pendingButton;
+               System.Threading.Timer timer;
+               const int TIMEOUT_MS = 1000;
 
                public HotKeysManager ()
                {
@@ -40,6 +43,7 @@ namespace LongoMatch.Services
                        Config.EventsBroker.KeyPressed += UIKeyListener;
                        Config.EventsBroker.KeyPressed += DashboardKeyListener;
                        Config.EventsBroker.DashboardEditedEvent += HandleDashboardEditedEvent;
+                       timer = new System.Threading.Timer (HandleTimeout);
                }
 
                void ReloadHotkeys ()
@@ -54,6 +58,16 @@ namespace LongoMatch.Services
                        }
                }
 
+               void HandleTimeout (object state)
+               {
+                       Config.DrawingToolkit.Invoke (delegate {
+                               if (pendingButton != null) {
+                                       analysisWindow.ClickButton (pendingButton);
+                                       pendingButton = null;
+                               }
+                       });
+               }
+
                void HandleDashboardEditedEvent ()
                {
                        ReloadHotkeys ();
@@ -106,7 +120,7 @@ namespace LongoMatch.Services
                                }
                        }
                }
-               
+
                public void DashboardKeyListener (object sender, HotKey key)
                {
                        KeyAction action;
@@ -114,7 +128,7 @@ namespace LongoMatch.Services
 
                        try {
                                action = Config.Hotkeys.ActionsHotkeys.GetKeyByValue (key);
-                       } catch (Exception ex) {
+                       } catch {
                                return;
                        }
                        if (action != KeyAction.None) {
@@ -122,11 +136,22 @@ namespace LongoMatch.Services
                                return;
                        }
                        
-                       if (!dashboardHotkeys.TryGetValue (key, out button)) {
-                               return;
-                       }
-                       if (! (button is AnalysisEventButton)) {
-                               analysisWindow.ClickButton (button);
+                       if (dashboardHotkeys.TryGetValue (key, out button)) {
+                               if (button is AnalysisEventButton) {
+                                       AnalysisEventButton evButton = button as AnalysisEventButton;
+                                       /* Finish tagging for the pending button */
+                                       if (pendingButton != null) {
+                                               analysisWindow.ClickButton (button);
+                                       }
+                                       if (evButton.AnalysisEventType.Tags.Count == 0) {
+                                               analysisWindow.ClickButton (button);
+                                       } else {
+                                               pendingButton = evButton;
+                                               timer.Change (TIMEOUT_MS, 0);
+                                       }
+                               } else {
+                                       analysisWindow.ClickButton (button);
+                               }
                        }
                }
        }


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