Deleted everything profile related and started semi-fresh
This commit is contained in:
@@ -1,24 +1,42 @@
|
||||
namespace Password_Manager
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace Password_Manager
|
||||
{
|
||||
public delegate string SearchQuery();
|
||||
public class PasswordListBox : ListBox
|
||||
{
|
||||
public event ProfileDataRequest? CurrentProfilePathRequest;
|
||||
public event DataRequest? PathRequest;
|
||||
public event SearchQuery? SearchQueryRequest;
|
||||
|
||||
public PasswordListBox() : base() { }
|
||||
public PasswordListBox(DataRequest PathRequest, SearchQuery? SearchQueryRequest = null) : base()
|
||||
{
|
||||
this.PathRequest = PathRequest;
|
||||
this.SearchQueryRequest = SearchQueryRequest;
|
||||
}
|
||||
|
||||
public void ReloadResults(object sender = null, EventArgs arg = null)
|
||||
public PasswordListBox() : base() { }
|
||||
/*do not instantiate this class using this constructor if you want to use the ReloadResults method afterwards.
|
||||
Use this so that the MainForm.Designer.cs file doesn't have a stroke due to Event References, then re-instantiate the object
|
||||
afterwards using the other constructor*/
|
||||
|
||||
public void ReloadResults(object? sender = null, EventArgs? arg = null)
|
||||
{
|
||||
DirectoryInfo d;
|
||||
FileInfo[] files = new FileInfo[0];
|
||||
try
|
||||
{
|
||||
d = new DirectoryInfo(CurrentProfilePathRequest?.Invoke());
|
||||
if (PathRequest != null)
|
||||
{
|
||||
d = new DirectoryInfo(PathRequest());
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new InvalidOperationException("You cannot use this method if you instantiated the object using the parameterless constructor");
|
||||
}
|
||||
files = d.GetFiles("*.gpg");
|
||||
} catch (ArgumentNullException e)
|
||||
{
|
||||
MessageBox.Show(e.ToString(), "Error: Invalid profile path", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
MessageBox.Show(e.ToString(), "Error: Invalid path", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
|
||||
string[] arrayTmp = new string[files.Length];
|
||||
@@ -29,8 +47,8 @@
|
||||
List<string> elements = new List<string>(arrayTmp);
|
||||
|
||||
string[] copy = elements.ToArray();
|
||||
string searchQuery = SearchQueryRequest?.Invoke();
|
||||
if (searchQuery != "") //we have a search query
|
||||
string? searchQuery = SearchQueryRequest?.Invoke();
|
||||
if (searchQuery != null) //we have a search query
|
||||
{
|
||||
foreach (string s in copy)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user