Ejemplo n.º 1
0
        public MainDemograftSim()
        {
            window              = new Window("HDemografiSim");
            window.DeleteEvent += (o, eargs) => {
                Application.Quit();
                eargs.RetVal = true;
            };
            window.ModifyBg(StateType.Normal, new Gdk.Color(130, 130, 160));

            ageDistribution = new HIndexedChartLine("Age Distribution", new DColor(250, 100, 255));
            ageDistribution.AddPoints();
            ageDistributionChart = new HChart("Age chart", ageDistribution);
            AddDefaultToAgeDist();

            populationLine  = new HIndexedChartLine("Population", new DColor(200, 140, 255));
            populationChart = new HChart("Population chart", populationLine);
            RecalculatePopulation();

            birthRate = new HIndexedChartLine("Birth rate", new DColor(100, 140, 255));
            deathRate = new HIndexedChartLine("Death rate", new DColor(55, 80, 180));
            rateChart = new HChart("Rates Chart", birthRate, deathRate);
            //RecalculateRates (0, 2, 1000);
            //RecalculateRates (0, 2, 1000);

            chanceOfDeath = new HStandardChartLine("Chance of death", new DColor(255, 80, 180));
            chanceOfDeath.AddPoint(0, 0.003f);
            chanceOfDeath.AddPoint(4, 0.001f);
            chanceOfDeath.AddPoint(8, 0.0005f);
            chanceOfDeath.AddPoint(16, 0.001f);
            chanceOfDeath.AddPoint(25, 0.0005f);
            chanceOfDeath.AddPoint(60, 0.003f);
            chanceOfDeath.AddPoint(80, 0.01f);
            chanceOfDeath.AddPoint(90, 0.03f);
            chanceOfDeath.AddPoint(119, 0.4f);
            chanceOfDeath.AddPoint(120, 0f);
            how1000PeopleDie   = new HIndexedChartLine("How 1000 people die", new DColor(255, 20, 40));
            chanceOfDeathChart = new HDoubleChart("Death Chart", new HChartLine[] { how1000PeopleDie }, chanceOfDeath);
            OnChanceOfDeathUpdated();

            var charts = new Table(2, 2, true);

            charts.SetRowSpacing(0, 10);
            charts.SetColSpacing(0, 10);
            charts.Attach(ageDistributionChart, 0, 1, 0, 1);
            charts.Attach(populationChart, 1, 2, 0, 1);
            charts.Attach(chanceOfDeathChart, 0, 1, 1, 2);
            charts.Attach(rateChart, 1, 2, 1, 2);

            var prevYear = new Button("Prev Year");

            prevYear.Clicked += (sender, e) => PrevYear();
            var nextYear = new Button("Next Year");

            nextYear.Clicked += (sender, e) => NextYear();
            var clearHistory = new Button("Halv history");

            clearHistory.Clicked += (sender, e) => ClearHistory();
            var traceCharts = new Button("Tace age distribution");

            traceCharts.Clicked += (sender, e) => TraceCharts();
            var shrinkCharts = new Button("Shrink Charts");

            shrinkCharts.Clicked += (sender, e) => ShrinkCharts();
            var fertilityRateLabel = new Label("Fertility rate:");

            fertilityRateLabel.ModifyFont(Pango.FontDescription.FromString("Sans 12"));
            fertilitySpinner             = new SpinButton(0, 100, 0.01f);
            fertilitySpinner.Value       = 2.1f;
            fertilitySpinner.SnapToTicks = false;

            var fertilitySettings = new HBox(false, 1);

            fertilitySettings.SetSizeRequest(10, -1);
            fertilitySpinner.ModifyBg(StateType.Normal, new Gdk.Color(150, 190, 200));
            fertilitySettings.Add(fertilityRateLabel);
            fertilitySettings.Add(fertilitySpinner);

            var bottomBar = new Table(1, 8, false);

            bottomBar.SetSizeRequest(-1, 30);
            bottomBar.Attach(prevYear, 0, 1, 0, 1);
            bottomBar.Attach(nextYear, 1, 2, 0, 1);
            bottomBar.Attach(clearHistory, 2, 3, 0, 1);
            bottomBar.Attach(traceCharts, 3, 4, 0, 1);
            bottomBar.Attach(shrinkCharts, 4, 5, 0, 1);
            bottomBar.Attach(fertilitySettings, 5, 8, 0, 1);

            var everythingBox = new VBox(false, 1);

            everythingBox.PackStart(charts, true, true, 0);
            everythingBox.PackStart(bottomBar, false, false, 0);

            window.Add(everythingBox);
            window.ShowAll();
        }
Ejemplo n.º 2
0
 public HIndexedChartLine(HIndexedChartLine copy, String name, DColor color)
     : base(name, color)
 {
     values = new List<Single> (copy.values);
     biggestYValue = copy.biggestYValue;
 }
Ejemplo n.º 3
0
 public HIndexedChartLine(HIndexedChartLine copy, String name, DColor color) : base(name, color)
 {
     values        = new List <Single> (copy.values);
     biggestYValue = copy.biggestYValue;
 }