src/FingersDance.ViewModel/CuttingViewModel.cs
author cavaliet
Mon, 16 Nov 2009 18:06:15 +0100
changeset 202 e15e7110ef6d
parent 192 11083c390ce4
child 229 05aba5def1fc
permissions -rw-r--r--
player modification for gesture part to be fully displayed.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
55
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
     1
using System;
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
     2
using System.Collections.Generic;
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
     3
using System.Linq;
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
     4
using System.Text;
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
     5
69
a4c44555f205 First Data binding for annotations and timeline
cavaliet
parents: 55
diff changeset
     6
using FingersDance.Data;
a4c44555f205 First Data binding for annotations and timeline
cavaliet
parents: 55
diff changeset
     7
a4c44555f205 First Data binding for annotations and timeline
cavaliet
parents: 55
diff changeset
     8
namespace FingersDance.ViewModels
55
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
     9
{
69
a4c44555f205 First Data binding for annotations and timeline
cavaliet
parents: 55
diff changeset
    10
    public class CuttingViewModel : ViewModelBase
55
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    11
    {
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: 167
diff changeset
    12
        private Cutting cut;
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: 167
diff changeset
    13
55
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    14
        private List<AnnotationViewModel> _annotList = new List<AnnotationViewModel>();
69
a4c44555f205 First Data binding for annotations and timeline
cavaliet
parents: 55
diff changeset
    15
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: 182
diff changeset
    16
        public CuttingViewModel(Cutting c, float annotWidth, Double scaleX)
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: 182
diff changeset
    17
        {
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: 182
diff changeset
    18
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: 182
diff changeset
    19
            cut = c;
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: 182
diff changeset
    20
            this._annotList = new List<AnnotationViewModel>();
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: 182
diff changeset
    21
            int i = 0;
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: 182
diff changeset
    22
            foreach (Annotation annot in c.AnnotList)
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: 182
diff changeset
    23
            {
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: 182
diff changeset
    24
                this._annotList.Add(new AnnotationViewModel(annot, annot.TcBegin - (i * annotWidth), 1 / scaleX));
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: 182
diff changeset
    25
                i++;
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: 182
diff changeset
    26
            }
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: 182
diff changeset
    27
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: 182
diff changeset
    28
        }
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: 182
diff changeset
    29
143
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 69
diff changeset
    30
        public CuttingViewModel(Cutting c, float annotWidth) {
69
a4c44555f205 First Data binding for annotations and timeline
cavaliet
parents: 55
diff changeset
    31
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: 167
diff changeset
    32
            cut = c;
69
a4c44555f205 First Data binding for annotations and timeline
cavaliet
parents: 55
diff changeset
    33
            this._annotList = new List<AnnotationViewModel>();
143
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 69
diff changeset
    34
            int i = 0;
69
a4c44555f205 First Data binding for annotations and timeline
cavaliet
parents: 55
diff changeset
    35
            foreach (Annotation annot in c.AnnotList)
143
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 69
diff changeset
    36
            {
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 69
diff changeset
    37
                this._annotList.Add(new AnnotationViewModel(annot, annot.TcBegin - (i * annotWidth)));
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 69
diff changeset
    38
                i++;
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 69
diff changeset
    39
            }
69
a4c44555f205 First Data binding for annotations and timeline
cavaliet
parents: 55
diff changeset
    40
a4c44555f205 First Data binding for annotations and timeline
cavaliet
parents: 55
diff changeset
    41
        }
a4c44555f205 First Data binding for annotations and timeline
cavaliet
parents: 55
diff changeset
    42
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: 167
diff changeset
    43
        public Cutting Cutting
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: 167
diff changeset
    44
        {
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: 167
diff changeset
    45
            get { return cut; }
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: 167
diff changeset
    46
            set
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: 167
diff changeset
    47
            {
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: 167
diff changeset
    48
                cut = 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: 167
diff changeset
    49
                base.OnPropertyChanged("Cutting");
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: 167
diff changeset
    50
            }
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: 167
diff changeset
    51
        }
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: 167
diff changeset
    52
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: 190
diff changeset
    53
        public String Id
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: 190
diff changeset
    54
        {
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: 190
diff changeset
    55
            get { return cut.Id; }
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: 190
diff changeset
    56
            set
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: 190
diff changeset
    57
            {
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: 190
diff changeset
    58
                if (value == cut.Id || String.IsNullOrEmpty(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: 190
diff changeset
    59
                    return;
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: 190
diff changeset
    60
                cut.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: 190
diff changeset
    61
                base.OnPropertyChanged("Id");
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: 190
diff changeset
    62
            }
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: 190
diff changeset
    63
        }
143
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 69
diff changeset
    64
        public String Title  
55
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    65
        {
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: 167
diff changeset
    66
            get { return cut.Title; }
55
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    67
            set
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    68
            {
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: 167
diff changeset
    69
                if (value == cut.Title || String.IsNullOrEmpty(value))
55
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    70
                    return;
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: 167
diff changeset
    71
                cut.Title = value;
55
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    72
                base.OnPropertyChanged("Title");
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    73
            }
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    74
        }
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    75
        public List<AnnotationViewModel> AnnotList
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    76
        {
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    77
            get { return _annotList; }
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    78
            set
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    79
            {
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    80
                _annotList = value;
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    81
                base.OnPropertyChanged("AnnotList");
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    82
            }
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    83
        }
143
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 69
diff changeset
    84
167
206f07a8d887 Annotation's scale is now still visually at one, whatever the timeline's scale.
cavaliet
parents: 146
diff changeset
    85
        public void setListFromAnnotations(List<Annotation> annotList, float annotWidth, Double scaleX)
143
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 69
diff changeset
    86
        {
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 69
diff changeset
    87
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 69
diff changeset
    88
            this._annotList = new List<AnnotationViewModel>();
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 69
diff changeset
    89
            int i = 0;
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 69
diff changeset
    90
            foreach (Annotation annot in annotList)
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 69
diff changeset
    91
            {
167
206f07a8d887 Annotation's scale is now still visually at one, whatever the timeline's scale.
cavaliet
parents: 146
diff changeset
    92
                this._annotList.Add(new AnnotationViewModel(annot, annot.TcBegin - (i * annotWidth), 1/scaleX));
143
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 69
diff changeset
    93
                i++;
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 69
diff changeset
    94
            }
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 69
diff changeset
    95
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 69
diff changeset
    96
        }
55
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    97
    }
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    98
}