[longomatch] Show play tag editor when tagging a new play



commit ce5350a821e53bd7c1a1c63d105367fd38dff853
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date:   Mon Sep 1 17:16:40 2014 +0200

    Show play tag editor when tagging a new play

 LongoMatch.Core/Common/EventsBroker.cs             |    6 +
 LongoMatch.Core/Handlers/Handlers.cs               |    2 +
 LongoMatch.Core/Interfaces/GUI/IGUIToolkit.cs      |    3 +-
 LongoMatch.GUI/Gui/Component/CodingWidget.cs       |   22 ++++-
 .../Gui/Component/PlaysCoordinatesTagger.cs        |    4 +
 LongoMatch.GUI/Gui/Dialog/PlayEditor.cs            |   41 ++++++++
 LongoMatch.GUI/Gui/GUIToolkit.cs                   |   16 +--
 LongoMatch.GUI/LongoMatch.GUI.mdp                  |    2 +
 LongoMatch.GUI/Makefile.am                         |    2 +
 .../gtk-gui/LongoMatch.Gui.Dialog.PlayEditor.cs    |   90 +++++++++++++++++
 LongoMatch.GUI/gtk-gui/gui.stetic                  |   95 +++++++++++++++++-
 LongoMatch.GUI/gtk-gui/objects.xml                 |  106 ++++++++++----------
 LongoMatch.Services/Services/EventsManager.cs      |   57 +++++++----
 13 files changed, 359 insertions(+), 87 deletions(-)
---
diff --git a/LongoMatch.Core/Common/EventsBroker.cs b/LongoMatch.Core/Common/EventsBroker.cs
index ade7079..8ca846c 100644
--- a/LongoMatch.Core/Common/EventsBroker.cs
+++ b/LongoMatch.Core/Common/EventsBroker.cs
@@ -29,6 +29,7 @@ namespace LongoMatch.Common
        {
        
                public event NewTagHandler NewTagEvent;
+               public event NewPlayHandler NewPlayEvent;
                public event PlaysDeletedHandler PlaysDeleted;
                public event LoadPlayHandler LoadPlayEvent;
                public event PlayLoadedHandler PlayLoadedEvent;
@@ -91,6 +92,11 @@ namespace LongoMatch.Common
                        if (NewTagEvent != null)
                                NewTagEvent (tagger, players, tags, start, stop);
                }
+               
+               public void EmitNewPlay (Play play) {
+                       if (NewPlayEvent != null)
+                               NewPlayEvent (play);
+               }
 
                public void EmitPlaysDeleted(List<Play> plays)
                {
diff --git a/LongoMatch.Core/Handlers/Handlers.cs b/LongoMatch.Core/Handlers/Handlers.cs
index d5d1185..324d2a7 100644
--- a/LongoMatch.Core/Handlers/Handlers.cs
+++ b/LongoMatch.Core/Handlers/Handlers.cs
@@ -38,6 +38,8 @@ namespace LongoMatch.Handlers
        public delegate void PlayLoadedHandler(Play play);
        /* A new play needs to be create for a specific category at the current play time */
        public delegate void NewTagHandler (TaggerButton tagger, List<Player> plays, List<Tag> tags, Time 
start, Time stop);
+       /* Add a new play to the current project */
+       public delegate void NewPlayHandler (Play play);
        //A play was edited
        public delegate void TimeNodeChangedHandler(TimeNode tNode, object val);
        public delegate void CategoryChangedHandler(AnalysisCategory cat);
diff --git a/LongoMatch.Core/Interfaces/GUI/IGUIToolkit.cs b/LongoMatch.Core/Interfaces/GUI/IGUIToolkit.cs
index 8faf1c0..c1045ac 100644
--- a/LongoMatch.Core/Interfaces/GUI/IGUIToolkit.cs
+++ b/LongoMatch.Core/Interfaces/GUI/IGUIToolkit.cs
@@ -78,7 +78,8 @@ namespace LongoMatch.Interfaces.GUI
                
                void ManageJobs ();
                
-               void TagPlay (Play play, Project project);
+               void EditPlay (Play play, Project project, bool editTags, bool editPositions, bool 
editPlayers, bool editNotes);
+
                void DrawingTool(Image pixbuf, Play play, FrameDrawing drawing);
                
                string RemuxFile (string filePath, string outputFile, VideoMuxerType muxer);
diff --git a/LongoMatch.GUI/Gui/Component/CodingWidget.cs b/LongoMatch.GUI/Gui/Component/CodingWidget.cs
index e49a827..1c0dd40 100644
--- a/LongoMatch.GUI/Gui/Component/CodingWidget.cs
+++ b/LongoMatch.GUI/Gui/Component/CodingWidget.cs
@@ -34,6 +34,7 @@ namespace LongoMatch.Gui.Component
        {
                TeamTagger teamtagger;
                ProjectType projectType;
+               Project project;
                List<Player> selectedPlayers;
                Play loadedPlay;
                List<Window> activeWindows;
@@ -77,6 +78,13 @@ namespace LongoMatch.Gui.Component
                        buttonswidget.FitMode = FitMode.Fit;
                        buttonswidget.ButtonsVisible = true;
                        buttonswidget.NewTagEvent += HandleNewTagEvent;
+                       
+                       TagPositions = true;
+               }
+
+               public bool TagPositions {
+                       get;
+                       set;
                }
 
                protected override void OnDestroyed ()
@@ -97,6 +105,7 @@ namespace LongoMatch.Gui.Component
                public void SetProject (Project project, ProjectType projectType, PlaysFilter filter)
                {
                        this.projectType = projectType;
+                       this.project = project;
                        buttonswidget.Visible = true;
                        if (project != null) {
                                buttonswidget.Template = project.Categories;
@@ -236,9 +245,18 @@ namespace LongoMatch.Gui.Component
                        selectedPlayers = players.ToList();
                }
                
-               void HandleNewTagEvent (TaggerButton tagger, List<Player> plays, List<Tag> tags, Time start, 
Time stop)
+               void HandleNewTagEvent (TaggerButton tagger, List<Player> players, List<Tag> tags, Time 
start, Time stop)
                {
-                       Config.EventsBroker.EmitNewTag (tagger, selectedPlayers, tags, start, stop);
+                       if (tagger is AnalysisCategory) {
+                               AnalysisCategory cat = tagger as AnalysisCategory;
+                               Play play = project.AddPlay (cat, start, stop, null);
+                               play.Players = selectedPlayers ?? new List<Player> ();
+                               play.Tags = tags ?? new List<Tag> ();
+                               if (cat.TagFieldPosition || cat.TagGoalPosition || cat.TagHalfFieldPosition) {
+                                       Config.GUIToolkit.EditPlay (play, project, false, true, false, false);
+                               }
+                               Config.EventsBroker.EmitNewPlay (play);
+                       }
                }
 
        }
diff --git a/LongoMatch.GUI/Gui/Component/PlaysCoordinatesTagger.cs 
b/LongoMatch.GUI/Gui/Component/PlaysCoordinatesTagger.cs
index 09d49c1..24f07f5 100644
--- a/LongoMatch.GUI/Gui/Component/PlaysCoordinatesTagger.cs
+++ b/LongoMatch.GUI/Gui/Component/PlaysCoordinatesTagger.cs
@@ -42,6 +42,9 @@ namespace LongoMatch.Gui.Component
                        field.Tagger.EmitSignals = false;
                        hfield.Tagger.EmitSignals = false;
                        goal.Tagger.EmitSignals = false;
+                       field.Tagger.Accuracy = 20;
+                       hfield.Tagger.Accuracy = 20;
+                       goal.Tagger.Accuracy = 20;
                }
 
                public void LoadBackgrounds (Project project) {
@@ -57,6 +60,7 @@ namespace LongoMatch.Gui.Component
                        field.Visible = play.Category.TagFieldPosition;
                        hfield.Visible = play.Category.TagHalfFieldPosition;
                        goal.Visible = play.Category.TagGoalPosition;
+                       vbox2.Visible = hfield.Visible || goal.Visible;
                        
                        play.AddDefaultPositions ();
 
diff --git a/LongoMatch.GUI/Gui/Dialog/PlayEditor.cs b/LongoMatch.GUI/Gui/Dialog/PlayEditor.cs
new file mode 100644
index 0000000..2f09358
--- /dev/null
+++ b/LongoMatch.GUI/Gui/Dialog/PlayEditor.cs
@@ -0,0 +1,41 @@
+//
+//  Copyright (C) 2014 Andoni Morales Alastruey
+//
+//  This program is free software; you can redistribute it and/or modify
+//  it under the terms of the GNU General Public License as published by
+//  the Free Software Foundation; either version 2 of the License, or
+//  (at your option) any later version.
+//
+//  This program is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+//  GNU General Public License for more details.
+//
+//  You should have received a copy of the GNU General Public License
+//  along with this program; if not, write to the Free Software
+//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+using System;
+using LongoMatch.Store;
+
+namespace LongoMatch.Gui.Dialog
+{
+       public partial class PlayEditor : Gtk.Dialog
+       {
+               public PlayEditor ()
+               {
+                       this.Build ();
+               }
+               
+               public void LoadPlay (Play play, Project project, bool editTags, bool editPos, bool 
editPlayers, bool editNotes) {
+                       notes.Visible = editNotes;
+                       tagger.Visible = editPos;
+
+                       tagger.LoadBackgrounds (project);
+                       tagger.LoadPlay (play);
+                       
+                       notes.Play = play;
+               }
+       }
+}
+
diff --git a/LongoMatch.GUI/Gui/GUIToolkit.cs b/LongoMatch.GUI/Gui/GUIToolkit.cs
index 4d19ab2..4bcefd2 100644
--- a/LongoMatch.GUI/Gui/GUIToolkit.cs
+++ b/LongoMatch.GUI/Gui/GUIToolkit.cs
@@ -215,17 +215,11 @@ namespace LongoMatch.Gui
                                sd.Destroy();
                }
                
-               public void TagPlay (Play play, Project project) {
-                       Gtk.Dialog d = new Gtk.Dialog (Catalog.GetString ("Tag field positions"), mainWindow,
-                                                      DialogFlags.Modal | DialogFlags.DestroyWithParent,
-                                                      Gtk.Stock.Ok, ResponseType.Ok);
-                       PlaysCoordinatesTagger tagger = new PlaysCoordinatesTagger ();
-                       tagger.LoadBackgrounds (project);
-                       tagger.LoadPlay (play);
-                       tagger.ShowAll ();
-                       d.VBox.PackStart (tagger, true, true, 0);
-                       d.Run();
-                       d.Destroy();
+               public void EditPlay (Play play, Project project, bool editTags, bool editPos, bool 
editPlayers, bool editNotes) {
+                       PlayEditor dialog = new PlayEditor ();
+                       dialog.LoadPlay (play, project, editTags, editPos, editPlayers, editNotes);
+                       dialog.Run();
+                       dialog.Destroy();
                }
 
                public void DrawingTool (Image image, Play play, FrameDrawing drawing) {
diff --git a/LongoMatch.GUI/LongoMatch.GUI.mdp b/LongoMatch.GUI/LongoMatch.GUI.mdp
index b828a0d..ca2eed2 100644
--- a/LongoMatch.GUI/LongoMatch.GUI.mdp
+++ b/LongoMatch.GUI/LongoMatch.GUI.mdp
@@ -175,6 +175,8 @@
     <File subtype="Code" buildaction="Compile" name="gtk-gui/LongoMatch.Gui.Component.DashboardWidget.cs" />
     <File subtype="Code" buildaction="Compile" name="Gui/Panel/PanelHeader.cs" />
     <File subtype="Code" buildaction="Compile" name="gtk-gui/LongoMatch.Gui.Panel.PanelHeader.cs" />
+    <File subtype="Code" buildaction="Compile" name="Gui/Dialog/PlayEditor.cs" />
+    <File subtype="Code" buildaction="Compile" name="gtk-gui/LongoMatch.Gui.Dialog.PlayEditor.cs" />
   </Contents>
   <References>
     <ProjectReference type="Package" localcopy="True" refto="atk-sharp, Version=2.12.0.0, Culture=neutral, 
PublicKeyToken=35e10195dab3c99f" />
diff --git a/LongoMatch.GUI/Makefile.am b/LongoMatch.GUI/Makefile.am
index 9325805..f852b32 100644
--- a/LongoMatch.GUI/Makefile.am
+++ b/LongoMatch.GUI/Makefile.am
@@ -49,6 +49,7 @@ SOURCES = Gui/Cairo.cs \
        Gui/Dialog/EntryDialog.cs \
        Gui/Dialog/FramesCaptureProgressDialog.cs \
        Gui/Dialog/HotKeySelectorDialog.cs \
+       Gui/Dialog/PlayEditor.cs \
        Gui/Dialog/RenderingJobsDialog.cs \
        Gui/Dialog/ShortcutsHelpDialog.cs \
        Gui/Dialog/SnapshotsDialog.cs \
@@ -119,6 +120,7 @@ SOURCES = Gui/Cairo.cs \
        gtk-gui/LongoMatch.Gui.Dialog.EntryDialog.cs \
        gtk-gui/LongoMatch.Gui.Dialog.FramesCaptureProgressDialog.cs \
        gtk-gui/LongoMatch.Gui.Dialog.HotKeySelectorDialog.cs \
+       gtk-gui/LongoMatch.Gui.Dialog.PlayEditor.cs \
        gtk-gui/LongoMatch.Gui.Dialog.RenderingJobsDialog.cs \
        gtk-gui/LongoMatch.Gui.Dialog.ShortcutsHelpDialog.cs \
        gtk-gui/LongoMatch.Gui.Dialog.SnapshotsDialog.cs \
diff --git a/LongoMatch.GUI/gtk-gui/LongoMatch.Gui.Dialog.PlayEditor.cs 
b/LongoMatch.GUI/gtk-gui/LongoMatch.Gui.Dialog.PlayEditor.cs
new file mode 100644
index 0000000..8571344
--- /dev/null
+++ b/LongoMatch.GUI/gtk-gui/LongoMatch.Gui.Dialog.PlayEditor.cs
@@ -0,0 +1,90 @@
+
+// This file has been generated by the GUI designer. Do not modify.
+namespace LongoMatch.Gui.Dialog
+{
+       public partial class PlayEditor
+       {
+               private global::Gtk.HBox hbox1;
+               private global::LongoMatch.Gui.Component.PlaysCoordinatesTagger tagger;
+               private global::LongoMatch.Gui.Component.NotesWidget notes;
+               private global::Gtk.Button buttonCancel;
+               private global::Gtk.Button buttonOk;
+
+               protected virtual void Build ()
+               {
+                       global::Stetic.Gui.Initialize (this);
+                       // Widget LongoMatch.Gui.Dialog.PlayEditor
+                       this.Name = "LongoMatch.Gui.Dialog.PlayEditor";
+                       this.Title = global::Mono.Unix.Catalog.GetString ("Edit play details");
+                       this.Icon = global::Stetic.IconLoader.LoadIcon (this, "longomatch", 
global::Gtk.IconSize.Menu);
+                       this.TypeHint = ((global::Gdk.WindowTypeHint)(1));
+                       this.WindowPosition = ((global::Gtk.WindowPosition)(4));
+                       this.Modal = true;
+                       this.Gravity = ((global::Gdk.Gravity)(5));
+                       this.SkipPagerHint = true;
+                       this.SkipTaskbarHint = true;
+                       // Internal child LongoMatch.Gui.Dialog.PlayEditor.VBox
+                       global::Gtk.VBox w1 = this.VBox;
+                       w1.Name = "dialog1_VBox";
+                       w1.BorderWidth = ((uint)(2));
+                       // Container child dialog1_VBox.Gtk.Box+BoxChild
+                       this.hbox1 = new global::Gtk.HBox ();
+                       this.hbox1.Name = "hbox1";
+                       this.hbox1.Spacing = 6;
+                       // Container child hbox1.Gtk.Box+BoxChild
+                       this.tagger = new global::LongoMatch.Gui.Component.PlaysCoordinatesTagger ();
+                       this.tagger.Events = ((global::Gdk.EventMask)(256));
+                       this.tagger.Name = "tagger";
+                       this.hbox1.Add (this.tagger);
+                       global::Gtk.Box.BoxChild w2 = ((global::Gtk.Box.BoxChild)(this.hbox1 [this.tagger]));
+                       w2.Position = 0;
+                       // Container child hbox1.Gtk.Box+BoxChild
+                       this.notes = new global::LongoMatch.Gui.Component.NotesWidget ();
+                       this.notes.Events = ((global::Gdk.EventMask)(256));
+                       this.notes.Name = "notes";
+                       this.hbox1.Add (this.notes);
+                       global::Gtk.Box.BoxChild w3 = ((global::Gtk.Box.BoxChild)(this.hbox1 [this.notes]));
+                       w3.Position = 1;
+                       w1.Add (this.hbox1);
+                       global::Gtk.Box.BoxChild w4 = ((global::Gtk.Box.BoxChild)(w1 [this.hbox1]));
+                       w4.Position = 0;
+                       // Internal child LongoMatch.Gui.Dialog.PlayEditor.ActionArea
+                       global::Gtk.HButtonBox w5 = this.ActionArea;
+                       w5.Name = "dialog1_ActionArea";
+                       w5.Spacing = 10;
+                       w5.BorderWidth = ((uint)(5));
+                       w5.LayoutStyle = ((global::Gtk.ButtonBoxStyle)(4));
+                       // Container child dialog1_ActionArea.Gtk.ButtonBox+ButtonBoxChild
+                       this.buttonCancel = new global::Gtk.Button ();
+                       this.buttonCancel.CanDefault = true;
+                       this.buttonCancel.CanFocus = true;
+                       this.buttonCancel.Name = "buttonCancel";
+                       this.buttonCancel.UseStock = true;
+                       this.buttonCancel.UseUnderline = true;
+                       this.buttonCancel.Label = "gtk-cancel";
+                       this.AddActionWidget (this.buttonCancel, -6);
+                       global::Gtk.ButtonBox.ButtonBoxChild w6 = ((global::Gtk.ButtonBox.ButtonBoxChild)(w5 
[this.buttonCancel]));
+                       w6.Expand = false;
+                       w6.Fill = false;
+                       // Container child dialog1_ActionArea.Gtk.ButtonBox+ButtonBoxChild
+                       this.buttonOk = new global::Gtk.Button ();
+                       this.buttonOk.CanDefault = true;
+                       this.buttonOk.CanFocus = true;
+                       this.buttonOk.Name = "buttonOk";
+                       this.buttonOk.UseStock = true;
+                       this.buttonOk.UseUnderline = true;
+                       this.buttonOk.Label = "gtk-ok";
+                       this.AddActionWidget (this.buttonOk, -5);
+                       global::Gtk.ButtonBox.ButtonBoxChild w7 = ((global::Gtk.ButtonBox.ButtonBoxChild)(w5 
[this.buttonOk]));
+                       w7.Position = 1;
+                       w7.Expand = false;
+                       w7.Fill = false;
+                       if ((this.Child != null)) {
+                               this.Child.ShowAll ();
+                       }
+                       this.DefaultWidth = 707;
+                       this.DefaultHeight = 441;
+                       this.Show ();
+               }
+       }
+}
diff --git a/LongoMatch.GUI/gtk-gui/gui.stetic b/LongoMatch.GUI/gtk-gui/gui.stetic
index 856601b..44d78bd 100644
--- a/LongoMatch.GUI/gtk-gui/gui.stetic
+++ b/LongoMatch.GUI/gtk-gui/gui.stetic
@@ -95,7 +95,7 @@
       </widget>
     </child>
   </widget>
-  <widget class="Gtk.Bin" id="LongoMatch.Gui.Component.DashboardWidget" design-size="1244 509">
+  <widget class="Gtk.Bin" id="LongoMatch.Gui.Component.DashboardWidget" design-size="1288 509">
     <property name="MemberName" />
     <child>
       <widget class="Gtk.HBox" id="hbox2">
@@ -7348,7 +7348,7 @@ You can continue with the current capture, cancel it or save your project.
       </widget>
     </child>
   </widget>
-  <widget class="Gtk.Bin" id="LongoMatch.Gui.Panel.TeamsTemplatesPanel" design-size="1325 560">
+  <widget class="Gtk.Bin" id="LongoMatch.Gui.Panel.TeamsTemplatesPanel" design-size="1325 583">
     <property name="MemberName" />
     <property name="Visible">False</property>
     <child>
@@ -10395,4 +10395,95 @@ You can continue with the current capture, cancel it or save your project.
       </widget>
     </child>
   </widget>
+  <widget class="Gtk.Dialog" id="LongoMatch.Gui.Dialog.PlayEditor" design-size="707 441">
+    <property name="MemberName" />
+    <property name="Title" translatable="yes">Edit play details</property>
+    <property name="Icon">stock:longomatch Menu</property>
+    <property name="TypeHint">Dialog</property>
+    <property name="WindowPosition">CenterOnParent</property>
+    <property name="Modal">True</property>
+    <property name="Gravity">Center</property>
+    <property name="SkipPagerHint">True</property>
+    <property name="SkipTaskbarHint">True</property>
+    <property name="Buttons">2</property>
+    <property name="HelpButton">False</property>
+    <child internal-child="VBox">
+      <widget class="Gtk.VBox" id="dialog1_VBox">
+        <property name="MemberName" />
+        <property name="BorderWidth">2</property>
+        <child>
+          <widget class="Gtk.HBox" id="hbox1">
+            <property name="MemberName" />
+            <property name="Spacing">6</property>
+            <child>
+              <widget class="LongoMatch.Gui.Component.PlaysCoordinatesTagger" id="tagger">
+                <property name="MemberName" />
+                <property name="Events">ButtonPressMask</property>
+              </widget>
+              <packing>
+                <property name="Position">0</property>
+                <property name="AutoSize">True</property>
+              </packing>
+            </child>
+            <child>
+              <widget class="LongoMatch.Gui.Component.NotesWidget" id="notes">
+                <property name="MemberName" />
+                <property name="Events">ButtonPressMask</property>
+              </widget>
+              <packing>
+                <property name="Position">1</property>
+                <property name="AutoSize">False</property>
+              </packing>
+            </child>
+          </widget>
+          <packing>
+            <property name="Position">0</property>
+            <property name="AutoSize">True</property>
+          </packing>
+        </child>
+      </widget>
+    </child>
+    <child internal-child="ActionArea">
+      <widget class="Gtk.HButtonBox" id="dialog1_ActionArea">
+        <property name="MemberName" />
+        <property name="Spacing">10</property>
+        <property name="BorderWidth">5</property>
+        <property name="Size">2</property>
+        <property name="LayoutStyle">End</property>
+        <child>
+          <widget class="Gtk.Button" id="buttonCancel">
+            <property name="MemberName" />
+            <property name="CanDefault">True</property>
+            <property name="CanFocus">True</property>
+            <property name="UseStock">True</property>
+            <property name="Type">StockItem</property>
+            <property name="StockId">gtk-cancel</property>
+            <property name="ResponseId">-6</property>
+            <property name="label">gtk-cancel</property>
+          </widget>
+          <packing>
+            <property name="Expand">False</property>
+            <property name="Fill">False</property>
+          </packing>
+        </child>
+        <child>
+          <widget class="Gtk.Button" id="buttonOk">
+            <property name="MemberName" />
+            <property name="CanDefault">True</property>
+            <property name="CanFocus">True</property>
+            <property name="UseStock">True</property>
+            <property name="Type">StockItem</property>
+            <property name="StockId">gtk-ok</property>
+            <property name="ResponseId">-5</property>
+            <property name="label">gtk-ok</property>
+          </widget>
+          <packing>
+            <property name="Position">1</property>
+            <property name="Expand">False</property>
+            <property name="Fill">False</property>
+          </packing>
+        </child>
+      </widget>
+    </child>
+  </widget>
 </stetic-interface>
\ No newline at end of file
diff --git a/LongoMatch.GUI/gtk-gui/objects.xml b/LongoMatch.GUI/gtk-gui/objects.xml
index def2331..0dca80c 100644
--- a/LongoMatch.GUI/gtk-gui/objects.xml
+++ b/LongoMatch.GUI/gtk-gui/objects.xml
@@ -234,7 +234,11 @@
     </signals>
   </object>
   <object type="LongoMatch.Gui.Component.CodingWidget" palette-category="General" allow-children="false" 
base-type="Gtk.Bin">
-    <itemgroups />
+    <itemgroups>
+      <itemgroup label="CodingWidget Properties">
+        <property name="TagPositions" />
+      </itemgroup>
+    </itemgroups>
     <signals />
   </object>
   <object type="LongoMatch.Gui.Component.ProjectPeriods" palette-category="General" allow-children="false" 
base-type="Gtk.Bin">
@@ -245,40 +249,15 @@
     <itemgroups />
     <signals />
   </object>
-  <object type="LongoMatch.Gui.CapturerBin" palette-category="General" allow-children="false" 
base-type="Gtk.Bin">
-    <itemgroups>
-      <itemgroup label="CapturerBin Properties">
-        <property name="Capturing" />
-      </itemgroup>
-    </itemgroups>
+  <object type="LongoMatch.Gui.Component.TeamsComboBox" palette-category="General" allow-children="false" 
base-type="Gtk.ComboBox">
+    <itemgroups />
     <signals />
   </object>
-  <object type="LongoMatch.Gui.PlayerBin" palette-category="General" allow-children="false" 
base-type="Gtk.Bin">
-    <itemgroups>
-      <itemgroup label="IPlayerBin Properties">
-        <property name="Sensitive" />
-      </itemgroup>
-    </itemgroups>
-    <signals>
-      <itemgroup label="PlayerBin Signals">
-        <signal name="Tick" />
-        <signal name="PlayStateChanged" />
-      </itemgroup>
-    </signals>
-  </object>
-  <object type="LongoMatch.Gui.PlayerCapturerBin" palette-category="General" allow-children="false" 
base-type="Gtk.Bin">
-    <itemgroups>
-      <itemgroup label="IPlayerBin Properties">
-        <property name="Sensitive" />
-      </itemgroup>
-    </itemgroups>
-    <signals>
-      <itemgroup label="IPlayerBin Signals">
-        <signal name="PlayStateChanged" />
-      </itemgroup>
-    </signals>
+  <object type="LongoMatch.Gui.Component.HomeTeamsComboBox" palette-category="General" 
allow-children="false" base-type="LongoMatch.Gui.Component.TeamsComboBox">
+    <itemgroups />
+    <signals />
   </object>
-  <object type="LongoMatch.Gui.Component.TeamsComboBox" palette-category="General" allow-children="false" 
base-type="Gtk.ComboBox">
+  <object type="LongoMatch.Gui.Component.AwayTeamsComboBox" palette-category="General" 
allow-children="false" base-type="LongoMatch.Gui.Component.TeamsComboBox">
     <itemgroups />
     <signals />
   </object>
@@ -307,17 +286,6 @@
       </itemgroup>
     </signals>
   </object>
-  <object type="LongoMatch.Gui.VideoWindow" palette-category="General" allow-children="false" 
base-type="Gtk.Bin">
-    <itemgroups />
-    <signals>
-      <itemgroup label="VideoWindow Signals">
-        <signal name="Realized" />
-        <signal name="ExposeEvent" />
-        <signal name="ButtonPressEvent" />
-        <signal name="ScrollEvent" />
-      </itemgroup>
-    </signals>
-  </object>
   <object type="LongoMatch.Gui.Component.DashboardWidget" palette-category="General" allow-children="false" 
base-type="Gtk.Bin">
     <itemgroups>
       <itemgroup label="DashboardWidget Properties">
@@ -330,20 +298,56 @@
       </itemgroup>
     </signals>
   </object>
-  <object type="LongoMatch.Gui.Component.HomeTeamsComboBox" palette-category="General" 
allow-children="false" base-type="LongoMatch.Gui.Component.TeamsComboBox">
+  <object type="LongoMatch.Gui.Panel.PanelHeader" palette-category="General" allow-children="false" 
base-type="Gtk.Bin">
     <itemgroups />
-    <signals />
+    <signals>
+      <itemgroup label="PanelHeader Signals">
+        <signal name="BackClicked" />
+        <signal name="ApplyClicked" />
+      </itemgroup>
+    </signals>
   </object>
-  <object type="LongoMatch.Gui.Component.AwayTeamsComboBox" palette-category="General" 
allow-children="false" base-type="LongoMatch.Gui.Component.TeamsComboBox">
-    <itemgroups />
+  <object type="LongoMatch.Gui.CapturerBin" palette-category="General" allow-children="false" 
base-type="Gtk.Bin">
+    <itemgroups>
+      <itemgroup label="CapturerBin Properties">
+        <property name="Capturing" />
+      </itemgroup>
+    </itemgroups>
     <signals />
   </object>
-  <object type="LongoMatch.Gui.Panel.PanelHeader" palette-category="General" allow-children="false" 
base-type="Gtk.Bin">
+  <object type="LongoMatch.Gui.PlayerBin" palette-category="General" allow-children="false" 
base-type="Gtk.Bin">
+    <itemgroups>
+      <itemgroup label="IPlayerBin Properties">
+        <property name="Sensitive" />
+      </itemgroup>
+    </itemgroups>
+    <signals>
+      <itemgroup label="PlayerBin Signals">
+        <signal name="Tick" />
+        <signal name="PlayStateChanged" />
+      </itemgroup>
+    </signals>
+  </object>
+  <object type="LongoMatch.Gui.PlayerCapturerBin" palette-category="General" allow-children="false" 
base-type="Gtk.Bin">
+    <itemgroups>
+      <itemgroup label="IPlayerBin Properties">
+        <property name="Sensitive" />
+      </itemgroup>
+    </itemgroups>
+    <signals>
+      <itemgroup label="IPlayerBin Signals">
+        <signal name="PlayStateChanged" />
+      </itemgroup>
+    </signals>
+  </object>
+  <object type="LongoMatch.Gui.VideoWindow" palette-category="General" allow-children="false" 
base-type="Gtk.Bin">
     <itemgroups />
     <signals>
-      <itemgroup label="PanelHeader Signals">
-        <signal name="ApplyClicked" />
-        <signal name="BackClicked" />
+      <itemgroup label="VideoWindow Signals">
+        <signal name="Realized" />
+        <signal name="ExposeEvent" />
+        <signal name="ButtonPressEvent" />
+        <signal name="ScrollEvent" />
       </itemgroup>
     </signals>
   </object>
diff --git a/LongoMatch.Services/Services/EventsManager.cs b/LongoMatch.Services/Services/EventsManager.cs
index 30ef943..06afedb 100644
--- a/LongoMatch.Services/Services/EventsManager.cs
+++ b/LongoMatch.Services/Services/EventsManager.cs
@@ -81,6 +81,7 @@ namespace LongoMatch.Services
                private void ConnectSignals ()
                {
                        Config.EventsBroker.NewTagEvent += OnNewTag;
+                       Config.EventsBroker.NewPlayEvent += HandleNewPlay;
                        Config.EventsBroker.PlaysDeleted += OnPlaysDeleted;
                        Config.EventsBroker.PlayCategoryChanged += OnPlayCategoryChanged;
                        Config.EventsBroker.DuplicatePlays += OnDuplicatePlays;
@@ -186,24 +187,14 @@ namespace LongoMatch.Services
                        return frame;
                }
 
-               private void AddNewPlay (AnalysisCategory category, Time start, Time stop, List<Player> 
players,
-                                        List<Tag> tags, Image miniature)
+               private void AddNewPlay (Play play)
                {
-                       Log.Debug (String.Format ("New play created start:{0} stop:{1} category:{2}",
-                                                 start, stop, category));
-                       
-                       /* Add the new created play to the project and update the GUI*/
-                       var play = openedProject.AddPlay (category, start, stop, miniature);
-                       if (players != null) {
-                               play.Players = players;
-                       }
-                       if (tags != null) {
-                               play.Tags = tags;
+                       /* Clip play boundaries */
+                       play.Start.MSeconds = Math.Max (0, play.Start.MSeconds);
+                       if (projectType == ProjectType.FileProject) {
+                               play.Stop.MSeconds = Math.Min (player.StreamLength.MSeconds, 
play.Stop.MSeconds);
                        }
 
-                       /* Tag subcategories of the new play */
-                       if (!Config.FastTagging)
-                               guiToolkit.TagPlay (play, openedProject);
                        analysisWindow.AddPlay (play);
                        filter.Update ();
                        if (projectType == ProjectType.FileProject) {
@@ -227,10 +218,32 @@ namespace LongoMatch.Services
                        if (player == null || openedProject == null || !(tagger is AnalysisCategory))
                                return;
                        
-                       start.MSeconds = Math.Max (0, start.MSeconds);
-                       if (projectType == ProjectType.FileProject) {
-                               stop.MSeconds = Math.Min (player.StreamLength.MSeconds, stop.MSeconds);
+                       if (projectType == ProjectType.CaptureProject ||
+                               projectType == ProjectType.URICaptureProject) {
+                               if (!capturer.Capturing) {
+                                       guiToolkit.WarningMessage (Catalog.GetString ("Video capture is 
stopped"));
+                                       return;
+                               }
                        }
+                       frame = CaptureFrame (start);
+                       Log.Debug (String.Format ("New play created start:{0} stop:{1} category:{2}",
+                                                 start.ToMSecondsString(), stop.ToMSecondsString(),
+                                                 tagger.Name));
+                       /* Add the new created play to the project and update the GUI*/
+                       var play = openedProject.AddPlay (tagger as AnalysisCategory, start, stop, frame);
+                       if (players != null) {
+                               play.Players = players;
+                       }
+                       if (tags != null) {
+                               play.Tags = tags;
+                       }
+                       AddNewPlay (play);
+               }
+
+               public void HandleNewPlay (Play play)
+               {
+                       if (player == null || openedProject == null)
+                               return;
                        
                        if (projectType == ProjectType.CaptureProject ||
                                projectType == ProjectType.URICaptureProject) {
@@ -239,8 +252,12 @@ namespace LongoMatch.Services
                                        return;
                                }
                        }
-                       frame = CaptureFrame (start);
-                       AddNewPlay (tagger as AnalysisCategory, start, stop, players, tags, frame);
+                       play.Miniature = CaptureFrame (play.Start);
+                       Log.Debug (String.Format ("New play created start:{0} stop:{1} category:{2}",
+                                                 play.Start.ToMSecondsString(), play.Stop.ToMSecondsString(),
+                                                 play.Category.Name));
+                       openedProject.Timeline.Add (play);
+                       AddNewPlay (play);
                }
 
                protected virtual void OnPlaysDeleted (List<Play> plays)


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