This project is designed to display bus information, including arrival times, route names, destination names, congestion levels, and error messages. The project uses a list of BusInfo objects to populate various labels on the user interface. The information is categorized and displayed based on urgency and availability of arrival times.
- Retrieve and display real-time bus arrival information.
- Display bus route names, destinations, and arrival times.
- Show remaining stops and congestion levels.
- Indicate low-floor buses for accessibility.
- Handle error messages and provide updates.
- C#
- .NET Framework
- Windows Forms
The MainForm class is the main user interface that displays real-time bus arrival information. It consists of various labels and panels to show bus routes, arrival times, remaining stops, congestion levels, and error messages.
This function displays bus information on the user interface. It categorizes the bus information into urgent and non-urgent lists and updates various labels based on the available data.
This function filters and sorts the bus information to return a list of urgent bus information. A bus is considered urgent if its arrival time is less than 2 minutes.
This function returns the congestion status text based on the input value:
- "2" returns "혼잡" (congested)
- "1" returns "여유" (spacious)
- Any other value returns "보통" (normal)
This function returns the type of bus based on the input value:
- "0" returns "일반" (regular)
- "1" returns "저상" (low-floor)
- Any other value returns an empty string
This function parses the XML data from the bus arrival API and returns a BusInfo object with the relevant information.
This function initializes a timer that triggers every 20 seconds to update the bus information.
This asynchronous function fetches bus information from the API and updates the user interface.
This function is triggered by the timer to call the UpdateBusInfo() function.
This function is called when the main form loads and initiates the first update of the bus information.
This function updates the current time label with the short time format of the current date and time.
The BusInfo class contains the following properties:
string RouteNameint? ArrivalTime1int? ArrivalTime2string DestNamestring StopCount1string StopCount2string Crowded1string Crowded2string LowPlate1string LowPlate2string ErrorMessage
These properties store information about the bus route, arrival times, destination, stop counts, congestion levels, bus type, and any error messages.
In order to use this project, follow these steps:
- Create instances of the
BusInfoclass with the relevant bus information. - Populate a
List<BusInfo>with theBusInfoinstances. - Call the
DisplayBusInfo(List<BusInfo> busInfoList)function with the populated list to display the bus information on the user interface.
The labels and panels in the code should be replaced with actual controls from your user interface design. This project can be extended and customized to fit specific requirements, such as adding more detailed bus information, enhancing the user interface, or integrating with a real-time bus information API.
List<BusInfo> busInfoList = new List<BusInfo>
{
new BusInfo
{
RouteName = "101",
ArrivalTime1 = 5,
ArrivalTime2 = 15,
DestName = "Central Station",
StopCount1 = "3",
StopCount2 = "7",
Crowded1 = "1",
Crowded2 = "2",
LowPlate1 = "0",
LowPlate2 = "1",
ErrorMessage = ""
},
// Add more BusInfo instances as needed
};
DisplayBusInfo(busInfoList);This project is licensed under the MIT License. See the LICENSE file for details.
Copyright ⓒ HappyBono 2025. All rights Reserved.