src/FingersDance.Control.UserPanel/UserControlUserPanel.xaml.cs
author ARIAS Santiago
Wed, 04 Nov 2009 11:49:52 +0100
changeset 181 a5b708a9e066
parent 180 1c4ad413c837
child 184 08d773b6ea30
permissions -rw-r--r--
Tag Control Continuation
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
35
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
     1
using System;
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
     2
using System.IO;
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
     3
using System.Net;
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
     4
using System.Windows;
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
     5
using System.Windows.Controls;
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
     6
using System.Windows.Data;
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
     7
using System.Windows.Media;
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
     8
using System.Windows.Media.Animation;
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
     9
using System.Windows.Navigation;
143
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 121
diff changeset
    10
using FingersDance.Data;
180
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
    11
using Microsoft.Surface.Presentation;
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
    12
using System.Globalization;
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
    13
using Microsoft.Surface.Presentation.Controls;
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
    14
using System.Reflection;
35
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
    15
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
    16
namespace FingersDance.Control.UserPanel
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
    17
{
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
    18
	public partial class UserControlUserPanel
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
    19
	{
162
0b9f989bcb37 Display annotations in all opened UserPanels with the user's color
sarias
parents: 160
diff changeset
    20
        #region Variables
0b9f989bcb37 Display annotations in all opened UserPanels with the user's color
sarias
parents: 160
diff changeset
    21
180
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
    22
        //public ContactEventHandler ContactDown;
162
0b9f989bcb37 Display annotations in all opened UserPanels with the user's color
sarias
parents: 160
diff changeset
    23
        public event EventHandler OnSuccessAnnotation;  //Event to display ColorAnnotation from different Users        
131
9331c3dea175 Close Control
sarias
parents: 121
diff changeset
    24
        public int id = 0;
162
0b9f989bcb37 Display annotations in all opened UserPanels with the user's color
sarias
parents: 160
diff changeset
    25
        public uint idcolor = 0;    //The color of the Pivot Button
143
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 121
diff changeset
    26
        Project _Project = new Project();
162
0b9f989bcb37 Display annotations in all opened UserPanels with the user's color
sarias
parents: 160
diff changeset
    27
        #endregion
143
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 121
diff changeset
    28
162
0b9f989bcb37 Display annotations in all opened UserPanels with the user's color
sarias
parents: 160
diff changeset
    29
        #region Properties
143
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 121
diff changeset
    30
        public Project Project
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 121
diff changeset
    31
        {
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 121
diff changeset
    32
            get { return _Project; }
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 121
diff changeset
    33
            set { _Project = value; }
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 121
diff changeset
    34
        }
162
0b9f989bcb37 Display annotations in all opened UserPanels with the user's color
sarias
parents: 160
diff changeset
    35
        #endregion
143
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 121
diff changeset
    36
162
0b9f989bcb37 Display annotations in all opened UserPanels with the user's color
sarias
parents: 160
diff changeset
    37
        #region Constructors
0b9f989bcb37 Display annotations in all opened UserPanels with the user's color
sarias
parents: 160
diff changeset
    38
        public UserControlUserPanel()
35
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
    39
		{
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
    40
			this.InitializeComponent();
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
    41
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
    42
			// Insert code required on object creation below this point.
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
    43
		}
119
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 35
diff changeset
    44
160
e940ca798fe3 Enhance color factory and send the current project (data) to the timeline instance in order to build the project's cutting's annotation list.
cavaliet
parents: 152
diff changeset
    45
        public UserControlUserPanel(int idPar, Color col, Project p, string path)
119
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 35
diff changeset
    46
        {
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 35
diff changeset
    47
            this.InitializeComponent();
150
569925b65604 Annotations are now colored with the same color as the pivot's button
cavaliet
parents: 146
diff changeset
    48
            id = idPar;
143
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 121
diff changeset
    49
            _Project = p;
160
e940ca798fe3 Enhance color factory and send the current project (data) to the timeline instance in order to build the project's cutting's annotation list.
cavaliet
parents: 152
diff changeset
    50
            this.UserControlSyncSource.Load(path, col, _Project.Cutting);
162
0b9f989bcb37 Display annotations in all opened UserPanels with the user's color
sarias
parents: 160
diff changeset
    51
            UserControlSyncSource.OnSuccessAnnotation+=new EventHandler(UserControlSyncSource_OnSuccessAnnotation);
180
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
    52
            //SAR -Contact Down event for TAG Control
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
    53
            InitializeDefinitions();
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
    54
        }
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
    55
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
    56
        private void InitializeDefinitions() 
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
    57
        { 
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
    58
            for (byte k = 1; k <= 5; k++)
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
    59
            { 
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
    60
                ByteTagVisualizationDefinition tagDef = new ByteTagVisualizationDefinition(); 
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
    61
                // The tag value that this definition will respond to. 
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
    62
                tagDef.Value = k; 
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
    63
                // The .xaml file for the UI. 
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
    64
                tagDef.Source = new Uri("FingersDance.Control.UserPanel;Component/TagVisuSoundControl.xaml", UriKind.Relative);
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
    65
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
    66
                // The maximum number for this tag value. tagDef.MaxCount = 2; 
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
    67
                // The visualization stays for 2 seconds after the tag is lifted. 
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
    68
                tagDef.LostTagTimeout = 2000.0; 
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
    69
                // The orientation offset (default). 
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
    70
                tagDef.OrientationOffsetFromTag = 0.0; 
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
    71
                // The physical offset (horizontal inches, vertical inches). 
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
    72
                tagDef.PhysicalCenterOffsetFromTag = new Vector(0.5, 0.25); 
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
    73
                // The tag removal behavior (default). 
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
    74
                tagDef.TagRemovedBehavior = TagRemovedBehavior.Fade; 
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
    75
                // Orient UI to tag? (default). 
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
    76
                tagDef.UsesTagOrientation = true; 
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
    77
                // Add the definition to the collection. 
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
    78
                this.tagVisualizer.Definitions.Add(tagDef); 
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
    79
            } 
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
    80
        }
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
    81
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
    82
        private void OnVisualizationAdded(object sender, TagVisualizerEventArgs e) 
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
    83
        { 
181
a5b708a9e066 Tag Control Continuation
ARIAS Santiago
parents: 180
diff changeset
    84
            TagVisuSoundControl tagsoundcontrol = (TagVisuSoundControl)e.TagVisualization; 
a5b708a9e066 Tag Control Continuation
ARIAS Santiago
parents: 180
diff changeset
    85
            switch (tagsoundcontrol.VisualizedTag.Byte.Value) 
a5b708a9e066 Tag Control Continuation
ARIAS Santiago
parents: 180
diff changeset
    86
            {
a5b708a9e066 Tag Control Continuation
ARIAS Santiago
parents: 180
diff changeset
    87
                case 1: tagsoundcontrol.volumeModel.Content = "Tag Value 1"; 
a5b708a9e066 Tag Control Continuation
ARIAS Santiago
parents: 180
diff changeset
    88
                break;
a5b708a9e066 Tag Control Continuation
ARIAS Santiago
parents: 180
diff changeset
    89
                case 2: tagsoundcontrol.volumeModel.Content = "Tag Value 2"; 
a5b708a9e066 Tag Control Continuation
ARIAS Santiago
parents: 180
diff changeset
    90
                break;
a5b708a9e066 Tag Control Continuation
ARIAS Santiago
parents: 180
diff changeset
    91
                case 3: tagsoundcontrol.volumeModel.Content = "Tag Value 3"; 
a5b708a9e066 Tag Control Continuation
ARIAS Santiago
parents: 180
diff changeset
    92
                break;
a5b708a9e066 Tag Control Continuation
ARIAS Santiago
parents: 180
diff changeset
    93
                case 4: tagsoundcontrol.volumeModel.Content = "Tag Value 4"; 
a5b708a9e066 Tag Control Continuation
ARIAS Santiago
parents: 180
diff changeset
    94
                break;
a5b708a9e066 Tag Control Continuation
ARIAS Santiago
parents: 180
diff changeset
    95
                case 5: tagsoundcontrol.volumeModel.Content = "Tag Value 5"; 
a5b708a9e066 Tag Control Continuation
ARIAS Santiago
parents: 180
diff changeset
    96
                break;
a5b708a9e066 Tag Control Continuation
ARIAS Santiago
parents: 180
diff changeset
    97
                default: tagsoundcontrol.volumeModel.Content = "UNKNOWN MODEL"; 
180
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
    98
                break; 
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
    99
            } 
119
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 35
diff changeset
   100
        }
162
0b9f989bcb37 Display annotations in all opened UserPanels with the user's color
sarias
parents: 160
diff changeset
   101
        #endregion
152
46577fd0a294 PlayerPause en resize
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 150
diff changeset
   102
46577fd0a294 PlayerPause en resize
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 150
diff changeset
   103
        public void PlayerPause()
46577fd0a294 PlayerPause en resize
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 150
diff changeset
   104
        {
46577fd0a294 PlayerPause en resize
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 150
diff changeset
   105
            UserControlSyncSource.PlayerPause();
46577fd0a294 PlayerPause en resize
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 150
diff changeset
   106
        }
162
0b9f989bcb37 Display annotations in all opened UserPanels with the user's color
sarias
parents: 160
diff changeset
   107
0b9f989bcb37 Display annotations in all opened UserPanels with the user's color
sarias
parents: 160
diff changeset
   108
0b9f989bcb37 Display annotations in all opened UserPanels with the user's color
sarias
parents: 160
diff changeset
   109
        private void UserControlSyncSource_OnSuccessAnnotation(object sender, EventArgs e)
0b9f989bcb37 Display annotations in all opened UserPanels with the user's color
sarias
parents: 160
diff changeset
   110
        {
0b9f989bcb37 Display annotations in all opened UserPanels with the user's color
sarias
parents: 160
diff changeset
   111
            OnSuccessAnnotation(this, new EventArgs());
0b9f989bcb37 Display annotations in all opened UserPanels with the user's color
sarias
parents: 160
diff changeset
   112
        }
0b9f989bcb37 Display annotations in all opened UserPanels with the user's color
sarias
parents: 160
diff changeset
   113
0b9f989bcb37 Display annotations in all opened UserPanels with the user's color
sarias
parents: 160
diff changeset
   114
        public void UserControlSyncSource_DisplayAnnotation(int id, Brush b)
0b9f989bcb37 Display annotations in all opened UserPanels with the user's color
sarias
parents: 160
diff changeset
   115
        {
0b9f989bcb37 Display annotations in all opened UserPanels with the user's color
sarias
parents: 160
diff changeset
   116
            UserControlSyncSource.UserControlPlayer_DisplayAnnotation(id, b);
0b9f989bcb37 Display annotations in all opened UserPanels with the user's color
sarias
parents: 160
diff changeset
   117
        }
180
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
   118
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
   119
        //SAR
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
   120
        public void UserControlUserPanel_ContactDown(object sender, ContactEventArgs e)
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
   121
        {
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
   122
            Contact c = e.Contact;
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
   123
            string type = "";
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
   124
            if (c.Tag.Type == TagType.Byte)
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
   125
            {
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
   126
                type = "Byte Tag";
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
   127
                type += (" Value: " + c.Tag.Byte.Value.ToString("X", CultureInfo.InvariantCulture));
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
   128
            }
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
   129
            else if (c.Tag.Type == TagType.Identity)
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
   130
            {
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
   131
                type = "Identity Tag";
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
   132
                type += (" Value: " + c.Tag.Byte.Value.ToString("X", CultureInfo.InvariantCulture));
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
   133
            }
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
   134
        }
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
   135
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
   136
        private void tagVisualizer_VisualizationAdded(object sender, Microsoft.Surface.Presentation.Controls.TagVisualizerEventArgs e)
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
   137
        {
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
   138
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
   139
        }
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
   140
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
   141
        private void v(object sender, Microsoft.Surface.Presentation.Controls.TagVisualizerEventArgs e)
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
   142
        {
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
   143
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
   144
        }
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
   145
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
   146
        
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
   147
    }
35
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
   148
}