public GlobalLibrary() { MusicLibrary = ModuleManager.GetInstanceOf<IMusicLibrary>("MusicLibrary"); VideoLibrary = ModuleManager.GetInstanceOf<ILibrary<IVideoMedia>>("VideoLibrary"); ImageLibrary = ModuleManager.GetInstanceOf<ILibrary<IImageMedia>>("ImageLibrary"); PlayListLibrary = ModuleManager.GetInstanceOf<ILibrary<IPlayList>>("PlayListLibrary"); CreatePlaylist = new RelayCommand((param) => CreatePlaylistBody(param as string)); Display = new RelayCommand((param) => DisplayBody(param as string)); OpenPlayListWindow = new RelayCommand((param) => OpenPlayListWindowBody()); PlayPlayList = new RelayCommand((param) => PlayPlayListBody(param as IPlayList)); BeginDragData = new RelayCommand((param) => BeginDragDataBody(param as FrameworkElement)); DropData = new RelayCommand((param) => DropDataBody(param as object[])); IDAL dal = ModuleManager.GetInstanceOf<IDAL>("XMLDAL"); if (dal != null) { foreach (IMusicMedia media in dal.MusicList) MusicLibrary.MediaList.Add(media); foreach (IVideoMedia media in dal.VideoList) VideoLibrary.MediaList.Add(media); foreach (IImageMedia media in dal.ImageList) ImageLibrary.MediaList.Add(media); foreach (IPlayList plist in dal.PlayListList) PlayListLibrary.MediaList.Add(plist); } }
public LibraryViewModel() { MusicList = new ObservableCollection<IMusicMedia>(); VideoList = new ObservableCollection<IVideoMedia>(); ImageList = new ObservableCollection<IImageMedia>(); PlayContextMenu = new RelayCommand((param) => { IMediaPlayer mp = ModuleManager.GetInstanceOf<IMediaPlayer>("MusicPlayerViewModel"); if (mp != null && SelectedItem != null) mp.Open.Execute(SelectedItem); }); EnableRaisePropertyChanged = false; IDAL DAL = ModuleManager.GetInstanceOf<IDAL>("XMLDAL"); foreach (IMedia media in DAL.MediaList) { media.AddToLibrary(this); } EnableRaisePropertyChanged = true; }