protected void OnConnectBtnActivated(object sender, EventArgs ev)
        {
            var dialog = new ChooseServerDialog();
            int response = dialog.Run();

            if (response == (int)Gtk.ResponseType.Cancel) {
                dialog.Destroy();
                return;
            }

            var serverHost = dialog.Server;
            string urlHttp80 = string.Format("http://{0}/craftalyst/instance.json", serverHost);
            string urlHttp8080 = string.Format("http://{0}:8080/craftalyst/instance.json", serverHost);
            InstanceDescription instanceDescription = null;

            dialog.Destroy();

            try {
                instanceDescription = DownloadDescription(urlHttp80);
            } catch (Exception) {
                Logger.Debug("Failed to retrieve URL '{0}', this might not be an error.", urlHttp80);
            }

            if (instanceDescription == null) {
                try {
                    instanceDescription = DownloadDescription(urlHttp8080);
                } catch (Exception) {
                    Logger.Debug("Failed to retrieve URL '{0}'", urlHttp8080);
                }
            }

            if (instanceDescription == null) {
                DedicatedLauncher.MessageBox("Failed to connect to Craftalyst server {0}", serverHost);
                return;
            }

            string localId = string.Format("{0}_{1}", serverHost, instanceDescription.Id);
            Instance instance = null;

            try {
                instance = Context.CreateInstance(localId, instanceDescription);
            } catch (Exception e) {
                DedicatedLauncher.MessageBox("Failed to create local instance {0}: "+e.Message);
                Logger.Debug(e);
            }

            if (instance == null) {
                DedicatedLauncher.MessageBox("Failed to create Craftalyst instance!");
                return;
            }

            var installDialog = new InstallationDialog();
            installDialog.Parent = this;
            installDialog.Present();
            var listener = new InstallationDialogStatusListener(installDialog);

            // Run install dialog as a separate thread,
            // and wait until it is done while processing UI events for it

            var thread = new Thread(delegate() {
                instance.Install(listener);
                var mc = instance.CreateMinecraft();
                mc.Setup(listener);
            });
            thread.IsBackground = true;
            thread.Name = "GameSync";
            thread.Start();
            GLib.Timeout.Add(100, delegate() {
                if (!thread.IsAlive) {
                    Gtk.Application.Quit();
                    return false;
                }

                return true;
            });

            DedicatedLauncher.Singleton.RunUx();
            installDialog.Destroy();

            RefreshInstances();
        }
        public void RunNew()
        {
            var instances = Craft.GetInstances();

            if (instances.Count == 0) {
                var dialog = new ChooseServerDialog();

                InstanceDescription instanceDescription = null;

                while (true) {
                    var dialogResult = dialog.Run();
                    if (dialogResult == (int)Gtk.ResponseType.Cancel)
                        throw new CancelException();

                    var serverHost = dialog.Server;
                    string urlHttp80 = string.Format("http://{0}/craftalyst/instance.json", serverHost);
                    string urlHttp8080 = string.Format("http://{0}:8080/craftalyst/instance.json", serverHost);

                    try {
                        instanceDescription = DownloadDescription(urlHttp80);
                    } catch (Exception) {
                        Logger.Debug("Failed to retrieve URL '{0}', this might not be an error.", urlHttp80);
                    }

                    if (instanceDescription == null) {
                        try {
                            instanceDescription = DownloadDescription(urlHttp8080);
                        } catch (Exception) {
                            Logger.Debug("Failed to retrieve URL '{0}'", urlHttp8080);
                        }
                    }

                    if (instanceDescription == null) {
                        MessageBox("Failed to connect to Craftalyst server {0}", serverHost);
                        continue;
                    }

                    string localId = string.Format("{0}_{1}", serverHost, instanceDescription.Id);
                    try {
                        Instance = Craft.CreateInstance(localId, instanceDescription);
                    } catch (Exception e) {
                        MessageBox("Failed to create local instance {0}: "+e.Message);
                        Logger.Debug(e);
                    }

                    if (Instance == null) {
                        MessageBox("Failed to create Craftalyst instance!");

                        return;
                    }

                    break;
                }

                dialog.Destroy();
            } else {
                var dialog = new InstanceSelectionDialog(Craft);

                while (true) {
                    var result = dialog.Run();

                    if (result == (int)Gtk.ResponseType.Cancel)
                        throw new CancelException();

                    Instance = dialog.SelectedInstance;

                    if (Instance == null) {
                        MessageBox("Please select an instance to launch.");
                        continue;
                    }

                    break;
                }

                dialog.Destroy();
            }

            RunInstance();
        }