-
Notifications
You must be signed in to change notification settings - Fork 0
/
ConsoleUI.cs
81 lines (69 loc) · 1.96 KB
/
ConsoleUI.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
namespace covergen;
/// <summary>
/// Console UI Interactionss
/// </summary>
internal class ConsoleUI
{
/// <summary>
/// Get the processing directory.
/// </summary>
/// <returns>the DirectoryInfo of processing dir</returns>
internal static DirectoryInfo GetProcessingDir()
{
Console.Write("Enter the music root path:");
// Read Input
string? path = Console.ReadLine();
if (path == null)
{
throw new ArgumentException();
}
DirectoryInfo di = new(path);
// If the input dir is not exsist, throw exception.
if (!di.Exists)
{
throw new DirectoryNotFoundException();
}
return di;
}
/// <summary>
/// Get the desired output width of covers.
/// </summary>
/// <returns>width of covers</returns>
internal static int GetOutputCoverWidth()
{
Console.WriteLine("Enter the desired output width of covers.");
string? input = Console.ReadLine();
// Parse the UserInput into Int
if (int.TryParse(input, out int cover_width))
{
return cover_width;
}
return 0;
}
/// <summary>
/// Confirm for user is ready for processing
/// </summary>
internal static void ConfirmForProcessing()
{
Console.WriteLine("Press enter to start processing");
Console.ReadLine();
}
/// <summary>
/// Display Exception Error Stack on Console output.
/// </summary>
/// <param name="ex"></param>
internal static void ShowException(Exception ex)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine(ex.ToString());
Console.ResetColor();
}
/// <summary>
/// Confirm for user is ready for exit the application.
/// </summary>
internal static void ConfirmForTerminate()
{
Console.WriteLine("\nPress any key to exit...");
Console.ReadLine();
}
}