src/FingersDance.ViewModel/AnnotationViewModel.cs
author ARIAS Santiago
Sun, 25 Oct 2009 12:55:07 +0100
changeset 169 3a407c966e57
parent 167 206f07a8d887
child 182 25b49d4f1635
permissions -rw-r--r--
Merge Timeline actions
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
    {
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    13
        private float _tcBegin;
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    14
        private float _dur;
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    15
        private String _gestureType;
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
    16
        private Color _color;
55
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    17
143
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 69
diff changeset
    18
        private float _marginLeft;
167
206f07a8d887 Annotation's scale is now still visually at one, whatever the timeline's scale.
cavaliet
parents: 160
diff changeset
    19
        private Double _scaleX = 1;
143
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 69
diff changeset
    20
167
206f07a8d887 Annotation's scale is now still visually at one, whatever the timeline's scale.
cavaliet
parents: 160
diff changeset
    21
        public AnnotationViewModel(Annotation a, float marginLeft, Double scaleX)
206f07a8d887 Annotation's scale is now still visually at one, whatever the timeline's scale.
cavaliet
parents: 160
diff changeset
    22
        {
206f07a8d887 Annotation's scale is now still visually at one, whatever the timeline's scale.
cavaliet
parents: 160
diff changeset
    23
            this._tcBegin = a.TcBegin;
206f07a8d887 Annotation's scale is now still visually at one, whatever the timeline's scale.
cavaliet
parents: 160
diff changeset
    24
            this._dur = a.Dur;
206f07a8d887 Annotation's scale is now still visually at one, whatever the timeline's scale.
cavaliet
parents: 160
diff changeset
    25
            this._gestureType = a.GestureType;
206f07a8d887 Annotation's scale is now still visually at one, whatever the timeline's scale.
cavaliet
parents: 160
diff changeset
    26
            this._color = a.Color;
206f07a8d887 Annotation's scale is now still visually at one, whatever the timeline's scale.
cavaliet
parents: 160
diff changeset
    27
            this._marginLeft = marginLeft;
206f07a8d887 Annotation's scale is now still visually at one, whatever the timeline's scale.
cavaliet
parents: 160
diff changeset
    28
            this._marginLeft = marginLeft;
206f07a8d887 Annotation's scale is now still visually at one, whatever the timeline's scale.
cavaliet
parents: 160
diff changeset
    29
            this._scaleX = scaleX;
206f07a8d887 Annotation's scale is now still visually at one, whatever the timeline's scale.
cavaliet
parents: 160
diff changeset
    30
        }
150
569925b65604 Annotations are now colored with the same color as the pivot's button
cavaliet
parents: 146
diff changeset
    31
        public AnnotationViewModel(Annotation a, float marginLeft)
569925b65604 Annotations are now colored with the same color as the pivot's button
cavaliet
parents: 146
diff changeset
    32
        {
69
a4c44555f205 First Data binding for annotations and timeline
cavaliet
parents: 55
diff changeset
    33
            this._tcBegin = a.TcBegin;
a4c44555f205 First Data binding for annotations and timeline
cavaliet
parents: 55
diff changeset
    34
            this._dur = a.Dur;
a4c44555f205 First Data binding for annotations and timeline
cavaliet
parents: 55
diff changeset
    35
            this._gestureType = a.GestureType;
150
569925b65604 Annotations are now colored with the same color as the pivot's button
cavaliet
parents: 146
diff changeset
    36
            this._color = a.Color;
143
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 69
diff changeset
    37
            this._marginLeft = marginLeft;
69
a4c44555f205 First Data binding for annotations and timeline
cavaliet
parents: 55
diff changeset
    38
        }
a4c44555f205 First Data binding for annotations and timeline
cavaliet
parents: 55
diff changeset
    39
a4c44555f205 First Data binding for annotations and timeline
cavaliet
parents: 55
diff changeset
    40
        public float TcBegin
55
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    41
        {
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    42
            get { return _tcBegin; }
150
569925b65604 Annotations are now colored with the same color as the pivot's button
cavaliet
parents: 146
diff changeset
    43
            set
569925b65604 Annotations are now colored with the same color as the pivot's button
cavaliet
parents: 146
diff changeset
    44
            {
55
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    45
                if (value == _tcBegin || float.IsNaN(value))
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    46
                    return;
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    47
                _tcBegin = value;
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    48
                base.OnPropertyChanged("TcBegin");
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    49
            }
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    50
        }
69
a4c44555f205 First Data binding for annotations and timeline
cavaliet
parents: 55
diff changeset
    51
        public float Dur
55
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    52
        {
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    53
            get { return _dur; }
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    54
            set
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    55
            {
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    56
                if (value == _dur || float.IsNaN(value))
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    57
                    return;
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    58
                _dur = value;
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    59
                base.OnPropertyChanged("Dur");
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    60
            }
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    61
        }
69
a4c44555f205 First Data binding for annotations and timeline
cavaliet
parents: 55
diff changeset
    62
        public String GestureType
55
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    63
        {
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    64
            get { return _gestureType; }
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    65
            set
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    66
            {
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    67
                if (value == _gestureType || String.IsNullOrEmpty(value))
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    68
                    return;
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    69
                _gestureType = value;
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    70
                base.OnPropertyChanged("GestureType");
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    71
            }
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    72
        }
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
    73
        public Color Color
150
569925b65604 Annotations are now colored with the same color as the pivot's button
cavaliet
parents: 146
diff changeset
    74
        {
569925b65604 Annotations are now colored with the same color as the pivot's button
cavaliet
parents: 146
diff changeset
    75
            get { return _color; }
569925b65604 Annotations are now colored with the same color as the pivot's button
cavaliet
parents: 146
diff changeset
    76
            set
569925b65604 Annotations are now colored with the same color as the pivot's button
cavaliet
parents: 146
diff changeset
    77
            {
569925b65604 Annotations are now colored with the same color as the pivot's button
cavaliet
parents: 146
diff changeset
    78
                if (value == _color)
569925b65604 Annotations are now colored with the same color as the pivot's button
cavaliet
parents: 146
diff changeset
    79
                    return;
569925b65604 Annotations are now colored with the same color as the pivot's button
cavaliet
parents: 146
diff changeset
    80
                _color = value;
569925b65604 Annotations are now colored with the same color as the pivot's button
cavaliet
parents: 146
diff changeset
    81
            }
569925b65604 Annotations are now colored with the same color as the pivot's button
cavaliet
parents: 146
diff changeset
    82
        }
143
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 69
diff changeset
    83
        public float MarginLeft
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 69
diff changeset
    84
        {
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 69
diff changeset
    85
            get { return _marginLeft; }
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 69
diff changeset
    86
            set
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 69
diff changeset
    87
            {
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 69
diff changeset
    88
                if (value == _marginLeft || float.IsNaN(value))
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 69
diff changeset
    89
                    return;
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 69
diff changeset
    90
                _marginLeft = value;
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 69
diff changeset
    91
                base.OnPropertyChanged("MarginLeft");
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 69
diff changeset
    92
            }
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 69
diff changeset
    93
        }
167
206f07a8d887 Annotation's scale is now still visually at one, whatever the timeline's scale.
cavaliet
parents: 160
diff changeset
    94
        public Double ScaleX
206f07a8d887 Annotation's scale is now still visually at one, whatever the timeline's scale.
cavaliet
parents: 160
diff changeset
    95
        {
206f07a8d887 Annotation's scale is now still visually at one, whatever the timeline's scale.
cavaliet
parents: 160
diff changeset
    96
            get { return _scaleX; }
206f07a8d887 Annotation's scale is now still visually at one, whatever the timeline's scale.
cavaliet
parents: 160
diff changeset
    97
            set
206f07a8d887 Annotation's scale is now still visually at one, whatever the timeline's scale.
cavaliet
parents: 160
diff changeset
    98
            {
206f07a8d887 Annotation's scale is now still visually at one, whatever the timeline's scale.
cavaliet
parents: 160
diff changeset
    99
                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
   100
                    return;
206f07a8d887 Annotation's scale is now still visually at one, whatever the timeline's scale.
cavaliet
parents: 160
diff changeset
   101
                _scaleX = value;
206f07a8d887 Annotation's scale is now still visually at one, whatever the timeline's scale.
cavaliet
parents: 160
diff changeset
   102
                base.OnPropertyChanged("ScaleX");
206f07a8d887 Annotation's scale is now still visually at one, whatever the timeline's scale.
cavaliet
parents: 160
diff changeset
   103
            }
206f07a8d887 Annotation's scale is now still visually at one, whatever the timeline's scale.
cavaliet
parents: 160
diff changeset
   104
        }
55
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
   105
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
   106
    }
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
   107
}