예제 #1
0
 private void SetupForm(PictureViewerForm pictureViewerForm, PictureFile.PictureFile startFile)
 {
     pictureViewerForm.Loop                = Loop;
     pictureViewerForm.TransitionTime      = TransitionTime;
     pictureViewerForm.DelayInSec          = DelayInSec;
     pictureViewerForm.OverlayTextTemplate = OverlayText;
     if (Browse)
     {
         if (!pictureViewerForm.Browsing)
         {
             _slideshowFiles     = pictureViewerForm.Files;
             _slideshowFileIndex = pictureViewerForm.FileIndex;
         }
         pictureViewerForm.Files     = new List <PictureFile.PictureFile>(_browseFiles);
         pictureViewerForm.FileIndex = startFile != null
                                           ? new List <PictureFile.PictureFile>(_browseFiles).IndexOf(startFile)
                                           : 0;
     }
     else
     {
         if (_slideshowFiles != null)
         {
             pictureViewerForm.FileIndex = _slideshowFileIndex;
             pictureViewerForm.Files     = _slideshowFiles;
         }
         else
         {
             List <PictureFile.PictureFile> pictureFiles;
             pictureViewerForm.FileIndex = PrepareFileList(_browseFiles, out pictureFiles);
             pictureViewerForm.Files     = pictureFiles;
         }
     }
     pictureViewerForm.Browsing = Browse;
     pictureViewerForm.ShowPicture();
 }
예제 #2
0
 private void MarkFile(int i, PictureFile.PictureFile pictureFile)
 {
     using (File.Create(pictureFile.FileName + ".ssv." + i))
     {
     }
     pictureBox1.LowerRightText = "MARKED " + i;
 }
예제 #3
0
        private string GetOverlayText(PictureFile.PictureFile file, string template)
        {
            string overlayText = Regex.Replace(template, @"\{(.*?)\}",
                                               match => GetReplacement(match.Groups[1].ToString().ToLower()));

            return(string.Join("\n", overlayText.SplitIntoLines().Where(s => s.Length > 0)));
        }
예제 #4
0
 private void PreLoadTimerOnElapsed(object sender, ElapsedEventArgs elapsedEventArgs)
 {
     for (int i = 0; i < Files.Count; i++)
     {
         PictureFile.PictureFile pictureFile = Files[i];
         if ((i < FileIndex - 3 || i > FileIndex + 3))
         {
             pictureFile.UnloadImage();
         }
         if (i >= FileIndex - 1 && i <= FileIndex + 1)
         {
             pictureFile.StartLoadingImage();
         }
     }
 }
예제 #5
0
 private void ToggleBrowsing(PictureFile.PictureFile file)
 {
     Browse = !Browse;
     SetupForm(_pictureViewerForm, file);
 }
예제 #6
0
        internal void ShowPicture(bool transition = false)
        {
            if (Files == null)
            {
                return;
            }
            if (FileIndex >= Files.Count)
            {
                if (Loop)
                {
                    if (AllPicturesShown != null)
                    {
                        AllPicturesShown(Files);
                    }
                    FileIndex = 0;
                }
                else
                {
                    Close();
                    return;
                }
            }
            if (FileIndex < 0)
            {
                if (Loop)
                {
                    FileIndex = Files.Count - 1;
                }
                else
                {
                    Close();
                    return;
                }
            }

            PictureFile.PictureFile file = Files[FileIndex];
            Image bitmap        = file.Data.Image;
            int   imageDuration = file.Data.ImageDuration;

            pictureBox1.HighQuality = imageDuration == 0;

            decimal interval = Math.Max(DelayInSec * 1000, imageDuration + imageDuration / 2);

            if (interval == 0)
            {
                interval = 1;
            }

            if (transition)
            {
                pictureBox1.TransitionImage(bitmap, TransitionTime);
                interval += (decimal)TransitionTime;
            }
            else
            {
                pictureBox1.SetImage(bitmap);
            }

            string lowerRightText = null;

            StopSlideShowTimer();
            if (!Browsing)
            {
                if (!Paused)
                {
                    StartSlideShowTimer(interval);
                }
                else
                {
                    lowerRightText = "PAUSED";
                }
                if (PictureShown != null)
                {
                    PictureShown(file);
                }
            }
            else
            {
                lowerRightText = "BROWSING";
            }
            switch (InfoState)
            {
            case InfoState.Template:
                pictureBox1.LowerRightText = lowerRightText;
                pictureBox1.LowerLeftText  = GetOverlayText(file, OverlayTextTemplate);
                break;

            case InfoState.Hidden:
                pictureBox1.LowerRightText = null;
                pictureBox1.LowerLeftText  = null;
                break;

            case InfoState.Details:
                pictureBox1.LowerRightText = lowerRightText;
                pictureBox1.LowerLeftText  = GetOverlayText(file, "{description}{nl}{dateTaken}{nl}{cameraDescription}{nl}{exposure}{nl}{dimensions}{nl}{fullName}{nl}{index} / {total}");
                break;

            case InfoState.Full:
                pictureBox1.LowerRightText = lowerRightText;
                pictureBox1.LowerLeftText  = String.Join("\n",
                                                         file.Data.Properties.Select(
                                                             pair => pair.Key + ": '" + pair.Value + "'"));
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
            _preLoadTimer.Stop();
            _preLoadTimer.Start();
        }