Switched messageboxes to custom events
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace Common;
|
namespace Common;
|
||||||
|
|
||||||
|
public delegate void Error(Exception e);
|
||||||
public static class ConfigFileManager
|
public static class ConfigFileManager
|
||||||
{
|
{
|
||||||
#region Config flags
|
#region Config flags
|
||||||
@@ -17,6 +18,7 @@ public static class ConfigFileManager
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
private static Config Configuration;
|
private static Config Configuration;
|
||||||
|
public static event Error? ExceptionOccured;
|
||||||
|
|
||||||
public static void Init()
|
public static void Init()
|
||||||
{
|
{
|
||||||
@@ -87,7 +89,7 @@ public static class ConfigFileManager
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
MessageBox.Show(e.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
ExceptionOccured?.Invoke(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
namespace Common;
|
namespace Common;
|
||||||
public static class PasswordGenerator
|
public static class PasswordGenerator
|
||||||
{
|
{
|
||||||
|
public static Error? ExceptionOccured;
|
||||||
private static string RandomStr(int length, bool no_symbols = false)
|
private static string RandomStr(int length, bool no_symbols = false)
|
||||||
{
|
{
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
@@ -32,6 +33,8 @@ public static class PasswordGenerator
|
|||||||
|
|
||||||
public static string? New(string recipient, int length, bool no_symbols = false)
|
public static string? New(string recipient, int length, bool no_symbols = false)
|
||||||
{
|
{
|
||||||
return new ProcessBuilder().GetOutput("cmd.exe", $"echo {RandomStr(length, no_symbols)} | gpg --quiet --encrypt --recipient {recipient}");
|
ProcessBuilder pb = new ProcessBuilder();
|
||||||
|
pb.ProcessFailed += (e) => ExceptionOccured?.Invoke(e);
|
||||||
|
return pb.GetOutput("cmd.exe", $"echo {RandomStr(length, no_symbols)} | gpg --quiet --encrypt --recipient {recipient}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user