src/FingersDance.Control.UserPanel/UserControlUserPanel.xaml.cs
author cavaliet
Wed, 04 Nov 2009 13:24:18 +0100
changeset 184 08d773b6ea30
parent 183 026018ce69e5
parent 181 a5b708a9e066
child 186 83615722dbab
permissions -rw-r--r--
Merge
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
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
    56
        public UserControlUserPanel(int idPar, Color col, Cutting cut, 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;
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
    61
            this.UserControlSyncSource.Load(path, col, cut);
162
0b9f989bcb37 Display annotations in all opened UserPanels with the user's color
sarias
parents: 160
diff changeset
    62
            UserControlSyncSource.OnSuccessAnnotation+=new EventHandler(UserControlSyncSource_OnSuccessAnnotation);
180
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
    63
            //SAR -Contact Down event for TAG Control
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
    64
            InitializeDefinitions();
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
    65
        }
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
    66
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
    67
        private void InitializeDefinitions() 
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
    68
        { 
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
    69
            for (byte k = 1; k <= 5; k++)
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
    70
            { 
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
    71
                ByteTagVisualizationDefinition tagDef = new ByteTagVisualizationDefinition(); 
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
    72
                // The tag value that this definition will respond to. 
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
    73
                tagDef.Value = k; 
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
    74
                // The .xaml file for the UI. 
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
    75
                tagDef.Source = new Uri("FingersDance.Control.UserPanel;Component/TagVisuSoundControl.xaml", UriKind.Relative);
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
    76
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
    77
                // The maximum number for this tag value. tagDef.MaxCount = 2; 
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
    78
                // The visualization stays for 2 seconds after the tag is lifted. 
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
    79
                tagDef.LostTagTimeout = 2000.0; 
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
    80
                // The orientation offset (default). 
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
    81
                tagDef.OrientationOffsetFromTag = 0.0; 
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
    82
                // The physical offset (horizontal inches, vertical inches). 
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
    83
                tagDef.PhysicalCenterOffsetFromTag = new Vector(0.5, 0.25); 
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
    84
                // The tag removal behavior (default). 
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
    85
                tagDef.TagRemovedBehavior = TagRemovedBehavior.Fade; 
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
    86
                // Orient UI to tag? (default). 
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
    87
                tagDef.UsesTagOrientation = true; 
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
    88
                // Add the definition to the collection. 
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
    89
                this.tagVisualizer.Definitions.Add(tagDef); 
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
    90
            } 
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
        private void OnVisualizationAdded(object sender, TagVisualizerEventArgs e) 
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
    94
        { 
181
a5b708a9e066 Tag Control Continuation
ARIAS Santiago
parents: 180
diff changeset
    95
            TagVisuSoundControl tagsoundcontrol = (TagVisuSoundControl)e.TagVisualization; 
a5b708a9e066 Tag Control Continuation
ARIAS Santiago
parents: 180
diff changeset
    96
            switch (tagsoundcontrol.VisualizedTag.Byte.Value) 
a5b708a9e066 Tag Control Continuation
ARIAS Santiago
parents: 180
diff changeset
    97
            {
a5b708a9e066 Tag Control Continuation
ARIAS Santiago
parents: 180
diff changeset
    98
                case 1: tagsoundcontrol.volumeModel.Content = "Tag Value 1"; 
a5b708a9e066 Tag Control Continuation
ARIAS Santiago
parents: 180
diff changeset
    99
                break;
a5b708a9e066 Tag Control Continuation
ARIAS Santiago
parents: 180
diff changeset
   100
                case 2: tagsoundcontrol.volumeModel.Content = "Tag Value 2"; 
a5b708a9e066 Tag Control Continuation
ARIAS Santiago
parents: 180
diff changeset
   101
                break;
a5b708a9e066 Tag Control Continuation
ARIAS Santiago
parents: 180
diff changeset
   102
                case 3: tagsoundcontrol.volumeModel.Content = "Tag Value 3"; 
a5b708a9e066 Tag Control Continuation
ARIAS Santiago
parents: 180
diff changeset
   103
                break;
a5b708a9e066 Tag Control Continuation
ARIAS Santiago
parents: 180
diff changeset
   104
                case 4: tagsoundcontrol.volumeModel.Content = "Tag Value 4"; 
a5b708a9e066 Tag Control Continuation
ARIAS Santiago
parents: 180
diff changeset
   105
                break;
a5b708a9e066 Tag Control Continuation
ARIAS Santiago
parents: 180
diff changeset
   106
                case 5: tagsoundcontrol.volumeModel.Content = "Tag Value 5"; 
a5b708a9e066 Tag Control Continuation
ARIAS Santiago
parents: 180
diff changeset
   107
                break;
a5b708a9e066 Tag Control Continuation
ARIAS Santiago
parents: 180
diff changeset
   108
                default: tagsoundcontrol.volumeModel.Content = "UNKNOWN MODEL"; 
180
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
   109
                break; 
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
   110
            } 
119
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 35
diff changeset
   111
        }
162
0b9f989bcb37 Display annotations in all opened UserPanels with the user's color
sarias
parents: 160
diff changeset
   112
        #endregion
152
46577fd0a294 PlayerPause en resize
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 150
diff changeset
   113
46577fd0a294 PlayerPause en resize
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 150
diff changeset
   114
        public void PlayerPause()
46577fd0a294 PlayerPause en resize
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 150
diff changeset
   115
        {
46577fd0a294 PlayerPause en resize
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 150
diff changeset
   116
            UserControlSyncSource.PlayerPause();
46577fd0a294 PlayerPause en resize
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 150
diff changeset
   117
        }
162
0b9f989bcb37 Display annotations in all opened UserPanels with the user's color
sarias
parents: 160
diff changeset
   118
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
        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
   121
        {
0b9f989bcb37 Display annotations in all opened UserPanels with the user's color
sarias
parents: 160
diff changeset
   122
            OnSuccessAnnotation(this, new EventArgs());
0b9f989bcb37 Display annotations in all opened UserPanels with the user's color
sarias
parents: 160
diff changeset
   123
        }
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
        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
   126
        {
0b9f989bcb37 Display annotations in all opened UserPanels with the user's color
sarias
parents: 160
diff changeset
   127
            UserControlSyncSource.UserControlPlayer_DisplayAnnotation(id, b);
0b9f989bcb37 Display annotations in all opened UserPanels with the user's color
sarias
parents: 160
diff changeset
   128
        }
180
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
   129
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
   130
        //SAR
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
   131
        public void UserControlUserPanel_ContactDown(object sender, ContactEventArgs e)
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
   132
        {
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
   133
            Contact c = e.Contact;
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
   134
            string type = "";
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
   135
            if (c.Tag.Type == TagType.Byte)
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
   136
            {
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
   137
                type = "Byte Tag";
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
   138
                type += (" Value: " + c.Tag.Byte.Value.ToString("X", CultureInfo.InvariantCulture));
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
   139
            }
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
   140
            else if (c.Tag.Type == TagType.Identity)
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
   141
            {
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
   142
                type = "Identity Tag";
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
   143
                type += (" Value: " + c.Tag.Byte.Value.ToString("X", CultureInfo.InvariantCulture));
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
        private void tagVisualizer_VisualizationAdded(object sender, Microsoft.Surface.Presentation.Controls.TagVisualizerEventArgs e)
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
   148
        {
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
        private void v(object sender, Microsoft.Surface.Presentation.Controls.TagVisualizerEventArgs e)
1c4ad413c837 Sound Control Base
ARIAS Santiago
parents: 162
diff changeset
   153
        {
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
    }
35
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
   159
}