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

41 lines
1.2 KiB
C#
Raw Normal View History

2023-03-24 12:40:10 +01:00
using System;
namespace Password_Manager
{
public class ResultListBox : ListBox
{
public ResultListBox() : base() { }
2023-03-24 14:03:09 +01:00
public void ReloadResults()
2023-03-24 12:40:10 +01:00
{
2023-03-24 14:03:09 +01:00
DirectoryInfo d = new DirectoryInfo(ProfileHandler.CurrentProfile.Path);
2023-03-24 12:40:10 +01:00
FileInfo[] files = d.GetFiles("*.gpg");
2023-03-24 14:03:09 +01:00
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);
2023-03-24 12:40:10 +01:00
2023-03-24 14:03:09 +01:00
string[] copy = elements.ToArray();
if (Program.mainForm.searchBox.Text != "") //we have a search query
2023-03-24 12:40:10 +01:00
{
2023-03-24 14:03:09 +01:00
foreach (string s in copy)
{
if (!s.Contains(Program.mainForm.searchBox.Text))
{
elements.Remove(s);
}
}
2023-03-24 12:40:10 +01:00
}
this.DataSource = elements;
}
2023-03-24 14:03:09 +01:00
public void ReloadResults(object o, EventArgs e) //needed so that I can subscribe this method to a delegate in MainForm
{
ReloadResults();
}
2023-03-24 12:40:10 +01:00
}
}