public List_items(List<Schedule> list, Rectangle location, list_type size) { this.position = location; this.flag_mouse = true; this.type = size; this.list_schedule = list; this.list_airliner = new List<Airliner>(0); this.list_flight = new List<Flight>(0); if (this.type == list_type.side_tab) { this.bar = new scrollbar(new Rectangle(this.position.X + this.position.Width - 7, this.position.Y, 7, this.position.Height), this.position.Height / 80); } }
public void Update(MouseState state) { this.hovering = -1; if (this.list_airliner.Count() > 0) { #region[Aircraft] if (this.type == list_type.side_tab) { this.bar.update(state, this.list_airliner.Count()+1); Rectangle location = new Rectangle(this.position.X, this.position.Y, this.position.Width - 7, 80); int adjustment = 0; string type = ""; for (int i = this.bar.current_element; i < this.list_airliner.Count(); i++) { if (type.CompareTo(this.list_airliner[i].Aircraft.Name) > 0) { adjustment += 20; type = this.list_airliner[i].Aircraft.Name; } location.Y = this.position.Y + (i - this.bar.current_element) *80 + adjustment; if (location.Bottom > this.position.Bottom) { break; } if(location.Contains(new Point(state.X,state.Y))) { this.hovering = i; } } } #endregion[Aircraft] } else if (this.list_flight.Count() > 0) { #region[Flight] #region[sidebar] if (this.type == list_type.side_tab) { this.bar.update(state, this.list_flight.Count() + 1); Rectangle location = new Rectangle(this.position.X, this.position.Y, this.position.Width - 7, 80); int adjustment = 0; int day = -10; for (int i = this.bar.current_element; i < this.list_flight.Count(); i++) { if ((this.list_flight[i].Departure / 1440 - Time.Today) > day) { adjustment += 20; day = (this.list_flight[i].Departure / 1440 - Time.Today); } location.Y = this.position.Y + (i - this.bar.current_element) * 80 + adjustment; if (location.Bottom > this.position.Bottom) { break; } if (location.Contains(new Point(state.X, state.Y))) { this.hovering = i; } } } #endregion[sidebar] #region[Airport_board] else if ((this.type == list_type.airport_board_a)||(this.type == list_type.airport_board_d)) { this.bar.update(state, this.list_flight.Count() + 1); Rectangle location = new Rectangle(this.position.X, this.position.Y, this.position.Width - 7, 100); int adjustment = 0; int day = -10; for (int i = this.bar.current_element; i < this.list_flight.Count(); i++) { if ((this.list_flight[i].Departure / 1440 - Time.Today) > day) { adjustment += 20; day = (this.list_flight[i].Departure / 1440 - Time.Today); } location.Y = this.position.Y + (i - this.bar.current_element) * 100 + adjustment; if (location.Bottom > this.position.Bottom) { break; } if (location.Contains(new Point(state.X, state.Y))) { this.hovering = i; } } } #endregion[Airport_board] #endregion[Flight] } else if (this.list_schedule.Count() > 0) { #region[Schedule] if (this.type == list_type.side_tab) { this.bar.update(state, this.list_schedule.Count() + 1); Rectangle location = new Rectangle(this.position.X, this.position.Y, this.position.Width - 7, 80); for (int i = 0; i < this.list_schedule.Count(); i++) { location.Y = this.position.Y + (i - this.bar.current_element) * 80; if (location.Bottom > this.position.Bottom) { break; } if (location.Contains(new Point(state.X, state.Y))) { this.hovering = i; } } } #endregion[Schedule] } }
public void Draw(SpriteBatch spritebatch) { if (this.list_airliner.Count() > 0) { #region[Aircraft] if (this.type == list_type.side_tab) { this.bar.Draw(spritebatch); Rectangle location = new Rectangle(this.position.X, this.position.Y, this.position.Width - 7, 80); int adjustment = 0; string type = ""; Vector2 text_location; for (int i = this.bar.current_element; i < this.list_airliner.Count(); i++) { location.Y = this.position.Y + (i - this.bar.current_element) * 80 + adjustment; if (type.CompareTo(list_airliner[i].Aircraft.Name) < 0) { adjustment += 20; type = list_airliner[i].Aircraft.Name; spritebatch.Draw(globals.gameDesign_airport, new Rectangle(location.X, location.Y, location.Width - 7, 20), Color.White); text_location = new Vector2(location.X + 0.5f * (location.Width - 7) - 0.5f * globals.font_normal.MeasureString(type).X, location.Y); spritebatch.DrawString(globals.font_normal, type, text_location, Color.Black); } location.Y = this.position.Y + (i - this.bar.current_element) * 80 + adjustment; if (location.Bottom > this.position.Bottom) { break; } if (i == this.hovering) { spritebatch.Draw(globals.gameHighlight_airport, new Rectangle(location.X, location.Y, location.Width - 7, 80), Color.White); } else { spritebatch.Draw(globals.gameDesign_airport, new Rectangle(location.X, location.Y, location.Width - 7, 80), Color.White); } String text = list_airliner[i].Information(list_type.side_tab); text_location = new Vector2(location.X + 5, location.Center.Y - 0.5f * globals.font_normal.MeasureString(text).Y); spritebatch.DrawString(globals.font_normal, text, text_location, Color.Black); } } #endregion[Aircraft] } else if (this.list_flight.Count() > 0) { #region[Flight] #region[sidebar] if (this.type == list_type.side_tab) { this.bar.Draw(spritebatch); Rectangle location = new Rectangle(this.position.X, this.position.Y, this.position.Width - 7, 80); int adjustment = 0; int day = -10; Vector2 text_location; for (int i = this.bar.current_element; i < this.list_flight.Count(); i++) { location.Y = this.position.Y + (i - this.bar.current_element) * 80 + adjustment; if ((this.list_flight[i].Departure / 1440 - Time.Today) > day) { adjustment += 20; day = this.list_flight[i].Departure / 1440 - Time.Today; spritebatch.Draw(globals.gameDesign_flight, new Rectangle(location.X, location.Y, location.Width - 7, 20), Color.White); text_location = new Vector2(location.X + 0.5f * (location.Width - 7) - 0.5f * globals.font_normal.MeasureString(Util.format_relativeDay(day)).X, location.Y); spritebatch.DrawString(globals.font_normal, Util.format_relativeDay(day), text_location, Color.Black); } location.Y = this.position.Y + (i - this.bar.current_element) * 80 + adjustment; if (location.Bottom > this.position.Bottom) { break; } if (i == this.hovering) { this.list_flight[i].Route.draw(spritebatch, 5, this.position.X - 20); spritebatch.Draw(globals.gameHighlight_airport, new Rectangle(location.X, location.Y, location.Width - 7, 80), Color.White); } else { spritebatch.Draw(globals.gameDesign_flight, new Rectangle(location.X, location.Y, location.Width - 7, 80), Color.White); } String text = this.list_flight[i].Information(list_type.side_tab); text_location = new Vector2(location.X + 5, location.Center.Y - 0.5f * globals.font_normal.MeasureString(text).Y); spritebatch.DrawString(globals.font_normal, text, text_location, Color.Black); } } #endregion[sidebar] #region[Airport_arrival] else if (this.type == list_type.airport_board_a) { this.bar.Draw(spritebatch); Rectangle location = new Rectangle(this.position.X, this.position.Y, this.position.Width - 7, 100); int adjustment = 0; int day = -10; Vector2 text_location; for (int i = this.bar.current_element; i < this.list_flight.Count(); i++) { location.Y = this.position.Y + (i - this.bar.current_element) * 100 + adjustment; if ((this.list_flight[i].Departure / 1440 - Time.Today) > day) { adjustment += 20; day = this.list_flight[i].Departure / 1440 - Time.Today; spritebatch.Draw(globals.gameDesign_flight, new Rectangle(location.X, location.Y, location.Width - 7, 20), Color.White); text_location = new Vector2(location.X + 0.5f * (location.Width - 7) - 0.5f * globals.font_normal.MeasureString(Util.format_relativeDay(day)).X, location.Y); spritebatch.DrawString(globals.font_normal, Util.format_relativeDay(day), text_location, Color.White); } location.Y = this.position.Y + (i - this.bar.current_element) * 100 + adjustment; if (location.Bottom > this.position.Bottom) { break; } if (i == this.hovering) { spritebatch.Draw(globals.gameHighlight_airport, new Rectangle(location.X, location.Y, location.Width - 7, 100), Color.White); } else { spritebatch.Draw(globals.gameDesign_flight, new Rectangle(location.X, location.Y, location.Width - 7, 100), Color.White); } String text = this.list_flight[i].Information(list_type.airport_board_a); text_location = new Vector2(location.X + 5, location.Center.Y - 0.5f * globals.font_normal.MeasureString(text).Y); spritebatch.DrawString(globals.font_normal, text, text_location, Color.Black); } } #endregion[Airport_arrival] #region[Airport_departure] else if (this.type == list_type.airport_board_d) { this.bar.Draw(spritebatch); Rectangle location = new Rectangle(this.position.X, this.position.Y, this.position.Width - 7, 100); int adjustment = 0; int day = -10; Vector2 text_location; for (int i = this.bar.current_element; i < this.list_flight.Count(); i++) { location.Y = this.position.Y + (i - this.bar.current_element) * 100 + adjustment; if ((this.list_flight[i].Departure / 1440 - Time.Today) > day) { adjustment += 20; day = this.list_flight[i].Departure / 1440 - Time.Today; spritebatch.Draw(globals.gameDesign_flight, new Rectangle(location.X, location.Y, location.Width - 7, 20), Color.White); text_location = new Vector2(location.X + 0.5f * (location.Width - 7) - 0.5f * globals.font_normal.MeasureString(Util.format_relativeDay(day)).X, location.Y); spritebatch.DrawString(globals.font_normal, Util.format_relativeDay(day), text_location, Color.White); } location.Y = this.position.Y + (i - this.bar.current_element) * 100 + adjustment; if (location.Bottom > this.position.Bottom) { break; } if (i == this.hovering) { spritebatch.Draw(globals.gameHighlight_airport, new Rectangle(location.X, location.Y, location.Width - 7, 100), Color.White); } else { spritebatch.Draw(globals.gameDesign_flight, new Rectangle(location.X, location.Y, location.Width - 7, 100), Color.White); } String text = this.list_flight[i].Information(list_type.airport_board_d); text_location = new Vector2(location.X + 5, location.Center.Y - 0.5f * globals.font_normal.MeasureString(text).Y); spritebatch.DrawString(globals.font_normal, text, text_location, Color.Black); } } #endregion[Airport_departure] #endregion[Flight] } else if (this.list_schedule.Count() > 0) { #region[Schedule] if (this.type == list_type.side_tab) { this.bar.Draw(spritebatch); Rectangle location = new Rectangle(this.position.X, this.position.Y, this.position.Width - 7, 80); Vector2 text_location; for (int i = 0; i < this.list_schedule.Count(); i++) { this.list_schedule[i].Route.draw(spritebatch, 2, this.position.X - 20); } for (int i = this.bar.current_element; i < this.list_schedule.Count(); i++) { location.Y = this.position.Y + (i - this.bar.current_element) * 80; if (location.Bottom > this.position.Bottom) { break; } if (i == this.hovering) { spritebatch.Draw(globals.gameHighlight_route, new Rectangle(location.X, location.Y, location.Width - 7, 80), Color.White); this.list_schedule[i].Route.draw(spritebatch, 5, this.position.X - 20); } else { spritebatch.Draw(globals.gameDesign_route, new Rectangle(location.X, location.Y, location.Width - 7, 80), Color.White); } String text = this.list_schedule[i].FlightNumber + "\n" + this.list_schedule[i].ToString() + "\n" + Util.format_time(this.list_schedule[i].Departure) + " - " + Util.format_time(this.list_schedule[i].Arrival) + "\n" + "Operates on " + Util.format_days(this.list_schedule[i].operates_on); text_location = new Vector2(location.X + 5, location.Center.Y - 0.5f * globals.font_normal.MeasureString(text).Y); spritebatch.DrawString(globals.font_normal, text, text_location, Color.Black); } } #endregion[Schedule] } }