コード例 #1
0
ファイル: PreviewForm.cs プロジェクト: ytak01/NBug
        internal void ShowDialog(UIMode uiMode, UIProvider uiProvider)
        {
            var exception =
                new SerializableException(new ArgumentException("Argument exception preview.", new Exception("Inner exception for argument exception.")));
            var report = new Report(exception);

            var consoleOut = new StringWriter();

            Console.SetOut(consoleOut);

            if (uiProvider == UIProvider.Console)
            {
                ConsoleUI.ShowDialog(uiMode, exception, report);
                this.consoleOutputTextBox.Text = consoleOut.ToString();
                this.ShowDialog();
            }
            else if (uiProvider == UIProvider.WinForms)
            {
                WinFormsUI.ShowDialog(uiMode, exception, report);
                this.Close();
            }
            else if (uiProvider == UIProvider.WPF)
            {
                WPFUI.ShowDialog(uiMode, exception, report);
                this.Close();
            }
            else if (uiProvider == UIProvider.Custom)
            {
                CustomUI.ShowDialog(uiMode, exception, report);
                this.Close();
            }
            else
            {
                throw new ArgumentException("Parameter supplied for UIProvider argument is invalid.");
            }
        }
コード例 #2
0
ファイル: API.cs プロジェクト: lexzh/Myproject
 private static extern int SendMessage(IntPtr hWnd, int msg, IntPtr wParam, WinFormsUI.Controls.TVITEM lparam);
コード例 #3
0
 private static void Main(string[] args)
 {
     // Creando un listener para la consola
     CreateConsoleTracing();
     WinFormsUI.MainLoop(args);
 }
コード例 #4
0
ファイル: WinFormsUITests.cs プロジェクト: ytak01/NBug
        public void Minimal()
        {
            var exception = new DummySerializableException();

            WinFormsUI.ShowDialog(UIMode.Minimal, exception, new Report(exception));
        }
コード例 #5
0
        internal static UIDialogResult DisplayBugReportUI(ExceptionThread exceptionThread,
                                                          SerializableException serializableException, Report report)
        {
            if (exceptionThread == ExceptionThread.Task)
            {
                // Do not interfere with the default behaviour for continuation on background thread exceptions. Just log and send'em (no UI...)
                return(new UIDialogResult(ExecutionFlow.ContinueExecution, SendReport.Send));
            }
            if (Settings.UIMode == UIMode.Auto)
            {
                // First of, test to see if the call is from an UI thread and if so, use the same UI type (WinForms, WPF, etc.)
                if (exceptionThread == ExceptionThread.UI_WinForms)
                {
                    return(WinFormsUI.ShowDialog(UIMode.Minimal, serializableException, report));
                }
                if (exceptionThread == ExceptionThread.UI_WPF)
                {
                    return(WPFUI.ShowDialog(UIMode.Minimal, serializableException, report));
                }
                if (exceptionThread == ExceptionThread.Main)
                {
                    // If the call is not from a non-UI thread like the main app thread, it may be from the current appdomain but
                    // the application may still be using an UI. Or it may be coming from an exception filter where UI type is undefined yet.
                    switch (DiscoverUI())
                    {
                    case UIProvider.WinForms:
                        return(WinFormsUI.ShowDialog(UIMode.Minimal, serializableException, report));

                    case UIProvider.WPF:
                        return(WPFUI.ShowDialog(UIMode.Minimal, serializableException, report));

                    case UIProvider.Console:
                        return(ConsoleUI.ShowDialog(UIMode.Minimal, serializableException, report));

                    case UIProvider.Custom:
                        return(CustomUI.ShowDialog(UIMode.Minimal, serializableException, report));

                    default:
                        throw new NBugRuntimeException("UISelector.DiscoverUI() returned an invalid UI type.");
                    }
                }
                throw new NBugRuntimeException(string.Format("Parameter supplied for '{0}' is not valid.",
                                                             typeof(ExceptionThread).Name));
            }
            if (Settings.UIMode == UIMode.None)
            {
                // Do not display an UI for UIMode.None
                if (Settings.ExitApplicationImmediately)
                {
                    return(new UIDialogResult(ExecutionFlow.BreakExecution, SendReport.Send));
                }
                return(new UIDialogResult(ExecutionFlow.ContinueExecution, SendReport.Send));
            }
            if (Settings.UIProvider == UIProvider.Console)
            {
                return(ConsoleUI.ShowDialog(Settings.UIMode, serializableException, report));
            }
            if (Settings.UIProvider == UIProvider.WinForms)
            {
                return(WinFormsUI.ShowDialog(Settings.UIMode, serializableException, report));
            }
            if (Settings.UIProvider == UIProvider.WPF)
            {
                return(WPFUI.ShowDialog(Settings.UIMode, serializableException, report));
            }
            if (Settings.UIProvider == UIProvider.Custom)
            {
                return(CustomUI.ShowDialog(UIMode.Minimal, serializableException, report));
            }
            if (Settings.UIProvider == UIProvider.Auto)
            {
                // In this case, UIProvider = Auto & UIMode != Auto so just discover the UI provider and use the selected UI mode
                switch (DiscoverUI())
                {
                case UIProvider.WinForms:
                    return(WinFormsUI.ShowDialog(Settings.UIMode, serializableException, report));

                case UIProvider.WPF:
                    return(WPFUI.ShowDialog(Settings.UIMode, serializableException, report));

                case UIProvider.Console:
                    return(ConsoleUI.ShowDialog(Settings.UIMode, serializableException, report));

                case UIProvider.Custom:
                    return(CustomUI.ShowDialog(UIMode.Minimal, serializableException, report));

                default:
                    throw new NBugRuntimeException("UISelector.DiscoverUI() returned an invalid UI type.");
                }
            }
            throw NBugConfigurationException.Create(() => Settings.UIProvider,
                                                    "Parameter supplied for settings property is invalid.");
        }
コード例 #6
0
 public CommandStateEventArgs(WinFormsUI.Controls.BrowserCommands commands)
 {
     this._commands = commands;
 }