@@ -9,12 +9,16 @@ namespace RadioTerm.Rendering;
9
9
10
10
public sealed class DisplayEngine : IDisplayEngine
11
11
{
12
- private void DrawHeader ( )
12
+ private void DrawHeader ( int stationCount )
13
13
{
14
14
Console . ForegroundColor = ConsoleColor . DarkYellow ;
15
- string title = "Welcome to RadioTerm" ;
15
+ const string title = "Welcome to RadioTerm" ;
16
16
WriteToCenter ( title , 1 ) ;
17
- DrawBar ( 2 , title . Length + 18 ) ;
17
+ Console . ResetColor ( ) ;
18
+ var stationCollection = $ "You have { stationCount } stations in your collection";
19
+ WriteToCenter ( stationCollection , 2 ) ;
20
+ // Console.ForegroundColor = ConsoleColor.DarkYellow;
21
+ DrawBar ( 3 , stationCollection . Length + 18 ) ;
18
22
Console . WriteLine ( ) ;
19
23
Console . WriteLine ( ) ;
20
24
Console . ResetColor ( ) ;
@@ -36,7 +40,7 @@ private void DrawStations(IEnumerable<Station> stations)
36
40
Console . ForegroundColor = ConsoleColor . Gray ;
37
41
}
38
42
39
- WriteToCenter ( station . Name , i + 4 ) ;
43
+ WriteToCenter ( station . Name , i + 5 ) ;
40
44
Console . ForegroundColor = ConsoleColor . Gray ;
41
45
}
42
46
}
@@ -80,14 +84,17 @@ private void DrawFooter()
80
84
81
85
public void Draw ( IEnumerable < Station > stations )
82
86
{
87
+ Console . CursorVisible = false ;
83
88
Console . Clear ( ) ;
84
- DrawHeader ( ) ;
85
- DrawStations ( stations ) ;
89
+ var stationsEnumerated = stations . ToList ( ) ;
90
+ DrawHeader ( stationsEnumerated . Count ) ;
91
+ DrawStations ( stationsEnumerated ) ;
86
92
DrawFooter ( ) ;
87
93
}
88
94
89
95
public ( string name , string url ) AddStation ( )
90
96
{
97
+ Console . CursorVisible = true ;
91
98
Console . Clear ( ) ;
92
99
Console . ForegroundColor = ConsoleColor . DarkYellow ;
93
100
Console . WriteLine ( "Add a radio" ) ;
@@ -107,14 +114,12 @@ public Guid DeleteStation(IEnumerable<Station> stations)
107
114
do
108
115
{
109
116
Console . Clear ( ) ;
110
- if ( k . Key == ConsoleKey . UpArrow )
111
- {
112
- selectedStation = stationList . Previous ( selectedStation ) ;
113
- }
114
- else if ( k . Key == ConsoleKey . DownArrow )
117
+ selectedStation = k . Key switch
115
118
{
116
- selectedStation = stationList . Next ( selectedStation ) ;
117
- }
119
+ ConsoleKey . UpArrow => stationList . Previous ( selectedStation ) ,
120
+ ConsoleKey . DownArrow => stationList . Next ( selectedStation ) ,
121
+ _ => selectedStation
122
+ } ;
118
123
119
124
foreach ( var st in stationList )
120
125
{
0 commit comments