client/src/Iri.Modernisation.Controls/ViewModel/VideoViewer/VideoViewerVM.cs
author totetm <>
Fri, 12 Feb 2010 16:22:57 +0100
changeset 47 9b26023b8c83
parent 38 bd33267300aa
permissions -rw-r--r--
Fixed| bug si on ferme un livre en le lisant ReFixed|faire fonctionner le seek, même quand play n'est pas activer

using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Iri.Modernisation.BaseMVVM.Commands;
using Iri.Modernisation.BaseMVVM.ViewModel;
namespace Iri.Modernisation.Controls.ViewModel
{
    public class VideoViewerVM : BaseMVVM.ViewModel.ViewModel
    {

        private String _source;
        public String Source
        {
            get
            {
                return _source;
            }
            set
            {
                _source = value;
               
                OnPropertyChanged(null);
            }
        }
        public Uri USource
        {
            get
            {
                if (Source != null)
                {
                    return new Uri(Source, UriKind.RelativeOrAbsolute);
                }
                else
                {
                    return null;
                }
            }

        }
        
        public String Info
        {
            get
            {
                return position + ":" + Source;
            }
            
        }
        
        private TimeSpan position = new TimeSpan(0,0,0);
        public TimeSpan Position
        {
            get
            {
                return position;
            }
            set
            {
                position = value;
                //OnPropertyChanged("Position");
               OnPropertyChanged("Info");
            
            }
        }

        private bool _playControl;
        public bool PlayControl
        {
            get
            {
                return _playControl;
            }
            set
            {
                _playControl = value;
                OnPropertyChanged("PlayControl");
            }
        }

        private bool _recordControl;
        public bool RecordControl
        {
            get
            {
                return _recordControl;
            }
            set
            {
                _recordControl = value;
                OnPropertyChanged("RecordControl");
            }
        }

        private bool _autoPlay;
        public bool AutoPlay
        {
            get
            {
                return _autoPlay;
            }
            set
            {
                _autoPlay = value;
                OnPropertyChanged("AutoPlay");
            }

        }

        public VideoViewerVM(bool playControl,bool recordControl )
        {
            _playControl = playControl;
            _recordControl = recordControl;
            InitializeCommands();
            AutoPlay = false;
            
        }

        public TimeSpan BeginIn { get; set; }
        public event EventHandler<VideoViewerVMEventArgs> Tick;

        private void InitializeCommands()
        {
           
        }
        public void GoTo(TimeSpan pos)
        {
            Position = pos;
            Commands.GoToTime.Execute(Position,this);
        }
        public void Pause()
        {
            Commands.VideoViewer.Pause.Execute(null, this);
        }
        public void Play()
        {
            Commands.VideoViewer.Play.Execute(this, this);
        }
        public void LaunchTick(TimeSpan Pos)
        {
            if(Tick!=null)
            {
                Tick(this, new VideoViewerVMEventArgs(Pos-BeginIn));
            }
        }

        private bool _isPlayed;
        public bool IsPLayed
        {
            get
            {
                return _isPlayed;
            }
            set
            {
                _isPlayed = value;
                OnPropertyChanged("IsPlayed");
            }
        }
    }
    public class VideoViewerVMEventArgs : EventArgs
    {
        public TimeSpan Position { get; set; }
        public VideoViewerVMEventArgs(TimeSpan pos)
        {
            Position = pos;
        }
    }
}