InitLocalEngine() public static method

public static InitLocalEngine ( ) : void
return void
Beispiel #1
0
        private void _OnUseLocalEngineButtonClicked(object obj, EventArgs args)
        {
            Trace.Call(obj, args);

            try {
                Gtk.MessageDialog md = new Gtk.MessageDialog(null, Gtk.DialogFlags.Modal,
                                                             Gtk.MessageType.Warning, Gtk.ButtonsType.YesNo,
                                                             _("Switching to local engine will disconnect you from the current engine!\n" +
                                                               "Are you sure you want to do this?"));
                int result = md.Run();
                md.Destroy();
                if ((Gtk.ResponseType)result == Gtk.ResponseType.Yes)
                {
                    Frontend.DisconnectEngineFromGUI();
                    Frontend.InitLocalEngine();
                    Frontend.ConnectEngineToGUI();
                }
            } catch (Exception ex) {
                Frontend.ShowException(this, ex);
            }
        }
Beispiel #2
0
        protected void OnUseLocalEngineActionActivated(object sender, EventArgs e)
        {
            Trace.Call(sender, e);

            try {
                var dialog = new Gtk.MessageDialog(
                    Parent, Gtk.DialogFlags.Modal,
                    Gtk.MessageType.Warning, Gtk.ButtonsType.YesNo,
                    _("Switching to local engine will disconnect you from the current engine!\n" +
                      "Are you sure you want to do this?")
                    );
                int result = dialog.Run();
                dialog.Destroy();
                if ((Gtk.ResponseType)result == Gtk.ResponseType.Yes)
                {
                    Frontend.DisconnectEngineFromGUI();
                    Frontend.InitLocalEngine();
                    Frontend.ConnectEngineToGUI();
                }
            } catch (Exception ex) {
                Frontend.ShowException(Parent, ex);
            }
        }
Beispiel #3
0
        private void _OnConnectButtonPressed()
        {
            if (_SelectedEngine == null || _SelectedEngine == String.Empty)
            {
                Gtk.MessageDialog md = new Gtk.MessageDialog(this,
                                                             Gtk.DialogFlags.Modal, Gtk.MessageType.Error,
                                                             Gtk.ButtonsType.Close, _("Please select an engine!"));
                md.Run();
                md.Destroy();
                // Re-run the Dialog
                Run();
                return;
            }

            if (_SelectedEngine == "<" + _("Local Engine") + ">")
            {
                Frontend.InitLocalEngine();
                Frontend.ConnectEngineToGUI();
                Destroy();
                return;
            }

            string engine = _SelectedEngine;

            try {
                _EngineManager.Connect(engine);
                var engineVersion   = _EngineManager.EngineVersion;
                var frontendVersion = Frontend.Version;
                if ((engineVersion >= new Version("0.8") &&
                     engineVersion.Major != frontendVersion.Major) ||
                    (engineVersion < new Version("0.8") &&
                     (engineVersion.Major != frontendVersion.Major ||
                      engineVersion.Minor != frontendVersion.Minor)))
                {
                    throw new ApplicationException(String.Format(
                                                       _("Your frontend version ({0}) does not match the engine version ({1})!"),
                                                       Frontend.Version, _EngineManager.EngineVersion));
                }

                Frontend.Session       = _EngineManager.Session;
                Frontend.UserConfig    = _EngineManager.UserConfig;
                Frontend.EngineVersion = _EngineManager.EngineVersion;
                Frontend.ConnectEngineToGUI();
            } catch (Exception ex) {
#if LOG4NET
                _Logger.Error(ex);
#endif
                // clean-up
                try {
                    _EngineManager.Disconnect();
                } catch (Exception disEx) {
#if LOG4NET
                    _Logger.Error(disEx);
#endif
                }

                string error_msg = ex.Message + "\n";
                if (ex.InnerException != null)
                {
                    error_msg += " [" + ex.InnerException.Message + "]\n";
                }

                string msg;
                msg  = _("An error occurred while connecting to the engine!") + "\n\n";
                msg += String.Format(_("Engine URL: {0}") + "\n",
                                     _EngineManager.EngineUrl);

                msg += String.Format(_("Error: {0}"), error_msg);

                Gtk.MessageDialog md = new Gtk.MessageDialog(this, Gtk.DialogFlags.Modal,
                                                             Gtk.MessageType.Error, Gtk.ButtonsType.Close, msg);
                md.Run();
                md.Destroy();

                // Re-run the Dialog
                Run();
            }
        }