src/FingersDance.Control.UserPanel/UserControlUserPanel.xaml.cs
author cavaliet
Wed, 04 Nov 2009 16:28:01 +0100
changeset 186 83615722dbab
parent 184 08d773b6ea30
child 188 e642ad0c366b
permissions -rw-r--r--
Debug data management for others panels to redisplay.
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;
182
25b49d4f1635 First step of data reorganisation : session is meant to disappear : a "session" is in fact a project and one project owns several cuttings, one per user. WARNING : this commit builds without problems but we can not open more than one UserPanel.
cavaliet
parents: 162
diff changeset
    15
using FingersDance.ViewModels;
35
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
    16
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
    17
namespace FingersDance.Control.UserPanel
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
    18
{
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
    19
	public partial class UserControlUserPanel
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
    20
	{
162
0b9f989bcb37 Display annotations in all opened UserPanels with the user's color
sarias
parents: 160
diff changeset
    21
        #region Variables
0b9f989bcb37 Display annotations in all opened UserPanels with the user's color
sarias
parents: 160
diff changeset
    22
180
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
    23
        //public ContactEventHandler ContactDown;
162
0b9f989bcb37 Display annotations in all opened UserPanels with the user's color
sarias
parents: 160
diff changeset
    24
        public event EventHandler OnSuccessAnnotation;  //Event to display ColorAnnotation from different Users        
131
9331c3dea175 Close Control
sarias
parents: 121
diff changeset
    25
        public int id = 0;
162
0b9f989bcb37 Display annotations in all opened UserPanels with the user's color
sarias
parents: 160
diff changeset
    26
        public uint idcolor = 0;    //The color of the Pivot Button
182
25b49d4f1635 First step of data reorganisation : session is meant to disappear : a "session" is in fact a project and one project owns several cuttings, one per user. WARNING : this commit builds without problems but we can not open more than one UserPanel.
cavaliet
parents: 162
diff changeset
    27
        //Project _Project = new Project();
25b49d4f1635 First step of data reorganisation : session is meant to disappear : a "session" is in fact a project and one project owns several cuttings, one per user. WARNING : this commit builds without problems but we can not open more than one UserPanel.
cavaliet
parents: 162
diff changeset
    28
        private CuttingViewModel cutVM;
25b49d4f1635 First step of data reorganisation : session is meant to disappear : a "session" is in fact a project and one project owns several cuttings, one per user. WARNING : this commit builds without problems but we can not open more than one UserPanel.
cavaliet
parents: 162
diff changeset
    29
162
0b9f989bcb37 Display annotations in all opened UserPanels with the user's color
sarias
parents: 160
diff changeset
    30
        #endregion
143
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 121
diff changeset
    31
162
0b9f989bcb37 Display annotations in all opened UserPanels with the user's color
sarias
parents: 160
diff changeset
    32
        #region Properties
182
25b49d4f1635 First step of data reorganisation : session is meant to disappear : a "session" is in fact a project and one project owns several cuttings, one per user. WARNING : this commit builds without problems but we can not open more than one UserPanel.
cavaliet
parents: 162
diff changeset
    33
        public CuttingViewModel CuttingVM
143
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 121
diff changeset
    34
        {
182
25b49d4f1635 First step of data reorganisation : session is meant to disappear : a "session" is in fact a project and one project owns several cuttings, one per user. WARNING : this commit builds without problems but we can not open more than one UserPanel.
cavaliet
parents: 162
diff changeset
    35
            get { return cutVM; }
25b49d4f1635 First step of data reorganisation : session is meant to disappear : a "session" is in fact a project and one project owns several cuttings, one per user. WARNING : this commit builds without problems but we can not open more than one UserPanel.
cavaliet
parents: 162
diff changeset
    36
            set { cutVM = value; }
143
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 121
diff changeset
    37
        }
162
0b9f989bcb37 Display annotations in all opened UserPanels with the user's color
sarias
parents: 160
diff changeset
    38
        #endregion
143
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 121
diff changeset
    39
182
25b49d4f1635 First step of data reorganisation : session is meant to disappear : a "session" is in fact a project and one project owns several cuttings, one per user. WARNING : this commit builds without problems but we can not open more than one UserPanel.
cavaliet
parents: 162
diff changeset
    40
        //#region Properties
25b49d4f1635 First step of data reorganisation : session is meant to disappear : a "session" is in fact a project and one project owns several cuttings, one per user. WARNING : this commit builds without problems but we can not open more than one UserPanel.
cavaliet
parents: 162
diff changeset
    41
        //public Project Project
25b49d4f1635 First step of data reorganisation : session is meant to disappear : a "session" is in fact a project and one project owns several cuttings, one per user. WARNING : this commit builds without problems but we can not open more than one UserPanel.
cavaliet
parents: 162
diff changeset
    42
        //{
25b49d4f1635 First step of data reorganisation : session is meant to disappear : a "session" is in fact a project and one project owns several cuttings, one per user. WARNING : this commit builds without problems but we can not open more than one UserPanel.
cavaliet
parents: 162
diff changeset
    43
        //    get { return _Project; }
25b49d4f1635 First step of data reorganisation : session is meant to disappear : a "session" is in fact a project and one project owns several cuttings, one per user. WARNING : this commit builds without problems but we can not open more than one UserPanel.
cavaliet
parents: 162
diff changeset
    44
        //    set { _Project = value; }
25b49d4f1635 First step of data reorganisation : session is meant to disappear : a "session" is in fact a project and one project owns several cuttings, one per user. WARNING : this commit builds without problems but we can not open more than one UserPanel.
cavaliet
parents: 162
diff changeset
    45
        //}
25b49d4f1635 First step of data reorganisation : session is meant to disappear : a "session" is in fact a project and one project owns several cuttings, one per user. WARNING : this commit builds without problems but we can not open more than one UserPanel.
cavaliet
parents: 162
diff changeset
    46
        //#endregion
25b49d4f1635 First step of data reorganisation : session is meant to disappear : a "session" is in fact a project and one project owns several cuttings, one per user. WARNING : this commit builds without problems but we can not open more than one UserPanel.
cavaliet
parents: 162
diff changeset
    47
162
0b9f989bcb37 Display annotations in all opened UserPanels with the user's color
sarias
parents: 160
diff changeset
    48
        #region Constructors
0b9f989bcb37 Display annotations in all opened UserPanels with the user's color
sarias
parents: 160
diff changeset
    49
        public UserControlUserPanel()
35
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
    50
		{
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
    51
			this.InitializeComponent();
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
    52
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
    53
			// Insert code required on object creation below this point.
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
    54
		}
119
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 35
diff changeset
    55
186
83615722dbab Debug data management for others panels to redisplay.
cavaliet
parents: 184
diff changeset
    56
        public UserControlUserPanel(int idPar, Color col, CuttingViewModel cutVMPar, string path)
119
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 35
diff changeset
    57
        {
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 35
diff changeset
    58
            this.InitializeComponent();
150
569925b65604 Annotations are now colored with the same color as the pivot's button
cavaliet
parents: 146
diff changeset
    59
            id = idPar;
182
25b49d4f1635 First step of data reorganisation : session is meant to disappear : a "session" is in fact a project and one project owns several cuttings, one per user. WARNING : this commit builds without problems but we can not open more than one UserPanel.
cavaliet
parents: 162
diff changeset
    60
            //_Project = p;
186
83615722dbab Debug data management for others panels to redisplay.
cavaliet
parents: 184
diff changeset
    61
            cutVM = cutVMPar;
83615722dbab Debug data management for others panels to redisplay.
cavaliet
parents: 184
diff changeset
    62
            this.UserControlSyncSource.Load(path, col, cutVM);
162
0b9f989bcb37 Display annotations in all opened UserPanels with the user's color
sarias
parents: 160
diff changeset
    63
            UserControlSyncSource.OnSuccessAnnotation+=new EventHandler(UserControlSyncSource_OnSuccessAnnotation);
180
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
    64
            //SAR -Contact Down event for TAG Control
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
    65
            InitializeDefinitions();
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
    66
        }
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
    67
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
    68
        private void InitializeDefinitions() 
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
    69
        { 
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
    70
            for (byte k = 1; k <= 5; k++)
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
    71
            { 
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
    72
                ByteTagVisualizationDefinition tagDef = new ByteTagVisualizationDefinition(); 
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
    73
                // The tag value that this definition will respond to. 
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
    74
                tagDef.Value = k; 
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
    75
                // The .xaml file for the UI. 
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
    76
                tagDef.Source = new Uri("FingersDance.Control.UserPanel;Component/TagVisuSoundControl.xaml", UriKind.Relative);
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
    77
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
    78
                // The maximum number for this tag value. tagDef.MaxCount = 2; 
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
    79
                // The visualization stays for 2 seconds after the tag is lifted. 
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
    80
                tagDef.LostTagTimeout = 2000.0; 
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
    81
                // The orientation offset (default). 
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
    82
                tagDef.OrientationOffsetFromTag = 0.0; 
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
    83
                // The physical offset (horizontal inches, vertical inches). 
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
    84
                tagDef.PhysicalCenterOffsetFromTag = new Vector(0.5, 0.25); 
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
    85
                // The tag removal behavior (default). 
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
    86
                tagDef.TagRemovedBehavior = TagRemovedBehavior.Fade; 
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
    87
                // Orient UI to tag? (default). 
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
    88
                tagDef.UsesTagOrientation = true; 
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
    89
                // Add the definition to the collection. 
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
    90
                this.tagVisualizer.Definitions.Add(tagDef); 
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
    91
            } 
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
    92
        }
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
    93
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
    94
        private void OnVisualizationAdded(object sender, TagVisualizerEventArgs e) 
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
    95
        { 
181
a5b708a9e066 Tag Control Continuation
ARIAS Santiago
parents: 180
diff changeset
    96
            TagVisuSoundControl tagsoundcontrol = (TagVisuSoundControl)e.TagVisualization; 
a5b708a9e066 Tag Control Continuation
ARIAS Santiago
parents: 180
diff changeset
    97
            switch (tagsoundcontrol.VisualizedTag.Byte.Value) 
a5b708a9e066 Tag Control Continuation
ARIAS Santiago
parents: 180
diff changeset
    98
            {
a5b708a9e066 Tag Control Continuation
ARIAS Santiago
parents: 180
diff changeset
    99
                case 1: tagsoundcontrol.volumeModel.Content = "Tag Value 1"; 
a5b708a9e066 Tag Control Continuation
ARIAS Santiago
parents: 180
diff changeset
   100
                break;
a5b708a9e066 Tag Control Continuation
ARIAS Santiago
parents: 180
diff changeset
   101
                case 2: tagsoundcontrol.volumeModel.Content = "Tag Value 2"; 
a5b708a9e066 Tag Control Continuation
ARIAS Santiago
parents: 180
diff changeset
   102
                break;
a5b708a9e066 Tag Control Continuation
ARIAS Santiago
parents: 180
diff changeset
   103
                case 3: tagsoundcontrol.volumeModel.Content = "Tag Value 3"; 
a5b708a9e066 Tag Control Continuation
ARIAS Santiago
parents: 180
diff changeset
   104
                break;
a5b708a9e066 Tag Control Continuation
ARIAS Santiago
parents: 180
diff changeset
   105
                case 4: tagsoundcontrol.volumeModel.Content = "Tag Value 4"; 
a5b708a9e066 Tag Control Continuation
ARIAS Santiago
parents: 180
diff changeset
   106
                break;
a5b708a9e066 Tag Control Continuation
ARIAS Santiago
parents: 180
diff changeset
   107
                case 5: tagsoundcontrol.volumeModel.Content = "Tag Value 5"; 
a5b708a9e066 Tag Control Continuation
ARIAS Santiago
parents: 180
diff changeset
   108
                break;
a5b708a9e066 Tag Control Continuation
ARIAS Santiago
parents: 180
diff changeset
   109
                default: tagsoundcontrol.volumeModel.Content = "UNKNOWN MODEL"; 
180
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
   110
                break; 
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
   111
            } 
119
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 35
diff changeset
   112
        }
162
0b9f989bcb37 Display annotations in all opened UserPanels with the user's color
sarias
parents: 160
diff changeset
   113
        #endregion
152
46577fd0a294 PlayerPause en resize
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 150
diff changeset
   114
46577fd0a294 PlayerPause en resize
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 150
diff changeset
   115
        public void PlayerPause()
46577fd0a294 PlayerPause en resize
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 150
diff changeset
   116
        {
46577fd0a294 PlayerPause en resize
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 150
diff changeset
   117
            UserControlSyncSource.PlayerPause();
46577fd0a294 PlayerPause en resize
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 150
diff changeset
   118
        }
162
0b9f989bcb37 Display annotations in all opened UserPanels with the user's color
sarias
parents: 160
diff changeset
   119
0b9f989bcb37 Display annotations in all opened UserPanels with the user's color
sarias
parents: 160
diff changeset
   120
0b9f989bcb37 Display annotations in all opened UserPanels with the user's color
sarias
parents: 160
diff changeset
   121
        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
   122
        {
0b9f989bcb37 Display annotations in all opened UserPanels with the user's color
sarias
parents: 160
diff changeset
   123
            OnSuccessAnnotation(this, new EventArgs());
0b9f989bcb37 Display annotations in all opened UserPanels with the user's color
sarias
parents: 160
diff changeset
   124
        }
0b9f989bcb37 Display annotations in all opened UserPanels with the user's color
sarias
parents: 160
diff changeset
   125
0b9f989bcb37 Display annotations in all opened UserPanels with the user's color
sarias
parents: 160
diff changeset
   126
        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
   127
        {
0b9f989bcb37 Display annotations in all opened UserPanels with the user's color
sarias
parents: 160
diff changeset
   128
            UserControlSyncSource.UserControlPlayer_DisplayAnnotation(id, b);
0b9f989bcb37 Display annotations in all opened UserPanels with the user's color
sarias
parents: 160
diff changeset
   129
        }
180
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
   130
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
   131
        //SAR
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
   132
        public void UserControlUserPanel_ContactDown(object sender, ContactEventArgs e)
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
   133
        {
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
   134
            Contact c = e.Contact;
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
   135
            string type = "";
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
   136
            if (c.Tag.Type == TagType.Byte)
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
   137
            {
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
   138
                type = "Byte Tag";
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
   139
                type += (" Value: " + c.Tag.Byte.Value.ToString("X", CultureInfo.InvariantCulture));
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
   140
            }
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
   141
            else if (c.Tag.Type == TagType.Identity)
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
   142
            {
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
   143
                type = "Identity Tag";
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
   144
                type += (" Value: " + c.Tag.Byte.Value.ToString("X", CultureInfo.InvariantCulture));
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
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
   148
        private void tagVisualizer_VisualizationAdded(object sender, Microsoft.Surface.Presentation.Controls.TagVisualizerEventArgs e)
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
   149
        {
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
   150
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
   151
        }
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
   152
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
   153
        private void v(object sender, Microsoft.Surface.Presentation.Controls.TagVisualizerEventArgs e)
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
   154
        {
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
   155
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
   156
        }
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
   157
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
   158
        
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
   159
    }
35
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
   160
}