Ejemplo n.º 1
0
 static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
 {
     FormError error = new FormError();
     error.Exception = e.ExceptionObject as Exception;
     error.Text = "Unexpected exception";
     error.ShowDialog();
 }
Ejemplo n.º 2
0
 static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
 {
     FormError error = new FormError();
     error.Exception = e.Exception;
     error.ShowDialog();
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Invoked (but back on the UI thread) on completeion of the solver
        /// </summary>
        private void SolverComplete()
        {
            try
            {
                if (lastException != null)
                {
                    FormError error = new FormError();
                    error.Exception = lastException;
                    error.ShowDialog();
                    return;
                }

                if (solver == null) return; // Thread Abort.

                // Found a solutions?
                if (solverEvalStatus == EvalStatus.CompleteSolution)
                {
                    DialogResult result = MessageBox.Show(
                        "Solution found, do you want to save it? This will also include a report in the description.",
                        "Solution Found", MessageBoxButtons.YesNo);
                    if (result == DialogResult.Yes)
                    {

                        Solution sol = new Solution(Map, Map.Map.Player);
                        sol.Details = new GenericDescription();
                        sol.Details.Name = "SokoSolve Solution";
                        sol.Details.Author = new GenericDescriptionAuthor();
                        sol.Details.Author.Name = ProfileController.Current.UserName;
                        sol.Details.Author.Email = ProfileController.Current.UserEmail;
                        sol.Details.Author.Homepage = ProfileController.Current.UserHomepage;
                        sol.Details.License = ProfileController.Current.UserLicense;
                        sol.Details.Date = DateTime.Now;
                        sol.Details.DateSpecified = true;

                        // Build a description
                        SolverLabelList labels = solver.Stats.GetDisplayData();
                        labels.Add("Machine", string.Format("{0} Running {1}.", DebugHelper.GetCPUDescription(), Environment.OSVersion));
                        labels.Add("SokoSolve", Program.GetVersionString());
                        sol.Details.Description = labels.ToHTML(null, "tabledata");

                        Path path = solver.Strategy.BuildPath(solver.Evaluator.Solutions[0].Data);
                        sol.Set(path);
                        Map.Solutions.Add(sol);
                    }
                }
                else
                {
                    MessageBox.Show("Solver failed: " + solverEvalStatus.ToString(), "No Solution Found",
                                    MessageBoxButtons.OK);
                }

                // Write a solver log report
                BuildSolverLogReport();

                complete = true;
                timer.Enabled = false;
                worker = null;
                UpdateStatus();
            }
            catch (Exception ex)
            {
                lastException = ex;
                FormError error = new FormError();
                error.Exception = lastException;
                error.ShowDialog();
                return;
            }
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Display any errors in the Error form
 /// </summary>
 /// <param name="Context"></param>
 /// <param name="ex"></param>
 public void HandleGameException(string Context, Exception ex)
 {
     FormError error = new FormError();
     error.Exception = ex;
     error.ShowDialog();
 }
Ejemplo n.º 5
0
 private void webBrowser_Navigating(object sender, WebBrowserNavigatingEventArgs e)
 {
     try
     {
         if (e.Url.Scheme == "app")
         {
             e.Cancel = true;
             if (OnCommand != null)
             {
                 OnCommand(this, new UIBrowserEvent(this, e.Url));
             }
         }
     }
     catch(Exception ex)
     {
         e.Cancel = true;
         FormError error = new FormError();
         error.Exception = ex;
         error.ShowDialog();
     }
 }