src/FingersDance.ViewModel/CuttingViewModel.cs
author cavaliet
Mon, 09 Nov 2009 12:11:42 +0100
changeset 190 619ca3ae13c7
parent 182 25b49d4f1635
child 192 11083c390ce4
permissions -rw-r--r--
MainViewModel is now well linked to all the users'cuttings. At any moment, the MVM has all annotations. This step prepares data saving.
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
143
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 69
diff changeset
    53
        public String Title  
55
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    54
        {
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
    55
            get { return cut.Title; }
55
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    56
            set
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    57
            {
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
    58
                if (value == cut.Title || String.IsNullOrEmpty(value))
55
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    59
                    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
    60
                cut.Title = value;
55
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    61
                base.OnPropertyChanged("Title");
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    62
            }
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    63
        }
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    64
        public List<AnnotationViewModel> AnnotList
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    65
        {
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    66
            get { return _annotList; }
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    67
            set
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    68
            {
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    69
                _annotList = value;
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    70
                base.OnPropertyChanged("AnnotList");
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    71
            }
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    72
        }
143
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 69
diff changeset
    73
167
206f07a8d887 Annotation's scale is now still visually at one, whatever the timeline's scale.
cavaliet
parents: 146
diff changeset
    74
        public void setListFromAnnotations(List<Annotation> annotList, float annotWidth, Double scaleX)
143
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 69
diff changeset
    75
        {
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 69
diff changeset
    76
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 69
diff changeset
    77
            this._annotList = new List<AnnotationViewModel>();
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 69
diff changeset
    78
            int i = 0;
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 69
diff changeset
    79
            foreach (Annotation annot in annotList)
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 69
diff changeset
    80
            {
167
206f07a8d887 Annotation's scale is now still visually at one, whatever the timeline's scale.
cavaliet
parents: 146
diff changeset
    81
                this._annotList.Add(new AnnotationViewModel(annot, annot.TcBegin - (i * annotWidth), 1/scaleX));
143
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 69
diff changeset
    82
                i++;
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 69
diff changeset
    83
            }
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 69
diff changeset
    84
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 69
diff changeset
    85
        }
55
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    86
    }
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    87
}