2023-03-24 10:17:54 +01:00
namespace Password_Manager
{
2023-03-27 10:24:40 +02:00
sealed public partial class MainForm : Form
2023-03-24 10:17:54 +01:00
{
2023-03-27 10:24:40 +02:00
public event DataRequest PathRequest ;
2023-03-28 10:35:23 +02:00
public event DataRequest ? RecipientRequest ;
2023-03-24 11:14:49 +01:00
2023-03-28 13:27:12 +02:00
public MainForm ( DataRequest PathRequest , DataRequest ? RecipientRequest = null )
2023-03-24 11:14:49 +01:00
{
2023-03-27 10:24:40 +02:00
this . PathRequest = PathRequest ;
2023-03-28 10:35:23 +02:00
this . RecipientRequest = RecipientRequest ;
2023-03-27 10:24:40 +02:00
InitializeComponent ( ) ;
2023-03-27 09:30:41 +02:00
2023-03-27 22:13:40 +02:00
ResultList . SearchQueryRequest + = ( ) = > SearchBox . Text ;
ResultList . ReloadResults ( ) ;
}
private void ReloadResults ( object? sender , EventArgs ? e ) //proxy method for SearchBox.TextChanged
{
2023-03-27 10:24:40 +02:00
ResultList . ReloadResults ( ) ;
2023-03-27 09:30:41 +02:00
}
2023-03-28 13:26:30 +02:00
private void ReloadResults ( )
{
ResultList . ReloadResults ( ) ;
}
2023-03-27 10:24:40 +02:00
private void OpenPasswordGenerator ( object sender , EventArgs e )
2023-03-27 09:30:41 +02:00
{
2023-03-28 10:35:23 +02:00
if ( RecipientRequest ! = null )
{
2023-03-28 13:26:30 +02:00
GeneratePassword gp = new GeneratePassword ( PathRequest ( ) , RecipientRequest ( ) , ReloadResults , SearchBox . Text ) ;
2023-03-28 10:35:23 +02:00
gp . ShowDialog ( ) ;
}
else
{
2023-03-28 12:53:59 +02:00
throw new InvalidOperationException ( "You cannot use the OpenPasswordGenerator method if you instantiated this form without a RecipientRequest event handler." ) ;
2023-03-28 10:35:23 +02:00
}
2023-03-27 09:30:41 +02:00
}
2023-03-27 22:13:40 +02:00
2023-03-28 08:22:08 +02:00
private void CancelPressed ( object sender , EventArgs e )
{
Close ( ) ;
}
2023-03-27 22:13:40 +02:00
private void Decrypt ( object sender , EventArgs e )
{
2023-03-28 08:22:08 +02:00
Close ( ) ;
2023-03-27 22:13:40 +02:00
}
2023-03-24 10:17:54 +01:00
}
2023-03-28 10:35:23 +02:00
}