Beispiel #1
0
        void bGenerate_Click(object sender, EventArgs e)
        {
            if (genState != null)
            {
                genState.CancelAsync();
                tStatus1.Text     = "Canceling...";
                bGenerate.Enabled = false;
                return;
            }
            Map = null;

            MapGeneratorParameters genParams = genGui.GetParameters();

            genState = genParams.CreateGenerator();

            tStatus1.Text = "Generating...";
            tStatus2.Text = "";
            if (genState.ReportsProgress)
            {
                progressBar.Style         = ProgressBarStyle.Continuous;
                genState.ProgressChanged +=
                    (progressSender, progressArgs) =>
                    bwGenerator.ReportProgress(progressArgs.ProgressPercentage, progressArgs.UserState);
            }
            else
            {
                progressBar.Style = ProgressBarStyle.Marquee;
            }
            if (genState.SupportsCancellation)
            {
                bGenerate.Text = "Cancel";
            }
            else
            {
                bGenerate.Enabled = false;
            }
            progressBar.Value   = 0;
            progressBar.Visible = true;
            Refresh();
            bwGenerator.RunWorkerAsync();
            World.MapChangedBy = WorldListEntry.WorldInfoSignature;
            World.MapChangedOn = DateTime.UtcNow;
        }
Beispiel #2
0
 void AsyncGenCompleted(object sender, RunWorkerCompletedEventArgs e)
 {
     stopwatch.Stop();
     if (genState.Canceled)
     {
         tStatus1.Text       = "Generation cancelled!";
         progressBar.Visible = false;
     }
     else if (Map == null)
     {
         tStatus1.Text = "Generation failed!";
         Logger.LogAndReportCrash("Exception while generating map", "ConfigGUI", e.Error, false);
         progressBar.Visible = false;
     }
     else
     {
         tStatus1.Text = "Generation successful (" + stopwatch.Elapsed.TotalSeconds.ToString("0.000") + "s)";
         tStatus2.Text = ", drawing...";
         Redraw(true);
     }
     bGenerate.Enabled = true;
     bGenerate.Text    = "Generate";
     genState          = null;
 }
Beispiel #3
0
 void AsyncGenCompleted( object sender, RunWorkerCompletedEventArgs e ) {
     stopwatch.Stop();
     if( genState.Canceled ) {
         tStatus1.Text = "Generation cancelled!";
         progressBar.Visible = false;
     } else if( Map == null ) {
         tStatus1.Text = "Generation failed!";
         Logger.LogAndReportCrash( "Exception while generating map", "ConfigGUI", e.Error, false );
         progressBar.Visible = false;
     } else {
         tStatus1.Text = "Generation successful (" + stopwatch.Elapsed.TotalSeconds.ToString( "0.000" ) + "s)";
         tStatus2.Text = ", drawing...";
         Redraw( true );
     }
     bGenerate.Enabled = true;
     bGenerate.Text = "Generate";
     genState = null;
 }
Beispiel #4
0
        void bGenerate_Click( object sender, EventArgs e ) {
            if( genState != null ) {
                genState.CancelAsync();
                tStatus1.Text = "Canceling...";
                bGenerate.Enabled = false;
                return;
            }
            Map = null;

            MapGeneratorParameters genParams = genGui.GetParameters();
            genState = genParams.CreateGenerator();

            tStatus1.Text = "Generating...";
            tStatus2.Text = "";
            if( genState.ReportsProgress ) {
                progressBar.Style = ProgressBarStyle.Continuous;
                genState.ProgressChanged +=
                    ( progressSender, progressArgs ) =>
                    bwGenerator.ReportProgress( progressArgs.ProgressPercentage, progressArgs.UserState );
            } else {
                progressBar.Style = ProgressBarStyle.Marquee;
            }
            if( genState.SupportsCancellation ) {
                bGenerate.Text = "Cancel";
            } else {
                bGenerate.Enabled = false;
            }
            progressBar.Value = 0;
            progressBar.Visible = true;
            Refresh();
            bwGenerator.RunWorkerAsync();
            World.MapChangedBy = WorldListEntry.WorldInfoSignature;
            World.MapChangedOn = DateTime.UtcNow;
        }