public void AfterLoad(World loadedWorld)
        {
            if (!FileLoader.Working && world != null)
            {
                world.Map.Dispose();
                world.MiniMap.Dispose();
                world.PageMiniMap.Dispose();
                foreach (Entity entity in world.Entities)
                {
                    if (entity.Identicon != null)
                    {
                        entity.Identicon.Dispose();
                    }
                }
                world = null;
            }

            world = loadedWorld;

            lblStatus.Text      = "Setup...";
            lblStatus.ForeColor = Color.Blue;
            ResetForm();
            Application.DoEvents();

            Browser.World = world;
            this.Text    += " " + world.Name;
            Browser.Navigate(ControlOption.HTML, world);

            txtLog.AppendText(world.Log.ToString());
            hfSearch          = new HistoricalFigureList(world);
            siteSearch        = new SitesList(world);
            regionSearch      = new RegionsList(world);
            uRegionSearch     = new UndergroundRegionsList(world);
            entitySearch      = new EntitiesList(world);
            warSearch         = new WarsList(world);
            battleSearch      = new BattlesList(world);
            conqueringsSearch = new ConqueringsList(world);
            beastAttackSearch = new BeastAttackList(world);
            artifactSearch    = new ArtifactList(world);

            dlgOpen.FileName = "";

            var races = from hf in world.HistoricalFigures
                        orderby hf.Race
                        group hf by hf.Race into race
                        select race;
            var castes = from hf in world.HistoricalFigures
                         orderby hf.Caste
                         group hf by hf.Caste into caste
                         select caste;
            var types = from hf in world.HistoricalFigures
                        orderby hf.AssociatedType
                        group hf by hf.AssociatedType into type
                        select type;
            var sites = from site in world.Sites
                        orderby site.Type
                        group site by site.Type into sitetype
                        select sitetype;
            var regions = from region in world.Regions
                          orderby region.Type
                          group region by region.Type into regiontype
                          select regiontype;
            var uregions = from uregion in world.UndergroundRegions
                           orderby uregion.Type
                           group uregion by uregion.Type into uregiontype
                           select uregiontype;
            var civRaces = from civ in world.Entities
                           orderby civ.Race
                           group civ by civ.Race into civRace
                           select civRace;
            var conquerTypes = from conquer in world.EventCollections.OfType <SiteConquered>()
                               orderby conquer.ConquerType
                               group conquer by conquer.ConquerType into conquers
                               select conquers;
            var populationTypes = from population in world.SitePopulations
                                  orderby population.Race
                                  group population by population.Race into type
                                  select type;
            var civPopulationTypes = from civPopulation in populationTypes
                                     where world.Entities.Count(entity => entity.Populations.Count(population => population.Race == civPopulation.Key) > 0) > 0
                                     select civPopulation;
            var historicalFigureEvents = from eventType in world.HistoricalFigures.SelectMany(hf => hf.Events)
                                         group eventType by eventType.Type into type
                                         select type.Key;
            var siteEvents = from eventType in world.Sites.SelectMany(site => site.Events)
                             group eventType by eventType.Type into type
                             select type.Key;
            var regionEvents = from eventType in world.Regions.SelectMany(region => region.Events)
                               group eventType by eventType.Type into type
                               select type.Key;
            var undergroundRegionEvents = from eventType in world.UndergroundRegions.SelectMany(uRegion => uRegion.Events)
                                          group eventType by eventType.Type into type
                                          select type.Key;
            var entityEvents = from eventType in world.Entities.SelectMany(hf => hf.Events)
                               group eventType by eventType.Type into type
                               select type.Key;
            var warEvents = from eventType in world.EventCollections.OfType <War>().SelectMany(war => war.GetSubEvents())
                            group eventType by eventType.Type into type
                            select type.Key;
            var battleEvents = from eventType in world.EventCollections.OfType <Battle>().SelectMany(battle => battle.GetSubEvents())
                               group eventType by eventType.Type into type
                               select type.Key;
            var conqueringEvents = from eventType in world.EventCollections.OfType <SiteConquered>().SelectMany(conquering => conquering.GetSubEvents())
                                   group eventType by eventType.Type into type
                                   select type.Key;
            var beastAttackEvents = from eventType in world.EventCollections.OfType <BeastAttack>().SelectMany(beastAttack => beastAttack.GetSubEvents())
                                    group eventType by eventType.Type into type
                                    select type.Key;

            var artifactEvents = from eventType in world.Artifacts.SelectMany(artifact => artifact.Events)
                                 group eventType by eventType.Type into type
                                 select type.Key;

            var eventTypes = from eventType in world.Events
                             group eventType by eventType.Type into type
                             select type.Key;

            TabEvents = new List <List <string> >();
            foreach (Type eventTabType in EventTabTypes)
            {
                if (eventTabType == typeof(HistoricalFigure))
                {
                    TabEvents.Add(historicalFigureEvents.ToList());
                }
                else if (eventTabType == typeof(Site))
                {
                    TabEvents.Add(siteEvents.ToList());
                }
                else if (eventTabType == typeof(Region))
                {
                    TabEvents.Add(regionEvents.ToList());
                }
                else if (eventTabType == typeof(UndergroundRegion))
                {
                    TabEvents.Add(undergroundRegionEvents.ToList());
                }
                else if (eventTabType == typeof(Entity))
                {
                    TabEvents.Add(entityEvents.ToList());
                }
                else if (eventTabType == typeof(War))
                {
                    TabEvents.Add(warEvents.ToList());
                }
                else if (eventTabType == typeof(Battle))
                {
                    TabEvents.Add(battleEvents.ToList());
                }
                else if (eventTabType == typeof(SiteConquered))
                {
                    TabEvents.Add(conqueringEvents.ToList());
                }
                else if (eventTabType == typeof(Era))
                {
                    TabEvents.Add(eventTypes.ToList());
                }
                else if (eventTabType == typeof(Artifact))
                {
                    TabEvents.Add(artifactEvents.ToList());
                }
                else if (eventTabType == typeof(BeastAttack))
                {
                    TabEvents.Add(beastAttackEvents.ToList());
                }
            }
            GenerateEventFilterCheckBoxes();

            foreach (Era era in world.Eras)
            {
                listEras.Items.Add(era);
            }


            cmbRace.Items.Add("All"); cmbRace.SelectedIndex = 0;
            foreach (var race in races)
            {
                cmbRace.Items.Add(race.Key);
            }
            cmbCaste.Items.Add("All"); cmbCaste.SelectedIndex = 0;
            foreach (var caste in castes)
            {
                cmbCaste.Items.Add(caste.Key);
            }
            cmbType.Items.Add("All"); cmbType.SelectedIndex = 0;
            foreach (var type in types)
            {
                cmbType.Items.Add(type.Key);
            }
            cmbSiteType.Items.Add("All"); cmbSiteType.SelectedIndex = 0;
            foreach (var site in sites)
            {
                cmbSiteType.Items.Add(site.Key);
            }
            cmbRegionType.Items.Add("All"); cmbRegionType.SelectedIndex = 0;
            foreach (var region in regions)
            {
                cmbRegionType.Items.Add(region.Key);
            }
            cmbURegionType.Items.Add("All"); cmbURegionType.SelectedIndex = 0;
            foreach (var uregion in uregions)
            {
                cmbURegionType.Items.Add(uregion.Key);
            }
            cmbCivRace.Items.Add("All"); cmbCivRace.SelectedIndex = 0;
            foreach (var civRace in civRaces)
            {
                cmbCivRace.Items.Add(civRace.Key);
            }
            cmbConqueringType.Items.Add("All"); cmbConqueringType.SelectedIndex = 0;
            foreach (var conquerType in conquerTypes)
            {
                cmbConqueringType.Items.Add(conquerType.Key);
            }
            cmbSitePopulation.Items.Add("All"); cmbSitePopulation.SelectedIndex = 0;
            foreach (var populationType in populationTypes)
            {
                cmbSitePopulation.Items.Add(populationType.Key);
            }
            cmbEntityPopulation.Items.Add("All"); cmbEntityPopulation.SelectedIndex = 0;
            foreach (var civPopulation in civPopulationTypes)
            {
                cmbEntityPopulation.Items.Add(civPopulation.Key);
            }


            numStart.Maximum = numEraEnd.Value = numEraEnd.Maximum = world.Events.Last().Year;


            DontRefreshBrowserPages = true;
            foreach (CheckBox eraCheck in tpEraEvents.Controls.OfType <CheckBox>())
            {
                eraCheck.Checked = false;
            }
            DontRefreshBrowserPages = false;
            lblStatus.Text          = "Done!";
            lblStatus.ForeColor     = Color.Green;
            FileLoader.Working      = false;
        }
        private void AfterLoad()
        {
            foreach (string delete in extractedFiles)
                System.IO.File.Delete(delete);
            extractedFiles.Clear();

            Browser.World = world;
            this.Text += " " + world.Name;
            Browser.Navigate(ControlOption.HTML, world);

            txtLog.AppendText(world.Log.ToString());
            hfSearch = new HistoricalFigureList(world);
            siteSearch = new SitesList(world);
            regionSearch = new RegionsList(world);
            uRegionSearch = new UndergroundRegionsList(world);
            entitySearch = new EntitiesList(world);
            warSearch = new WarsList(world);
            battleSearch = new BattlesList(world);
            conqueringsSearch = new ConqueringsList(world);
            beastAttackSearch = new BeastAttackList(world);

            dlgOpen.FileName = "";

            var races = from hf in world.HistoricalFigures
                        orderby hf.Race
                        group hf by hf.Race into race
                        select race;
            var castes = from hf in world.HistoricalFigures
                         orderby hf.Caste
                         group hf by hf.Caste into caste
                         select caste;
            var types = from hf in world.HistoricalFigures
                        orderby hf.AssociatedType
                        group hf by hf.AssociatedType into type
                        select type;
            var sites = from site in world.Sites
                        orderby site.Type
                        group site by site.Type into sitetype
                        select sitetype;
            var regions = from region in world.Regions
                          orderby region.Type
                          group region by region.Type into regiontype
                          select regiontype;
            var uregions = from uregion in world.UndergroundRegions
                           orderby uregion.Type
                           group uregion by uregion.Type into uregiontype
                           select uregiontype;
            var civRaces = from civ in world.Entities
                           orderby civ.Race
                           group civ by civ.Race into civRace
                           select civRace;
            var conquerTypes = from conquer in world.EventCollections.OfType<SiteConquered>()
                               orderby conquer.ConquerType
                               group conquer by conquer.ConquerType into conquers
                               select conquers;
            var populationTypes = from population in world.SitePopulations
                                  orderby population.Race
                                  group population by population.Race into type
                                  select type;
            var civPopulationTypes = from civPopulation in populationTypes
                                     where world.Entities.Count(entity => entity.Populations.Count(population => population.Race == civPopulation.Key) > 0) > 0
                                     select civPopulation;
            var historicalFigureEvents = from eventType in world.HistoricalFigures.SelectMany(hf => hf.Events)
                                         group eventType by eventType.Type into type
                                         select type.Key;
            var siteEvents = from eventType in world.Sites.SelectMany(site => site.Events)
                                         group eventType by eventType.Type into type
                                         select type.Key;
            var regionEvents = from eventType in world.Regions.SelectMany(region => region.Events)
                                         group eventType by eventType.Type into type
                                         select type.Key;
            var undergroundRegionEvents = from eventType in world.UndergroundRegions.SelectMany(uRegion => uRegion.Events)
                                         group eventType by eventType.Type into type
                                         select type.Key;
            var entityEvents = from eventType in world.Entities.SelectMany(hf => hf.Events)
                                         group eventType by eventType.Type into type
                                         select type.Key;
            var warEvents = from eventType in world.EventCollections.OfType<War>().SelectMany(war => war.GetSubEvents())
                                         group eventType by eventType.Type into type
                                         select type.Key;
            var battleEvents = from eventType in world.EventCollections.OfType<Battle>().SelectMany(battle => battle.GetSubEvents())
                                         group eventType by eventType.Type into type
                                         select type.Key;
            var conqueringEvents = from eventType in world.EventCollections.OfType<SiteConquered>().SelectMany(conquering => conquering.GetSubEvents())
                                         group eventType by eventType.Type into type
                                         select type.Key;
            var beastAttackEvents = from eventType in world.EventCollections.OfType<BeastAttack>().SelectMany(beastAttack => beastAttack.GetSubEvents())
                                   group eventType by eventType.Type into type
                                   select type.Key;
            var eventTypes = from eventType in world.Events
                             group eventType by eventType.Type into type
                             select type.Key;

            TabEvents = new List<List<string>>();
            foreach (Type eventTabType in EventTabTypes)
            {
                if (eventTabType == typeof(HistoricalFigure))
                    TabEvents.Add(historicalFigureEvents.ToList());
                else if (eventTabType == typeof(Site))
                    TabEvents.Add(siteEvents.ToList());
                else if (eventTabType == typeof(Region))
                    TabEvents.Add(regionEvents.ToList());
                else if (eventTabType == typeof(UndergroundRegion))
                    TabEvents.Add(undergroundRegionEvents.ToList());
                else if (eventTabType == typeof(Entity))
                    TabEvents.Add(entityEvents.ToList());
                else if (eventTabType == typeof(War))
                    TabEvents.Add(warEvents.ToList());
                else if (eventTabType == typeof(Battle))
                    TabEvents.Add(battleEvents.ToList());
                else if (eventTabType == typeof(SiteConquered))
                    TabEvents.Add(conqueringEvents.ToList());
                else if (eventTabType == typeof(Era))
                    TabEvents.Add(eventTypes.ToList());
                else if (eventTabType == typeof(BeastAttack))
                    TabEvents.Add(beastAttackEvents.ToList());
            }
            GenerateEventFilterCheckBoxes();

            foreach (Era era in world.Eras)
                listEras.Items.Add(era);

            //if (Browser == null) Browser = new DwarfTabControl();//new DwarfBrowser(Browser, World);
            //else Browser.World = World;

            cmbRace.Items.Add("All"); cmbRace.SelectedIndex = 0;
            foreach (var race in races)
                cmbRace.Items.Add(race.Key);
            cmbCaste.Items.Add("All"); cmbCaste.SelectedIndex = 0;
            foreach (var caste in castes)
                cmbCaste.Items.Add(caste.Key);
            cmbType.Items.Add("All"); cmbType.SelectedIndex = 0;
            foreach (var type in types)
                cmbType.Items.Add(type.Key);
            cmbSiteType.Items.Add("All"); cmbSiteType.SelectedIndex = 0;
            foreach (var site in sites)
                cmbSiteType.Items.Add(site.Key);
            cmbRegionType.Items.Add("All"); cmbRegionType.SelectedIndex = 0;
            foreach (var region in regions)
                cmbRegionType.Items.Add(region.Key);
            cmbURegionType.Items.Add("All"); cmbURegionType.SelectedIndex = 0;
            foreach (var uregion in uregions)
                cmbURegionType.Items.Add(uregion.Key);
            cmbCivRace.Items.Add("All"); cmbCivRace.SelectedIndex = 0;
            foreach (var civRace in civRaces)
                cmbCivRace.Items.Add(civRace.Key);
            cmbConqueringType.Items.Add("All"); cmbConqueringType.SelectedIndex = 0;
            foreach (var conquerType in conquerTypes)
                cmbConqueringType.Items.Add(conquerType.Key);
            cmbSitePopulation.Items.Add("All"); cmbSitePopulation.SelectedIndex = 0;
            foreach (var populationType in populationTypes)
                cmbSitePopulation.Items.Add(populationType.Key);
            cmbEntityPopulation.Items.Add("All"); cmbEntityPopulation.SelectedIndex = 0;
            foreach(var civPopulation in civPopulationTypes)
                cmbEntityPopulation.Items.Add(civPopulation.Key);

            numStart.Maximum = numEraEnd.Value = numEraEnd.Maximum = world.Events.Last().Year;

            loading = false;
            DontRefreshBrowserPages = true;
            foreach (CheckBox eraCheck in tpEraEvents.Controls.OfType<CheckBox>())
                eraCheck.Checked = false;
            DontRefreshBrowserPages = false;
            btnLoad.Enabled = true;
            lblStatus.Text = "Done!";
            lblStatus.ForeColor = Color.Green;
        }