コード例 #1
0
 private void MediaEnded(object sender, RoutedEventArgs e)
 {
     FullScreenMedia.Position = new TimeSpan(0);
     FullScreenMedia.Stop();
     FullScreenMedia.Source = null;
     NextMediaItem();
 }
コード例 #2
0
        private void NextMediaItem()
        {
            FullScreenMedia.Stop();
            FullScreenMedia.Source = null; // FIXED Overlay display info is correct on video until you use forward/back arrow keys to traverse to images.
            imageRotationAngle     = 0;
            switch (algorithm)
            {
            case PreferenceManager.ALGORITHM_SEQUENTIAL:
                incrementCurrentItem();
                Console.WriteLine("NextMediaItem(): 0 isLoadingFiles = " + isLoadingFiles + ", currentItem = " + currentItem + ", mediaFiles.Count = " + mediaFiles.Count);
                break;

            case PreferenceManager.ALGORITHM_RANDOM_NO_REPEAT:
                incrementCurrentItem();
                if (isLoadingFiles)
                {
                    // Sleep to buffer some images to start
                    Console.WriteLine("NextMediaItem(): 1 isLoadingFiles = " + isLoadingFiles + ", currentItem = " + currentItem + ", mediaFiles.Count = " + mediaFiles.Count + ", algorithm = " + algorithm);
                    if (currentItem == 0)
                    {
                        Thread.Sleep(1000);
                    }

                    currentItem = new Random().Next(mediaFiles.Count);
                    Console.WriteLine("NextMediaItem(): 2 isLoadingFiles = " + isLoadingFiles + ", currentItem = " + currentItem + ", mediaFiles.Count = " + mediaFiles.Count);

                    // Maintain previous media list while loading/randomizing
                    addLastMedia();
                }
                Console.WriteLine("NextMediaItem(): 3 isLoadingFiles = " + isLoadingFiles + ", currentItem = " + currentItem + ", mediaFiles.Count = " + mediaFiles.Count);


                break;

            case PreferenceManager.ALGORITHM_RANDOM:
                currentItem = new Random().Next(mediaFiles.Count);
                addLastMedia();
                break;
            }
            if (mediaFiles.Count == 0)
            {
                ShowError("There are no files to show!");
                FullScreenImage.Source = null;
                FullScreenMedia.Stop();
                FullScreenMedia.Source = null;
                return;
            }

            FileInfo fi = new FileInfo(mediaFiles[currentItem]);

            if (acceptedExtensionsImages.Contains(fi.Extension.ToLower())) // check if it image or video
            {
                LoadImage(fi.FullName);
            }
            else
            {
                LoadMedia(fi.FullName);
            }
        }
コード例 #3
0
        private void PrevMediaItem()
        {
            FullScreenMedia.Stop();
            FullScreenMedia.Source = null; // FIXED Overlay display info is correct on video until you use forward/back arrow keys to traverse to images.
            imageRotationAngle     = 0;
            switch (algorithm)
            {
            case PreferenceManager.ALGORITHM_SEQUENTIAL:
            case PreferenceManager.ALGORITHM_RANDOM_NO_REPEAT:
                currentItem--;
                if (currentItem < 0)
                {
                    if (isLoadingFiles)
                    {
                        currentItem = 0;
                    }
                    else
                    {
                        currentItem = mediaFiles.Count - 1;
                    }
                }
                break;

            case PreferenceManager.ALGORITHM_RANDOM:
                if (lastMedia.Count >= 2)
                {
                    if (currentLastMediaItem > 0)
                    {
                        currentLastMediaItem--;
                    }
                    currentItem = mediaFiles.IndexOf(lastMedia[currentLastMediaItem]);
                    //lastMedia.RemoveAt(lastMedia.Count - 1);
                }
                else
                {
                    imageTimer.Start();
                }
                break;
            }
            if (mediaFiles.Count == 0)
            {
                ShowError("There are no files to show!");
                FullScreenImage.Source = null;
                FullScreenMedia.Stop();
                FullScreenMedia.Source = null;
                return;
            }

            FileInfo fi = new FileInfo(mediaFiles[currentItem]);

            if (acceptedExtensionsImages.Contains(fi.Extension.ToLower())) // check if it image or video
            {
                LoadImage(fi.FullName);
            }
            else
            {
                LoadMedia(fi.FullName);
            }
        }
コード例 #4
0
        private void PrevMediaItem()
        {
            FullScreenMedia.Stop();
            FullScreenMedia.Source = null; // FIXED Overlay display info is correct on video until you use forward/back arrow keys to traverse to images.
            imageRotationAngle     = 0;

            Console.WriteLine("PrevMediaItem(): 1 isLoadingFiles = " + isLoadingFiles + ", lastMedia.Count = " + lastMedia.Count + ", currentItem = " + currentItem + ", mediaFiles.Count = " + mediaFiles.Count);
            switch (algorithm)
            {
            case PreferenceManager.ALGORITHM_SEQUENTIAL:
                decrementCurrentItem();
                break;

            case PreferenceManager.ALGORITHM_RANDOM_NO_REPEAT:
                if (isLoadingFiles)
                {
                    getLastMedia();
                }
                else
                {
                    decrementCurrentItem();
                }
                break;

            case PreferenceManager.ALGORITHM_RANDOM:
                getLastMedia();
                break;
            }
            if (mediaFiles.Count == 0)
            {
                ShowError("There are no files to show!");
                FullScreenImage.Source = null;
                FullScreenMedia.Stop();
                FullScreenMedia.Source = null;
                return;
            }

            FileInfo fi = new FileInfo(mediaFiles[currentItem]);

            if (acceptedExtensionsImages.Contains(fi.Extension.ToLower())) // check if it image or video
            {
                LoadImage(fi.FullName);
            }
            else
            {
                LoadMedia(fi.FullName);
            }

            Console.WriteLine("PrevMediaItem(): 2 isLoadingFiles = " + isLoadingFiles + ", lastMedia.Count = " + lastMedia.Count + ", currentItem = " + currentItem + ", mediaFiles.Count = " + mediaFiles.Count);
        }
コード例 #5
0
        private void NextMediaItem()
        {
            FullScreenMedia.Stop();
            FullScreenMedia.Source = null; // FIXED Overlay display info is correct on video until you use forward/back arrow keys to traverse to images.
            imageRotationAngle     = 0;
            switch (algorithm)
            {
            case PreferenceManager.ALGORITHM_SEQUENTIAL:
            case PreferenceManager.ALGORITHM_RANDOM_NO_REPEAT:
                currentItem++;
                if (currentItem >= mediaFiles.Count)
                {
                    currentItem = 0;
                }
                break;

            case PreferenceManager.ALGORITHM_RANDOM:
                currentItem = new Random().Next(mediaFiles.Count);
                lastMedia.Add(mediaFiles[currentItem]);
                if (lastMedia.Count > 100)
                {
                    lastMedia.RemoveAt(0);
                }
                break;
            }
            if (mediaFiles.Count == 0)
            {
                ShowError("There are no files to show!");
                FullScreenImage.Source = null;
                FullScreenMedia.Stop();
                FullScreenMedia.Source = null;
                return;
            }

            FileInfo fi = new FileInfo(mediaFiles[currentItem]);

            if (acceptedExtensionsImages.Contains(fi.Extension.ToLower())) // check if it image or video
            {
                LoadImage(fi.FullName);
            }
            else
            {
                LoadMedia(fi.FullName);
            }
        }
コード例 #6
0
        private void MediaEnded(object sender, RoutedEventArgs e)
        {
            String userName = Environment.UserName;

            try
            {
                File.AppendAllText(@"C:\Users\" + userName + @"\Downloads\logfile.log", $"[{DateTime.Now.ToString()}] {"Entering MediaEnded\n"}");
                FullScreenMedia.Position = new TimeSpan(0);
                FullScreenMedia.Stop();
                FullScreenMedia.Source = null;
                NextMediaItem();
                File.AppendAllText(@"C:\Users\" + userName + @"\Downloads\logfile.log", $"[{DateTime.Now.ToString()}] {"Exiting MediaEnded\n"}");
            }
            catch (Exception ex)
            {
                File.AppendAllText(@"C:\Users\" + userName + @"\Downloads\logfile.log", $"[{DateTime.Now.ToString()}] {ex.ToString()+"\n"}");
            }
            finally
            {
                NextMediaItem();
            }
        }
コード例 #7
0
        private void NextMediaItem()
        {
            FullScreenMedia.Stop();
            FullScreenMedia.Source = null; // FIXED Overlay display info is correct on video until you use forward/back arrow keys to traverse to images.
            imageRotationAngle     = 0;
            if (isLoadingFiles)
            {
                if ((currentItem + 1) >= mediaFiles.Count || mediaFiles.Count == 0) // first condition is for ALGORITHM_SEQUENTIAL and ALGORITHM_RANDOM_NO_REPEAT , second is for ALGORITHM_RANDOM
                {
                    ShowError("Wait untill more files loaded");
                    infoShowingTimer.Start();
                    Application.Current.Dispatcher.Invoke(DispatcherPriority.Background, new Action(delegate { }));
                    do
                    {
                        Thread.Sleep(100);
                    } while (isLoadingFiles && currentItem >= mediaFiles.Count);
                }
            }
            switch (algorithm)
            {
            case PreferenceManager.ALGORITHM_SEQUENTIAL:
            case PreferenceManager.ALGORITHM_RANDOM_NO_REPEAT:
                sleepAtStart();
                currentItem++;
                if (currentItem >= mediaFiles.Count)
                {
                    currentItem = 0;
                }
                break;

            case PreferenceManager.ALGORITHM_RANDOM:
                sleepAtStart();
                if (currentLastMediaItem < (lastMedia.Count - 1))
                {
                    currentLastMediaItem++;
                    currentItem = mediaFiles.IndexOf(lastMedia[currentLastMediaItem]);
                }
                else
                {
                    currentItem = new Random().Next(mediaFiles.Count - 1);
                    lastMedia.Add(mediaFiles[currentItem]);
                    if (lastMedia.Count > 100)
                    {
                        lastMedia.RemoveAt(0);
                    }
                    currentLastMediaItem = lastMedia.Count - 1;
                }
                break;
            }
            if (mediaFiles.Count == 0)
            {
                ShowError("There are no files to show!");
                FullScreenImage.Source = null;
                FullScreenMedia.Stop();
                FullScreenMedia.Source = null;
                return;
            }

            FileInfo fi = new FileInfo(mediaFiles[currentItem]);

            if (acceptedExtensionsImages.Contains(fi.Extension.ToLower())) // check if it image or video
            {
                LoadImage(fi.FullName);
            }
            else
            {
                LoadMedia(fi.FullName);
            }
        }