private void UpdateUi()
        {
            if (Stream != null)
            {
                roundsLabel.Text  = string.Empty;
                playerLabel.Text  = string.Empty;
                stateLabel.Text   = string.Empty;
                infoPanel.Visible = true;

                loadingProgressBar.Value   = 0;
                loadingProgressBar.Visible = true;
                try
                {
                    Stream.Seek(0, SeekOrigin.Begin);
                    AntVideoReader  reader    = new AntVideoReader(Stream);
                    SimulationState lastState = reader.Read();
                    loadingProgressBar.Maximum = lastState.TotalRounds;
                    while (!reader.Complete)
                    {
                        lastState = reader.Read();
                        loadingProgressBar.Value = lastState.CurrentRound;
                    }
                    roundsLabel.Text = lastState.CurrentRound.ToString();
                    stateLabel.Text  = lastState.CurrentRound == lastState.TotalRounds ? "Finished" : "Not Finished";
                    playerLabel.Text = string.Join("\r\n", lastState.ColonyStates.Select(c => c.ColonyName));
                }
                catch (Exception ex)
                {
                    infoPanel.Visible = false;

                    MessageBox.Show(ex.Message);

                    Stream.Close();
                    Stream.Dispose();
                    Stream = null;
                }

                loadingProgressBar.Visible = false;
            }
            else
            {
                infoPanel.Visible          = false;
                loadingProgressBar.Visible = false;
            }
        }
Esempio n. 2
0
        public void CreateState(ref SimulationState simulationState)
        {
            if (reader != null)
            {
                simulationState = reader.Read();

                if (reader.Complete)
                {
                    control.Invoke((MethodInvoker)Stop);
                }
            }
        }
        public void CreateState(ref SimulationState state)
        {
            if (reader != null)
            {
                state = reader.Read();
            }

            if (reader.Complete)
            {
                control.Invoke((MethodInvoker)(() =>
                {
                    Stop();
                }));
            }
        }