@@ -1107,24 +1107,31 @@ void ShowTimetableEnvironment()
11071107 void ShowDetails ( )
11081108 {
11091109 Win32 . LockWindowUpdate ( Handle ) ;
1110- ClearDetails ( ) ;
1110+ ClearPanel ( ) ;
1111+ AddDetails ( ) ;
1112+ FlowDetails ( ) ;
1113+ Win32 . LockWindowUpdate ( IntPtr . Zero ) ;
1114+ }
1115+
1116+ private void AddDetails ( )
1117+ {
11111118 if ( SelectedRoute != null && SelectedRoute . Description != null )
1112- ShowDetail ( catalog . GetStringFmt ( "Route: {0}" , SelectedRoute . Name ) , SelectedRoute . Description . Split ( '\n ' ) ) ;
1119+ AddDetail ( catalog . GetStringFmt ( "Route: {0}" , SelectedRoute . Name ) , SelectedRoute . Description . Split ( '\n ' ) ) ;
11131120
11141121 if ( radioButtonModeActivity . Checked )
11151122 {
11161123 if ( SelectedConsist != null && SelectedConsist . Locomotive != null && SelectedConsist . Locomotive . Description != null )
11171124 {
1118- ShowDetail ( catalog . GetStringFmt ( "Locomotive: {0}" , SelectedConsist . Locomotive . Name ) , SelectedConsist . Locomotive . Description . Split ( '\n ' ) ) ;
1125+ AddDetail ( catalog . GetStringFmt ( "Locomotive: {0}" , SelectedConsist . Locomotive . Name ) , SelectedConsist . Locomotive . Description . Split ( '\n ' ) ) ;
11191126 }
11201127 if ( SelectedActivity != null && SelectedActivity . Description != null )
11211128 {
1122- ShowDetail ( catalog . GetStringFmt ( "Activity: {0}" , SelectedActivity . Name ) , SelectedActivity . Description . Split ( '\n ' ) ) ;
1123- ShowDetail ( catalog . GetString ( "Activity Briefing" ) , SelectedActivity . Briefing . Split ( '\n ' ) ) ;
1129+ AddDetail ( catalog . GetStringFmt ( "Activity: {0}" , SelectedActivity . Name ) , SelectedActivity . Description . Split ( '\n ' ) ) ;
1130+ AddDetail ( catalog . GetString ( "Activity Briefing" ) , SelectedActivity . Briefing . Split ( '\n ' ) ) ;
11241131 }
11251132 else if ( SelectedPath != null )
11261133 {
1127- ShowDetail ( catalog . GetStringFmt ( "Path: {0}" , SelectedPath . Name ) , new [ ] {
1134+ AddDetail ( catalog . GetStringFmt ( "Path: {0}" , SelectedPath . Name ) , new [ ] {
11281135 catalog . GetStringFmt ( "Starting at: {0}" , SelectedPath . Start ) ,
11291136 catalog . GetStringFmt ( "Heading to: {0}" , SelectedPath . End )
11301137 } ) ;
@@ -1133,29 +1140,26 @@ void ShowDetails()
11331140 if ( radioButtonModeTimetable . Checked )
11341141 {
11351142 if ( SelectedTimetableSet != null )
1136- ShowDetail ( catalog . GetStringFmt ( "Timetable set: {0}" , SelectedTimetableSet ) , new string [ 0 ] ) ;
1137- // Description not shown as no description is available for a timetable set.
1143+ AddDetail ( catalog . GetStringFmt ( "Timetable set: {0}" , SelectedTimetableSet ) , new string [ 0 ] ) ;
1144+ // Description not shown as no description is available for a timetable set.
11381145
11391146 if ( SelectedTimetable != null )
1140- ShowDetail ( catalog . GetStringFmt ( "Timetable: {0}" , SelectedTimetable ) , SelectedTimetable . Briefing . Split ( '\n ' ) ) ;
1147+ AddDetail ( catalog . GetStringFmt ( "Timetable: {0}" , SelectedTimetable ) , SelectedTimetable . Briefing . Split ( '\n ' ) ) ;
11411148
11421149 if ( SelectedTimetableTrain != null )
11431150 {
1144- ShowDetail ( catalog . GetStringFmt ( "Train: {0}" , SelectedTimetableTrain ) , HideStartParameters ( SelectedTimetableTrain . ToInfo ( ) ) ) ;
1151+ AddDetail ( catalog . GetStringFmt ( "Train: {0}" , SelectedTimetableTrain ) , HideStartParameters ( SelectedTimetableTrain . ToInfo ( ) ) ) ;
11451152
11461153 if ( SelectedTimetableConsist != null )
11471154 {
1148- ShowDetail ( catalog . GetStringFmt ( "Consist: {0}" , SelectedTimetableConsist . Name ) , new string [ 0 ] ) ;
1155+ AddDetail ( catalog . GetStringFmt ( "Consist: {0}" , SelectedTimetableConsist . Name ) , new string [ 0 ] ) ;
11491156 if ( SelectedTimetableConsist . Locomotive != null && SelectedTimetableConsist . Locomotive . Description != null )
1150- ShowDetail ( catalog . GetStringFmt ( "Locomotive: {0}" , SelectedTimetableConsist . Locomotive . Name ) , SelectedTimetableConsist . Locomotive . Description . Split ( '\n ' ) ) ;
1157+ AddDetail ( catalog . GetStringFmt ( "Locomotive: {0}" , SelectedTimetableConsist . Locomotive . Name ) , SelectedTimetableConsist . Locomotive . Description . Split ( '\n ' ) ) ;
11511158 }
11521159 if ( SelectedTimetablePath != null )
1153- ShowDetail ( catalog . GetStringFmt ( "Path: {0}" , SelectedTimetablePath . Name ) , SelectedTimetablePath . ToInfo ( ) ) ;
1160+ AddDetail ( catalog . GetStringFmt ( "Path: {0}" , SelectedTimetablePath . Name ) , SelectedTimetablePath . ToInfo ( ) ) ;
11541161 }
11551162 }
1156-
1157- FlowDetails ( ) ;
1158- Win32 . LockWindowUpdate ( IntPtr . Zero ) ;
11591163 }
11601164
11611165 /// <summary>
@@ -1194,14 +1198,14 @@ public Detail(Control title, Control expander, Control summary, Control lines)
11941198 }
11951199 }
11961200
1197- void ClearDetails ( )
1201+ void ClearPanel ( )
11981202 {
11991203 Details . Clear ( ) ;
12001204 while ( panelDetails . Controls . Count > 0 )
12011205 panelDetails . Controls . RemoveAt ( 0 ) ;
12021206 }
12031207
1204- void ShowDetail ( string title , string [ ] lines )
1208+ void AddDetail ( string title , string [ ] lines )
12051209 {
12061210 var titleControl = new Label { Margin = new Padding ( 2 ) , Text = title , UseMnemonic = false , Font = new Font ( panelDetails . Font , FontStyle . Bold ) , TextAlign = ContentAlignment . BottomLeft } ;
12071211 panelDetails . Controls . Add ( titleControl ) ;
@@ -1225,7 +1229,7 @@ void ShowDetail(string title, string[] lines)
12251229 summaryControl . Width = panelDetails . ClientSize . Width - summaryControl . Margin . Horizontal ;
12261230 summaryControl . Height = TextRenderer . MeasureText ( "1\n 2\n 3\n 4\n 5" , summaryControl . Font ) . Height ;
12271231
1228- // Find out where we need to cut the text to make the summary 5 lines long. Uses a binaty search to find the cut point.
1232+ // Find out where we need to cut the text to make the summary 5 lines long. Uses a binary search to find the cut point.
12291233 var size = MeasureText ( summaryControl . Text , summaryControl ) ;
12301234 if ( size > summaryControl . Height )
12311235 {
@@ -1463,68 +1467,77 @@ void comboBoxTimetable_EnabledChanged(object sender, EventArgs e)
14631467 }
14641468
14651469 #region Notifications
1470+ // Will probably move this region and the Details region into separate files.
14661471
1467- bool IsNotificationsVisible = false ;
1472+ bool AreNotificationsVisible = false ;
1473+ int NewNotificationCount = 1 ;
1474+ int LastNotificationViewed = 0 ;
14681475
14691476 List < Notification > NotificationList = new List < Notification > ( ) ;
14701477 class Notification
14711478 {
1472- //readonly Control Title;
1473- //readonly Control Expander;
1474- //readonly Control Summary;
1475- //readonly Control Description;
1476- //bool Expanded;
1477- //Notification(Control title, Control expander, Control summary, Control lines)
1478- //{
1479- // Title = title;
1480- // Expander = expander;
1481- // Summary = summary;
1482- // Description = lines;
1483- // Expanded = false;
1484- //}
14851479 }
14861480
1487- void ClearNotifications ( )
1481+ private void pbNotificationsNone_Click ( object sender , EventArgs e )
14881482 {
1489- NotificationList . Clear ( ) ;
1490- while ( panelDetails . Controls . Count > 0 )
1491- panelDetails . Controls . RemoveAt ( 0 ) ;
1483+ ToggleNotifications ( ) ;
1484+ }
1485+ private void pbNotificationsSome_Click ( object sender , EventArgs e )
1486+ {
1487+ ToggleNotifications ( ) ;
1488+ }
1489+ private void lblNotificationCount_Click ( object sender , EventArgs e )
1490+ {
1491+ ToggleNotifications ( ) ;
14921492 }
14931493
1494- private void pbNotifications_Click ( object sender , EventArgs e )
1494+ private void ToggleNotifications ( )
14951495 {
1496- // Show/hide notifications
1497- IsNotificationsVisible = ! IsNotificationsVisible ;
1498- if ( IsNotificationsVisible )
1496+ if ( AreNotificationsVisible == false )
14991497 {
1500- ClearDetails ( ) ;
15011498 ShowNotifications ( ) ;
1499+ FiddleNewNotificationCount ( ) ;
15021500 }
15031501 else
15041502 {
1505- ClearNotifications ( ) ;
15061503 ShowDetails ( ) ;
15071504 }
1505+ AreNotificationsVisible = ! AreNotificationsVisible ;
1506+ }
1507+
1508+ private void FiddleNewNotificationCount ( )
1509+ {
1510+ LastNotificationViewed = 1 ;
1511+ if ( LastNotificationViewed >= NewNotificationCount )
1512+ {
1513+ pbNotificationsSome . Visible = false ;
1514+ lblNotificationCount . Visible = false ;
1515+ }
15081516 }
15091517
15101518 void ShowNotifications ( )
15111519 {
1512- if ( NotificationList . Count == 0 )
1520+ Win32 . LockWindowUpdate ( Handle ) ;
1521+ ClearPanel ( ) ;
1522+ AddNotifications ( ) ;
1523+ FlowDetails ( ) ;
1524+ Win32 . LockWindowUpdate ( IntPtr . Zero ) ;
1525+ }
1526+
1527+ private void AddNotifications ( )
1528+ {
1529+ //if (NotificationList.Count == 0)
1530+ if ( NotificationList . Count != 0 )
15131531 {
1514- var titleControl = new Label
1515- { Margin = new Padding ( 2 )
1516- , Text = "No notifications are available"
1517- , UseMnemonic = false
1518- , Font = new Font ( panelDetails . Font , FontStyle . Bold )
1519- , TextAlign = ContentAlignment . BottomLeft
1520- } ;
1521- panelDetails . Controls . Add ( titleControl ) ;
1522- titleControl . Left = titleControl . Margin . Left ;
1523- titleControl . Width = panelDetails . ClientSize . Width - titleControl . Margin . Horizontal - titleControl . PreferredHeight ;
1524- titleControl . Height = titleControl . PreferredHeight ;
1525- titleControl . Anchor = AnchorStyles . Left | AnchorStyles . Top | AnchorStyles . Right ;
1532+ AddDetail ( "Notifications" , new string [ ] { "No notifications are available." } ) ;
15261533 }
1534+ else
1535+ {
1536+ AddDetail ( "Notification 1" , new string [ ] { "This is a dummy notification." } ) ;
1537+ }
1538+ AddDetail ( "" , new string [ ] { "Toggle icon to hide notifications." } ) ;
15271539 }
1540+
15281541 #endregion Notifications
15291542 }
15301543}
0 commit comments