Esempio n. 1
0
        private void LoadNewDefaultModelAndExtraStuff()
        {
            m_console = new DockableConsole("Log");
            Locator.Register(() => m_console, "console");

            List <OutbreakResponseTeam> orts = new List <OutbreakResponseTeam>();

            Dictionary <string, Tuple <int, Color> > ortCounts = new Dictionary <string, Tuple <int, Color> >();
            string  json = File.ReadAllText(@"Data/Governments.dat");
            dynamic d    = JObject.Parse(json);

            foreach (dynamic govt in d["Governments"])
            {
                string cc           = govt["cc"];
                int    numberOfORTs = govt["ORTs"];
                Color  color        = Color.FromName(govt["Color"].ToString());
                ortCounts.Add(cc, new Tuple <int, Color> (numberOfORTs, color));
            }

            WorldModel = new WorldModel(MapData.LoadFrom("Data/MapData.dat"), SimCountryData.LoadFrom("Data/CountryData.dat"), ortCounts);
            WorldModel.Executive.ClockAboutToChange += exec =>
            {
                DateTime newTime = ((IExecEvent)exec.EventList[0]).When;
                double   howMuch = 100 * (newTime - WorldModel.ExecutionParameters.StartTime).TotalHours /
                                   (WorldModel.ExecutionParameters.EndTime - WorldModel.ExecutionParameters.StartTime).TotalHours;

                m_statusStrip.InvokeIfRequired(strip =>
                {
                    ((ToolStripProgressBar)strip.Items["Progress"]).Value      = (int)howMuch;
                    ((ToolStripStatusLabel)strip.Items["DateTimeStatus"]).Text = newTime.ToString("dd MMM yyy HH:mm:ss");
                });
            };
            WorldModel.Controller.StateChanged += HandleStateChange;

            m_map = new DockableMap();
            m_map.AssignWorldModel(WorldModel);
            DockableTrendChart dc1 = new DockableTrendChart("Mortality");

            dc1.Bind(WorldModel,
                     new[]
            {
                GetTotal(n => n.Killed),
                GetTotal(n => n.Dead)
            },
                     new[]
            {
                "Killed",
                "Dead"
            });

            DockableTrendChart dc2 = new DockableTrendChart("Disease Stages");

            dc2.Bind(WorldModel,
                     new[]
            {
                GetTotal(n => n.ContagiousAsymptomatic),
                GetTotal(n => n.ContagiousSymptomatic),
                GetTotal(n => n.NonContagiousInfected),
                GetTotal(n => n.Immune),
            },
                     new[]
            {
                "ContagiousAsymptomatic",
                "ContagiousSymptomatic",
                "NonContagiousInfected",
                "Immune"
            });

            DockableRegionPieChart drpc1 = new DockableRegionPieChart("Nepal");

            drpc1.Bind(WorldModel, "NPL");
            drpc1.Show(m_dockPanel, DockState.DockLeft);

            DockableRegionPieChart drpc2 = new DockableRegionPieChart("Ireland");

            drpc2.Bind(WorldModel, "IRL");
            drpc2.Show(m_dockPanel, DockState.DockLeft);

            DockablePropertyGrid dpg = new DockablePropertyGrid()
            {
                SelectedObject = WorldModel.ExecutionParameters,
                TabText        = "Simulation Timing"
            };

            dpg.Show(m_dockPanel, DockState.DockLeft);

            DockablePropertyGrid country = new DockablePropertyGrid()
            {
                SelectedObject = WorldModel.CountryForCode("USA"),
                TabText        = "Selected Country",
                ToolTipText    = "Selected Country",
            };

            country.ToolbarVisible = false;
            m_map.CountrySelected += data => country.SelectedObject = data;

            m_map.MdiParent = this;
            m_map.Show(m_dockPanel, DockState.Document);
            ((DockableConsole)m_console).Show(m_dockPanel, DockState.DockBottom);
            country.Show(dpg.Pane, DockAlignment.Bottom, 0.6);
            dc1.Show(m_dockPanel, DockState.DockRight);
            dc2.Show(dc1.Pane, DockAlignment.Bottom, 0.5);
        }