src/FingersDance.Control.Screen/UserControlScreen.xaml.cs
author PAMPHILE Jonathan <pamphile@efrei.fr>
Fri, 13 Nov 2009 20:10:00 +0100
changeset 195 48b3139bb182
parent 192 11083c390ce4
child 208 0699cab5cbb3
permissions -rw-r--r--
Dictionnaire de données
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;
148
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 143
diff changeset
     4
using System.Collections.Generic;
35
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
     5
using System.Windows;
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
     6
using System.Windows.Controls;
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
     7
using System.Windows.Data;
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
     8
using System.Windows.Media;
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
     9
using System.Windows.Media.Animation;
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
    10
using System.Windows.Navigation;
192
11083c390ce4 Second step of data saving : id added for cutting and annotation, and now we can load/display/change the already existing projects.
cavaliet
parents: 191
diff changeset
    11
using System.Xml.Linq;
104
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 95
diff changeset
    12
using FingersDance.Control.ListVideo;
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 95
diff changeset
    13
using FingersDance.Control.SessionInput;
143
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 112
diff changeset
    14
using FingersDance.ViewModels;
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 112
diff changeset
    15
using FingersDance.Data;
35
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
    16
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
    17
namespace FingersDance.Control.Screen
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
    18
{
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
    19
	public partial class UserControlScreen
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
    20
	{
82
c37122b567fa Work ControlScreen
sarias
parents: 80
diff changeset
    21
        public String contexteGrid;
112
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 104
diff changeset
    22
        public int id = 0;
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: 156
diff changeset
    23
        public event EventHandler UC_Screen_NewCutting;
190
619ca3ae13c7 MainViewModel is now well linked to all the users'cuttings. At any moment, the MVM has all annotations. This step prepares data saving.
cavaliet
parents: 187
diff changeset
    24
        private MainViewModel _mainViewModel;
619ca3ae13c7 MainViewModel is now well linked to all the users'cuttings. At any moment, the MVM has all annotations. This step prepares data saving.
cavaliet
parents: 187
diff changeset
    25
        public Cutting Cutting;
192
11083c390ce4 Second step of data saving : id added for cutting and annotation, and now we can load/display/change the already existing projects.
cavaliet
parents: 191
diff changeset
    26
11083c390ce4 Second step of data saving : id added for cutting and annotation, and now we can load/display/change the already existing projects.
cavaliet
parents: 191
diff changeset
    27
        private String videoName;
11083c390ce4 Second step of data saving : id added for cutting and annotation, and now we can load/display/change the already existing projects.
cavaliet
parents: 191
diff changeset
    28
        private String videoPath;
11083c390ce4 Second step of data saving : id added for cutting and annotation, and now we can load/display/change the already existing projects.
cavaliet
parents: 191
diff changeset
    29
148
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 143
diff changeset
    30
        User User = new User();
95
07972aa3f2e0 ListVideo
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 82
diff changeset
    31
143
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 112
diff changeset
    32
        public UserControlScreen(int id, MainViewModel mvmodel)
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 112
diff changeset
    33
        {
152
46577fd0a294 PlayerPause en resize
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 148
diff changeset
    34
            try
143
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 112
diff changeset
    35
            {
152
46577fd0a294 PlayerPause en resize
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 148
diff changeset
    36
                this.InitializeComponent();
46577fd0a294 PlayerPause en resize
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 148
diff changeset
    37
                this.id = id;
186
83615722dbab Debug data management for others panels to redisplay.
cavaliet
parents: 182
diff changeset
    38
                User.Name = "User " + id;
190
619ca3ae13c7 MainViewModel is now well linked to all the users'cuttings. At any moment, the MVM has all annotations. This step prepares data saving.
cavaliet
parents: 187
diff changeset
    39
                _mainViewModel = mvmodel;
619ca3ae13c7 MainViewModel is now well linked to all the users'cuttings. At any moment, the MVM has all annotations. This step prepares data saving.
cavaliet
parents: 187
diff changeset
    40
                if (_mainViewModel.Project.VideoPath.Equals(""))
152
46577fd0a294 PlayerPause en resize
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 148
diff changeset
    41
                {
46577fd0a294 PlayerPause en resize
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 148
diff changeset
    42
                    //1-Creation de la ListVideo
46577fd0a294 PlayerPause en resize
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 148
diff changeset
    43
                    UserControlListVideo ListVideo = new UserControlListVideo();
46577fd0a294 PlayerPause en resize
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 148
diff changeset
    44
                    ListVideo.Name = "ListVideo1";
46577fd0a294 PlayerPause en resize
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 148
diff changeset
    45
                    //2-Ajout de la ListVideo au ControlScreen
46577fd0a294 PlayerPause en resize
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 148
diff changeset
    46
                    this.AddToGrid(ListVideo);
46577fd0a294 PlayerPause en resize
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 148
diff changeset
    47
                    //3-Creation des Events pour chaque item de la video
191
8a25a85f2656 First step of data saving in a ldt/xml file. First step of displaying the existing ldt files (not loaded yet)
cavaliet
parents: 190
diff changeset
    48
                    ListVideo.EH_ItemVideo1_ContactDown += new System.EventHandler(ListVideo_EH_ItemVideo_ContactDown);
152
46577fd0a294 PlayerPause en resize
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 148
diff changeset
    49
                }
46577fd0a294 PlayerPause en resize
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 148
diff changeset
    50
                else
46577fd0a294 PlayerPause en resize
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 148
diff changeset
    51
                    OpenProject();
143
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 112
diff changeset
    52
            }
152
46577fd0a294 PlayerPause en resize
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 148
diff changeset
    53
            catch (Exception)
46577fd0a294 PlayerPause en resize
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 148
diff changeset
    54
            {
190
619ca3ae13c7 MainViewModel is now well linked to all the users'cuttings. At any moment, the MVM has all annotations. This step prepares data saving.
cavaliet
parents: 187
diff changeset
    55
                Cutting = null;
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: 156
diff changeset
    56
                if (UC_Screen_NewCutting != null)
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: 156
diff changeset
    57
                    UC_Screen_NewCutting(this, new EventArgs());
152
46577fd0a294 PlayerPause en resize
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 148
diff changeset
    58
            }
143
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 112
diff changeset
    59
        }
35
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
    60
82
c37122b567fa Work ControlScreen
sarias
parents: 80
diff changeset
    61
        //Rajout un UIElement vers la grid du screen.
c37122b567fa Work ControlScreen
sarias
parents: 80
diff changeset
    62
        public void AddToGrid(UIElement uie)
c37122b567fa Work ControlScreen
sarias
parents: 80
diff changeset
    63
        {
c37122b567fa Work ControlScreen
sarias
parents: 80
diff changeset
    64
            if (uie != null)
c37122b567fa Work ControlScreen
sarias
parents: 80
diff changeset
    65
            {
c37122b567fa Work ControlScreen
sarias
parents: 80
diff changeset
    66
                try { LayoutRoot.Children.Add(uie); }
c37122b567fa Work ControlScreen
sarias
parents: 80
diff changeset
    67
                catch(Exception){}
c37122b567fa Work ControlScreen
sarias
parents: 80
diff changeset
    68
            }          
c37122b567fa Work ControlScreen
sarias
parents: 80
diff changeset
    69
        }
c37122b567fa Work ControlScreen
sarias
parents: 80
diff changeset
    70
104
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 95
diff changeset
    71
        private void ListVideo_EH_ItemVideo_ContactDown(object sender, EventArgs e)
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 95
diff changeset
    72
        {
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 95
diff changeset
    73
            try
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 95
diff changeset
    74
            {
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: 156
diff changeset
    75
                //1 renseigner la video choisie au screen et créer un nouveau projet à partir de ce chemin vidéo
192
11083c390ce4 Second step of data saving : id added for cutting and annotation, and now we can load/display/change the already existing projects.
cavaliet
parents: 191
diff changeset
    76
                videoName = ((UserControlListVideo)sender).VideoName;
11083c390ce4 Second step of data saving : id added for cutting and annotation, and now we can load/display/change the already existing projects.
cavaliet
parents: 191
diff changeset
    77
                videoPath = ((UserControlListVideo)sender).path;
11083c390ce4 Second step of data saving : id added for cutting and annotation, and now we can load/display/change the already existing projects.
cavaliet
parents: 191
diff changeset
    78
                _mainViewModel.CreateProject(videoName, videoPath);
148
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 143
diff changeset
    79
                //2-Supression du UC List Video
104
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 95
diff changeset
    80
                LayoutRoot.Children.Remove((UserControlListVideo)sender);
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: 156
diff changeset
    81
                OpenProjectList();
104
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 95
diff changeset
    82
            }
152
46577fd0a294 PlayerPause en resize
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 148
diff changeset
    83
            catch (Exception ex)
46577fd0a294 PlayerPause en resize
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 148
diff changeset
    84
            {
190
619ca3ae13c7 MainViewModel is now well linked to all the users'cuttings. At any moment, the MVM has all annotations. This step prepares data saving.
cavaliet
parents: 187
diff changeset
    85
                Cutting = null;
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: 156
diff changeset
    86
                if (UC_Screen_NewCutting != null)
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: 156
diff changeset
    87
                    UC_Screen_NewCutting(this, new EventArgs());
152
46577fd0a294 PlayerPause en resize
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 148
diff changeset
    88
            }
104
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 95
diff changeset
    89
        }
148
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 143
diff changeset
    90
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: 156
diff changeset
    91
        private void OpenProjectList()
148
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 143
diff changeset
    92
        {
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 143
diff changeset
    93
            try
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 143
diff changeset
    94
            {
192
11083c390ce4 Second step of data saving : id added for cutting and annotation, and now we can load/display/change the already existing projects.
cavaliet
parents: 191
diff changeset
    95
                // We get all the ldt/project files from the current directory...
11083c390ce4 Second step of data saving : id added for cutting and annotation, and now we can load/display/change the already existing projects.
cavaliet
parents: 191
diff changeset
    96
                List<String> existingProjects = new List<String>();
11083c390ce4 Second step of data saving : id added for cutting and annotation, and now we can load/display/change the already existing projects.
cavaliet
parents: 191
diff changeset
    97
                foreach (String filename in Directory.GetFiles("./"))
11083c390ce4 Second step of data saving : id added for cutting and annotation, and now we can load/display/change the already existing projects.
cavaliet
parents: 191
diff changeset
    98
                {
11083c390ce4 Second step of data saving : id added for cutting and annotation, and now we can load/display/change the already existing projects.
cavaliet
parents: 191
diff changeset
    99
                    if (filename.Substring(filename.Length-4).ToLower()==".ldt")
11083c390ce4 Second step of data saving : id added for cutting and annotation, and now we can load/display/change the already existing projects.
cavaliet
parents: 191
diff changeset
   100
                        existingProjects.Add(filename.Substring(2, filename.Length - 6));
11083c390ce4 Second step of data saving : id added for cutting and annotation, and now we can load/display/change the already existing projects.
cavaliet
parents: 191
diff changeset
   101
                }
11083c390ce4 Second step of data saving : id added for cutting and annotation, and now we can load/display/change the already existing projects.
cavaliet
parents: 191
diff changeset
   102
                // ... and display them the the select box UserControlListProject
187
b266af50744c Change file and event names for code to be clearer and more coherent with the project and cuttings organisation
cavaliet
parents: 186
diff changeset
   103
                UserControlListProject listProject = new UserControlListProject(existingProjects);
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: 156
diff changeset
   104
                listProject.Name = "ListProject";
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: 156
diff changeset
   105
                LayoutRoot.Children.Add(listProject);
187
b266af50744c Change file and event names for code to be clearer and more coherent with the project and cuttings organisation
cavaliet
parents: 186
diff changeset
   106
                listProject.EH_ListProject_ContactDown += new EventHandler(listProject_EH_ListProject_ContactDown);
148
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 143
diff changeset
   107
            }
152
46577fd0a294 PlayerPause en resize
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 148
diff changeset
   108
            catch (Exception)
46577fd0a294 PlayerPause en resize
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 148
diff changeset
   109
            {
190
619ca3ae13c7 MainViewModel is now well linked to all the users'cuttings. At any moment, the MVM has all annotations. This step prepares data saving.
cavaliet
parents: 187
diff changeset
   110
                Cutting = null;
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: 156
diff changeset
   111
                if (UC_Screen_NewCutting != null)
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: 156
diff changeset
   112
                    UC_Screen_NewCutting(this, new EventArgs());
152
46577fd0a294 PlayerPause en resize
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 148
diff changeset
   113
            }
148
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 143
diff changeset
   114
        }
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 143
diff changeset
   115
187
b266af50744c Change file and event names for code to be clearer and more coherent with the project and cuttings organisation
cavaliet
parents: 186
diff changeset
   116
        void listProject_EH_ListProject_ContactDown(object sender, EventArgs e)
148
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 143
diff changeset
   117
        {
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 143
diff changeset
   118
            try
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 143
diff changeset
   119
            {
187
b266af50744c Change file and event names for code to be clearer and more coherent with the project and cuttings organisation
cavaliet
parents: 186
diff changeset
   120
                LayoutRoot.Children.Remove((UserControlListProject)sender);
b266af50744c Change file and event names for code to be clearer and more coherent with the project and cuttings organisation
cavaliet
parents: 186
diff changeset
   121
                if (((UserControlListProject)sender).SelectedItem.Equals("New Project"))
148
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 143
diff changeset
   122
                {
187
b266af50744c Change file and event names for code to be clearer and more coherent with the project and cuttings organisation
cavaliet
parents: 186
diff changeset
   123
                    UserControlNewProjectForm ProjectInput = new UserControlNewProjectForm();
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: 156
diff changeset
   124
                    ProjectInput.Name = "ProjectInput";
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: 156
diff changeset
   125
                    LayoutRoot.Children.Add(ProjectInput);
187
b266af50744c Change file and event names for code to be clearer and more coherent with the project and cuttings organisation
cavaliet
parents: 186
diff changeset
   126
                    ProjectInput.EH_NewProjectForm_ContactDown += new System.EventHandler(this.ProjectInput_EH_NewProjectForm_ContactDown);
148
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 143
diff changeset
   127
                }
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 143
diff changeset
   128
                else
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 143
diff changeset
   129
                {
192
11083c390ce4 Second step of data saving : id added for cutting and annotation, and now we can load/display/change the already existing projects.
cavaliet
parents: 191
diff changeset
   130
                    // ((UserControlListProject)sender).SelectedItem is the name of the selected project
11083c390ce4 Second step of data saving : id added for cutting and annotation, and now we can load/display/change the already existing projects.
cavaliet
parents: 191
diff changeset
   131
                    // Now we load the xml/ldt file to load all its datas (cuttings, annotations...)
11083c390ce4 Second step of data saving : id added for cutting and annotation, and now we can load/display/change the already existing projects.
cavaliet
parents: 191
diff changeset
   132
                    XDocument loadedLdt = XDocument.Load(((UserControlListProject)sender).SelectedItem + ".ldt");
11083c390ce4 Second step of data saving : id added for cutting and annotation, and now we can load/display/change the already existing projects.
cavaliet
parents: 191
diff changeset
   133
                    Project loadedProject = new Project(videoName, videoPath);
11083c390ce4 Second step of data saving : id added for cutting and annotation, and now we can load/display/change the already existing projects.
cavaliet
parents: 191
diff changeset
   134
                    loadedProject.Name = loadedLdt.Root.Element("project").Attribute("title").Value;
11083c390ce4 Second step of data saving : id added for cutting and annotation, and now we can load/display/change the already existing projects.
cavaliet
parents: 191
diff changeset
   135
                    loadedProject.Description = loadedLdt.Root.Element("project").Attribute("abstract").Value;
11083c390ce4 Second step of data saving : id added for cutting and annotation, and now we can load/display/change the already existing projects.
cavaliet
parents: 191
diff changeset
   136
                    loadedProject.Cuttings = new List<Cutting>();
11083c390ce4 Second step of data saving : id added for cutting and annotation, and now we can load/display/change the already existing projects.
cavaliet
parents: 191
diff changeset
   137
                    XElement cuttingsParentNode = loadedLdt.Root.Element("annotations").Element("content");
11083c390ce4 Second step of data saving : id added for cutting and annotation, and now we can load/display/change the already existing projects.
cavaliet
parents: 191
diff changeset
   138
                    foreach (XElement cuttingNode in cuttingsParentNode.Elements())
148
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 143
diff changeset
   139
                    {
192
11083c390ce4 Second step of data saving : id added for cutting and annotation, and now we can load/display/change the already existing projects.
cavaliet
parents: 191
diff changeset
   140
                        List<Annotation> la = new List<Annotation>();
11083c390ce4 Second step of data saving : id added for cutting and annotation, and now we can load/display/change the already existing projects.
cavaliet
parents: 191
diff changeset
   141
                        foreach (XElement annotNode in cuttingNode.Element("elements").Elements())
148
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 143
diff changeset
   142
                        {
192
11083c390ce4 Second step of data saving : id added for cutting and annotation, and now we can load/display/change the already existing projects.
cavaliet
parents: 191
diff changeset
   143
                            String aId = annotNode.Attribute("id").Value;
11083c390ce4 Second step of data saving : id added for cutting and annotation, and now we can load/display/change the already existing projects.
cavaliet
parents: 191
diff changeset
   144
                            float begin = (float)annotNode.Attribute("begin");
11083c390ce4 Second step of data saving : id added for cutting and annotation, and now we can load/display/change the already existing projects.
cavaliet
parents: 191
diff changeset
   145
                            float dur = (float)annotNode.Attribute("dur");
11083c390ce4 Second step of data saving : id added for cutting and annotation, and now we can load/display/change the already existing projects.
cavaliet
parents: 191
diff changeset
   146
                            String gt = annotNode.Element("gestureType").Value;
11083c390ce4 Second step of data saving : id added for cutting and annotation, and now we can load/display/change the already existing projects.
cavaliet
parents: 191
diff changeset
   147
                            String colorString = annotNode.Attribute("color").Value; // is type 0xRRGGBB
11083c390ce4 Second step of data saving : id added for cutting and annotation, and now we can load/display/change the already existing projects.
cavaliet
parents: 191
diff changeset
   148
                            Byte r = Convert.ToByte(colorString.Substring(2, 2), 16);
11083c390ce4 Second step of data saving : id added for cutting and annotation, and now we can load/display/change the already existing projects.
cavaliet
parents: 191
diff changeset
   149
                            Byte g = Convert.ToByte(colorString.Substring(4, 2), 16);
11083c390ce4 Second step of data saving : id added for cutting and annotation, and now we can load/display/change the already existing projects.
cavaliet
parents: 191
diff changeset
   150
                            Byte b = Convert.ToByte(colorString.Substring(6, 2), 16);
11083c390ce4 Second step of data saving : id added for cutting and annotation, and now we can load/display/change the already existing projects.
cavaliet
parents: 191
diff changeset
   151
                            Color c = Color.FromRgb(r, g, b);
11083c390ce4 Second step of data saving : id added for cutting and annotation, and now we can load/display/change the already existing projects.
cavaliet
parents: 191
diff changeset
   152
                            la.Add(new Annotation(aId, begin, dur, gt, c));
148
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 143
diff changeset
   153
                        }
192
11083c390ce4 Second step of data saving : id added for cutting and annotation, and now we can load/display/change the already existing projects.
cavaliet
parents: 191
diff changeset
   154
                        loadedProject.Cuttings.Add(new Cutting(cuttingNode.Attribute("id").Value,cuttingNode.Element("title").Value,la));
148
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 143
diff changeset
   155
                    }
192
11083c390ce4 Second step of data saving : id added for cutting and annotation, and now we can load/display/change the already existing projects.
cavaliet
parents: 191
diff changeset
   156
                    // We define the loaded project as the current session's project.
11083c390ce4 Second step of data saving : id added for cutting and annotation, and now we can load/display/change the already existing projects.
cavaliet
parents: 191
diff changeset
   157
                    _mainViewModel.Project = new ProjectViewModel(loadedProject);
11083c390ce4 Second step of data saving : id added for cutting and annotation, and now we can load/display/change the already existing projects.
cavaliet
parents: 191
diff changeset
   158
                    OpenProject();
148
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 143
diff changeset
   159
                }
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 143
diff changeset
   160
            }
152
46577fd0a294 PlayerPause en resize
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 148
diff changeset
   161
            catch (Exception)
46577fd0a294 PlayerPause en resize
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 148
diff changeset
   162
            {
190
619ca3ae13c7 MainViewModel is now well linked to all the users'cuttings. At any moment, the MVM has all annotations. This step prepares data saving.
cavaliet
parents: 187
diff changeset
   163
                Cutting = null;
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: 156
diff changeset
   164
                if (UC_Screen_NewCutting != null)
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: 156
diff changeset
   165
                    UC_Screen_NewCutting(this, new EventArgs());
152
46577fd0a294 PlayerPause en resize
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 148
diff changeset
   166
            }
148
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 143
diff changeset
   167
        }
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 143
diff changeset
   168
187
b266af50744c Change file and event names for code to be clearer and more coherent with the project and cuttings organisation
cavaliet
parents: 186
diff changeset
   169
        private void ProjectInput_EH_NewProjectForm_ContactDown(object sender, EventArgs e)
104
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 95
diff changeset
   170
        {
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 95
diff changeset
   171
            try
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 95
diff changeset
   172
            {
187
b266af50744c Change file and event names for code to be clearer and more coherent with the project and cuttings organisation
cavaliet
parents: 186
diff changeset
   173
                //MainViewModel.Project.Alias = ((UserControlNewProjectForm)sender).Alias;
b266af50744c Change file and event names for code to be clearer and more coherent with the project and cuttings organisation
cavaliet
parents: 186
diff changeset
   174
                //MainViewModel.Project.Email = ((UserControlNewProjectForm)sender).Email;
190
619ca3ae13c7 MainViewModel is now well linked to all the users'cuttings. At any moment, the MVM has all annotations. This step prepares data saving.
cavaliet
parents: 187
diff changeset
   175
                _mainViewModel.Project.Description = ((UserControlNewProjectForm)sender).Description;
192
11083c390ce4 Second step of data saving : id added for cutting and annotation, and now we can load/display/change the already existing projects.
cavaliet
parents: 191
diff changeset
   176
                _mainViewModel.Project.Name = ((UserControlNewProjectForm)sender).ProjectName.Trim();
148
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 143
diff changeset
   177
                
186
83615722dbab Debug data management for others panels to redisplay.
cavaliet
parents: 182
diff changeset
   178
                
104
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 95
diff changeset
   179
                //2-Suppression UCSession Input
187
b266af50744c Change file and event names for code to be clearer and more coherent with the project and cuttings organisation
cavaliet
parents: 186
diff changeset
   180
                LayoutRoot.Children.Remove((UserControlNewProjectForm)sender);
148
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 143
diff changeset
   181
                OpenProject();
104
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 95
diff changeset
   182
            }
152
46577fd0a294 PlayerPause en resize
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 148
diff changeset
   183
            catch (Exception ex) 
46577fd0a294 PlayerPause en resize
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 148
diff changeset
   184
            {
190
619ca3ae13c7 MainViewModel is now well linked to all the users'cuttings. At any moment, the MVM has all annotations. This step prepares data saving.
cavaliet
parents: 187
diff changeset
   185
                Cutting = null;
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: 156
diff changeset
   186
                if (UC_Screen_NewCutting != null)
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: 156
diff changeset
   187
                    UC_Screen_NewCutting(this, new EventArgs());
152
46577fd0a294 PlayerPause en resize
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 148
diff changeset
   188
            }
104
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 95
diff changeset
   189
        }
148
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 143
diff changeset
   190
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 143
diff changeset
   191
        private void OpenProject()
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 143
diff changeset
   192
        {
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 143
diff changeset
   193
            try
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 143
diff changeset
   194
            {
192
11083c390ce4 Second step of data saving : id added for cutting and annotation, and now we can load/display/change the already existing projects.
cavaliet
parents: 191
diff changeset
   195
                // We display the list of cuttings available for the current project
190
619ca3ae13c7 MainViewModel is now well linked to all the users'cuttings. At any moment, the MVM has all annotations. This step prepares data saving.
cavaliet
parents: 187
diff changeset
   196
                UserControlListCutting listCuttings = new UserControlListCutting(_mainViewModel.Project.CuttingsDict);
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: 156
diff changeset
   197
                listCuttings.Name = "listCuttings";
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: 156
diff changeset
   198
                LayoutRoot.Children.Add(listCuttings);
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: 156
diff changeset
   199
                listCuttings.EH_Item_ContactDown += new EventHandler(listCuttings_EH_Item_ContactDown);
148
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 143
diff changeset
   200
            }
152
46577fd0a294 PlayerPause en resize
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 148
diff changeset
   201
            catch (Exception) 
46577fd0a294 PlayerPause en resize
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 148
diff changeset
   202
            {
190
619ca3ae13c7 MainViewModel is now well linked to all the users'cuttings. At any moment, the MVM has all annotations. This step prepares data saving.
cavaliet
parents: 187
diff changeset
   203
                Cutting = null;
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: 156
diff changeset
   204
                if (UC_Screen_NewCutting != null)
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: 156
diff changeset
   205
                    UC_Screen_NewCutting(this, new EventArgs());
152
46577fd0a294 PlayerPause en resize
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 148
diff changeset
   206
            }
148
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 143
diff changeset
   207
        }
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 143
diff changeset
   208
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: 156
diff changeset
   209
        void listCuttings_EH_Item_ContactDown(object sender, EventArgs e)
148
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 143
diff changeset
   210
        {
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 143
diff changeset
   211
            try
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 143
diff changeset
   212
            {
187
b266af50744c Change file and event names for code to be clearer and more coherent with the project and cuttings organisation
cavaliet
parents: 186
diff changeset
   213
                LayoutRoot.Children.Remove((UserControlListCutting)sender);
b266af50744c Change file and event names for code to be clearer and more coherent with the project and cuttings organisation
cavaliet
parents: 186
diff changeset
   214
                if (((UserControlListCutting)sender).SelectedItem.Equals("New Cutting"))
148
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 143
diff changeset
   215
                {
192
11083c390ce4 Second step of data saving : id added for cutting and annotation, and now we can load/display/change the already existing projects.
cavaliet
parents: 191
diff changeset
   216
                    // "New Uutting" was was selected -> we display the form
187
b266af50744c Change file and event names for code to be clearer and more coherent with the project and cuttings organisation
cavaliet
parents: 186
diff changeset
   217
                    UserControlNewCuttingForm newCutting = new UserControlNewCuttingForm(User);
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: 156
diff changeset
   218
                    newCutting.Name = "newCutting";
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: 156
diff changeset
   219
                    LayoutRoot.Children.Add(newCutting);
187
b266af50744c Change file and event names for code to be clearer and more coherent with the project and cuttings organisation
cavaliet
parents: 186
diff changeset
   220
                    newCutting.EH_NewCuttingForm_ContactDown += new EventHandler(newCutting_EH_ContactDown);
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: 156
diff changeset
   221
                }
148
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 143
diff changeset
   222
                else
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 143
diff changeset
   223
                {
192
11083c390ce4 Second step of data saving : id added for cutting and annotation, and now we can load/display/change the already existing projects.
cavaliet
parents: 191
diff changeset
   224
                    // An already existing project was clicked -> we load the selected project from the dictionnary
11083c390ce4 Second step of data saving : id added for cutting and annotation, and now we can load/display/change the already existing projects.
cavaliet
parents: 191
diff changeset
   225
                    Cutting = _mainViewModel.Project.CuttingsDict[((UserControlListCutting)sender).SelectedItem];
11083c390ce4 Second step of data saving : id added for cutting and annotation, and now we can load/display/change the already existing projects.
cavaliet
parents: 191
diff changeset
   226
                    if (UC_Screen_NewCutting != null)
11083c390ce4 Second step of data saving : id added for cutting and annotation, and now we can load/display/change the already existing projects.
cavaliet
parents: 191
diff changeset
   227
                        UC_Screen_NewCutting(this, new EventArgs());
11083c390ce4 Second step of data saving : id added for cutting and annotation, and now we can load/display/change the already existing projects.
cavaliet
parents: 191
diff changeset
   228
                    return;
148
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 143
diff changeset
   229
                }
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 143
diff changeset
   230
            }
152
46577fd0a294 PlayerPause en resize
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 148
diff changeset
   231
            catch (Exception)
46577fd0a294 PlayerPause en resize
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 148
diff changeset
   232
            {
190
619ca3ae13c7 MainViewModel is now well linked to all the users'cuttings. At any moment, the MVM has all annotations. This step prepares data saving.
cavaliet
parents: 187
diff changeset
   233
                Cutting = null;
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: 156
diff changeset
   234
                if (UC_Screen_NewCutting != null)
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: 156
diff changeset
   235
                    UC_Screen_NewCutting(this, new EventArgs());
152
46577fd0a294 PlayerPause en resize
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 148
diff changeset
   236
            }
148
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 143
diff changeset
   237
        }
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 143
diff changeset
   238
186
83615722dbab Debug data management for others panels to redisplay.
cavaliet
parents: 182
diff changeset
   239
        void newCutting_EH_ContactDown(object sender, EventArgs e)
148
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 143
diff changeset
   240
        {
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 143
diff changeset
   241
            try
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 143
diff changeset
   242
            {
187
b266af50744c Change file and event names for code to be clearer and more coherent with the project and cuttings organisation
cavaliet
parents: 186
diff changeset
   243
                LayoutRoot.Children.Remove((UserControlNewCuttingForm)sender);
192
11083c390ce4 Second step of data saving : id added for cutting and annotation, and now we can load/display/change the already existing projects.
cavaliet
parents: 191
diff changeset
   244
                // The new cutting form sent the cutting instance so we can dispatch the event UC_Screen_NewCutting
190
619ca3ae13c7 MainViewModel is now well linked to all the users'cuttings. At any moment, the MVM has all annotations. This step prepares data saving.
cavaliet
parents: 187
diff changeset
   245
                Cutting = ((UserControlNewCuttingForm)sender).Cutting;
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: 156
diff changeset
   246
                if (UC_Screen_NewCutting != null)
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: 156
diff changeset
   247
                    UC_Screen_NewCutting(this, new EventArgs());
148
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 143
diff changeset
   248
            }
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: 156
diff changeset
   249
            catch (Exception)
152
46577fd0a294 PlayerPause en resize
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 148
diff changeset
   250
            {
190
619ca3ae13c7 MainViewModel is now well linked to all the users'cuttings. At any moment, the MVM has all annotations. This step prepares data saving.
cavaliet
parents: 187
diff changeset
   251
                Cutting = null;
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: 156
diff changeset
   252
                if (UC_Screen_NewCutting != null)
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: 156
diff changeset
   253
                    UC_Screen_NewCutting(this, new EventArgs());
152
46577fd0a294 PlayerPause en resize
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 148
diff changeset
   254
            }
148
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 143
diff changeset
   255
        }
35
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
   256
	}
ed77793b767a Control Pivot,
sarias
parents:
diff changeset
   257
}