public static bool ShowReconnectDialog(Gtk.Window parent) { Trace.Call(parent); Gtk.MessageDialog md = new Gtk.MessageDialog(parent, Gtk.DialogFlags.Modal, Gtk.MessageType.Error, Gtk.ButtonsType.OkCancel, _("The frontend has lost the connection to the server.\nDo you want to reconnect now?")); Gtk.ResponseType res = (Gtk.ResponseType)md.Run(); md.Destroy(); if (res != Gtk.ResponseType.Ok) { Quit(); return(false); } while (true) { try { Frontend.ReconnectEngineToGUI(); // yay, we made it _InReconnectHandler = false; break; } catch (Exception e) { #if LOG4NET _Logger.Error("ShowReconnectDialog(): Reconnect failed, exception:", e); #endif var msg = _("Reconnecting to the server has failed.\nDo you want to try again?"); // the parent window is hidden (MainWindow) at this // point thus modal doesn't make sense here md = new Gtk.MessageDialog(parent, Gtk.DialogFlags.DestroyWithParent, Gtk.MessageType.Error, Gtk.ButtonsType.OkCancel, msg); md.SetPosition(Gtk.WindowPosition.CenterAlways); res = (Gtk.ResponseType)md.Run(); md.Destroy(); if (res != Gtk.ResponseType.Ok) { // give up Quit(); return(false); } } } return(true); }
public static bool ShowReconnectDialog(Gtk.Window parent) { Trace.Call(parent); Gtk.MessageDialog md = new Gtk.MessageDialog(parent, Gtk.DialogFlags.Modal, Gtk.MessageType.Error, Gtk.ButtonsType.OkCancel, _("The frontend has lost the connection to the server.\nDo you want to reconnect now?")); Gtk.ResponseType res = (Gtk.ResponseType) md.Run(); md.Destroy(); if (res != Gtk.ResponseType.Ok) { Quit(); return false; } while (true) { try { Frontend.ReconnectEngineToGUI(); // yay, we made it _InReconnectHandler = false; break; } catch (Exception e) { #if LOG4NET _Logger.Error("ShowReconnectDialog(): Reconnect failed, exception:", e); #endif var msg = _("Reconnecting to the server has failed.\nDo you want to try again?"); // the parent window is hidden (MainWindow) at this // point thus modal doesn't make sense here md = new Gtk.MessageDialog(parent, Gtk.DialogFlags.DestroyWithParent, Gtk.MessageType.Error, Gtk.ButtonsType.OkCancel, msg); md.SetPosition(Gtk.WindowPosition.CenterAlways); res = (Gtk.ResponseType) md.Run(); md.Destroy(); if (res != Gtk.ResponseType.Ok) { // give up Quit(); return false; } } } return true; }
public static void ShowException(Gtk.Window parent, Exception ex) { Trace.Call(parent, ex != null ? ex.GetType() : null); if (parent == null) { parent = _MainWindow; } if (!IsGuiThread()) { Gtk.Application.Invoke(delegate { ShowException(parent, ex); }); return; } #if LOG4NET _Logger.Error("ShowException(): Exception:", ex); #endif // HACK: ugly MS .NET throws underlaying SocketException instead of // wrapping those into a nice RemotingException, see: // http://projects.qnetp.net/issues/show/232 if (ex is System.Runtime.Remoting.RemotingException || ex is System.Net.Sockets.SocketException) { if (_InReconnectHandler || _InCrashHandler) { // one reconnect is good enough and a crash we won't survive return; } _InReconnectHandler = true; Gtk.MessageDialog md = new Gtk.MessageDialog(parent, Gtk.DialogFlags.Modal, Gtk.MessageType.Error, Gtk.ButtonsType.OkCancel, _("The frontend has lost the connection to the server.\nDo you want to reconnect now?")); Gtk.ResponseType res = (Gtk.ResponseType) md.Run(); md.Destroy(); if (res == Gtk.ResponseType.Ok) { while (true) { try { Frontend.ReconnectEngineToGUI(); // yay, we made it _InReconnectHandler = false; break; } catch (Exception e) { #if LOG4NET _Logger.Error("ShowException(): Reconnect failed, exception:", e); #endif var msg = _("Reconnecting to the server has failed.\nDo you want to try again?"); // the parent window is hidden (MainWindow) at this // point thus modal doesn't make sense here md = new Gtk.MessageDialog(parent, Gtk.DialogFlags.DestroyWithParent, Gtk.MessageType.Error, Gtk.ButtonsType.OkCancel, msg); md.SetPosition(Gtk.WindowPosition.CenterAlways); res = (Gtk.ResponseType) md.Run(); md.Destroy(); if (res != Gtk.ResponseType.Ok) { // give up Quit(); return; } } } return; } Quit(); return; } if (_InCrashHandler) { // only show not more than one crash dialog, else the user // will not be able to copy/paste the stack trace and stuff return; } _InCrashHandler = true; CrashDialog cd = new CrashDialog(parent, ex); cd.Run(); cd.Destroy(); if (SysDiag.Debugger.IsAttached) { // allow the debugger to examine the situation //SysDiag.Debugger.Break(); // HACK: Break() would be nicer but crashes the runtime throw ex; } Quit(); }