コード例 #1
0
        public StatisticsForm(SimulationRenderHelper helper, Func <IChartDrawer> createChartDrawerFunc)
            : base(helper)
        {
            _chartDrawer = new Lazy <IChartDrawer>(createChartDrawerFunc);
            InitializeComponent();

            foreach (var tabPage in _graphControlDefinitions)
            {
                tabControl1.TabPages.Add(tabPage.TabPage);
            }
        }
コード例 #2
0
        public BudgetForm(SimulationRenderHelper helper)
            : base(helper)
        {
            InitializeComponent();

            _taxDefinitionGridViewController = new BudgetComponentDefinitionGridViewController <TaxDefinition>(
                targetGridView: taxesDataGridView,
                definitions: TaxDefinition.TaxDefinitions,
                cityBudgetConfiguration: helper.SimulationSession.CityBudgetConfiguration,
                costsLabel: "Projected income",
                getCostsFunc: (definition, statistics) => definition.GetProjectedIncome(statistics)
                );

            _cityServiceDefinitionGridViewController = new BudgetComponentDefinitionGridViewController <CityServiceDefinition>(
                targetGridView: serviceExpensesDataGridView,
                definitions: CityServiceDefinition.CityServiceDefinitions,
                cityBudgetConfiguration: helper.SimulationSession.CityBudgetConfiguration,
                costsLabel: "Projected expenses",
                getCostsFunc: (definition, statistics) => definition.GetProjectedExpenses(statistics)
                );

            _totalsGridViewController = new TotalsGridViewController(totalsDataGridView);
        }
コード例 #3
0
        public void Show(IWin32Window parent, SimulationRenderHelper helper)
        {
            helper
            .SimulationSession
            .GetRecentStatistics()
            .WithResultIfHasMatch(statistics =>
            {
                if (_currentFormInstance == null)
                {
                    var instance = _factory(helper);

                    helper.Stopping += (x, y) => instance.Close();

                    instance.Closed += (x, y) =>
                    {
                        _currentFormInstance.Dispose();
                        _currentFormInstance = null;
                    };

                    _currentFormInstance = instance;
                    _currentFormInstance.Show(parent);
                }
            });
        }
コード例 #4
0
 protected FormWithCityStatisticsEvent(SimulationRenderHelper helper)
 {
     this.Shown += (x, y) => UpdatePrivate(helper.SimulationSession.GetAllCityStatistics(), helper.SimulationSession.GetRecentStatistics().MatchingObject);
     helper.SimulationSession.CityStatisticsUpdated += (x, y) => UpdatePrivate(helper.SimulationSession.GetAllCityStatistics(), y.EventData);
 }
コード例 #5
0
        private void RegisterAreaRenderHelper(TerraformingOptions terraformingOptions = null, PersistedSimulation persistedSimulation = null)
        {
            _gamePanel.Controls.Clear();

            var areaOptions = terraformingOptions != null
                ? new SimulationOptions(terraformingOptions,
                                        new ProcessOptions(() => showGrowthPathFinding.Checked, () => enableMoneyCheatToolStripMenuItem.Checked))
                : new SimulationOptions(persistedSimulation,
                                        new ProcessOptions(() => showGrowthPathFinding.Checked, () => enableMoneyCheatToolStripMenuItem.Checked));

            if (_areaRenderHelper != null)
            {
                _areaRenderHelper.Stop();
                ReloadGamePanel();
            }

            _areaRenderHelper = new SimulationRenderHelper(
                gamePanel: _gamePanel,
                renderZoneOptions: new RenderZoneOptions(
                    showDebugGrowthPathFinding: () => showGrowthPathFinding.Checked,
                    selectedGraphicsManagerFunc: () => _graphicsManagerSelection.GetCurrentOption(),
                    getCurrentOverlayOptionFunc: () => _overlaySelection.GetCurrentOption()
                    ),
                options: areaOptions
                );

            _areaRenderHelper.SimulationSession.OnAreaMessage +=
                (_sender, _e) =>
                statusStrip1.BeginInvoke(new MethodInvoker(() => { toolStripStatusLabel1.Text = _e.Message; }));

            _areaRenderHelper.SimulationSession.OnAreaHotMessage +=
                (_sender, _e) =>
            {
                if (_webserverForm == null)
                {
                    MessageBox.Show(_e.Message, _e.Title, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    statusStrip1.BeginInvoke(new MethodInvoker(() => { toolStripStatusLabel1.Text = _e.Message; }));
                }
            };

            _areaRenderHelper.SimulationSession.OnCityBudgetValueChanged +=
                (_sender, _e) =>
                statusStrip1.BeginInvoke(new MethodInvoker(() =>
            {
                foreach (var x in new[]
                {
                    new
                    {
                        LabelControl = cityBudgetLabel,
                        Text = _e.EventData.CurrentAmountDescription,
                        Amount = _e.EventData.CurrentAmount
                    },
                    new
                    {
                        LabelControl = projectedIncomeLabel,
                        Text = _e.EventData.ProjectedIncomeDescription,
                        Amount = _e.EventData.ProjectedIncome
                    }
                })
                {
                    x.LabelControl.Text      = x.Text;
                    x.LabelControl.ForeColor = x.Amount >= 0
                                ? SystemColors.ControlText
                                : Color.Red;
                }
            }));

            _areaRenderHelper.SimulationSession.OnYearAndOrMonthChanged +=
                (_sender, _e) =>
            {
                if (statusStrip1.IsHandleCreated)
                {
                    statusStrip1.BeginInvoke(new MethodInvoker(
                                                 () => { monthAndYearLabel.Text = _e.EventData.GetCurrentDescription(); }));
                }
            };

            _areaRenderHelper.Start();
            _citySaveStateController.ToggleSaveFunctionalityAvailable();
        }
コード例 #6
0
 public EvaluationForm(SimulationRenderHelper helper) : base(helper)
 {
     InitializeComponent();
 }