[longomatch] Connect event handlers only when needed.



commit 2186a0903244695ad1c5d3b59007c1d647dcd525
Author: Julien Moutte <julien fluendo com>
Date:   Fri Mar 27 14:14:33 2015 +0100

    Connect event handlers only when needed.
    
    This allows to remove an unnecessary safety check and function calls in single camera mode.

 LongoMatch.GUI/Gui/Component/ProjectPeriods.cs |   13 +++++++------
 1 files changed, 7 insertions(+), 6 deletions(-)
---
diff --git a/LongoMatch.GUI/Gui/Component/ProjectPeriods.cs b/LongoMatch.GUI/Gui/Component/ProjectPeriods.cs
index 31f2b9b..72eeded 100644
--- a/LongoMatch.GUI/Gui/Component/ProjectPeriods.cs
+++ b/LongoMatch.GUI/Gui/Component/ProjectPeriods.cs
@@ -105,9 +105,7 @@ namespace LongoMatch.Gui.Component
                        // Listen for seek events from the timerule
                        Config.EventsBroker.SeekEvent += Seek;
                        Config.EventsBroker.KeyPressed += HandleKeyPressed;
-                       // Handle dragging of cameras and periods
-                       camerasTimeline.CameraDragged += HandleCameraDragged;
-                       camerasTimeline.SelectedCameraChanged += HandleSelectedCameraChanged;
+                       // Handle dragging of periods
                        camerasTimeline.TimeNodeChanged += HandleTimeNodeChanged;
                        camerasTimeline.ShowTimerMenuEvent += HandleShowTimerMenuEvent;
 
@@ -238,7 +236,13 @@ namespace LongoMatch.Gui.Component
                                if (fileSet.Count > 1) {
                                        // Start with initial didactic message
                                        ShowDidactic (DidacticMessage.Initial);
+                                       // Connect secondary camera event handlers
+                                       camerasTimeline.CameraDragged += HandleCameraDragged;
+                                       camerasTimeline.SelectedCameraChanged += HandleSelectedCameraChanged;
                                } else {
+                                       // Disconnect secondary camera event handlers
+                                       camerasTimeline.CameraDragged -= HandleCameraDragged;
+                                       camerasTimeline.SelectedCameraChanged -= HandleSelectedCameraChanged;
                                        // Just in case it was previously visible, a mediafile might still be 
loaded if 
                                        // the user is going back and forth adding/removing files to the set.
                                        HideSecondaryPlayer ();
@@ -421,9 +425,6 @@ namespace LongoMatch.Gui.Component
                /// </summary>
                void ShowDidactic (DidacticMessage message)
                {
-                       if (project.Description.FileSet.Count == 1) {
-                               return;
-                       }
                        // Show didactic message, hide secondary player
                        HideSecondaryPlayer ();
                        switch (message) {


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