Commit 9cfd1d4

mo khan <mo@mokhan.ca>
2010-02-07 02:58:51
added an error window for when errors occur.
1 parent cc4fec8
Changed files (6)
product/client/presentation.windows/bootstrappers/Bootstrapper.cs
@@ -0,0 +1,55 @@
+using System.Collections.Generic;
+using System.ComponentModel;
+using Autofac.Builder;
+using Gorilla.Commons.Infrastructure.Container;
+using Gorilla.Commons.Infrastructure.Logging;
+using gorilla.commons.infrastructure.thirdparty.Autofac;
+using gorilla.commons.infrastructure.thirdparty.Log4Net;
+using gorilla.commons.utility;
+using MoMoney.Service.Infrastructure.Eventing;
+using MoMoney.Service.Infrastructure.Threading;
+using presentation.windows.commands;
+using presentation.windows.presenters;
+using presentation.windows.views;
+
+namespace presentation.windows.bootstrappers
+{
+    static public class Bootstrapper
+    {
+        static public ShellWindow create_window()
+        {
+            var builder = new ContainerBuilder();
+            var shell_window = new ShellWindow();
+            builder.Register(x => shell_window).SingletonScoped();
+            builder.Register(x => shell_window).As<RegionManager>().SingletonScoped();
+
+            //needs startups
+            builder.Register<ComposeShell>().As<NeedStartup>();
+
+            // infrastructure
+            builder.Register<Log4NetLogFactory>().As<LogFactory>().SingletonScoped();
+
+            // presentation infrastructure
+            builder.Register<WpfApplicationController>().As<ApplicationController>().SingletonScoped();
+            builder.Register<WpfPresenterFactory>().As<PresenterFactory>().SingletonScoped();
+            builder.Register<SynchronizedEventAggregator>().As<EventAggregator>().SingletonScoped();
+            builder.Register(x => AsyncOperationManager.SynchronizationContext);
+
+            // presenters
+            builder.Register<StatusBarPresenter>().SingletonScoped();
+            builder.Register<CompensationPresenter>();
+            builder.Register<AddFamilyMemberPresenter>();
+
+            // commanding
+            builder.Register<ContainerCommandBuilder>().As<CommandBuilder>().SingletonScoped();
+            builder.Register<AsynchronousCommandProcessor>().As<CommandProcessor>().SingletonScoped();
+            builder.Register<AddFamilyMember>();
+
+            Resolve.initialize_with(new AutofacDependencyRegistryBuilder(builder).build());
+            Resolve.the<IEnumerable<NeedStartup>>().each(x => x.run());
+            Resolve.the<CommandProcessor>().run();
+
+            return shell_window;
+        }
+    }
+}
\ No newline at end of file
product/client/presentation.windows/commands/AddFamilyMember.cs
@@ -1,5 +1,4 @@
 using System.Threading;
-using Gorilla.Commons.Infrastructure.Logging;
 using gorilla.commons.utility;
 using presentation.windows.commands.dto;
 
@@ -9,7 +8,6 @@ namespace presentation.windows.commands
     {
         public void run_against(FamilyMemberToAdd item)
         {
-            this.log().debug("adding family member");
             Thread.Sleep(5000);
         }
     }
product/client/presentation.windows/views/ErrorWindow.xaml
@@ -0,0 +1,11 @@
+<Window x:Class="presentation.windows.views.ErrorWindow"
+    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+    Title="Oops... I'm sorry but an un-expected error occurred." Width="600">
+    <DockPanel>
+        <Label DockPanel.Dock="Top" Content="{Binding Message}" />
+        <Expander>
+            <TextBlock Text="{Binding StackTrace}"></TextBlock>
+        </Expander>
+    </DockPanel>
+</Window>
product/client/presentation.windows/views/ErrorWindow.xaml.cs
@@ -0,0 +1,26 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Shapes;
+
+namespace presentation.windows.views
+{
+    /// <summary>
+    /// Interaction logic for ErrorWindow.xaml
+    /// </summary>
+    public partial class ErrorWindow : Window
+    {
+        public ErrorWindow()
+        {
+            InitializeComponent();
+        }
+    }
+}
product/client/presentation.windows/presentation.windows.csproj
@@ -72,6 +72,10 @@
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
     </Page>
+    <Page Include="views\ErrorWindow.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
     <Page Include="views\ShellWIndow.xaml">
       <Generator>MSBuild:Compile</Generator>
       <SubType>Designer</SubType>
@@ -87,6 +91,7 @@
   </ItemGroup>
   <ItemGroup>
     <Compile Include="ApplicationController.cs" />
+    <Compile Include="bootstrappers\Bootstrapper.cs" />
     <Compile Include="commands\ParameterizedCommandBuilder.cs" />
     <Compile Include="commands\UpdateOnLongRunningProcess.cs" />
     <Compile Include="Dialog.cs" />
@@ -130,6 +135,9 @@
     <Compile Include="Tab.cs" />
     <Compile Include="TabPresenter.cs" />
     <Compile Include="presenters\IObservableCommand.cs" />
+    <Compile Include="views\ErrorWindow.xaml.cs">
+      <DependentUpon>ErrorWindow.xaml</DependentUpon>
+    </Compile>
     <Compile Include="views\MainMenu.cs" />
     <Compile Include="views\MenuItemExtensions.cs" />
     <Compile Include="presenters\SimpleCommand.cs" />
product/client/presentation.windows/Program.cs
@@ -1,19 +1,7 @@
 using System;
-using System.Collections.Generic;
-using System.ComponentModel;
 using System.Security.Principal;
 using System.Windows;
-using Autofac.Builder;
-using Gorilla.Commons.Infrastructure.Container;
-using Gorilla.Commons.Infrastructure.Logging;
-using gorilla.commons.infrastructure.thirdparty.Autofac;
-using gorilla.commons.infrastructure.thirdparty.Log4Net;
-using gorilla.commons.utility;
-using MoMoney.Service.Infrastructure.Eventing;
-using MoMoney.Service.Infrastructure.Threading;
 using presentation.windows.bootstrappers;
-using presentation.windows.commands;
-using presentation.windows.presenters;
 using presentation.windows.views;
 
 namespace presentation.windows
@@ -27,46 +15,10 @@ namespace presentation.windows
             var application = new Application();
             application.DispatcherUnhandledException += (o, e) =>
             {
-                MessageBox.Show(e.to_string());
+                new ErrorWindow {DataContext = e.Exception}.ShowDialog();
             };
             application.ShutdownMode = ShutdownMode.OnMainWindowClose;
-            application.Run(create_window());
-        }
-
-        static ShellWindow create_window()
-        {
-            var builder = new ContainerBuilder();
-            var shell_window = new ShellWindow();
-            builder.Register(x => shell_window).SingletonScoped();
-            builder.Register(x => shell_window).As<RegionManager>().SingletonScoped();
-
-            //needs startups
-            builder.Register<ComposeShell>().As<NeedStartup>();
-
-            // infrastructure
-            builder.Register<Log4NetLogFactory>().As<LogFactory>().SingletonScoped();
-
-            // presentation infrastructure
-            builder.Register<WpfApplicationController>().As<ApplicationController>().SingletonScoped();
-            builder.Register<WpfPresenterFactory>().As<PresenterFactory>().SingletonScoped();
-            builder.Register<SynchronizedEventAggregator>().As<EventAggregator>().SingletonScoped();
-            builder.Register(x => AsyncOperationManager.SynchronizationContext);
-
-            // presenters
-            builder.Register<StatusBarPresenter>().SingletonScoped();
-            builder.Register<CompensationPresenter>();
-            builder.Register<AddFamilyMemberPresenter>();
-
-            // commanding
-            builder.Register<ContainerCommandBuilder>().As<CommandBuilder>().SingletonScoped();
-            builder.Register<AsynchronousCommandProcessor>().As<CommandProcessor>().SingletonScoped();
-            builder.Register<AddFamilyMember>();
-
-            Resolve.initialize_with(new AutofacDependencyRegistryBuilder(builder).build());
-            Resolve.the<IEnumerable<NeedStartup>>().each(x => x.run());
-            Resolve.the<CommandProcessor>().run();
-
-            return shell_window;
+            application.Run(Bootstrapper.create_window());
         }
     }
 }
\ No newline at end of file