[longomatch] Add support for tag hotkeys



commit 21b1da0b2fc75aa97198d71f7c040d197bea709b
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date:   Fri Nov 21 18:31:43 2014 +0100

    Add support for tag hotkeys

 LongoMatch.Core/Interfaces/GUI/IAnalysisWindow.cs  |    3 ++-
 LongoMatch.Drawing/CanvasObjects/CategoryObject.cs |    6 ++++++
 .../CanvasObjects/PlayersTaggerObject.cs           |   17 ++++++++++++++---
 LongoMatch.Drawing/Widgets/DashboardCanvas.cs      |   10 +++++++---
 LongoMatch.Drawing/Widgets/TeamTagger.cs           |    5 +++++
 LongoMatch.GUI/Gui/Component/AnalysisComponent.cs  |    9 +++++++--
 LongoMatch.GUI/Gui/Component/CodingWidget.cs       |    9 +++++++--
 LongoMatch.GUI/Gui/Component/DashboardWidget.cs    |    4 ++--
 .../Gui/Component/FakeAnalysisComponent.cs         |    9 +++++++--
 LongoMatch.Services/Services/HotKeysManager.cs     |   10 +++++++++-
 10 files changed, 66 insertions(+), 16 deletions(-)
---
diff --git a/LongoMatch.Core/Interfaces/GUI/IAnalysisWindow.cs 
b/LongoMatch.Core/Interfaces/GUI/IAnalysisWindow.cs
index 1ae3fc5..98ed9bb 100644
--- a/LongoMatch.Core/Interfaces/GUI/IAnalysisWindow.cs
+++ b/LongoMatch.Core/Interfaces/GUI/IAnalysisWindow.cs
@@ -40,8 +40,9 @@ namespace LongoMatch.Core.Interfaces.GUI
                void ShowDashboard ();
                void ShowTimeline ();
                void ShowZonalTags ();
-               void ClickButton (DashboardButton button);
+               void ClickButton (DashboardButton button, Tag tag = null);
                void TagPlayer (Player player);
+               void TagTeam (Team team);
                
                IPlayerBin Player{get;}
                ICapturerBin Capturer{get;}
diff --git a/LongoMatch.Drawing/CanvasObjects/CategoryObject.cs 
b/LongoMatch.Drawing/CanvasObjects/CategoryObject.cs
index 191d996..429c580 100644
--- a/LongoMatch.Drawing/CanvasObjects/CategoryObject.cs
+++ b/LongoMatch.Drawing/CanvasObjects/CategoryObject.cs
@@ -180,6 +180,12 @@ namespace LongoMatch.Drawing.CanvasObjects
                        }
                }
 
+               public void ClickTag (Tag tag)
+               {
+                       SelectedTags.Add (tag);
+                       ReDraw ();
+               }
+
                void Clear ()
                {
                        recording = false;
diff --git a/LongoMatch.Drawing/CanvasObjects/PlayersTaggerObject.cs 
b/LongoMatch.Drawing/CanvasObjects/PlayersTaggerObject.cs
index 311cbf4..ef7a87e 100644
--- a/LongoMatch.Drawing/CanvasObjects/PlayersTaggerObject.cs
+++ b/LongoMatch.Drawing/CanvasObjects/PlayersTaggerObject.cs
@@ -211,7 +211,7 @@ namespace LongoMatch.Drawing.CanvasObjects
                {
                        ResetSelection ();
                        foreach (Player p in players) {
-                               Select (p, true);
+                               Select (p, true, false);
                        }
                        homeButton.Active = team == Team.BOTH || team == Team.LOCAL;
                        awayButton.Active = team == Team.BOTH || team == Team.VISITOR;
@@ -220,7 +220,18 @@ namespace LongoMatch.Drawing.CanvasObjects
                        }
                }
 
-               public void Select (Player player, bool silent=false)
+               public void Select (Team team)
+               {
+                       if (team == Team.LOCAL) {
+                               homeButton.Active = true;
+                               awayButton.Active = false;
+                       } else {
+                               awayButton.Active = true;
+                               homeButton.Active = false;
+                       }
+               }
+
+               public void Select (Player player, bool silent=false, bool reset=false)
                {
                        PlayerObject po;
 
@@ -229,7 +240,7 @@ namespace LongoMatch.Drawing.CanvasObjects
                                po = awayPlayers.FirstOrDefault (p => p.Player == player);
                        }
                        if (po != null) {
-                               if (!silent) {
+                               if (reset) {
                                        ResetSelection ();
                                }
                                SelectedPlayers.Add (player);
diff --git a/LongoMatch.Drawing/Widgets/DashboardCanvas.cs b/LongoMatch.Drawing/Widgets/DashboardCanvas.cs
index d454a41..f71a323 100644
--- a/LongoMatch.Drawing/Widgets/DashboardCanvas.cs
+++ b/LongoMatch.Drawing/Widgets/DashboardCanvas.cs
@@ -122,10 +122,14 @@ namespace LongoMatch.Drawing.Widgets
                        }
                }
 
-               public void Click (DashboardButton b)
+               public void Click (DashboardButton b, Tag tag = null)
                {
-                       TaggerObject co = Objects.OfType<TaggerObject>().FirstOrDefault (o => o.Tagger == b);
-                       co.Click ();
+                       TaggerObject co = Objects.OfType<TaggerObject> ().FirstOrDefault (o => o.Tagger == b);
+                       if (tag != null && co is CategoryObject) {
+                               (co as CategoryObject).ClickTag (tag);
+                       } else {
+                               co.Click ();
+                       }
                }
 
                public void RedrawButton (DashboardButton b)
diff --git a/LongoMatch.Drawing/Widgets/TeamTagger.cs b/LongoMatch.Drawing/Widgets/TeamTagger.cs
index 0118141..f518aca 100644
--- a/LongoMatch.Drawing/Widgets/TeamTagger.cs
+++ b/LongoMatch.Drawing/Widgets/TeamTagger.cs
@@ -123,6 +123,11 @@ namespace LongoMatch.Drawing.Widgets
                        tagger.ResetSelection ();
                } 
 
+               public void Select (Team team)
+               {
+                       tagger.Select (team);
+               }
+
                public void Select (List<Player> players, Team team)
                {
                        tagger.Select (players, team);
diff --git a/LongoMatch.GUI/Gui/Component/AnalysisComponent.cs 
b/LongoMatch.GUI/Gui/Component/AnalysisComponent.cs
index 585af34..c301a36 100644
--- a/LongoMatch.GUI/Gui/Component/AnalysisComponent.cs
+++ b/LongoMatch.GUI/Gui/Component/AnalysisComponent.cs
@@ -104,15 +104,20 @@ namespace LongoMatch.Gui.Component
                        codingwidget.ShowZonalTags ();
                }
 
-               public void ClickButton (DashboardButton button)
+               public void ClickButton (DashboardButton button, Tag tag = null)
                {
-                       codingwidget.ClickButton (button);
+                       codingwidget.ClickButton (button, tag);
                }
 
                public void TagPlayer (Player player)
                {
                        codingwidget.TagPlayer (player);
                }
+               
+               public void TagTeam (Team team)
+               {
+                       codingwidget.TagTeam (team);
+               }
 
                public void DetachPlayer ()
                {
diff --git a/LongoMatch.GUI/Gui/Component/CodingWidget.cs b/LongoMatch.GUI/Gui/Component/CodingWidget.cs
index 73e66bc..967ec90 100644
--- a/LongoMatch.GUI/Gui/Component/CodingWidget.cs
+++ b/LongoMatch.GUI/Gui/Component/CodingWidget.cs
@@ -140,15 +140,20 @@ namespace LongoMatch.Gui.Component
                        SelectPage (playspositionviewer1);
                }
 
-               public void ClickButton (DashboardButton button)
+               public void ClickButton (DashboardButton button, Tag tag = null)
                {
-                       buttonswidget.ClickButton (button);
+                       buttonswidget.ClickButton (button, tag);
                }
 
                public void TagPlayer (Player player)
                {
                        teamtagger.Select (player);
                }
+               
+               public void TagTeam (Team team)
+               {
+                       teamtagger.Select (team);
+               }
 
                public void SetProject (Project project, ProjectType projectType, EventsFilter filter)
                {
diff --git a/LongoMatch.GUI/Gui/Component/DashboardWidget.cs b/LongoMatch.GUI/Gui/Component/DashboardWidget.cs
index e1e8b50..92ee68f 100644
--- a/LongoMatch.GUI/Gui/Component/DashboardWidget.cs
+++ b/LongoMatch.GUI/Gui/Component/DashboardWidget.cs
@@ -206,9 +206,9 @@ namespace LongoMatch.Gui.Component
                        }
                }
 
-               public void ClickButton (DashboardButton button)
+               public void ClickButton (DashboardButton button, Tag tag = null)
                {
-                       tagger.Click (button);
+                       tagger.Click (button, tag);
                }
                
                public void Refresh (DashboardButton b = null) {
diff --git a/LongoMatch.GUI/Gui/Component/FakeAnalysisComponent.cs 
b/LongoMatch.GUI/Gui/Component/FakeAnalysisComponent.cs
index a04cacd..e94350f 100644
--- a/LongoMatch.GUI/Gui/Component/FakeAnalysisComponent.cs
+++ b/LongoMatch.GUI/Gui/Component/FakeAnalysisComponent.cs
@@ -92,9 +92,9 @@ namespace LongoMatch.Gui.Component
                        codingwidget1.ShowZonalTags ();
                }
 
-               public void ClickButton (DashboardButton button)
+               public void ClickButton (DashboardButton button, Tag tag = null)
                {
-                       codingwidget1.ClickButton (button);
+                       codingwidget1.ClickButton (button, tag);
                }
 
                public void TagPlayer (Player player)
@@ -102,6 +102,11 @@ namespace LongoMatch.Gui.Component
                        codingwidget1.TagPlayer (player);
                }
 
+               public void TagTeam (Team team)
+               {
+                       codingwidget1.TagTeam (team);
+               }
+
                public IPlayerBin Player {
                        get {
                                return null;
diff --git a/LongoMatch.Services/Services/HotKeysManager.cs b/LongoMatch.Services/Services/HotKeysManager.cs
index a32dded..26a28ad 100644
--- a/LongoMatch.Services/Services/HotKeysManager.cs
+++ b/LongoMatch.Services/Services/HotKeysManager.cs
@@ -104,6 +104,7 @@ namespace LongoMatch.Services
                        this.analysisWindow = analysisWindow;
                        this.capturer = analysisWindow.Capturer;
                        openedProject = project;
+                       this.projectType = projectType;
                        if (project == null) {
                                dashboard = null;
                        } else {
@@ -193,9 +194,16 @@ namespace LongoMatch.Services
                                inPlayerTagging = true;
                                taggedTeam = action == KeyAction.LocalPlayer ? Team.LOCAL : Team.VISITOR;
                                playerNumber = "";
+                               analysisWindow.TagTeam (taggedTeam);
                                timer.Change (TIMEOUT_MS, 0);
                        } else if (action == KeyAction.None) {
-                               if (dashboardHotkeys.TryGetValue (key, out button)) {
+                               if (pendingButton != null) {
+                                       Tag tag = pendingButton.AnalysisEventType.Tags.FirstOrDefault (t => 
t.HotKey == key);
+                                       if (tag != null) {
+                                               analysisWindow.ClickButton (pendingButton, tag);
+                                               timer.Change (TIMEOUT_MS, 0);
+                                       }
+                               } else if (dashboardHotkeys.TryGetValue (key, out button)) {
                                        if (inPlayerTagging) {
                                                TagPlayer ();
                                        }


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