src/FingersDance.Views/TimelineAnnotationView.xaml.cs
author ARIAS Santiago
Sat, 14 Nov 2009 19:07:51 +0100
changeset 201 16287a7d1f1a
parent 167 206f07a8d887
permissions -rw-r--r--
Surface ScrollViewer for Control.Menu
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
using System.Windows;
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
     6
using System.Windows.Controls;
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
     7
using System.Windows.Data;
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
     8
using System.Windows.Documents;
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
     9
using System.Windows.Input;
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    10
using System.Windows.Media;
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    11
using System.Windows.Media.Imaging;
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    12
using System.Windows.Navigation;
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    13
using System.Windows.Shapes;
143
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 74
diff changeset
    14
using Microsoft.Surface.Presentation;
55
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    15
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    16
namespace FingersDance.Views
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    17
{
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    18
    /// <summary>
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    19
    /// Interaction logic for TimelineAnnotationView.xaml
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    20
    /// </summary>
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    21
    public partial class TimelineAnnotationView : UserControl
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    22
    {
167
206f07a8d887 Annotation's scale is now still visually at one, whatever the timeline's scale.
cavaliet
parents: 160
diff changeset
    23
206f07a8d887 Annotation's scale is now still visually at one, whatever the timeline's scale.
cavaliet
parents: 160
diff changeset
    24
        public static readonly DependencyProperty ScaleXProperty = DependencyProperty.Register("ScaleX", typeof(Double), typeof(TimelineAnnotationView));
206f07a8d887 Annotation's scale is now still visually at one, whatever the timeline's scale.
cavaliet
parents: 160
diff changeset
    25
55
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    26
        public TimelineAnnotationView()
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    27
        {
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    28
            InitializeComponent();
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    29
        }
167
206f07a8d887 Annotation's scale is now still visually at one, whatever the timeline's scale.
cavaliet
parents: 160
diff changeset
    30
206f07a8d887 Annotation's scale is now still visually at one, whatever the timeline's scale.
cavaliet
parents: 160
diff changeset
    31
        public Double ScaleX
206f07a8d887 Annotation's scale is now still visually at one, whatever the timeline's scale.
cavaliet
parents: 160
diff changeset
    32
        {
206f07a8d887 Annotation's scale is now still visually at one, whatever the timeline's scale.
cavaliet
parents: 160
diff changeset
    33
            get { return (Double)GetValue(ScaleXProperty); }
206f07a8d887 Annotation's scale is now still visually at one, whatever the timeline's scale.
cavaliet
parents: 160
diff changeset
    34
            set { SetValue(ScaleXProperty, value); }
206f07a8d887 Annotation's scale is now still visually at one, whatever the timeline's scale.
cavaliet
parents: 160
diff changeset
    35
        }
55
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    36
    }
71
31900a35e162 We can set a margin to an annotation.
cavaliet
parents: 55
diff changeset
    37
31900a35e162 We can set a margin to an annotation.
cavaliet
parents: 55
diff changeset
    38
    public class ThicknessSingleValueConverter : IValueConverter
31900a35e162 We can set a margin to an annotation.
cavaliet
parents: 55
diff changeset
    39
    {
31900a35e162 We can set a margin to an annotation.
cavaliet
parents: 55
diff changeset
    40
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
31900a35e162 We can set a margin to an annotation.
cavaliet
parents: 55
diff changeset
    41
        {
31900a35e162 We can set a margin to an annotation.
cavaliet
parents: 55
diff changeset
    42
            ThicknessConverter myThicknessConverter = new ThicknessConverter();
31900a35e162 We can set a margin to an annotation.
cavaliet
parents: 55
diff changeset
    43
            Thickness th1 = (Thickness)myThicknessConverter.ConvertFrom(value);
74
7ce946833eae First step of data binding where we can add an annotation by clicking on the timeline
cavaliet
parents: 71
diff changeset
    44
            th1.Top = 0;
7ce946833eae First step of data binding where we can add an annotation by clicking on the timeline
cavaliet
parents: 71
diff changeset
    45
            th1.Bottom = th1.Right = 0;
71
31900a35e162 We can set a margin to an annotation.
cavaliet
parents: 55
diff changeset
    46
            return th1;
31900a35e162 We can set a margin to an annotation.
cavaliet
parents: 55
diff changeset
    47
        }
31900a35e162 We can set a margin to an annotation.
cavaliet
parents: 55
diff changeset
    48
        public object ConvertBack(object value, Type targetTypes, object parameter, System.Globalization.CultureInfo culture)
31900a35e162 We can set a margin to an annotation.
cavaliet
parents: 55
diff changeset
    49
        {
31900a35e162 We can set a margin to an annotation.
cavaliet
parents: 55
diff changeset
    50
            Thickness thickness = (Thickness)value;
31900a35e162 We can set a margin to an annotation.
cavaliet
parents: 55
diff changeset
    51
            return thickness.Left;
31900a35e162 We can set a margin to an annotation.
cavaliet
parents: 55
diff changeset
    52
        }
31900a35e162 We can set a margin to an annotation.
cavaliet
parents: 55
diff changeset
    53
    }
143
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 74
diff changeset
    54
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 74
diff changeset
    55
    public class VisibilityConverter : IValueConverter
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 74
diff changeset
    56
    {
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 74
diff changeset
    57
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 74
diff changeset
    58
        {
150
569925b65604 Annotations are now colored with the same color as the pivot's button
cavaliet
parents: 146
diff changeset
    59
            Visibility v = ((float)value > 0) ? Visibility.Visible : Visibility.Hidden;
143
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 74
diff changeset
    60
            return v;
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 74
diff changeset
    61
        }
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 74
diff changeset
    62
        public object ConvertBack(object value, Type targetTypes, object parameter, System.Globalization.CultureInfo culture)
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 74
diff changeset
    63
        {
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 74
diff changeset
    64
            return 1.0;
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 74
diff changeset
    65
        }
PAMPHILE Jonathan <pamphile@efrei.fr>
parents: 74
diff changeset
    66
    }
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
    67
    
150
569925b65604 Annotations are now colored with the same color as the pivot's button
cavaliet
parents: 146
diff changeset
    68
    public class ColorConverter : IValueConverter
569925b65604 Annotations are now colored with the same color as the pivot's button
cavaliet
parents: 146
diff changeset
    69
    {
569925b65604 Annotations are now colored with the same color as the pivot's button
cavaliet
parents: 146
diff changeset
    70
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
569925b65604 Annotations are now colored with the same color as the pivot's button
cavaliet
parents: 146
diff changeset
    71
        {
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
    72
            //UInt32 argb = (UInt32)value;
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
            //Color c = Color.FromArgb((Byte)((argb >> 24) & 0xFF), (Byte)((argb >> 16) & 0xFF), (Byte)((argb >> 8) & 0xFF), (Byte)(argb & 0xFF));
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
    74
            SolidColorBrush scb = new SolidColorBrush((Color)value);
150
569925b65604 Annotations are now colored with the same color as the pivot's button
cavaliet
parents: 146
diff changeset
    75
            return scb;
569925b65604 Annotations are now colored with the same color as the pivot's button
cavaliet
parents: 146
diff changeset
    76
        }
569925b65604 Annotations are now colored with the same color as the pivot's button
cavaliet
parents: 146
diff changeset
    77
        public object ConvertBack(object value, Type targetTypes, object parameter, System.Globalization.CultureInfo culture)
569925b65604 Annotations are now colored with the same color as the pivot's button
cavaliet
parents: 146
diff changeset
    78
        {
569925b65604 Annotations are now colored with the same color as the pivot's button
cavaliet
parents: 146
diff changeset
    79
            return 1.0;
569925b65604 Annotations are now colored with the same color as the pivot's button
cavaliet
parents: 146
diff changeset
    80
        }
569925b65604 Annotations are now colored with the same color as the pivot's button
cavaliet
parents: 146
diff changeset
    81
    }
55
1ec0ef228158 data, viewmodel and view added
cavaliet
parents:
diff changeset
    82
}