示例#1
0
 internal HandlersManager(MainAppForm form)
 {
     _form             = form;
     _nodesMap         = new Dictionary <string, TreeNode>(10);
     _loadedAssemblies = new Dictionary <Guid, HandlerAssembly>(5);
     _sessions         = new Dictionary <Guid, List <int> >(10);
 }
示例#2
0
    private static void GoCore(IWin32Window owner, string title, string text, out bool success, Action action,
                               Action cancelAction = null
                               )
    {
        success = false;
        var sw = Stopwatch.StartNew();

        // Try running the action briefly before pulling up the wait form, to avoid a flicker of the wait form for
        // very fast tasks.
        var task = Task.Run(action);

        try {
            task.Wait(millisecondsTimeout: 100);
        } catch (Exception ex) {
            Ui.ShowError(owner, title, ex);
            return;
        }

        if (task.IsCompleted)
        {
            try {
                task.GetAwaiter().GetResult();
            } catch (Exception ex) {
                Ui.ShowError(owner, title, ex);
                return;
            }
        }
        else
        {
            using WaitForm f   = new(title, text, () => task.GetAwaiter().GetResult(), allowCancel : cancelAction != null);
            f.CancelRequested += delegate {
                cancelAction?.Invoke();
            };
            var result = f.ShowDialogWithPositioning(owner);
            if (result == DialogResult.Cancel)
            {
                success = false;
                return;
            }
            if (result != DialogResult.OK)
            {
                Ui.ShowError(owner, title, f.ResultException);
                return;
            }
        }

        success = true;
        MainAppForm?.SetFinished(sw.Elapsed);
        return;
    }
示例#3
0
        public int Main(string[] args)
        {
            Thread.CurrentThread.Name = "Main";
            DebugThreadInterrupter.theInstance.RegisterThread(Thread.CurrentThread);
            MainAppForm mainAppForm = null;

            try
            {
                ParseArgs(args);
                try
                {
                    BuildConfig.Initialize();
                    if (BuildConfig.theConfig.buildConfiguration == "Broken")
                    {
                        throw new ConfigurationException(
                                  "MapCruncher configuration is broken. Please reinstall MapCruncher.");
                    }

                    if (_remoteFoxitServer != null)
                    {
                        int result = _remoteFoxitServer.Run();
                        return(result);
                    }

                    Application.EnableVisualStyles();
                    mainAppForm = new MainAppForm(_startDocumentPath, _renderOnLaunch);
                    mainAppForm.StartUpApplication();
                }
                catch (ConfigurationException ex)
                {
                    D.Say(0, ex.ToString());
                    HTMLMessageBox.Show(ex.Message, "MapCruncher Configuration Problem");
                    int result = 2;
                    return(result);
                }

                Application.Run(mainAppForm);
            }
            finally
            {
                DebugThreadInterrupter.theInstance.Quit();
                if (mainAppForm != null)
                {
                    mainAppForm.UndoConstruction();
                }
            }

            return(_applicationResultCode);
        }
        public Panel CreateOnlineStoragePage(Point location, int width, int height, MainAppForm _form)
        {
            mainForm = _form;

            MainPanel           = new Panel();
            MainPanel.Location  = location;
            MainPanel.Size      = new Size(width, height);
            MainPanel.BackColor = Color.Transparent;

            if (!UserSettings.LoggedOn)
            {
                CreateOfflinePage();
            }
            else
            {
                CreateOnlinePage();
            }

            return(MainPanel);
        }
 public MainAppForm()
 {
     mainAppForm = this;
 }