コード例 #1
0
        public static void Present(this UserPresentableException e, object uiContext = null)
        {
            Log.Error(TAG, $"{e.Message} ({e.Details})", e.InnerException ?? e);

            MainThread.Ensure();

            var window = new MetroDialogWindow {
                Title   = e.Message,
                Message = e.Details,
                AffirmativeButtonText = Catalog.GetString("OK")
            };

            var ownerWindow = uiContext as Window;

            if (ownerWindow == null)
            {
                window.Owner = ownerWindow;
                window.Width = 400;
                window.WindowStartupLocation = WindowStartupLocation.CenterScreen;
            }
            else
            {
                window.Width = ownerWindow.Width;
                window.WindowStartupLocation = WindowStartupLocation.CenterOwner;
            }

            window.ShowDialog();
        }
コード例 #2
0
        public static void Present(this UserPresentableException e, object uiContext = null)
        {
            Log.Error(TAG, $"{e.Message} ({e.Details})", e.InnerException ?? e);

            MainThread.Ensure();

            uiContext = uiContext ?? e.UIContext;

            var window = (uiContext as NSViewController)?.View?.Window
                         ?? (uiContext as NSView)?.Window
                         ?? (uiContext as NSWindowController)?.Window
                         ?? uiContext as NSWindow;

            var alert = new NSAlert {
                AlertStyle      = NSAlertStyle.Critical,
                MessageText     = e.Message,
                InformativeText = e.Details
            };

            if (window == null)
            {
                alert.RunModal();
            }
            else
            {
                alert.BeginSheet(window, resp => { });
            }
        }
コード例 #3
0
ファイル: Error.cs プロジェクト: pietervp/workbooks-1
 public Error(UserPresentableException upe) : base("error.upe")
 {
     CallerName = upe.CallerMemberName;
     CallerFile = upe.CallerFilePath;
     CallerLine = upe.CallerLineNumber;
 }
コード例 #4
0
ファイル: Message.cs プロジェクト: MrGeoSerge/workbooks-1
 public static Message CreateErrorAlert(UserPresentableException exception)
 => Create(
     MessageKind.Alert,
     MessageSeverity.Error,
     exception.Message,
     exception.Details);
コード例 #5
0
 protected override void PresentError(UserPresentableException upe)
 => upe.Present(viewController);