Display annotations in all opened UserPanels with the user's color
authorsarias
Fri, 16 Oct 2009 21:06:25 +0200
changeset 162 0b9f989bcb37
parent 161 643d31851d02
child 163 d5148710e229
Display annotations in all opened UserPanels with the user's color
src/FingersDance.Control.Pivot/UserControlPivot.xaml.cs
src/FingersDance.Control.Player/UserControlPlayer.xaml
src/FingersDance.Control.Player/UserControlPlayer.xaml.cs
src/FingersDance.Control.SyncSource/UserControlSyncSource.xaml.cs
src/FingersDance.Control.TimeLine/UserControlTimeLine.xaml.cs
src/FingersDance.Control.UserPanel/UserControlUserPanel.xaml.cs
src/FingersDance/MainSurfaceWindow.xaml.cs
--- a/src/FingersDance.Control.Pivot/UserControlPivot.xaml.cs	Fri Oct 16 16:26:21 2009 +0200
+++ b/src/FingersDance.Control.Pivot/UserControlPivot.xaml.cs	Fri Oct 16 21:06:25 2009 +0200
@@ -21,8 +21,9 @@
 			this.InitializeComponent();
             
 			// Insert code required on object creation below this point.
-		}
+        }
 
+        #region Pivot Button Actions
         private void SurfaceButtonPlayer1_ContactDown(object sender, Microsoft.Surface.Presentation.ContactEventArgs e)
         {
             if(EH_SurfaceButtonPlayer_ContactDown!=null)
@@ -66,6 +67,7 @@
         {
             SurfaceButtonPlayer4_ContactDown(this, null);
         }
+        #endregion
 
         public void ApplyColor(int id, uint color)
         {
--- a/src/FingersDance.Control.Player/UserControlPlayer.xaml	Fri Oct 16 16:26:21 2009 +0200
+++ b/src/FingersDance.Control.Player/UserControlPlayer.xaml	Fri Oct 16 21:06:25 2009 +0200
@@ -138,10 +138,10 @@
     			<Custom:SurfaceButton x:Name="Play_Pause_area" ContactDown="ButtonPlayPause_ContactDown" Click="ButtonPlayPause_Click" Foreground="{x:Null}" 
                                       Background="#FFFFFFFF" BorderBrush="{x:Null}" Margin="72,0,126,0" Style="{DynamicResource FingersDance.Control.PlayerButton}" Opacity="0"/>
     			<StackPanel Opacity="1" HorizontalAlignment="Right" Width="50" Background="#FF0046F6" x:Name="StackPanelAnnotation" VerticalAlignment="Bottom" Height="Auto">
-    				<Rectangle Width="50" Height="50" Fill="#FFFFFFFF" Stroke="#FF000000"/>
-    				<Rectangle Width="50" Height="50" Fill="#FFFFFFFF" Stroke="#FF000000"/>
-    				<Rectangle Width="50" Height="50" Fill="#FFFFFFFF" Stroke="#FF000000"/>
-    				<Rectangle Width="50" Height="50" Fill="#FFFFFFFF" Stroke="#FF000000" VerticalAlignment="Bottom"/>
+    				<Rectangle x:Name="rect1" Width="50" Height="50" Fill="#FFFFFFFF" Stroke="#FF000000"/>
+    				<Rectangle x:Name="rect2" Width="50" Height="50" Fill="#FFFFFFFF" Stroke="#FF000000"/>
+    				<Rectangle x:Name="rect3" Width="50" Height="50" Fill="#FFFFFFFF" Stroke="#FF000000"/>
+    				<Rectangle x:Name="rect4" Width="50" Height="50" Fill="#FFFFFFFF" Stroke="#FF000000" VerticalAlignment="Bottom"/>
     			</StackPanel>
     		</Grid>
     	</Viewbox>
--- a/src/FingersDance.Control.Player/UserControlPlayer.xaml.cs	Fri Oct 16 16:26:21 2009 +0200
+++ b/src/FingersDance.Control.Player/UserControlPlayer.xaml.cs	Fri Oct 16 21:06:25 2009 +0200
@@ -85,6 +85,7 @@
         
         #endregion
 
+        #region Button Simple Player Actions
         private void ButtonPlayPause_ContactDown(object sender, Microsoft.Surface.Presentation.ContactEventArgs e)
         {
             if (!isPlaying)//Play
@@ -171,6 +172,8 @@
             }
         }
 
+        #endregion
+
         private void MediaElementVideo_MediaOpened(object sender, RoutedEventArgs e)
         {
             OnPlayerOpened();
@@ -253,5 +256,18 @@
             }
 
         }
+
+        //This function Sets a brush in a specific rectangle of the StackPanelAnnotation
+        public void displayStackPanelAnnotations(int id, Brush brushAnnotation)
+        {
+            switch (id)
+            {
+                case 1: rect1.Fill = brushAnnotation; break;
+                case 2: rect2.Fill = brushAnnotation; break;
+                case 3: rect3.Fill = brushAnnotation; break;
+                case 4: rect4.Fill = brushAnnotation; break;
+                default: break;
+            }
+        }
 	}
 }
\ No newline at end of file
--- a/src/FingersDance.Control.SyncSource/UserControlSyncSource.xaml.cs	Fri Oct 16 16:26:21 2009 +0200
+++ b/src/FingersDance.Control.SyncSource/UserControlSyncSource.xaml.cs	Fri Oct 16 21:06:25 2009 +0200
@@ -14,6 +14,10 @@
 {
 	public partial class UserControlSyncSource
 	{
+        #region Variables   
+            public event EventHandler OnSuccessAnnotation;
+        #endregion
+
 		public UserControlSyncSource()
 		{
 			this.InitializeComponent();
@@ -27,6 +31,7 @@
             //Initialisation du Timer
             UCTimeLine.initTimer(col, projCutting);
             this.UserControlPlayer.playerPlay();
+            this.userControlTimeLine.OnSuccessAnnotation+=new EventHandler(userControlTimeLine_OnSuccessAnnotation);
         }
 
         #region player
@@ -38,6 +43,12 @@
             UCTimeLine.timerStart();
 
         }
+
+        //Set a bursh color to the stack panel in the Player
+        public void UserControlPlayer_DisplayAnnotation(int id, Brush b)
+        {
+            UserControlPlayer.displayStackPanelAnnotations(id, b);
+        }
         #endregion
 
         #region TimeLine
@@ -52,6 +63,10 @@
         private void UserControlTimeLine_DragCompleted(object sender, EventArgs e)
         {
         }
+        private void userControlTimeLine_OnSuccessAnnotation(object sender, EventArgs e)
+        {
+            OnSuccessAnnotation(this, new EventArgs());
+        }
         #endregion
 
 
--- a/src/FingersDance.Control.TimeLine/UserControlTimeLine.xaml.cs	Fri Oct 16 16:26:21 2009 +0200
+++ b/src/FingersDance.Control.TimeLine/UserControlTimeLine.xaml.cs	Fri Oct 16 21:06:25 2009 +0200
@@ -33,6 +33,9 @@
         public event EventHandler DragStarted;
         public event EventHandler DragCompleted;
         public event EventHandler TimerTick;
+        //SAR
+        public event EventHandler OnSuccessAnnotation;
+        //ENDSAR
 
         private double totalmilliseconds;
         
@@ -281,6 +284,9 @@
                 }
 
             }
+            //Raise Event to display Annotation in all Openned UserPanels
+            if (annotOk)
+                OnSuccessAnnotation(this, new EventArgs());
 
         }
 
@@ -339,6 +345,9 @@
                     AnnotWaiting = false;
                 }
             }
+            //Raise Event to display Annotation in all Openned UserPanels
+            if(annotOk)
+                OnSuccessAnnotation(this, new EventArgs());
         }
 
         private void listview_PreviewContactDown(object sender, Microsoft.Surface.Presentation.ContactEventArgs e)
--- a/src/FingersDance.Control.UserPanel/UserControlUserPanel.xaml.cs	Fri Oct 16 16:26:21 2009 +0200
+++ b/src/FingersDance.Control.UserPanel/UserControlUserPanel.xaml.cs	Fri Oct 16 21:06:25 2009 +0200
@@ -13,16 +13,24 @@
 {
 	public partial class UserControlUserPanel
 	{
+        #region Variables
+
+        public event EventHandler OnSuccessAnnotation;  //Event to display ColorAnnotation from different Users        
         public int id = 0;
+        public uint idcolor = 0;    //The color of the Pivot Button
         Project _Project = new Project();
+        #endregion
 
+        #region Properties
         public Project Project
         {
             get { return _Project; }
             set { _Project = value; }
         }
+        #endregion
 
-		public UserControlUserPanel()
+        #region Constructors
+        public UserControlUserPanel()
 		{
 			this.InitializeComponent();
 
@@ -35,11 +43,24 @@
             id = idPar;
             _Project = p;
             this.UserControlSyncSource.Load(path, col, _Project.Cutting);
+            UserControlSyncSource.OnSuccessAnnotation+=new EventHandler(UserControlSyncSource_OnSuccessAnnotation);
         }
+        #endregion
 
         public void PlayerPause()
         {
             UserControlSyncSource.PlayerPause();
         }
+
+
+        private void UserControlSyncSource_OnSuccessAnnotation(object sender, EventArgs e)
+        {
+            OnSuccessAnnotation(this, new EventArgs());
+        }
+
+        public void UserControlSyncSource_DisplayAnnotation(int id, Brush b)
+        {
+            UserControlSyncSource.UserControlPlayer_DisplayAnnotation(id, b);
+        }
 	}
 }
\ No newline at end of file
--- a/src/FingersDance/MainSurfaceWindow.xaml.cs	Fri Oct 16 16:26:21 2009 +0200
+++ b/src/FingersDance/MainSurfaceWindow.xaml.cs	Fri Oct 16 21:06:25 2009 +0200
@@ -40,8 +40,7 @@
         private UserControlUserPanel Panel3 = null;
         private UserControlUserPanel Panel4 = null;
         ActionGenerator _Factory = (new ActionFactory()).GetGenerator();
-        private MainViewModel _mainviewmodel = new MainViewModel();      
-
+        private MainViewModel _mainviewmodel = new MainViewModel();
         #endregion
 
 
@@ -49,7 +48,6 @@
         public SurfaceWindow1()
         {
             InitializeComponent();
-
             //Permet d'initialiser l'inertie du Pivot une fois relaché.
             InitPivotInertia();
             //Permet d'initialiser les quand Grid à la position initiale du pivot
@@ -94,6 +92,7 @@
 
         #endregion
 
+        #region Application Default Functions
         /// <summary>
         /// Occurs when the window is about to close. 
         /// </summary>
@@ -183,10 +182,14 @@
             // Dismiss the loading screen.
             ApplicationLauncher.SignalApplicationLoadComplete();
         }
+        #endregion
 
+
+        
+
+        #region Pivot Actions
         private void scaterview_ContactChanged(object sender, ContactEventArgs e)
-        {  }
-
+        { }
         private void ScatterViewItemPivot_ContactChanged(object sender, ContactEventArgs e)
         {
             //Permet la MAJ des 4 Grids à la position du pivot
@@ -387,9 +390,12 @@
                     }
                     break;
             }
-                        
+
         }
 
+        #endregion
+
+
         //Button Submit du control SessionInput
         private void SessionInput_EH_SurfaceButtonSubmit_ContactDown(object sender, EventArgs e)
         {
@@ -415,6 +421,8 @@
                             UserControlPivot.ApplyColor(1, color);
                             Panel1 = new UserControlUserPanel(1, (new ColorFactory()).Colors[color], newProject, _mainviewmodel.Session.VideoPath);
                             Panel1.Name = "UserPanel1";
+                            Panel1.OnSuccessAnnotation += new EventHandler(Panel_OnSuccessAnnotation);
+                            Panel1.idcolor = color;
                             //3-Rajout sur la Grid Root
                             root.Children.Add(Panel1);
                             break;
@@ -422,6 +430,8 @@
                             UserControlPivot.ApplyColor(2, color);
                             Panel2 = new UserControlUserPanel(2, (new ColorFactory()).Colors[color], newProject, _mainviewmodel.Session.VideoPath);
                             Panel2.Name = "UserPanel2";
+                            Panel2.OnSuccessAnnotation += new EventHandler(Panel_OnSuccessAnnotation);
+                            Panel2.idcolor = color;
                             //3-Rajout sur la Grid Root
                             root.Children.Add(Panel2);
                             break;
@@ -429,6 +439,8 @@
                             UserControlPivot.ApplyColor(3, color);
                             Panel3 = new UserControlUserPanel(3, (new ColorFactory()).Colors[color], newProject, _mainviewmodel.Session.VideoPath);
                             Panel3.Name = "UserPanel3";
+                            Panel3.OnSuccessAnnotation += new EventHandler(Panel_OnSuccessAnnotation);
+                            Panel3.idcolor = color;
                             //3-Rajout sur la Grid Root
                             root.Children.Add(Panel3);
                             break;
@@ -436,6 +448,8 @@
                             UserControlPivot.ApplyColor(4, color);
                             Panel4 = new UserControlUserPanel(4, (new ColorFactory()).Colors[color], newProject, _mainviewmodel.Session.VideoPath);
                             Panel4.Name = "UserPanel4";
+                            Panel4.OnSuccessAnnotation += new EventHandler(Panel_OnSuccessAnnotation);
+                            Panel4.idcolor = color;
                             //3-Rajout sur la Grid Root
                             root.Children.Add(Panel4);
                             break;
@@ -478,5 +492,25 @@
             root.Children.Remove(((UserControlClose)sender));
         }
 
+
+        //On success annotation Display annotations in the different Panels
+        private void Panel_OnSuccessAnnotation(object sender, EventArgs e)
+        {
+            UserControlUserPanel PanelAnnotation = (UserControlUserPanel)sender;
+            int idUser = PanelAnnotation.id;
+            //Get Color Of User
+            Brush brushAnnot = new SolidColorBrush((new ColorFactory()).Colors[PanelAnnotation.idcolor]);
+            //set Color to All Panels
+            if(Panel1!=null)
+                Panel1.UserControlSyncSource_DisplayAnnotation(idUser, brushAnnot);
+            if (Panel2 != null)
+                Panel2.UserControlSyncSource_DisplayAnnotation(idUser, brushAnnot);
+            if (Panel3 != null)
+                Panel3.UserControlSyncSource_DisplayAnnotation(idUser, brushAnnot);
+            if (Panel4 != null)
+                Panel4.UserControlSyncSource_DisplayAnnotation(idUser, brushAnnot);
+
+
+        }
     }
 }
\ No newline at end of file