public SiteConqueredPrinter(SiteConquered conquering, World world)
 {
     _conquering = conquering;
     _world      = world;
 }
Пример #2
0
        private void dgResults_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
        {
            Type   objectType = dgResults.Rows[e.RowIndex].DataBoundItem.GetType();
            string column     = dgResults.Columns[e.ColumnIndex].HeaderText;

            if (e.Value != null && e.Value.GetType().IsEnum)
            {
                e.Value = e.Value.GetDescription();
            }

            if (objectType == typeof(HistoricalFigure))
            {
                HistoricalFigure hf = dgResults.Rows[e.RowIndex].DataBoundItem as HistoricalFigure;
                if (column == "Kills")
                {
                    e.Value = hf.NotableKills.Count;
                }
                else if (column == "Abductions")
                {
                    e.Value = hf.Abductions.Count;
                }
                else if (column == "Battles")
                {
                    e.Value = hf.Battles.Count;
                }
                else if (column == "Beast Attacks")
                {
                    e.Value = hf.BeastAttacks.Count;
                }
                else if (column == "Age")
                {
                    int    age;
                    string deathYear;
                    if (hf.DeathYear == -1)
                    {
                        age       = World.Events.Last().Year - hf.BirthYear;
                        deathYear = "Present";
                    }
                    else
                    {
                        age       = hf.DeathYear - hf.BirthYear;
                        deathYear = hf.DeathYear.ToString();
                    }

                    e.Value = age + " (" + hf.BirthYear + " - " + deathYear + ")";
                }
                else if (column == "Events")
                {
                    e.Value = hf.FilteredEvents.Count + " / " + hf.Events.Count;
                }
            }
            else if (objectType == typeof(Entity))
            {
                Entity entity = dgResults.Rows[e.RowIndex].DataBoundItem as Entity;
                if (column == "Name")
                {
                    e.Value = entity.ToString();
                    if (entity.IsCiv)
                    {
                        e.Value += " <Civ>";
                    }
                    e.Value += " (" + entity.Race + ")";
                }
                else if (column == "Sites")
                {
                    e.Value = entity.CurrentSites.Count;
                }
                else if (column == "Lost Sites")
                {
                    e.Value = entity.LostSites.Count;
                }
                else if (column == "Population")
                {
                    e.Value = entity.Populations.Sum(population => population.Count);
                }
                else if (column == "Wars")
                {
                    e.Value = entity.Wars.Count;
                }
                else if (column == "Wins : Losses")
                {
                    e.Value = entity.WarVictories + " / " + entity.WarLosses;
                }
                else if (column == "Kills : Deaths")
                {
                    e.Value = entity.WarKills + " / " + entity.WarDeaths;
                }
                else if (column == "Events")
                {
                    e.Value = entity.FilteredEvents.Count + " / " + entity.Events.Count;
                }
            }
            else if (objectType == typeof(Site))
            {
                Site site = dgResults.Rows[e.RowIndex].DataBoundItem as Site;
                if (column == "Owner")
                {
                    if (e.Value == null)
                    {
                        e.Value = "";
                    }
                    else
                    {
                        e.Value = site.CurrentOwner;
                        if (site.CurrentOwner is Entity)
                        {
                            e.Value += " (" + ((Entity)site.CurrentOwner).Race + ")";
                        }
                    }
                }
                else if (column == "Previous Owners")
                {
                    e.Value = site.PreviousOwners.Count;
                }
                else if (column == "Deaths")
                {
                    e.Value = site.Deaths.Count;
                }
                else if (column == "Warfare")
                {
                    e.Value = site.Warfare.Count;
                }
                else if (column == "Population")
                {
                    e.Value = site.Populations.Sum(population => population.Count);
                }
                else if (column == "Beast Attacks")
                {
                    e.Value = site.BeastAttacks.Count;
                }
                else if (column == "Events")
                {
                    e.Value = site.FilteredEvents.Count + " / " + site.Events.Count;
                }
            }
            else if (objectType == typeof(WorldRegion))
            {
                WorldRegion region = dgResults.Rows[e.RowIndex].DataBoundItem as WorldRegion;
                if (column == "Battles")
                {
                    e.Value = region.Battles.Count;
                }
                else if (column == "Deaths")
                {
                    e.Value = region.Deaths.Count;
                }
                else if (column == "Events")
                {
                    e.Value = region.FilteredEvents.Count + " / " + region.Events.Count;
                }
            }
            else if (objectType == typeof(UndergroundRegion))
            {
                UndergroundRegion uregion = dgResults.Rows[e.RowIndex].DataBoundItem as UndergroundRegion;
                if (column == "Events")
                {
                    e.Value = uregion.FilteredEvents.Count + " / " + uregion.Events.Count;
                }
            }
            else if (objectType == typeof(War))
            {
                War war = dgResults.Rows[e.RowIndex].DataBoundItem as War;
                //if (column == "Battles") e.Value = war.Battles;
                if (column == "Length")
                {
                    e.Value = war.StartYear + " - ";
                    if (war.EndYear == -1)
                    {
                        e.Value += "Present";
                    }
                    else
                    {
                        e.Value += war.EndYear.ToString();
                    }
                    e.Value += " (" + war.Length + ")";
                }
                else if (column == "Attacker")
                {
                    e.Value = war.Attacker.ToString() + " (" + war.Attacker.Race + ")";
                }
                else if (column == "Defender")
                {
                    e.Value = war.Defender.ToString() + " (" + war.Defender.Race + ")";
                }
                else if (column == "Kills")
                {
                    e.Value = war.DefenderDeathCount + " / " + war.AttackerDeathCount;
                }
                else if (column == "Victories")
                {
                    e.Value = war.AttackerBattleVictories.Count + " / " + war.DefenderBattleVictories.Count;
                }
                else if (column == "Sites Lost")
                {
                    e.Value = war.DefenderConquerings.Count(conquering => conquering.Notable) + " / " + war.AttackerConquerings.Count(conquering => conquering.Notable);
                }
                else if (column == "Events")
                {
                    e.Value = war.FilteredEvents.Count + " / " + war.AllEvents.Count;
                }
            }
            else if (objectType == typeof(Battle))
            {
                Battle battle = dgResults.Rows[e.RowIndex].DataBoundItem as Battle;
                if (column == "Attacker")
                {
                    e.Value = battle.Attacker.ToString() + " (" + battle.Attacker.Race + ")";
                }
                else if (column == "Defender")
                {
                    e.Value = battle.Defender.ToString() + " (" + battle.Defender.Race + ")";
                }
                else if (column == "Deaths")
                {
                    e.Value = battle.DeathCount;
                }
                else if (column == "Combatants")
                {
                    e.Value = battle.AttackersAsList.Count + " / " + battle.DefendersAsList.Count;
                }
                else if (column == "Remaining")
                {
                    e.Value = battle.AttackersRemainingCount + " / " + battle.DefendersRemainingCount;
                }
                else if (column == "Conquering")
                {
                    if (battle.Conquering == null)
                    {
                        e.Value = "";
                    }
                    else
                    {
                        e.Value = battle.Conquering.ToString();
                    }
                }
                else if (column == "Events")
                {
                    e.Value = battle.FilteredEvents.Count + " / " + battle.AllEvents.Count;
                }
            }
            else if (objectType == typeof(SiteConquered))
            {
                SiteConquered conquering = dgResults.Rows[e.RowIndex].DataBoundItem as SiteConquered;
                if (column == "Name")
                {
                    e.Value = conquering.ToString();
                }
                else if (column == "Deaths")
                {
                    e.Value = conquering.Deaths.Count;
                }
                else if (column == "Events")
                {
                    e.Value = conquering.FilteredEvents.Count + " / " + conquering.AllEvents.Count;
                }
            }
            else if (objectType == typeof(BeastAttack))
            {
                BeastAttack attack = dgResults.Rows[e.RowIndex].DataBoundItem as BeastAttack;
                if (column == "Name")
                {
                    e.Value = attack.ToString();
                }
                else if (column == "Deaths")
                {
                    e.Value = attack.Deaths.Count;
                }
                else if (column == "Events")
                {
                    e.Value = attack.FilteredEvents.Count + " / " + attack.AllEvents.Count;
                }
            }
            else if (objectType == typeof(Artifact))
            {
                Artifact artifact = dgResults.Rows[e.RowIndex].DataBoundItem as Artifact;
                if (column == "Events")
                {
                    e.Value = artifact.Events.Count;
                }
            }

            //if (objectType.BaseType == typeof(WorldObject) && column == "Events")
            //    e.Value = (dgResults.Rows[e.RowIndex].DataBoundItem as WorldObject).Events.Count;
            //if (objectType.BaseType == typeof(EventCollection) && column == "Events")
            //    e.Value = (dgResults.Rows[e.RowIndex].DataBoundItem as EventCollection).AllEvents.Count;

            dgResults.Rows[e.RowIndex].HeaderCell.Value = (e.RowIndex + 1).ToString();
        }