public MainViewModel(MainWindowViewModel model, PlaylistViewModel playlist)
        {
            _nextcmd = new RelayCommand(NextCmd, CanNext);
            _previouscmd = new RelayCommand(PreviousCmd, CanPrevious);
            _playlistcmd = new RelayCommand(PlaylistCmd, () => true);
            _playcmd = new RelayCommand(PlayCmd, () => true);
            _repeatcmd = new RelayCommand(RepeatCmd, () => true);
            _randcmd = new RelayCommand(RandCmd, () => true);
            _stopcmd = new RelayCommand(StopCmd, () => true);
            _fullscreencmd = new RelayCommand(FullScreenCmd, CanFullScreen);
            _exitfullscreencmd = new RelayCommand(ExitFullScreenCmd, () => true);
            _changevolumecmd = new RelayCommand(ChangeVolumeCmd, () => true);
            _mediainfoscmd = new RelayCommand(MediaInfosCmd, CanMediaInfos);

            _typeFilter = WMP.Model.MediaFilter.TITLE;
            _playmediacmd = new RelayCommand(playMediaCmd, () => true);
            _addvideoscmd = new RelayCommand(addVideoCmd, () => true);
            _addsongscmd = new RelayCommand(addSongCmd, () => true);
            _addpicturescmd = new RelayCommand(addPictureCmd, () => true);
            _addsongtoplaylist = new RelayCommand(addSongToPlayList, () => true);
            _addvideotoplaylist = new RelayCommand(addVideoToPlayList, () => true);
            _addpicturetoplaylist = new RelayCommand(addPictureToPlayList, () => true);
            _deletevideocmd = new RelayCommand(deleteVideoCmd, () => true);
            _deletesongcmd = new RelayCommand(deleteSongCmd, () => true);
            _deletepicturecmd = new RelayCommand(deletePictureCmd, () => true);
            _clearvideos = new RelayCommand(clearVideos, () => true);
            _clearpictures = new RelayCommand(clearPictures, () => true);
            _clearsongs = new RelayCommand(clearSongs, () => true);
            _clearallcmd = new RelayCommand(clearAll, () => true);

            ListVideos = new ObservableCollection<VideoMedia>();
            ListSongs = new ObservableCollection<AudioMedia>();
            ListPictures = new ObservableCollection<PictureMedia>();

            _rand = 0;
            _playlist = playlist;
            _isRandEnabled = false;
            _repeatState = repeatStatus.NONE    ;
            _model = model;
            _media = null;
            _search = "";
            _mediaInfosOpen = false;
            _mediaInfos = new Window[(int)t_MediaType.NONE];
            _mediaInfos[(int)t_MediaType.AUDIO] = null;
            _mediaInfos[(int)t_MediaType.VIDEO] = null;
            _mediaInfos[(int)t_MediaType.PICTURE] = null;
            _mediaInfosFillers = new Action[(int)t_MediaType.NONE];
            _mediaInfosFillers[(int)t_MediaType.AUDIO] = new Action(FillAudioModel);
            _mediaInfosFillers[(int)t_MediaType.VIDEO] = new Action(FillVideoModel);
            _mediaInfosFillers[(int)t_MediaType.PICTURE] = new Action(FillPictureModel);
            _createMediaWindow = new Func<Window>[(int)t_MediaType.NONE];
            _createMediaWindow[(int)t_MediaType.AUDIO] = new Func<Window>(CreateAudioWindow);
            _createMediaWindow[(int)t_MediaType.VIDEO] = new Func<Window>(CreateVideoWindow);
            _createMediaWindow[(int)t_MediaType.PICTURE] = new Func<Window>(CreatePictureWindow);
            _infosModels = new ViewModelBase[(int)t_MediaType.NONE];
            _infosModels[(int)t_MediaType.AUDIO] = new AudioMediaViewModel();
            _infosModels[(int)t_MediaType.VIDEO] = new VideoMediaViewModel();
            _infosModels[(int)t_MediaType.PICTURE] = new PictureMediaViewModel();
            _fullScreen = false;
            _rnd = new Random();
            _progress = new Timer(200);
            _progress.Elapsed += ProgressElapsed;
            _player = new MediaElement();
            _player.LoadedBehavior = MediaState.Manual;
            _player.MediaOpened += MediaLoaded;
            _player.MediaEnded += OnMediaEnded;
            _player.MediaFailed += OnMediaFailed;

            loadPicturesLibrary();
            loadSongsLibrary();
            loadVideosLibrary();
        }
Exemplo n.º 2
0
        public MainViewModel(MainWindowViewModel model, PlaylistViewModel playlist)
        {
            _nextcmd           = new RelayCommand(NextCmd, CanNext);
            _previouscmd       = new RelayCommand(PreviousCmd, CanPrevious);
            _playlistcmd       = new RelayCommand(PlaylistCmd, () => true);
            _playcmd           = new RelayCommand(PlayCmd, () => true);
            _repeatcmd         = new RelayCommand(RepeatCmd, () => true);
            _randcmd           = new RelayCommand(RandCmd, () => true);
            _stopcmd           = new RelayCommand(StopCmd, () => true);
            _fullscreencmd     = new RelayCommand(FullScreenCmd, CanFullScreen);
            _exitfullscreencmd = new RelayCommand(ExitFullScreenCmd, () => true);
            _changevolumecmd   = new RelayCommand(ChangeVolumeCmd, () => true);
            _mediainfoscmd     = new RelayCommand(MediaInfosCmd, CanMediaInfos);

            _typeFilter           = WMP.Model.MediaFilter.TITLE;
            _playmediacmd         = new RelayCommand(playMediaCmd, () => true);
            _addvideoscmd         = new RelayCommand(addVideoCmd, () => true);
            _addsongscmd          = new RelayCommand(addSongCmd, () => true);
            _addpicturescmd       = new RelayCommand(addPictureCmd, () => true);
            _addsongtoplaylist    = new RelayCommand(addSongToPlayList, () => true);
            _addvideotoplaylist   = new RelayCommand(addVideoToPlayList, () => true);
            _addpicturetoplaylist = new RelayCommand(addPictureToPlayList, () => true);
            _deletevideocmd       = new RelayCommand(deleteVideoCmd, () => true);
            _deletesongcmd        = new RelayCommand(deleteSongCmd, () => true);
            _deletepicturecmd     = new RelayCommand(deletePictureCmd, () => true);
            _clearvideos          = new RelayCommand(clearVideos, () => true);
            _clearpictures        = new RelayCommand(clearPictures, () => true);
            _clearsongs           = new RelayCommand(clearSongs, () => true);
            _clearallcmd          = new RelayCommand(clearAll, () => true);

            ListVideos   = new ObservableCollection <VideoMedia>();
            ListSongs    = new ObservableCollection <AudioMedia>();
            ListPictures = new ObservableCollection <PictureMedia>();

            _rand           = 0;
            _playlist       = playlist;
            _isRandEnabled  = false;
            _repeatState    = repeatStatus.NONE;
            _model          = model;
            _media          = null;
            _search         = "";
            _mediaInfosOpen = false;
            _mediaInfos     = new Window[(int)t_MediaType.NONE];
            _mediaInfos[(int)t_MediaType.AUDIO]   = null;
            _mediaInfos[(int)t_MediaType.VIDEO]   = null;
            _mediaInfos[(int)t_MediaType.PICTURE] = null;
            _mediaInfosFillers = new Action[(int)t_MediaType.NONE];
            _mediaInfosFillers[(int)t_MediaType.AUDIO]   = new Action(FillAudioModel);
            _mediaInfosFillers[(int)t_MediaType.VIDEO]   = new Action(FillVideoModel);
            _mediaInfosFillers[(int)t_MediaType.PICTURE] = new Action(FillPictureModel);
            _createMediaWindow = new Func <Window> [(int)t_MediaType.NONE];
            _createMediaWindow[(int)t_MediaType.AUDIO]   = new Func <Window>(CreateAudioWindow);
            _createMediaWindow[(int)t_MediaType.VIDEO]   = new Func <Window>(CreateVideoWindow);
            _createMediaWindow[(int)t_MediaType.PICTURE] = new Func <Window>(CreatePictureWindow);
            _infosModels = new ViewModelBase[(int)t_MediaType.NONE];
            _infosModels[(int)t_MediaType.AUDIO]   = new AudioMediaViewModel();
            _infosModels[(int)t_MediaType.VIDEO]   = new VideoMediaViewModel();
            _infosModels[(int)t_MediaType.PICTURE] = new PictureMediaViewModel();
            _fullScreen            = false;
            _rnd                   = new Random();
            _progress              = new Timer(200);
            _progress.Elapsed     += ProgressElapsed;
            _player                = new MediaElement();
            _player.LoadedBehavior = MediaState.Manual;
            _player.MediaOpened   += MediaLoaded;
            _player.MediaEnded    += OnMediaEnded;
            _player.MediaFailed   += OnMediaFailed;

            loadPicturesLibrary();
            loadSongsLibrary();
            loadVideosLibrary();
        }