41 lines
1.2 KiB
C#
41 lines
1.2 KiB
C#
using System;
|
|
|
|
namespace Password_Manager
|
|
{
|
|
public class ResultListBox : ListBox
|
|
{
|
|
public ResultListBox() : base() { }
|
|
|
|
public void ReloadResults()
|
|
{
|
|
DirectoryInfo d = new DirectoryInfo(ProfileHandler.CurrentProfile.Path);
|
|
FileInfo[] files = d.GetFiles("*.gpg");
|
|
string[] arrayTmp = new string[files.Length];
|
|
for (int i = 0; i < arrayTmp.Length; i++)
|
|
{
|
|
arrayTmp[i] = files[i].Name;
|
|
}
|
|
List<string> elements = new List<string>(arrayTmp);
|
|
|
|
string[] copy = elements.ToArray();
|
|
if (Program.mainForm.searchBox.Text != "") //we have a search query
|
|
{
|
|
foreach (string s in copy)
|
|
{
|
|
if (!s.Contains(Program.mainForm.searchBox.Text))
|
|
{
|
|
elements.Remove(s);
|
|
}
|
|
}
|
|
}
|
|
|
|
this.DataSource = elements;
|
|
}
|
|
|
|
public void ReloadResults(object o, EventArgs e) //needed so that I can subscribe this method to a delegate in MainForm
|
|
{
|
|
ReloadResults();
|
|
}
|
|
}
|
|
}
|