--- 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