Ejemplo n.º 1
0
        /// <summary>
        /// Just Load A Media
        /// </summary>
        private void                            LoadMedia(string Path)
        {
            if (File.Exists(Path))
            {
                CMD_Stop_Executed(null);
                Video.Media.Source = new Uri(Path);
                Video.Media.Play();

                IsPlaying = true;
                IsLoaded  = true;
                NotifyPropertyChanged("VideoName");
                NotifyPropertyChanged("PlaylistPos");
                NotifyPropertyChanged("BtnPlayPauseImg");
                CMD_PlayPause.RaiseCanExecuteChanged();
                CMD_Stop.RaiseCanExecuteChanged();
                CMD_FullScreen.RaiseCanExecuteChanged();
                CMD_Prev.RaiseCanExecuteChanged();
                CMD_Next.RaiseCanExecuteChanged();
                CMD_SavePlayList.RaiseCanExecuteChanged();
            }
            else
            {
                System.Windows.Forms.MessageBox.Show("Unable To Load " + Path, "Error", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Warning);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Remove From a List
        /// </summary>
        public void                             CMD_DeleteIndex_Executed(ListView Arg)
        {
            if (Arg != null)
            {
                if (Arg.Name == "PlayList")
                {
                    bool              NeedToNext = false;
                    int               Tmp2       = PlaylistPos;
                    Model.Film        Tmp        = Playlist.GetCurrent();
                    List <Model.Film> DelList    = new List <Model.Film>();

                    foreach (var F in Arg.SelectedItems)
                    {
                        DelList.Add(F as Model.Film);
                    }
                    foreach (var F in DelList)
                    {
                        if (Tmp == F)
                        {
                            NeedToNext = true;
                        }
                        Playlist.Remove(F as Model.Film);
                    }
                    if (NeedToNext)
                    {
                        CMD_Stop_Executed(null);
                        if (Playlist.Films.Count > 0)
                        {
                            LoadMedia(Playlist.GetIndex(Tmp2).Path);
                        }
                    }
                    if (Playlist.Films.Count == 0)
                    {
                        IsLoaded = false;
                        CMD_PlayPause.RaiseCanExecuteChanged();
                        CMD_Stop.RaiseCanExecuteChanged();
                        CMD_FullScreen.RaiseCanExecuteChanged();
                        CMD_Prev.RaiseCanExecuteChanged();
                        CMD_Next.RaiseCanExecuteChanged();
                        NotifyPropertyChanged("IsLoaded");
                    }
                    NotifyPropertyChanged("PlaylistPos");
                    CMD_SavePlayList.RaiseCanExecuteChanged();
                }
                else
                {
                    List <Model.Film> DelList = new List <Model.Film>();
                    foreach (var F in Arg.SelectedItems)
                    {
                        DelList.Add(F as Model.Film);
                    }
                    foreach (var F in DelList)
                    {
                        Library.Remove(F as Model.Film);
                    }
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        ///  Opening A New Media File And Playing It
        /// </summary>
        public void                             CMD_Open_Executed(String Arg)
        {
            OpenFileDialog Dialog = new OpenFileDialog();

            Dialog.Multiselect     = true;
            Dialog.Title           = "Select One Or Several Media Files";
            Dialog.Filter         += "Video Files (*.avi, *.mpeg, *.mpg, *.mp4, *.wmv) | *.avi;*.mpeg;*.mpg;*.mp4;*.wmv;";
            Dialog.Filter         += " | Audio Files (*.mp3, *.wav, *.mid, *.midi) | *.mp3;*.wav;*.mid;*.midi;";
            Dialog.Filter         += " | Image Files (*.jpg, *.jpeg, *.png, *.gif, *.bmp) | *.jpg;*.jpeg;*.png;*.gif;*.bmp;";
            Dialog.CheckFileExists = true;
            Dialog.CheckPathExists = true;
            var Player = new WindowsMediaPlayer();

            if (Dialog.ShowDialog() == true)
            {
                Loading = true;
                Task T = new Task(() =>
                {
                    if (Arg == "OPEN")
                    {
                        App.Current.Dispatcher.BeginInvoke((Action) delegate() { Playlist.Clean(); });
                    }

                    foreach (String _File in Dialog.FileNames)
                    {
                        var Clip           = Player.newMedia(_File);
                        Model.Film NewFilm = new Model.Film(Path.GetFileNameWithoutExtension(_File), TimeSpan.FromSeconds((Clip.duration == 0 ? 4 : Clip.duration)), _File, false, MyGetType(Path.GetExtension(_File)));

                        if (Arg == "LIBRARY")
                        {
                            App.Current.Dispatcher.BeginInvoke((Action) delegate() { Library.AddFilm(NewFilm); });
                        }
                        else
                        {
                            App.Current.Dispatcher.BeginInvoke((Action) delegate() { Playlist.AddFilm(NewFilm); });
                        }
                        _NbFilesLoaded++;
                        NotifyPropertyChanged("NbFilesLoaded");
                    }

                    if (Arg == "OPEN")
                    {
                        App.Current.Dispatcher.BeginInvoke((Action) delegate() { LoadMedia(Playlist.GetFirst().Path); });
                    }
                    App.Current.Dispatcher.BeginInvoke((Action) delegate() { CMD_SavePlayList.RaiseCanExecuteChanged(); });
                });

                T.ContinueWith(antecedent => Loading = false, TaskScheduler.FromCurrentSynchronizationContext());
                T.Start();
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Opening A Whole Folder
        /// </summary>
        public void                             CMD_OpenFolder_Executed(String Arg)
        {
            CommonOpenFileDialog Dialog = new CommonOpenFileDialog();

            Dialog.Title                     = "Choose A Folder";
            Dialog.IsFolderPicker            = true;
            Dialog.InitialDirectory          = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            Dialog.AddToMostRecentlyUsedList = false;
            Dialog.AllowNonFileSystemItems   = false;
            Dialog.DefaultDirectory          = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            Dialog.EnsureFileExists          = true;
            Dialog.EnsurePathExists          = true;
            Dialog.EnsureReadOnly            = false;
            Dialog.EnsureValidNames          = true;
            Dialog.Multiselect               = false;
            Dialog.ShowPlacesList            = true;

            if (Dialog.ShowDialog() == CommonFileDialogResult.Ok)
            {
                Loading = true;
                Task T = new Task(() =>
                {
                    if (Arg == "OPEN")
                    {
                        App.Current.Dispatcher.BeginInvoke((Action) delegate() { Playlist.Clean(); });
                    }
                    ScanFolder(Dialog.FileName, Arg);
                    if (Arg == "OPEN" && Playlist.Films.Count > 0)
                    {
                        App.Current.Dispatcher.BeginInvoke((Action) delegate() { LoadMedia(Playlist.GetFirst().Path); });
                    }
                    App.Current.Dispatcher.BeginInvoke((Action) delegate() { CMD_SavePlayList.RaiseCanExecuteChanged(); });
                });

                T.ContinueWith(antecedent => Loading = false, TaskScheduler.FromCurrentSynchronizationContext());
                T.Start();
            }
        }