This repository has been archived on 2025-09-26. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
Password-Manager-Legacy/Password Manager/ResultListBox.cs
2023-03-24 14:03:09 +01:00

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();
}
}
}