src/FingersDance.ViewModel/AnnotationViewModel.cs
author cavaliet
Wed, 28 Oct 2009 17:07:27 +0100
changeset 182 25b49d4f1635
parent 167 206f07a8d887
child 192 11083c390ce4
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;
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
a4c44555f205 First Data binding for annotations and timeline
cavaliet
parents: 55
diff changeset
    33
        public float TcBegin
55
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    34
        {
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
    35
            get { return a.TcBegin; }
150
569925b65604 Annotations are now colored with the same color as the pivot's button
cavaliet
parents: 146
diff changeset
    36
            set
569925b65604 Annotations are now colored with the same color as the pivot's button
cavaliet
parents: 146
diff changeset
    37
            {
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
    38
                if (value == a.TcBegin || float.IsNaN(value))
55
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    39
                    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
    40
                a.TcBegin = value;
55
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    41
                base.OnPropertyChanged("TcBegin");
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    42
            }
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    43
        }
69
a4c44555f205 First Data binding for annotations and timeline
cavaliet
parents: 55
diff changeset
    44
        public float Dur
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.Dur; }
55
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    47
            set
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
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.Dur || 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.Dur = value;
55
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    52
                base.OnPropertyChanged("Dur");
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 String GestureType
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.GestureType; }
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.GestureType || String.IsNullOrEmpty(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.GestureType = value;
55
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    63
                base.OnPropertyChanged("GestureType");
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    64
            }
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    65
        }
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
    66
        public Color Color
150
569925b65604 Annotations are now colored with the same color as the pivot's button
cavaliet
parents: 146
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.Color; }
150
569925b65604 Annotations are now colored with the same color as the pivot's button
cavaliet
parents: 146
diff changeset
    69
            set
569925b65604 Annotations are now colored with the same color as the pivot's button
cavaliet
parents: 146
diff changeset
    70
            {
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
    71
                if (value == a.Color)
150
569925b65604 Annotations are now colored with the same color as the pivot's button
cavaliet
parents: 146
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.Color = value;
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
        }
143
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 69
diff changeset
    76
        public float MarginLeft
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 69
diff changeset
    77
        {
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 69
diff changeset
    78
            get { return _marginLeft; }
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 69
diff changeset
    79
            set
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 69
diff changeset
    80
            {
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 69
diff changeset
    81
                if (value == _marginLeft || float.IsNaN(value))
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 69
diff changeset
    82
                    return;
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 69
diff changeset
    83
                _marginLeft = value;
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 69
diff changeset
    84
                base.OnPropertyChanged("MarginLeft");
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 69
diff changeset
    85
            }
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 69
diff changeset
    86
        }
167
206f07a8d887 Annotation's scale is now still visually at one, whatever the timeline's scale.
cavaliet
parents: 160
diff changeset
    87
        public Double ScaleX
206f07a8d887 Annotation's scale is now still visually at one, whatever the timeline's scale.
cavaliet
parents: 160
diff changeset
    88
        {
206f07a8d887 Annotation's scale is now still visually at one, whatever the timeline's scale.
cavaliet
parents: 160
diff changeset
    89
            get { return _scaleX; }
206f07a8d887 Annotation's scale is now still visually at one, whatever the timeline's scale.
cavaliet
parents: 160
diff changeset
    90
            set
206f07a8d887 Annotation's scale is now still visually at one, whatever the timeline's scale.
cavaliet
parents: 160
diff changeset
    91
            {
206f07a8d887 Annotation's scale is now still visually at one, whatever the timeline's scale.
cavaliet
parents: 160
diff changeset
    92
                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
    93
                    return;
206f07a8d887 Annotation's scale is now still visually at one, whatever the timeline's scale.
cavaliet
parents: 160
diff changeset
    94
                _scaleX = value;
206f07a8d887 Annotation's scale is now still visually at one, whatever the timeline's scale.
cavaliet
parents: 160
diff changeset
    95
                base.OnPropertyChanged("ScaleX");
206f07a8d887 Annotation's scale is now still visually at one, whatever the timeline's scale.
cavaliet
parents: 160
diff changeset
    96
            }
206f07a8d887 Annotation's scale is now still visually at one, whatever the timeline's scale.
cavaliet
parents: 160
diff changeset
    97
        }
55
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    98
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    99
    }
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
   100
}