@@ -13,19 +13,32 @@ public class ProgressBar : Input
1313 public ConsoleColor BackgroundColour = ConsoleColor . Gray ;
1414 public ConsoleColor BarColour = ConsoleColor . Black ;
1515
16- public int PercentageComplete = 50 ;
16+ private int percentageComplete ;
17+ public int PercentageComplete {
18+ get { return this . percentageComplete ; }
19+ set {
20+ if ( value < 0 || value > 100 ) {
21+ throw new ArgumentOutOfRangeException ( String . Format ( "Percentage must be between 0 & 100, actual:{0}" , value ) ) ;
22+ }
23+ this . percentageComplete = value ;
24+ Draw ( ) ;
25+ }
26+ }
1727
18- public ProgressBar ( int x , int y , int height , int width , String iD , Window parentWindow ) : base ( x , y , height , width , parentWindow , iD )
28+ public ProgressBar ( int percentageComplete , int x , int y , int height , int width , String iD , Window parentWindow ) : base ( x , y , height , width , parentWindow , iD )
1929 {
2030 Selectable = false ;
21- }
31+ PercentageComplete = percentageComplete ;
32+ }
2233
2334 public override void Draw ( )
2435 {
2536 int widthCompleted = ( int ) Math . Round ( Width * ( ( double ) PercentageComplete / 100 ) ) ;
2637 int widthUncompleted = Width - widthCompleted ;
2738
2839 //WindowManager.DrawColourBlock(BackgroundColour, Xpostion, Ypostion, Xpostion + Height, Ypostion + Width);
40+
41+
2942 WindowManager . WirteText ( "" . PadRight ( widthCompleted , '█' ) , Xpostion , Ypostion , BarColour , BackgroundColour ) ;
3043 WindowManager . WirteText ( "" . PadRight ( widthUncompleted , '▒' ) , Xpostion , Ypostion + widthCompleted , BarColour , BackgroundColour ) ;
3144 }
0 commit comments