main
 1using System;
 2using System.Windows.Forms;
 3using momoney.presentation.presenters;
 4using momoney.presentation.views;
 5using MoMoney.Presentation.Winforms.Resources;
 6
 7namespace MoMoney.Presentation.Winforms.Views
 8{
 9    public partial class UnhandledErrorView : ApplicationWindow, IUnhandledErrorView
10    {
11        ControlAction<EventArgs> close_action = x => { };
12        ControlAction<EventArgs> restart_action = x => { };
13        readonly IWin32Window window;
14
15        public UnhandledErrorView(IWin32Window window)
16        {
17            InitializeComponent();
18            ux_image.Image = ApplicationImages.Splash;
19            ux_image.SizeMode = PictureBoxSizeMode.StretchImage;
20            titled("Aw snap... something went wrong!")
21                .create_tool_tip_for("Ignore", "Ignore the error and continue working.", close_button)
22                .create_tool_tip_for("Restart", "Discard any unsaved changes and restart the application.",
23                                     restart_button);
24
25            close_button.Click += (sender, args) => close_action(args);
26            restart_button.Click += (sender, args) => restart_action(args);
27            this.window = window;
28        }
29
30        public void attach_to(IUnhandledErrorPresenter presenter)
31        {
32            close_action = x => Close();
33            restart_action = x => presenter.restart_application();
34        }
35
36        public void display(Exception exception)
37        {
38            ux_message.Text = exception.ToString();
39            ShowDialog(window);
40        }
41    }
42}