# HG changeset patch # User ARIAS Santiago # Date 1257457236 -3600 # Node ID e642ad0c366bb99c8718d86202589b6c0b423bf2 # Parent b266af50744c96bc8e9212fdd661da2a3c0f9bef Tag Visualisation Control Sound (Use Byte Value "01") and Mute all other Players opened diff -r b266af50744c -r e642ad0c366b src/FingersDance.Control.Player/UserControlPlayer.xaml.cs --- a/src/FingersDance.Control.Player/UserControlPlayer.xaml.cs Thu Nov 05 13:13:52 2009 +0100 +++ b/src/FingersDance.Control.Player/UserControlPlayer.xaml.cs Thu Nov 05 22:40:36 2009 +0100 @@ -65,7 +65,6 @@ MediaElementVideo= value; } } - #endregion @@ -97,7 +96,22 @@ if (PlayerStopOrPause != null) PlayerStopOrPause(false, new EventArgs()); } - + + public void setSound(double val) + { + if (((MediaElementVideo.Volume + val) < 1) && ((MediaElementVideo.Volume + val) > 0)) + MediaElementVideo.Volume += val; + else if ((MediaElementVideo.Volume + val) > 1) + MediaElementVideo.Volume = 1; + else + MediaElementVideo.Volume = 0; + } + + public void setMute(bool b) + { + if (b) MediaElementVideo.IsMuted = true; + else MediaElementVideo.IsMuted = false; + } #endregion #region GestureEvents diff -r b266af50744c -r e642ad0c366b src/FingersDance.Control.SyncSource/UserControlSyncSource.xaml.cs --- a/src/FingersDance.Control.SyncSource/UserControlSyncSource.xaml.cs Thu Nov 05 13:13:52 2009 +0100 +++ b/src/FingersDance.Control.SyncSource/UserControlSyncSource.xaml.cs Thu Nov 05 22:40:36 2009 +0100 @@ -58,6 +58,24 @@ userControlTimeLine.thumbRotation((bool)sender); }catch(Exception ){} } + + public void setUserPlayerVolume(double val) + { + try + { + UserControlPlayer.setSound(val); + } + catch (Exception) { } + } + public void setUserPlayerMute(bool b) + { + try + { + UserControlPlayer.setMute(b); + } + catch (Exception) { } + } + #endregion #region TimeLine diff -r b266af50744c -r e642ad0c366b src/FingersDance.Control.UserPanel/TagVisuSoundControl.xaml --- a/src/FingersDance.Control.UserPanel/TagVisuSoundControl.xaml Thu Nov 05 13:13:52 2009 +0100 +++ b/src/FingersDance.Control.UserPanel/TagVisuSoundControl.xaml Thu Nov 05 22:40:36 2009 +0100 @@ -3,8 +3,94 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="http://schemas.microsoft.com/surface/2008" Loaded="TagVisuSoundControl_Loaded" - Height="100" Width="100"> - - + Height="150" Width="150" + x:Name="tagVisualization" > + + + diff -r b266af50744c -r e642ad0c366b src/FingersDance.Control.UserPanel/TagVisuSoundControl.xaml.cs --- a/src/FingersDance.Control.UserPanel/TagVisuSoundControl.xaml.cs Thu Nov 05 13:13:52 2009 +0100 +++ b/src/FingersDance.Control.UserPanel/TagVisuSoundControl.xaml.cs Thu Nov 05 22:40:36 2009 +0100 @@ -14,6 +14,7 @@ using Microsoft.Surface; using Microsoft.Surface.Presentation; using Microsoft.Surface.Presentation.Controls; +using System.ComponentModel; namespace FingersDance.Control.UserPanel { @@ -22,17 +23,115 @@ /// public partial class TagVisuSoundControl : TagVisualization { + //Base sound + int sound =5; + int lastlevel = 0; + //Vars For Debug + List listniveau = new List(); + List listsound = new List(); + public TagVisuSoundControl() { InitializeComponent(); + lastlevel = 1; + TagVisuSoundLevelUpdate(0); } private void TagVisuSoundControl_Loaded(object sender, RoutedEventArgs e) { //TODO: customize TagVisuSoundControl's UI based on this.VisualizedTag here - Label l = new Label(); - l.Content = "Detected!"; - //grid.Children.Add(l); + + } + + //This Method Make the different elipses visible in accordance to the viriable "niveau" + public void TagVisuSoundLevelUpdate(int niveau) + { + int tempsound = 0; + //--DEBUG listniveau.Add(niveau); + if (Math.Abs(lastlevel - niveau) == 1) + { + lastlevel = niveau; + tempsound = sound + niveau; + if (tempsound < 0) + tempsound = 0; + if (tempsound > 10) + tempsound = 10; + //--DEBUG listsound.Add(tempsound); + for (int i = 1; i <= tempsound; i++) + { + switch (i) + { + case 1: + elipse01.Visibility = Visibility.Visible; + break; + case 2: + elipse02.Visibility = Visibility.Visible; + break; + case 3: + elipse03.Visibility = Visibility.Visible; + break; + case 4: + elipse04.Visibility = Visibility.Visible; + break; + case 5: + elipse05.Visibility = Visibility.Visible; + break; + case 6: + elipse06.Visibility = Visibility.Visible; + break; + case 7: + elipse07.Visibility = Visibility.Visible; + break; + case 8: + elipse08.Visibility = Visibility.Visible; + break; + case 9: + elipse09.Visibility = Visibility.Visible; + break; + case 10: + elipse10.Visibility = Visibility.Visible; + break; + } + } + for (int i = tempsound + 1; i < 11; i++) + { + switch (i) + { + case 1: + elipse01.Visibility = Visibility.Hidden; + break; + case 2: + elipse02.Visibility = Visibility.Hidden; + break; + case 3: + elipse03.Visibility = Visibility.Hidden; + break; + case 4: + elipse04.Visibility = Visibility.Hidden; + break; + case 5: + elipse05.Visibility = Visibility.Hidden; + break; + case 6: + elipse06.Visibility = Visibility.Hidden; + break; + case 7: + elipse07.Visibility = Visibility.Hidden; + break; + case 8: + elipse08.Visibility = Visibility.Hidden; + break; + case 9: + elipse09.Visibility = Visibility.Hidden; + break; + case 10: + elipse10.Visibility = Visibility.Hidden; + break; + } + } + } } } + + } diff -r b266af50744c -r e642ad0c366b src/FingersDance.Control.UserPanel/UserControlUserPanel.xaml --- a/src/FingersDance.Control.UserPanel/UserControlUserPanel.xaml Thu Nov 05 13:13:52 2009 +0100 +++ b/src/FingersDance.Control.UserPanel/UserControlUserPanel.xaml Thu Nov 05 22:40:36 2009 +0100 @@ -17,7 +17,8 @@ x:Name="tagVisualizer" Background="#00000000" Height="Auto" - Width="Auto" + Width="Auto" + VisualizationMoved="tagVisualizer_VisualizationMoved" VisualizationAdded="OnVisualizationAdded"/> diff -r b266af50744c -r e642ad0c366b src/FingersDance.Control.UserPanel/UserControlUserPanel.xaml.cs --- a/src/FingersDance.Control.UserPanel/UserControlUserPanel.xaml.cs Thu Nov 05 13:13:52 2009 +0100 +++ b/src/FingersDance.Control.UserPanel/UserControlUserPanel.xaml.cs Thu Nov 05 22:40:36 2009 +0100 @@ -21,12 +21,19 @@ #region Variables //public ContactEventHandler ContactDown; - public event EventHandler OnSuccessAnnotation; //Event to display ColorAnnotation from different Users + public event EventHandler OnSuccessAnnotation; //Event to display ColorAnnotation from different Users + public event EventHandler OnTagVisualisation; //Event to Mute all Players public int id = 0; public uint idcolor = 0; //The color of the Pivot Button //Project _Project = new Project(); private CuttingViewModel cutVM; + //variables for TagSound Control + double baseOrientation = 0; + double deltaOrientation = 0; + double lastdeltaOrientation = 0; + int lastSoundlevel = 0; + bool rise = true; //rise is true if the curse of the volume is positive #endregion #region Properties @@ -61,62 +68,130 @@ cutVM = cutVMPar; this.UserControlSyncSource.Load(path, col, cutVM); UserControlSyncSource.OnSuccessAnnotation+=new EventHandler(UserControlSyncSource_OnSuccessAnnotation); - //SAR -Contact Down event for TAG Control + //SAR -Initialize Tag Values InitializeDefinitions(); } + #endregion - private void InitializeDefinitions() - { + #region Tag Management + + private void InitializeDefinitions() + { for (byte k = 1; k <= 5; k++) - { - ByteTagVisualizationDefinition tagDef = new ByteTagVisualizationDefinition(); + { + ByteTagVisualizationDefinition tagDef = new ByteTagVisualizationDefinition(); // The tag value that this definition will respond to. - tagDef.Value = k; + tagDef.Value = k; // The .xaml file for the UI. tagDef.Source = new Uri("FingersDance.Control.UserPanel;Component/TagVisuSoundControl.xaml", UriKind.Relative); // The maximum number for this tag value. tagDef.MaxCount = 2; // The visualization stays for 2 seconds after the tag is lifted. - tagDef.LostTagTimeout = 2000.0; + tagDef.LostTagTimeout = 2000.0; // The orientation offset (default). - tagDef.OrientationOffsetFromTag = 0.0; + tagDef.OrientationOffsetFromTag = 0.0; // The physical offset (horizontal inches, vertical inches). - tagDef.PhysicalCenterOffsetFromTag = new Vector(0.5, 0.25); + tagDef.PhysicalCenterOffsetFromTag = new Vector(0.5, 0.25); // The tag removal behavior (default). - tagDef.TagRemovedBehavior = TagRemovedBehavior.Fade; + tagDef.TagRemovedBehavior = TagRemovedBehavior.Fade; // Orient UI to tag? (default). - tagDef.UsesTagOrientation = true; + tagDef.UsesTagOrientation = true; // Add the definition to the collection. - this.tagVisualizer.Definitions.Add(tagDef); - } + this.tagVisualizer.Definitions.Add(tagDef); + } } - private void OnVisualizationAdded(object sender, TagVisualizerEventArgs e) - { - TagVisuSoundControl tagsoundcontrol = (TagVisuSoundControl)e.TagVisualization; - switch (tagsoundcontrol.VisualizedTag.Byte.Value) + //SAR - Event Rised when Tag Control is moved or rotated + private void tagVisualizer_VisualizationMoved(object sender, TagVisualizerEventArgs e) + { + /*TagVisuSoundControl tagsoundcontrol = (TagVisuSoundControl)e.TagVisualization; + BindingExpression be = tagsoundcontrol.volumeModel.GetBindingExpression(Label.ContentProperty); + be.UpdateSource();*/ + + TagVisuSoundControl tagsoundcontrol = (TagVisuSoundControl)e.TagVisualization; + + deltaOrientation = (tagsoundcontrol.Orientation - baseOrientation) % 360; + if (deltaOrientation < 0) + deltaOrientation = 360 + deltaOrientation; + int niveau = (int)(deltaOrientation / 36); + + //if (((niveau == 9) || (niveau == 8) || (niveau == 7)) && lastSoundlevel == 0) + if (((niveau == 9) || (niveau == 8)) && lastSoundlevel == 0) + rise = false; + //else if (((niveau == 1) || (niveau == 2) || (niveau == 3)) && lastSoundlevel == 0) + else if (((niveau == 1) || (niveau == 2)) && lastSoundlevel == 0) + rise = true; + + + if (!rise) + { + niveau = (niveau - 10) % 10; + } + //ToDo + //--1 Mute all other Players + + //--2 Elipse visibility + tagsoundcontrol.TagVisuSoundLevelUpdate(niveau); + //Set the Sound of the Player. + if (Math.Abs(lastSoundlevel - niveau) == 1) { - case 1: tagsoundcontrol.volumeModel.Content = "Tag Value 1"; - break; - case 2: tagsoundcontrol.volumeModel.Content = "Tag Value 2"; - break; - case 3: tagsoundcontrol.volumeModel.Content = "Tag Value 3"; - break; - case 4: tagsoundcontrol.volumeModel.Content = "Tag Value 4"; - break; - case 5: tagsoundcontrol.volumeModel.Content = "Tag Value 5"; - break; - default: tagsoundcontrol.volumeModel.Content = "UNKNOWN MODEL"; - break; - } + UserControlSyncSource.setUserPlayerVolume((double)niveau / 10.0); + } + lastSoundlevel = niveau; + tagsoundcontrol.volumeModel.Content = niveau;//deltaOrientation.ToString(); + } + private void OnVisualizationAdded(object sender, TagVisualizerEventArgs e) + { + TagVisuSoundControl tagsoundcontrol = (TagVisuSoundControl)e.TagVisualization; + + switch (tagsoundcontrol.VisualizedTag.Byte.Value) + { + case 1: + try + { + /* + Binding mybinding = new Binding("Orientation"); + mybinding.Source = tagsoundcontrol; + mybinding.UpdateSourceTrigger= UpdateSourceTrigger.PropertyChanged ; + tagsoundcontrol.volumeModel.SetBinding(Label.ContentProperty,mybinding); + */ + + baseOrientation = tagsoundcontrol.Orientation % 360; + deltaOrientation = ((tagsoundcontrol.Orientation % 360) - baseOrientation) % 360; + tagsoundcontrol.volumeModel.Content = deltaOrientation; + + //RiseEvent To Mute all other Players + OnTagVisualisation(this, new EventArgs()); + PlayerMute(false); + } + catch (Exception ex) + { + } + break; + case 2: tagsoundcontrol.volumeModel.Content = "Tag Value 2"; + break; + case 3: tagsoundcontrol.volumeModel.Content = "Tag Value 3"; + break; + case 4: tagsoundcontrol.volumeModel.Content = "Tag Value 4"; + break; + case 5: tagsoundcontrol.volumeModel.Content = "Tag Value 5"; + break; + default: tagsoundcontrol.volumeModel.Content = "UNKNOWN MODEL"; + break; + } + } + #endregion public void PlayerPause() { UserControlSyncSource.PlayerPause(); } - + public void PlayerMute(bool b) + { + UserControlSyncSource.setUserPlayerMute(b); + } private void UserControlSyncSource_OnSuccessAnnotation(object sender, EventArgs e) { @@ -126,35 +201,6 @@ public void UserControlSyncSource_DisplayAnnotation(int id, Brush b) { UserControlSyncSource.UserControlPlayer_DisplayAnnotation(id, b); - } - - //SAR - public void UserControlUserPanel_ContactDown(object sender, ContactEventArgs e) - { - Contact c = e.Contact; - string type = ""; - if (c.Tag.Type == TagType.Byte) - { - type = "Byte Tag"; - type += (" Value: " + c.Tag.Byte.Value.ToString("X", CultureInfo.InvariantCulture)); - } - else if (c.Tag.Type == TagType.Identity) - { - type = "Identity Tag"; - type += (" Value: " + c.Tag.Byte.Value.ToString("X", CultureInfo.InvariantCulture)); - } - } - - private void tagVisualizer_VisualizationAdded(object sender, Microsoft.Surface.Presentation.Controls.TagVisualizerEventArgs e) - { - - } - - private void v(object sender, Microsoft.Surface.Presentation.Controls.TagVisualizerEventArgs e) - { - - } - - + } } } \ No newline at end of file diff -r b266af50744c -r e642ad0c366b src/FingersDance/MainSurfaceWindow.xaml.cs --- a/src/FingersDance/MainSurfaceWindow.xaml.cs Thu Nov 05 13:13:52 2009 +0100 +++ b/src/FingersDance/MainSurfaceWindow.xaml.cs Thu Nov 05 22:40:36 2009 +0100 @@ -434,6 +434,7 @@ Panel1 = new UserControlUserPanel(1, (new ColorFactory()).Colors[color], newCuttingVM, _mainviewmodel.Project.VideoPath); Panel1.Name = "UserPanel1"; Panel1.OnSuccessAnnotation += new EventHandler(Panel_OnSuccessAnnotation); + Panel1.OnTagVisualisation += new EventHandler(Panel_OnTagVisualisation); Panel1.idcolor = color; //3-Rajout sur la Grid Root root.Children.Add(Panel1); @@ -443,6 +444,7 @@ Panel2 = new UserControlUserPanel(2, (new ColorFactory()).Colors[color], newCuttingVM, _mainviewmodel.Project.VideoPath); Panel2.Name = "UserPanel2"; Panel2.OnSuccessAnnotation += new EventHandler(Panel_OnSuccessAnnotation); + Panel2.OnTagVisualisation += new EventHandler(Panel_OnTagVisualisation); Panel2.idcolor = color; //3-Rajout sur la Grid Root root.Children.Add(Panel2); @@ -452,6 +454,7 @@ Panel3 = new UserControlUserPanel(3, (new ColorFactory()).Colors[color], newCuttingVM, _mainviewmodel.Project.VideoPath); Panel3.Name = "UserPanel3"; Panel3.OnSuccessAnnotation += new EventHandler(Panel_OnSuccessAnnotation); + Panel3.OnTagVisualisation += new EventHandler(Panel_OnTagVisualisation); Panel3.idcolor = color; //3-Rajout sur la Grid Root root.Children.Add(Panel3); @@ -461,6 +464,7 @@ Panel4 = new UserControlUserPanel(4, (new ColorFactory()).Colors[color], newCuttingVM, _mainviewmodel.Project.VideoPath); Panel4.Name = "UserPanel4"; Panel4.OnSuccessAnnotation += new EventHandler(Panel_OnSuccessAnnotation); + Panel4.OnTagVisualisation += new EventHandler(Panel_OnTagVisualisation); Panel4.idcolor = color; //3-Rajout sur la Grid Root root.Children.Add(Panel4); @@ -523,8 +527,32 @@ Panel3.UserControlSyncSource_DisplayAnnotation(idUser, brushAnnot); if (Panel4 != null) Panel4.UserControlSyncSource_DisplayAnnotation(idUser, brushAnnot); - - + } + //On Tag Visualisation Mute all the other Players + private void Panel_OnTagVisualisation(object sender, EventArgs e) + { + UserControlUserPanel PanelMaster = (UserControlUserPanel)sender; + if (Panel1 != null) + { + if (!PanelMaster.Name.Equals(Panel1.Name)) + Panel1.PlayerMute(true); + } + if (Panel2 != null) + { + if (!PanelMaster.Name.Equals(Panel2.Name)) + Panel2.PlayerMute(true); + } + if (Panel3 != null) + { + if (!PanelMaster.Name.Equals(Panel3.Name)) + Panel3.PlayerMute(true); + } + if (Panel4 != null) + { + if (!PanelMaster.Name.Equals(Panel4.Name)) + Panel4.PlayerMute(true); + + } } } } \ No newline at end of file