Filter image files

This commit is contained in:
Jaex 2022-03-16 22:40:15 +03:00
parent 961e445d52
commit 2a9600edd4

View file

@ -24,6 +24,7 @@
#endregion License Information (GPL v3)
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
@ -52,6 +53,7 @@ private ImageViewer(string[] images, int currentImageIndex = 0)
Images = images;
CurrentImageIndex = currentImageIndex;
FilterImageFiles();
LoadCurrentImage();
}
@ -95,6 +97,37 @@ private void NavigateImage(int position)
}
}
private void FilterImageFiles()
{
List<string> filteredImages = new List<string>();
for (int i = 0; i < Images.Length; i++)
{
string imageFilePath = Images[i];
bool isImageFile = !string.IsNullOrEmpty(imageFilePath) && Helpers.IsImageFile(imageFilePath);
if (i == CurrentImageIndex)
{
if (isImageFile)
{
CurrentImageIndex = filteredImages.Count;
}
else
{
CurrentImageIndex = 0;
}
}
if (isImageFile)
{
filteredImages.Add(imageFilePath);
}
}
Images = filteredImages.ToArray();
}
private void UpdateIndexLabel()
{
if (!SupportsImageNavigation || Images.Length < 2) return;