src/FingersDance.ViewModel/AnnotationViewModel.cs
author cavaliet
Wed, 25 Nov 2009 10:49:44 +0100
changeset 231 4eff6b0c9215
parent 225 b60e13ed75c8
permissions -rw-r--r--
Merge
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;
160
e940ca798fe3 Enhance color factory and send the current project (data) to the timeline instance in order to build the project's cutting's annotation list.
cavaliet
parents: 150
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 AnnotationViewModel : 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
        readonly Annotation a;
55
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    14
143
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 69
diff changeset
    15
        private float _marginLeft;
167
206f07a8d887 Annotation's scale is now still visually at one, whatever the timeline's scale.
cavaliet
parents: 160
diff changeset
    16
        private Double _scaleX = 1;
143
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 69
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
        public AnnotationViewModel(Annotation aPar, float marginLeft, Double scaleX)
167
206f07a8d887 Annotation's scale is now still visually at one, whatever the timeline's scale.
cavaliet
parents: 160
diff changeset
    19
        {
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
    20
            a = aPar;
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
    21
167
206f07a8d887 Annotation's scale is now still visually at one, whatever the timeline's scale.
cavaliet
parents: 160
diff changeset
    22
            this._marginLeft = marginLeft;
206f07a8d887 Annotation's scale is now still visually at one, whatever the timeline's scale.
cavaliet
parents: 160
diff changeset
    23
            this._marginLeft = marginLeft;
206f07a8d887 Annotation's scale is now still visually at one, whatever the timeline's scale.
cavaliet
parents: 160
diff changeset
    24
            this._scaleX = scaleX;
206f07a8d887 Annotation's scale is now still visually at one, whatever the timeline's scale.
cavaliet
parents: 160
diff changeset
    25
        }
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
    26
        public AnnotationViewModel(Annotation aPar, float marginLeft)
150
569925b65604 Annotations are now colored with the same color as the pivot's button
cavaliet
parents: 146
diff changeset
    27
        {
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
    28
            a = aPar;
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
143
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 69
diff changeset
    30
            this._marginLeft = marginLeft;
69
a4c44555f205 First Data binding for annotations and timeline
cavaliet
parents: 55
diff changeset
    31
        }
a4c44555f205 First Data binding for annotations and timeline
cavaliet
parents: 55
diff changeset
    32
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: 182
diff changeset
    33
        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: 182
diff changeset
    34
        {
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: 182
diff changeset
    35
            get { return a.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: 182
diff changeset
    36
            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: 182
diff changeset
    37
            {
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: 182
diff changeset
    38
                if (value == a.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: 182
diff changeset
    39
                    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: 182
diff changeset
    40
                a.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: 182
diff changeset
    41
                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: 182
diff changeset
    42
            }
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: 182
diff changeset
    43
        }
69
a4c44555f205 First Data binding for annotations and timeline
cavaliet
parents: 55
diff changeset
    44
        public float TcBegin
55
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    45
        {
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
            get { return a.TcBegin; }
150
569925b65604 Annotations are now colored with the same color as the pivot's button
cavaliet
parents: 146
diff changeset
    47
            set
569925b65604 Annotations are now colored with the same color as the pivot's button
cavaliet
parents: 146
diff changeset
    48
            {
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
    49
                if (value == a.TcBegin || float.IsNaN(value))
55
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    50
                    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
    51
                a.TcBegin = value;
55
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    52
                base.OnPropertyChanged("TcBegin");
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    53
            }
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    54
        }
69
a4c44555f205 First Data binding for annotations and timeline
cavaliet
parents: 55
diff changeset
    55
        public float Dur
55
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    56
        {
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
    57
            get { return a.Dur; }
55
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    58
            set
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    59
            {
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
                if (value == a.Dur || float.IsNaN(value))
55
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    61
                    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
    62
                a.Dur = value;
55
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    63
                base.OnPropertyChanged("Dur");
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    64
            }
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    65
        }
225
b60e13ed75c8 Now an annotation has a list of gesture string and not simple gesture string. These are saved into and loaded from the ldt xml file.
cavaliet
parents: 192
diff changeset
    66
        public List<String> GestureType
55
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    67
        {
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
    68
            get { return a.GestureType; }
55
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    69
            set
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    70
            {
225
b60e13ed75c8 Now an annotation has a list of gesture string and not simple gesture string. These are saved into and loaded from the ldt xml file.
cavaliet
parents: 192
diff changeset
    71
                if (value == a.GestureType)
55
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    72
                    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
    73
                a.GestureType = value;
55
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    74
                base.OnPropertyChanged("GestureType");
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    75
            }
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    76
        }
160
e940ca798fe3 Enhance color factory and send the current project (data) to the timeline instance in order to build the project's cutting's annotation list.
cavaliet
parents: 150
diff changeset
    77
        public Color Color
150
569925b65604 Annotations are now colored with the same color as the pivot's button
cavaliet
parents: 146
diff changeset
    78
        {
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
    79
            get { return a.Color; }
150
569925b65604 Annotations are now colored with the same color as the pivot's button
cavaliet
parents: 146
diff changeset
    80
            set
569925b65604 Annotations are now colored with the same color as the pivot's button
cavaliet
parents: 146
diff changeset
    81
            {
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
    82
                if (value == a.Color)
150
569925b65604 Annotations are now colored with the same color as the pivot's button
cavaliet
parents: 146
diff changeset
    83
                    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
    84
                a.Color = value;
150
569925b65604 Annotations are now colored with the same color as the pivot's button
cavaliet
parents: 146
diff changeset
    85
            }
569925b65604 Annotations are now colored with the same color as the pivot's button
cavaliet
parents: 146
diff changeset
    86
        }
143
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 69
diff changeset
    87
        public float MarginLeft
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 69
diff changeset
    88
        {
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 69
diff changeset
    89
            get { return _marginLeft; }
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 69
diff changeset
    90
            set
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 69
diff changeset
    91
            {
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 69
diff changeset
    92
                if (value == _marginLeft || float.IsNaN(value))
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 69
diff changeset
    93
                    return;
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 69
diff changeset
    94
                _marginLeft = value;
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 69
diff changeset
    95
                base.OnPropertyChanged("MarginLeft");
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 69
diff changeset
    96
            }
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 69
diff changeset
    97
        }
167
206f07a8d887 Annotation's scale is now still visually at one, whatever the timeline's scale.
cavaliet
parents: 160
diff changeset
    98
        public Double ScaleX
206f07a8d887 Annotation's scale is now still visually at one, whatever the timeline's scale.
cavaliet
parents: 160
diff changeset
    99
        {
206f07a8d887 Annotation's scale is now still visually at one, whatever the timeline's scale.
cavaliet
parents: 160
diff changeset
   100
            get { return _scaleX; }
206f07a8d887 Annotation's scale is now still visually at one, whatever the timeline's scale.
cavaliet
parents: 160
diff changeset
   101
            set
206f07a8d887 Annotation's scale is now still visually at one, whatever the timeline's scale.
cavaliet
parents: 160
diff changeset
   102
            {
206f07a8d887 Annotation's scale is now still visually at one, whatever the timeline's scale.
cavaliet
parents: 160
diff changeset
   103
                if (value == _scaleX || Double.IsNaN(value))
206f07a8d887 Annotation's scale is now still visually at one, whatever the timeline's scale.
cavaliet
parents: 160
diff changeset
   104
                    return;
206f07a8d887 Annotation's scale is now still visually at one, whatever the timeline's scale.
cavaliet
parents: 160
diff changeset
   105
                _scaleX = value;
206f07a8d887 Annotation's scale is now still visually at one, whatever the timeline's scale.
cavaliet
parents: 160
diff changeset
   106
                base.OnPropertyChanged("ScaleX");
206f07a8d887 Annotation's scale is now still visually at one, whatever the timeline's scale.
cavaliet
parents: 160
diff changeset
   107
            }
206f07a8d887 Annotation's scale is now still visually at one, whatever the timeline's scale.
cavaliet
parents: 160
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
    }
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
   111
}