src/FingersDance.ViewModel/CuttingViewModel.cs
author cavaliet
Wed, 28 Oct 2009 17:07:27 +0100
changeset 182 25b49d4f1635
parent 167 206f07a8d887
child 190 619ca3ae13c7
permissions -rw-r--r--
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.
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
143
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 69
diff changeset
    16
        public CuttingViewModel(Cutting c, float annotWidth) {
69
a4c44555f205 First Data binding for annotations and timeline
cavaliet
parents: 55
diff changeset
    17
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
    18
            cut = c;
69
a4c44555f205 First Data binding for annotations and timeline
cavaliet
parents: 55
diff changeset
    19
            this._annotList = new List<AnnotationViewModel>();
143
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 69
diff changeset
    20
            int i = 0;
69
a4c44555f205 First Data binding for annotations and timeline
cavaliet
parents: 55
diff changeset
    21
            foreach (Annotation annot in c.AnnotList)
143
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 69
diff changeset
    22
            {
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 69
diff changeset
    23
                this._annotList.Add(new AnnotationViewModel(annot, annot.TcBegin - (i * annotWidth)));
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 69
diff changeset
    24
                i++;
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 69
diff changeset
    25
            }
69
a4c44555f205 First Data binding for annotations and timeline
cavaliet
parents: 55
diff changeset
    26
a4c44555f205 First Data binding for annotations and timeline
cavaliet
parents: 55
diff changeset
    27
        }
a4c44555f205 First Data binding for annotations and timeline
cavaliet
parents: 55
diff changeset
    28
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
    29
        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
    30
        {
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
    31
            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
    32
            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
    33
            {
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
    34
                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
    35
                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
    36
            }
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
    37
        }
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
    38
143
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 69
diff changeset
    39
        public String Title  
55
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    40
        {
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
    41
            get { return cut.Title; }
55
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    42
            set
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    43
            {
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
    44
                if (value == cut.Title || String.IsNullOrEmpty(value))
55
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    45
                    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
    46
                cut.Title = value;
55
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    47
                base.OnPropertyChanged("Title");
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    48
            }
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    49
        }
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    50
        public List<AnnotationViewModel> AnnotList
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    51
        {
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    52
            get { return _annotList; }
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    53
            set
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    54
            {
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    55
                _annotList = value;
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    56
                base.OnPropertyChanged("AnnotList");
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    57
            }
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    58
        }
143
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 69
diff changeset
    59
167
206f07a8d887 Annotation's scale is now still visually at one, whatever the timeline's scale.
cavaliet
parents: 146
diff changeset
    60
        public void setListFromAnnotations(List<Annotation> annotList, float annotWidth, Double scaleX)
143
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 69
diff changeset
    61
        {
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 69
diff changeset
    62
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 69
diff changeset
    63
            this._annotList = new List<AnnotationViewModel>();
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 69
diff changeset
    64
            int i = 0;
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 69
diff changeset
    65
            foreach (Annotation annot in annotList)
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 69
diff changeset
    66
            {
167
206f07a8d887 Annotation's scale is now still visually at one, whatever the timeline's scale.
cavaliet
parents: 146
diff changeset
    67
                this._annotList.Add(new AnnotationViewModel(annot, annot.TcBegin - (i * annotWidth), 1/scaleX));
143
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 69
diff changeset
    68
                i++;
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 69
diff changeset
    69
            }
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 69
diff changeset
    70
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 69
diff changeset
    71
        }
55
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    72
    }
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    73
}