ShowError() публичный статический Метод

public static ShowError ( Gtk parent, Exception ex ) : void
parent Gtk
ex System.Exception
Результат void
Пример #1
0
        protected void OnAddServerActionActivated(object sender, EventArgs e)
        {
            Trace.Call(sender, e);

            ServerDialog dialog = null;

            try {
                var controller = new ServerListController(Frontend.UserConfig);
                dialog = new ServerDialog(Parent, null,
                                          Frontend.Session.GetSupportedProtocols(),
                                          controller.GetNetworks());
                int         res    = dialog.Run();
                ServerModel server = dialog.GetServer();
                if (res != (int)Gtk.ResponseType.Ok)
                {
                    return;
                }

                controller.AddServer(server);
                controller.Save();

                // reload server list in join bar
                JoinWidget.InitNetworks(controller.GetNetworks());
            } catch (InvalidOperationException ex) {
                Frontend.ShowError(Parent, _("Unable to add server: "), ex);
            } catch (Exception ex) {
                Frontend.ShowException(Parent, ex);
            } finally {
                if (dialog != null)
                {
                    dialog.Destroy();
                }
            }
        }
Пример #2
0
        private void _CommandSync(CommandModel cmd)
        {
            if (Frontend.IsLocalEngine)
            {
                return;
            }

            var chatView = ChatViewManager.CurrentChatView;

            ThreadPool.QueueUserWorkItem(delegate {
                try {
                    var oldValue = Frontend.UseLowBandwidthMode;
                    // HACK: force a full sync
                    Frontend.UseLowBandwidthMode = false;
                    chatView.Sync();
                    Frontend.UseLowBandwidthMode = oldValue;

                    Gtk.Application.Invoke(delegate {
                        Frontend.UseLowBandwidthMode = false;
                        chatView.Populate();
                        Frontend.UseLowBandwidthMode = oldValue;
                        chatView.ScrollToEnd();
                    });
                } catch (Exception ex) {
                    Frontend.ShowError(null, ex);
                }
            });
        }
Пример #3
0
        protected virtual void OnTreeViewSelectionChanged(object sender, EventArgs e)
        {
            Trace.Call(sender, e);

            try {
                ServerModel server = GetCurrentServer();
                if (server == null)
                {
                    return;
                }

                f_Widget.Load(server);
                // we are not editing server entries here instead we use
                // whatever values are entered
                f_Widget.ProtocolComboBox.Sensitive = true;
                // this field doesn't make sense here
                f_Widget.NetworkComboBoxEntry.Sensitive = false;
                // only enable the hostname field if there it's not empty, as
                // some protocols don't allow custom hosts, e.g. twitter
                if (!String.IsNullOrEmpty(f_Widget.HostnameEntry.Text))
                {
                    f_Widget.HostnameEntry.Sensitive = true;
                }
            } catch (ApplicationException ex) {
                Frontend.ShowError(this, _("Unable to load server: "), ex);
            } catch (Exception ex) {
                Frontend.ShowException(ex);
            }
        }
Пример #4
0
        protected virtual void OnServerAddButtonClicked(object sender, EventArgs e)
        {
            Trace.Call(sender, e);

            ServerDialog dialog = null;

            try {
                ServerListController controller = new ServerListController(Frontend.UserConfig);
                dialog = new ServerDialog(this, null,
                                          Frontend.Session.GetSupportedProtocols(),
                                          controller.GetNetworks());
                int         res    = dialog.Run();
                ServerModel server = dialog.GetServer();
                if (res != (int)Gtk.ResponseType.Ok)
                {
                    return;
                }

                controller.AddServer(server);
                controller.Save();
            } catch (InvalidOperationException ex) {
                Frontend.ShowError(this, _("Unable to add server: "), ex);
            } catch (Exception ex) {
                Frontend.ShowException(this, ex);
            } finally {
                if (dialog != null)
                {
                    dialog.Destroy();
                }
            }
        }
Пример #5
0
        protected virtual void OnAddButtonClicked(object sender, EventArgs e)
        {
            Trace.Call(sender, e);

            try {
                Add();
            } catch (InvalidOperationException ex) {
                Frontend.ShowError(_Parent, _("Unable to add server: "), ex);
            } catch (Exception ex) {
                Frontend.ShowException(ex);
            }
        }
Пример #6
0
        protected virtual void OnOpenLogChatMenuItemActivated(object sender, EventArgs e)
        {
            Trace.Call(sender, e);

            try {
                ThreadPool.QueueUserWorkItem(delegate {
                    try {
                        SysDiag.Process.Start(_Notebook.CurrentChatView.ChatModel.LogFile);
                    } catch (Exception ex) {
                        Frontend.ShowError(this, ex);
                    }
                });
            } catch (Exception ex) {
                Frontend.ShowException(this, ex);
            }
        }
Пример #7
0
        protected void OnOpenLogActionActivated(object sender, EventArgs e)
        {
            Trace.Call(sender, e);

            try {
                var logFile = ChatViewManager.CurrentChatView.ChatModel.LogFile;
                ThreadPool.QueueUserWorkItem(delegate {
                    try {
                        SysDiag.Process.Start(logFile);
                    } catch (Exception ex) {
                        Frontend.ShowError(Parent, ex);
                    }
                });
            } catch (Exception ex) {
                Frontend.ShowException(Parent, ex);
            }
        }
Пример #8
0
        protected virtual void OnLoggingOpenButtonClicked(object sender, EventArgs e)
        {
            Trace.Call(sender, e);

            ThreadPool.QueueUserWorkItem(delegate {
                try {
                    var logPath = Platform.LogPath;
                    if (!Directory.Exists(logPath))
                    {
                        Directory.CreateDirectory(logPath);
                    }
                    Process.Start(logPath);
                } catch (Exception ex) {
                    Frontend.ShowError(Parent, ex);
                }
            });
        }
Пример #9
0
        protected virtual void OnTreeViewRowActivated(object sender, Gtk.RowActivatedArgs e)
        {
            Trace.Call(sender, e);

            try {
                ServerModel server = GetCurrentServer();
                if (server == null)
                {
                    return;
                }

                Edit(server);
            } catch (ApplicationException ex) {
                Frontend.ShowError(_Parent, _("Unable to edit server: "), ex);
            } catch (Exception ex) {
                Frontend.ShowException(ex);
            }
        }
Пример #10
0
        protected virtual void OnFindButtonClicked(object sender, System.EventArgs e)
        {
            Trace.Call(sender, e);

            try {
                string nameFilter = f_NameEntry.Text.Trim();
                if (!(Frontend.EngineVersion >= new Version("0.8.1")) &&
                    String.IsNullOrEmpty(nameFilter))
                {
                    Gtk.MessageDialog md = new Gtk.MessageDialog(
                        this,
                        Gtk.DialogFlags.Modal,
                        Gtk.MessageType.Warning,
                        Gtk.ButtonsType.YesNo,
                        _("Searching for group chats without a filter is not " +
                          "recommended.  This may take a while, or may not " +
                          "work at all.\n" +
                          "Do you wish to continue?")
                        );
                    int result = md.Run();
                    md.Destroy();
                    if (result != (int)Gtk.ResponseType.Yes)
                    {
                        return;
                    }
                }

                f_ListStore.Clear();
                CancelFindThread();

                GroupChatModel filter = new GroupChatModel(null, nameFilter, null);
                f_FindThread = new Thread(new ThreadStart(delegate {
                    try {
                        Gtk.Application.Invoke(delegate {
                            GdkWindow.Cursor = new Gdk.Cursor(Gdk.CursorType.Watch);
                        });

                        IList <GroupChatModel> chats = f_ProtocolManager.FindGroupChats(filter);

                        Gtk.Application.Invoke(delegate {
                            Gdk.Color bgColor = f_TreeView.Style.Background(Gtk.StateType.Normal);
                            foreach (GroupChatModel chat in chats)
                            {
                                f_ListStore.AppendValues(
                                    chat,
                                    chat.PersonCount,
                                    chat.Name,
                                    PangoTools.ToMarkup(chat.Topic, bgColor)
                                    );
                            }
                        });
                    } catch (ThreadAbortException) {
#if LOG4NET
                        f_Logger.Debug("FindThread aborted");
#endif
                        Thread.ResetAbort();
                    } catch (Exception ex) {
                        Frontend.ShowError(this, _("Error while fetching the list of group chats from the server."), ex);
                    } finally {
                        Gtk.Application.Invoke(delegate {
                            // if the dialog is gone the GdkWindow might be destroyed already
                            if (GdkWindow != null)
                            {
                                GdkWindow.Cursor = null;
                            }
                        });
                    }
                }));
                f_FindThread.IsBackground = true;
                f_FindThread.Start();
            } catch (Exception ex) {
                Frontend.ShowException(ex);
            }
        }