//returns the value for a statistics type for a route class public int getStatisticsValue(RouteAirlinerClass aClass, StatisticsType type) { if (this.Stats.ContainsKey(aClass) && this.Stats[aClass].ContainsKey(type)) return this.Stats[aClass][type]; else return 0; }
//adds the value for a statistics type for a year public void addStatisticsValue(int year, StatisticsType type, double value) { StatisticsValue item = this.StatValues.Find(s => s.Year == year && s.Stat.Shortname == type.Shortname); if (item == null) this.StatValues.Add(new StatisticsValue(year, type, value)); else item.Value += value; }
//adds the value for a statistics type to an airline for a year public void addStatisticsValue(int year, Airline airline, StatisticsType type, int value) { AirportStatisticsValue item = this.Stats.Find(s => s.Year == year && s.Airline == airline && s.Stat.Shortname == type.Shortname); if (item == null) this.Stats.Add(new AirportStatisticsValue(airline, year, type, value)); else item.Value += value; }
//returns the value for a statistics type for an airline for a year public double getStatisticsValue(int year, Airline airline, StatisticsType type) { if (this.Stats.ContainsKey(year)) { AirportStatisticsValue value = this.Stats[year].Find(asv => asv.Airline == airline && asv.Stat == type); if (value != null) return value.Value; } return 0; }
//returns the total value for a statistics type for a year public double getTotalValue(int year, StatisticsType type) { if (!this.Stats.ContainsKey(year)) return 0; return (from s in this.Stats[year] where s.Stat == type select s.Value).Sum(); }
//adds the value for a statistics type to a route class public void addStatisticsValue(RouteAirlinerClass aClass, StatisticsType type, int value) { RouteStatisticsItem item = this.Stats.Find(i => i.Type.Shortname == type.Shortname && i.RouteClass == aClass); if (item == null) this.Stats.Add(new RouteStatisticsItem(aClass, type, value)); else item.Value += value; }
//sets the value for a statistics type for an airline for a year public void setStatisticsValue(int year, Airline airline, StatisticsType type, int value) { if (!(this.Stats.ContainsKey(year))) this.Stats.Add(year, new List<AirportStatisticsValue>()); AirportStatisticsValue statValue = this.Stats[year].Find(asv => asv.Airline == airline && asv.Stat == type); if (statValue != null) statValue.Value = value; else this.Stats[year].Add(new AirportStatisticsValue(airline, type, value)); }
//returns the total valu for a statistics type public double getStatisticsValue(StatisticsType type) { double value = 0; foreach (int year in this.StatValues.Keys) { StatisticsValue statValue = this.StatValues[year].Find(sv => sv.Stat == type); if (statValue != null) value += statValue.Value; } return value; }
//adds the value for a statistics type to a route class public void addStatisticsValue(RouteAirlinerClass aClass, StatisticsType type, int value) { lock (this.Stats) { if (!this.Stats.ContainsKey(aClass)) this.Stats.Add(aClass, new Dictionary<StatisticsType, int>()); if (!this.Stats[aClass].ContainsKey(type)) this.Stats[aClass].Add(type, 0); this.Stats[aClass][type] += value; } }
//returns the value for a statistics type for a year public double getStatisticsValue(int year, StatisticsType type) { lock (this.StatValues) { if (this.StatValues.ContainsKey(year)) { StatisticsValue value = this.StatValues[year].Find(sv => sv.Stat == type); if (value != null) return value.Value; } return 0; } }
//adds the value for a statistics type for a year public void addStatisticsValue(int year, StatisticsType type, double value) { lock (this.StatValues) { if (!this.StatValues.ContainsKey(year)) this.StatValues.Add(year, new List<StatisticsValue>()); StatisticsValue statValue = this.StatValues[year].Find(sv => sv.Stat == type); if (statValue != null) statValue.Value += value; else this.StatValues[year].Add(new StatisticsValue(type, value)); } }
//returns the total value of a statistics type public int getTotalValue(StatisticsType type) { int value = 0; lock (this.Stats) { foreach (RouteAirlinerClass aClass in this.Stats.Keys) { if (this.Stats[aClass].ContainsKey(type)) value += this.Stats[aClass][type]; } } return value; }
//creates the airlines statistics private StackPanel createStatisticsPanel(StatisticsType type, Boolean inPercent) { StackPanel panelStatistics = new StackPanel(); panelStatistics.Margin = new Thickness(0, 0, 0, 5); ContentControl ccHeader = new ContentControl(); ccHeader.ContentTemplate = this.Resources["StatHeader"] as DataTemplate; ccHeader.Content = new KeyValuePair<StatisticsType, KeyValuePair<int, int>>(type, new KeyValuePair<int, int>(GameObject.GetInstance().GameTime.Year - 1, GameObject.GetInstance().GameTime.Year)); panelStatistics.Children.Add(ccHeader); ListBox lbStats = new ListBox(); lbStats.ItemContainerStyleSelector = new ListBoxItemStyleSelector(); lbStats.ItemTemplate = inPercent ? this.Resources["StatPercentItem"] as DataTemplate : this.Resources["StatItem"] as DataTemplate; List<Airline> airlines = Airlines.GetAllAirlines().FindAll(a=>!a.IsSubsidiary); airlines.Sort((delegate(Airline a1, Airline a2) { return a1.Profile.Name.CompareTo(a2.Profile.Name); })); List<KeyValuePair<Airline, StatisticsType>> values = new List<KeyValuePair<Airline, StatisticsType>>(); foreach (Airline airline in airlines) { values.Add(new KeyValuePair<Airline, StatisticsType>(airline, type)); foreach (SubsidiaryAirline sAirline in airline.Subsidiaries) values.Add(new KeyValuePair<Airline, StatisticsType>(sAirline, type)); } lbStats.ItemsSource = values; panelStatistics.Children.Add(lbStats); lbToUpdate.Add(lbStats); /* if (!inPercent) { ContentControl ccTotal = new ContentControl(); ccTotal.Margin = new Thickness(5, 0, 0, 0); ccTotal.ContentTemplate = this.Resources["StatTotalItem"] as DataTemplate; ccTotal.Content = type; panelStatistics.Children.Add(ccTotal); } * */ return panelStatistics; }
public long getStatisticsValue(StatisticsType type) { RouteAirlinerClass aClass = new RouteAirlinerClass(AirlinerClass.ClassType.Economy_Class, RouteAirlinerClass.SeatingType.Free_Seating, 0); return getStatisticsValue(aClass, type); }
//returns the total value for a statistics type for a year public double getTotalValue(int year, StatisticsType type) { return this.Stats.Where(s => s.Year == year && s.Stat.Shortname == type.Shortname).Sum(s => s.Value); }
//returns the value for a statistics type for an airline for a year public double getStatisticsValue(int year, Airline airline, StatisticsType type) { AirportStatisticsValue item = this.Stats.Find(s => s.Year == year && s.Airline == airline && s.Stat.Shortname == type.Shortname); if (item == null) return 0; else return item.Value; }
//returns the value for a statistics type for a year public double getStatisticsValue(int year, StatisticsType type) { var stats = new List<StatisticsValue>(this.StatValues); StatisticsValue item = stats.FirstOrDefault(s => s.Stat != null && s.Year == year && s.Stat.Shortname == type.Shortname); if (item == null) return 0; else return item.Value; }
//adds a type to the collection public static void AddStatisticsType(StatisticsType type) { types.Add(type.Shortname, type); }
public AirportStatisticsValue(Airline airline, int year, StatisticsType stat, int value) : base(year,stat, value) { this.Airline = airline; }
//returns the total value of a statistics type public long getTotalValue(StatisticsType type) { long value = 0; lock (this.Stats) { value = this.Stats.Where(s => s.Type.Shortname == type.Shortname).Sum(s => s.Value); } return value; }
public RouteStatisticsItem(RouteAirlinerClass routeClass, StatisticsType type, int value) { this.RouteClass = routeClass; this.Type = type; this.Value = value; }
//returns the total value for a statistics type public double getStatisticsValue(StatisticsType type) { if (this.StatValues != null && this.StatValues.Exists(s => s.Stat != null && s.Stat.Shortname == type.Shortname)) return this.StatValues.Where(s => s.Stat != null && s.Stat.Shortname == type.Shortname).Sum(s => s.Value); else return 0; }
//returns the value for a statistics type for a route class public long getStatisticsValue(RouteAirlinerClass aClass, StatisticsType type) { RouteStatisticsItem item = this.Stats.Find(i => i.Type.Shortname == type.Shortname && i.RouteClass.Type == aClass.Type); if (item == null) return 0; else return item.Value; }
public AirportStatisticsValue(Airline airline,int year, StatisticsType stat) : this(airline,year, stat, 0) { }
//sets the value for a statistics type to a route class public void setStatisticsValue(RouteAirlinerClass aClass, StatisticsType type, int value) { if (!this.Stats.ContainsKey(aClass)) this.Stats.Add(aClass, new Dictionary<StatisticsType, int>()); if (!this.Stats[aClass].ContainsKey(type)) this.Stats[aClass].Add(type, value); else this.Stats[aClass][type] = value; }
public AirlineStatisticsMVVM(Airline airline, StatisticsType type) { this.Type = type; this.Airline = airline; }
public StatisticsValue(StatisticsType stat, double value) { this.Value = value; this.Stat = stat; }
//´creates the airport statistics private StackPanel createStatisticsPanel(StatisticsType type) { StackPanel panelStatistics = new StackPanel(); panelStatistics.Margin = new Thickness(0, 0, 0, 5); ContentControl ccHeader = new ContentControl(); ccHeader.ContentTemplate = this.Resources["AirportStatHeader"] as DataTemplate; ccHeader.Content = new KeyValuePair<string, KeyValuePair<int, int>>(string.Format(Translator.GetInstance().GetString("PageAirportStatistics", "1002"), type.Name), new KeyValuePair<int, int>(GameObject.GetInstance().GameTime.Year - 1, GameObject.GetInstance().GameTime.Year)); panelStatistics.Children.Add(ccHeader); ListBox lbStatistics = new ListBox(); lbStatistics.ItemContainerStyleSelector = new ListBoxItemStyleSelector(); lbStatistics.ItemTemplate = this.Resources["AirportStatItem"] as DataTemplate; List<Airline> airlines = Airlines.GetAllAirlines(); airlines.Sort((delegate(Airline a1, Airline a2) { return a1.Profile.Name.CompareTo(a2.Profile.Name); })); foreach (Airline airline in airlines) lbStatistics.Items.Add(new KeyValuePair<Airline, KeyValuePair<Airport, StatisticsType>>(airline, new KeyValuePair<Airport, StatisticsType>(this.Airport, type))); panelStatistics.Children.Add(lbStatistics); ContentControl ccTotal = new ContentControl(); ccTotal.Margin = new Thickness(5, 0, 0, 0); ccTotal.ContentTemplate = this.Resources["AirportStatTotalItem"] as DataTemplate; ccTotal.Content = new KeyValuePair<Airport, StatisticsType>(this.Airport, type); panelStatistics.Children.Add(ccTotal); return panelStatistics; }
public FleetAirlinerStatisticsMVVM(FleetAirliner airliner, StatisticsType type) { this.Type = type; this.Airliner = airliner; }
public void addStatisticsValue(StatisticsType type, int value) { RouteAirlinerClass aClass = new RouteAirlinerClass(AirlinerClass.ClassType.Economy_Class, RouteAirlinerClass.SeatingType.Free_Seating, 0); addStatisticsValue(aClass,type,value); }