示例#1
0
        /// <summary>
        /// Called when the EventOccured event should be fired
        /// </summary>
        /// <param name="processedEvent">The event that was processed</param>
        public void OnEventOccured(Event processedEvent)
        {
            SimulationEventArgs e = new SimulationEventArgs {
                ProcessedEvent = processedEvent
            };

            //Verify that there are actually handlers registered to the event
            if (EventOccured != null)
            {
                EventOccured(this, e);
            }
        }
        private async void Simulation_SimulationEvent(object sender, SimulationEventArgs e)
        {
            var data = new DataViewModel
            {
                Year       = e.CurrentYear,
                Population = ((Simulator)sender).CurrentPopuation,
                BornInfos  = e.BornInfos.Values.OrderBy(x => x.Order)
            };

            SaveDataToFile(data);

            await Dispatcher.InvokeAsync(() =>
            {
                _items.Add(data);
                DataGrid.ScrollIntoView(data);
            });
        }
        protected virtual void OnSimulationPaused(SimulationEventArgs e)
        {
            EventHandler <SimulationEventArgs> handler = SimulationPaused;

            handler?.Invoke(this, e);
        }