A list of files (pictures) can be searched and shown in listbox
This commit is contained in:
63
ImageHandlingLibrary/Helpers/Dialogs.cs
Normal file
63
ImageHandlingLibrary/Helpers/Dialogs.cs
Normal file
@ -0,0 +1,63 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows.Forms;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.IO;
|
||||
using ImageHandlingLibrary.InterFaces;
|
||||
|
||||
namespace ImageHandlingLibrary.Helpers
|
||||
{
|
||||
public class Dialogs : IDialogs
|
||||
{
|
||||
|
||||
public List<FileInfo> ChooseFiles()
|
||||
{
|
||||
using (OpenFileDialog ofd = new OpenFileDialog())
|
||||
{
|
||||
var outPut = new List<FileInfo>();
|
||||
ofd.Title = "Välj bild-fil!";
|
||||
ofd.InitialDirectory = "C:\\";
|
||||
ofd.Filter = "Picture files (*.jpg)|*.jpg;*.jpeg|All files (*.*)|*.*";
|
||||
ofd.FilterIndex = 1;
|
||||
ofd.RestoreDirectory = true;
|
||||
ofd.Multiselect = true;
|
||||
ofd.ShowDialog();
|
||||
var fnames = ofd.FileNames;
|
||||
if (fnames.Length > 1)
|
||||
{
|
||||
foreach (var fname in fnames)
|
||||
{
|
||||
outPut.Add(new FileInfo(fname));
|
||||
}
|
||||
}
|
||||
//else
|
||||
//{
|
||||
// string fName = ofd.FileName;
|
||||
// if (fName.Trim() != "")
|
||||
// {
|
||||
// int fNamePos = fName.LastIndexOf(@"\") + 1;
|
||||
// lblFileName.Text = fName.Substring(fNamePos);
|
||||
// lblPath.Text = fName.Substring(0, fNamePos);
|
||||
// listLocalFiles();
|
||||
|
||||
// for (int i = 0; i < lstPicFiles.Items.Count; i++)
|
||||
// {
|
||||
// if (lstPicFiles.Items[i].ToString() == lblFileName.Text)
|
||||
// {
|
||||
// lstPicFiles.SelectedIndex = i;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
|
||||
// }
|
||||
|
||||
//}
|
||||
return outPut;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user