当前位置: 首页>>代码示例>>C#>>正文


C# Gtk.MessageDialog.SetPosition方法代码示例

本文整理汇总了C#中Gtk.MessageDialog.SetPosition方法的典型用法代码示例。如果您正苦于以下问题:C# Gtk.MessageDialog.SetPosition方法的具体用法?C# Gtk.MessageDialog.SetPosition怎么用?C# Gtk.MessageDialog.SetPosition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Gtk.MessageDialog的用法示例。


在下文中一共展示了Gtk.MessageDialog.SetPosition方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ShowReconnectDialog

        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;
        }
开发者ID:knocte,项目名称:smuxi,代码行数:45,代码来源:Frontend.cs

示例2: ShowException

        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();
        }
开发者ID:txdv,项目名称:smuxi,代码行数:92,代码来源:Frontend.cs


注:本文中的Gtk.MessageDialog.SetPosition方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。