src/FingersDance.ViewModel/CuttingViewModel.cs
author cavaliet
Tue, 24 Nov 2009 22:08:57 +0100
changeset 229 05aba5def1fc
parent 192 11083c390ce4
permissions -rw-r--r--
add an attribute Color to a Cutting, save it in ldt xml file and redisplay it in the pivot's button. Make ColorFactory truly static.
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;
229
05aba5def1fc add an attribute Color to a Cutting, save it in ldt xml file and redisplay it in the pivot's button. Make ColorFactory truly static.
cavaliet
parents: 192
diff changeset
     5
using System.Windows.Media;
55
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
     6
69
a4c44555f205 First Data binding for annotations and timeline
cavaliet
parents: 55
diff changeset
     7
using FingersDance.Data;
a4c44555f205 First Data binding for annotations and timeline
cavaliet
parents: 55
diff changeset
     8
a4c44555f205 First Data binding for annotations and timeline
cavaliet
parents: 55
diff changeset
     9
namespace FingersDance.ViewModels
55
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    10
{
69
a4c44555f205 First Data binding for annotations and timeline
cavaliet
parents: 55
diff changeset
    11
    public class CuttingViewModel : ViewModelBase
55
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    12
    {
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
    13
        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
    14
55
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    15
        private List<AnnotationViewModel> _annotList = new List<AnnotationViewModel>();
69
a4c44555f205 First Data binding for annotations and timeline
cavaliet
parents: 55
diff changeset
    16
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
    17
        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
    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
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
            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
    21
            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
    22
            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
    23
            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
    24
            {
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
                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
    26
                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
    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
        }
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
    30
143
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 69
diff changeset
    31
        public CuttingViewModel(Cutting c, float annotWidth) {
69
a4c44555f205 First Data binding for annotations and timeline
cavaliet
parents: 55
diff changeset
    32
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
    33
            cut = c;
69
a4c44555f205 First Data binding for annotations and timeline
cavaliet
parents: 55
diff changeset
    34
            this._annotList = new List<AnnotationViewModel>();
143
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 69
diff changeset
    35
            int i = 0;
69
a4c44555f205 First Data binding for annotations and timeline
cavaliet
parents: 55
diff changeset
    36
            foreach (Annotation annot in c.AnnotList)
143
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 69
diff changeset
    37
            {
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 69
diff changeset
    38
                this._annotList.Add(new AnnotationViewModel(annot, annot.TcBegin - (i * annotWidth)));
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 69
diff changeset
    39
                i++;
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 69
diff changeset
    40
            }
69
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
        }
a4c44555f205 First Data binding for annotations and timeline
cavaliet
parents: 55
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
        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
    45
        {
25b49d4f1635 First step of data reorganisation : session is meant to disappear : a "session" is in fact a project and one project owns several cuttings, one per user. WARNING : this commit builds without problems but we can not open more than one UserPanel.
cavaliet
parents: 167
diff changeset
    46
            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
    47
            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
    48
            {
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
                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
    50
                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
    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
        }
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
    53
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
    54
        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
    55
        {
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
            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
    57
            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
    58
            {
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
                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
    60
                    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
    61
                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
    62
                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
    63
            }
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
    64
        }
143
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 69
diff changeset
    65
        public String Title  
55
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    66
        {
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
    67
            get { return cut.Title; }
55
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    68
            set
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    69
            {
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
    70
                if (value == cut.Title || String.IsNullOrEmpty(value))
55
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    71
                    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
    72
                cut.Title = value;
55
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    73
                base.OnPropertyChanged("Title");
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    74
            }
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    75
        }
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    76
        public List<AnnotationViewModel> AnnotList
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    77
        {
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    78
            get { return _annotList; }
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    79
            set
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    80
            {
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    81
                _annotList = value;
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    82
                base.OnPropertyChanged("AnnotList");
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    83
            }
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    84
        }
229
05aba5def1fc add an attribute Color to a Cutting, save it in ldt xml file and redisplay it in the pivot's button. Make ColorFactory truly static.
cavaliet
parents: 192
diff changeset
    85
        public Color Color
05aba5def1fc add an attribute Color to a Cutting, save it in ldt xml file and redisplay it in the pivot's button. Make ColorFactory truly static.
cavaliet
parents: 192
diff changeset
    86
        {
05aba5def1fc add an attribute Color to a Cutting, save it in ldt xml file and redisplay it in the pivot's button. Make ColorFactory truly static.
cavaliet
parents: 192
diff changeset
    87
            get { return cut.Color; }
05aba5def1fc add an attribute Color to a Cutting, save it in ldt xml file and redisplay it in the pivot's button. Make ColorFactory truly static.
cavaliet
parents: 192
diff changeset
    88
            set
05aba5def1fc add an attribute Color to a Cutting, save it in ldt xml file and redisplay it in the pivot's button. Make ColorFactory truly static.
cavaliet
parents: 192
diff changeset
    89
            {
05aba5def1fc add an attribute Color to a Cutting, save it in ldt xml file and redisplay it in the pivot's button. Make ColorFactory truly static.
cavaliet
parents: 192
diff changeset
    90
                if (value == cut.Color)
05aba5def1fc add an attribute Color to a Cutting, save it in ldt xml file and redisplay it in the pivot's button. Make ColorFactory truly static.
cavaliet
parents: 192
diff changeset
    91
                    return;
05aba5def1fc add an attribute Color to a Cutting, save it in ldt xml file and redisplay it in the pivot's button. Make ColorFactory truly static.
cavaliet
parents: 192
diff changeset
    92
                cut.Color = value;
05aba5def1fc add an attribute Color to a Cutting, save it in ldt xml file and redisplay it in the pivot's button. Make ColorFactory truly static.
cavaliet
parents: 192
diff changeset
    93
                base.OnPropertyChanged("Title");
05aba5def1fc add an attribute Color to a Cutting, save it in ldt xml file and redisplay it in the pivot's button. Make ColorFactory truly static.
cavaliet
parents: 192
diff changeset
    94
            }
05aba5def1fc add an attribute Color to a Cutting, save it in ldt xml file and redisplay it in the pivot's button. Make ColorFactory truly static.
cavaliet
parents: 192
diff changeset
    95
        }
143
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 69
diff changeset
    96
167
206f07a8d887 Annotation's scale is now still visually at one, whatever the timeline's scale.
cavaliet
parents: 146
diff changeset
    97
        public void setListFromAnnotations(List<Annotation> annotList, float annotWidth, Double scaleX)
143
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 69
diff changeset
    98
        {
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 69
diff changeset
    99
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 69
diff changeset
   100
            this._annotList = new List<AnnotationViewModel>();
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 69
diff changeset
   101
            int i = 0;
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 69
diff changeset
   102
            foreach (Annotation annot in annotList)
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 69
diff changeset
   103
            {
167
206f07a8d887 Annotation's scale is now still visually at one, whatever the timeline's scale.
cavaliet
parents: 146
diff changeset
   104
                this._annotList.Add(new AnnotationViewModel(annot, annot.TcBegin - (i * annotWidth), 1/scaleX));
143
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 69
diff changeset
   105
                i++;
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 69
diff changeset
   106
            }
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 69
diff changeset
   107
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 69
diff changeset
   108
        }
55
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
   109
    }
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
   110
}