Commit 630dc3b

mo khan <mo@mokhan.ca>
2010-02-03 02:51:22
got all the unit tests passing, and the app running from visual studio.
1 parent 1132d03
product/client/boot/boot/container/registration/WireUpThePresentationModules.cs
@@ -11,6 +11,7 @@ using MoMoney.Presentation.Model.Menu.File;
 using MoMoney.Presentation.Model.Menu.Help;
 using MoMoney.Presentation.Model.Menu.window;
 using momoney.presentation.presenters;
+using momoney.presentation.views;
 using MoMoney.Presentation.Views;
 using MoMoney.Service.Infrastructure.Eventing;
 
@@ -27,7 +28,7 @@ namespace MoMoney.boot.container.registration
 
         public void run(Assembly item)
         {
-            Func<IApplicationController> target = () => new ApplicationController(Lazy.load<Shell>(), Lazy.load<PresenterFactory>(), Lazy.load<EventAggregator>());
+            Func<IApplicationController> target = () => new ApplicationController(Lazy.load<Shell>(), Lazy.load<PresenterFactory>(), Lazy.load<EventAggregator>(), Lazy.load<ViewFactory>());
             registry.proxy<IApplicationController, SynchronizedConfiguration<IApplicationController>>(target.memorize());
 
             registry.transient(typeof (IRunThe<>), typeof (RunThe<>));
product/client/boot/Modules/ApplicationShellModule.cs
@@ -1,4 +1,3 @@
-using momoney.modules;
 using MoMoney.Presentation;
 using momoney.presentation.presenters;
 using MoMoney.Presentation.Presenters;
@@ -21,6 +20,7 @@ namespace MoMoney.Modules
             command.run<StatusBarPresenter>();
             command.run<TaskTrayPresenter>();
             command.run<MainMenuPresenter>();
+            command.run<UnhandledErrorPresenter>();
         }
     }
 }
\ No newline at end of file
product/client/presentation/Core/ApplicationController.cs
@@ -1,31 +1,44 @@
+using momoney.presentation.views;
 using MoMoney.Presentation.Views;
 using MoMoney.Service.Infrastructure.Eventing;
 
 namespace MoMoney.Presentation.Core
 {
-    public interface IApplicationController
-    {
-        void run<Presenter>() where Presenter : Core.Presenter;
-    }
-
     public class ApplicationController : IApplicationController
     {
         Shell shell;
         PresenterFactory presenter_factory;
         EventAggregator broker;
+        ViewFactory view_factory;
 
-        public ApplicationController(Shell shell, PresenterFactory presenter_factory, EventAggregator broker)
+        public ApplicationController(Shell shell, PresenterFactory presenter_factory, EventAggregator broker, ViewFactory view_factory)
         {
             this.presenter_factory = presenter_factory;
+            this.view_factory = view_factory;
             this.broker = broker;
             this.shell = shell;
         }
 
-        public void run<Presenter>() where Presenter : Core.Presenter
+        public void run<TPresenter>() where TPresenter : Presenter
+        {
+            var presenter = presenter_factory.create<TPresenter>();
+            broker.subscribe(presenter);
+            view_factory.create_for<TPresenter>().attach_to(presenter);
+            presenter.present(shell);
+        }
+
+        public void launch_dialog<TPresenter>() where TPresenter : DialogPresenter
         {
-            var presenter = presenter_factory.create<Presenter>();
+            var presenter = presenter_factory.create<TPresenter>();
             broker.subscribe(presenter);
+            var view = view_factory.create_for<TPresenter>() as Dialog<TPresenter>;
+            view.attach_to(presenter);
+            presenter.close = () =>
+            {
+                view.Close();
+            };
             presenter.present(shell);
+            view.show_dialog(shell);
         }
     }
 }
\ No newline at end of file
product/client/presentation/Core/ApplicationControllerSpecs.cs
@@ -1,40 +1,45 @@
-using developwithpassion.bdd.contexts;
-using Gorilla.Commons.Testing;
-using MoMoney.Presentation.Views;
-
-namespace MoMoney.Presentation.Core
-{
-    public class ApplicationControllerSpecs
-    {
-        [Concern(typeof (ApplicationController))]
-        public abstract class concern : concerns_for<IApplicationController, ApplicationController>
-        {
-            context c = () =>
-                        {
-                            presenter_factory = the_dependency<PresenterFactory>();
-                            shell = the_dependency<Shell>();
-                        };
-
-            static protected Shell shell;
-            static protected PresenterFactory presenter_factory;
-        }
-
-        public class when_the_application_controller_is_asked_to_run_a_presenter : concern
-        {
-            context c = () =>
-                        {
-                            implementation_of_the_presenter = an<Presenter>();
-                            presenter_factory
-                                .is_told_to(r => r.create<Presenter>())
-                                .it_will_return(implementation_of_the_presenter);
-                        };
-
-            because b = () => sut.run<Presenter>();
-
-            it should_initialize_the_presenter_to_run =
-                () => implementation_of_the_presenter.was_told_to(p => p.present(shell));
-
-            static Presenter implementation_of_the_presenter;
-        }
-    }
+using developwithpassion.bdd.contexts;
+using Gorilla.Commons.Testing;
+using momoney.presentation.views;
+
+namespace MoMoney.Presentation.Core
+{
+    public class ApplicationControllerSpecs
+    {
+        [Concern(typeof (ApplicationController))]
+        public abstract class concern : concerns_for<IApplicationController, ApplicationController>
+        {
+            context c = () =>
+            {
+                presenter_factory = the_dependency<PresenterFactory>();
+                view_factory = the_dependency<ViewFactory>();
+                shell = the_dependency<Shell>();
+            };
+
+            static protected Shell shell;
+            static protected PresenterFactory presenter_factory;
+            static protected ViewFactory view_factory;
+        }
+
+        public class when_the_application_controller_is_asked_to_run_a_presenter : concern
+        {
+            context c = () =>
+            {
+                implementation_of_the_presenter = an<Presenter>();
+                view = an<View<Presenter>>();
+                presenter_factory
+                    .is_told_to(r => r.create<Presenter>())
+                    .it_will_return(implementation_of_the_presenter);
+                view_factory.is_told_to(x => x.create_for<Presenter>()).it_will_return(view);
+            };
+
+            because b = () => sut.run<Presenter>();
+
+            it should_initialize_the_presenter_to_run =
+                () => implementation_of_the_presenter.was_told_to(p => p.present(shell));
+
+            static Presenter implementation_of_the_presenter;
+            static View<Presenter> view;
+        }
+    }
 }
\ No newline at end of file
product/client/presentation/Core/CachedPresenterFactory.cs
@@ -5,20 +5,15 @@ namespace MoMoney.Presentation.Core
     public class CachedPresenterFactory : PresenterFactory
     {
         Registry<Presenter> presenters;
-        ViewFactory view_factory;
 
-        public CachedPresenterFactory(Registry<Presenter> presenters, ViewFactory view_factory)
+        public CachedPresenterFactory(Registry<Presenter> presenters)
         {
             this.presenters = presenters;
-            this.view_factory = view_factory;
         }
 
         public TPresenter create<TPresenter>() where TPresenter : Presenter
         {
-            var presenter = presenters.find_an_implementation_of<Presenter, TPresenter>();
-            var view = view_factory.create_for<TPresenter>();
-            view.attach_to(presenter);
-            return presenter;
+            return presenters.find_an_implementation_of<Presenter, TPresenter>();
         }
     }
 }
\ No newline at end of file
product/client/presentation/Core/DialogPresenter.cs
@@ -1,4 +1,9 @@
-namespace MoMoney.Presentation.Core
-{
-    public interface DialogPresenter : Presenter { }
+using System;
+
+namespace MoMoney.Presentation.Core
+{
+    public interface DialogPresenter : Presenter
+    {
+        Action close { set; }
+    }
 }
\ No newline at end of file
product/client/presentation/Core/IApplicationController.cs
@@ -0,0 +1,8 @@
+namespace MoMoney.Presentation.Core
+{
+    public interface IApplicationController
+    {
+        void run<TPresenter>() where TPresenter : Presenter;
+        void launch_dialog<TPresenter>() where TPresenter : DialogPresenter;
+    }
+}
\ No newline at end of file
product/client/presentation/Core/Presenter.cs
@@ -1,4 +1,4 @@
-using MoMoney.Presentation.Views;
+using momoney.presentation.views;
 
 namespace MoMoney.Presentation.Core
 {
product/client/presentation/Model/Menu/File/CloseWindowCommand.cs
@@ -1,5 +1,5 @@
 using gorilla.commons.utility;
-using MoMoney.Presentation.Views;
+using momoney.presentation.views;
 
 namespace momoney.presentation.model.menu.file
 {
@@ -19,4 +19,4 @@ namespace momoney.presentation.model.menu.file
             shell.close_the_active_window();
         }
     }
-}
\ No newline at end of file
+}
product/client/presentation/Model/Menu/File/SaveChangesPresenter.cs
@@ -14,9 +14,7 @@ namespace MoMoney.Presentation.Model.Menu.File
         readonly ISaveAsCommand save_as_command;
         ISaveChangesCallback callback;
 
-        protected SaveChangesPresenter()
-        {
-        }
+        protected SaveChangesPresenter() {}
 
         public SaveChangesPresenter(IProjectController current_project, ISaveChangesView view, ISaveAsCommand save_as_command)
         {
@@ -66,5 +64,7 @@ namespace MoMoney.Presentation.Model.Menu.File
         {
             callback.cancelled();
         }
+
+        public Action close { get; set; }
     }
 }
\ No newline at end of file
product/client/presentation/Model/Menu/Help/HelpMenu.cs
@@ -1,53 +1,53 @@
-using System.Collections.Generic;
-using MoMoney.Presentation.model.menu.help;
-using momoney.presentation.presenters;
-using MoMoney.Presentation.Presenters;
-using MoMoney.Presentation.Winforms.Resources;
-
-namespace MoMoney.Presentation.Model.Menu.Help
-{
-    public interface IHelpMenu : ISubMenu
-    {
-    }
-
-    public class HelpMenu : SubMenu, IHelpMenu
-    {
-        readonly IRunPresenterCommand command;
-
-        public HelpMenu(IRunPresenterCommand command)
-        {
-            this.command = command;
-        }
-
-        public override string name
-        {
-            get { return "&Help"; }
-        }
-
-        public override IEnumerable<IMenuItem> all_menu_items()
-        {
-            yield return Create
-                .a_menu_item()
-                .named("&About")
-                .that_executes<IDisplayInformationAboutTheApplication>()
-                .represented_by(ApplicationIcons.About)
-                .build();
-
-            yield return Create
-                .a_menu_item()
-                .named("Check For Updates...")
-                .represented_by(ApplicationIcons.Update)
-                .that_executes(() => command.run<CheckForUpdatesPresenter>())
-                .build();
-
-            yield return Create.a_menu_item_separator();
-
-            yield return Create
-                .a_menu_item()
-                .named("View Log File")
-                .represented_by(ApplicationIcons.ViewLog)
-                .that_executes(() => command.run<LogFilePresenter>())
-                .build();
-        }
-    }
+using System.Collections.Generic;
+using MoMoney.Presentation.Core;
+using MoMoney.Presentation.model.menu.help;
+using momoney.presentation.presenters;
+using MoMoney.Presentation.Winforms.Resources;
+
+namespace MoMoney.Presentation.Model.Menu.Help
+{
+    public interface IHelpMenu : ISubMenu
+    {
+    }
+
+    public class HelpMenu : SubMenu, IHelpMenu
+    {
+        readonly IApplicationController command;
+
+        public HelpMenu(IApplicationController command)
+        {
+            this.command = command;
+        }
+
+        public override string name
+        {
+            get { return "&Help"; }
+        }
+
+        public override IEnumerable<IMenuItem> all_menu_items()
+        {
+            yield return Create
+                .a_menu_item()
+                .named("&About")
+                .that_executes<IDisplayInformationAboutTheApplication>()
+                .represented_by(ApplicationIcons.About)
+                .build();
+
+            yield return Create
+                .a_menu_item()
+                .named("Check For Updates...")
+                .represented_by(ApplicationIcons.Update)
+                .that_executes(() => command.launch_dialog<CheckForUpdatesPresenter>())
+                .build();
+
+            yield return Create.a_menu_item_separator();
+
+            yield return Create
+                .a_menu_item()
+                .named("View Log File")
+                .represented_by(ApplicationIcons.ViewLog)
+                .that_executes(() => command.run<LogFilePresenter>())
+                .build();
+        }
+    }
 }
\ No newline at end of file
product/client/presentation/Presenters/AddNewIncomePresenterSpecs.cs
@@ -2,7 +2,8 @@ using System.Collections.Generic;
 using developwithpassion.bdd.contexts;
 using Gorilla.Commons.Testing;
 using MoMoney.DTO;
-using MoMoney.Presentation.Presenters;
+using MoMoney.Presentation.Presenters;
+using momoney.presentation.views;
 using MoMoney.Presentation.Views;
 using MoMoney.Service.Contracts.Application;
 
product/client/presentation/Presenters/ApplicationMenuPresenter.cs
@@ -2,7 +2,7 @@ using System.Windows.Forms;
 using gorilla.commons.utility;
 using MoMoney.Presentation.Core;
 using MoMoney.Presentation.Model.Menu;
-using MoMoney.Presentation.Views;
+using momoney.presentation.views;
 
 namespace momoney.presentation.presenters
 {
@@ -20,4 +20,4 @@ namespace momoney.presentation.presenters
             shell.region<MenuStrip>(x => registry.all().each(y => y.add_to(x)));
         }
     }
-}
\ No newline at end of file
+}
product/client/presentation/Presenters/ApplicationShellPresenter.cs
@@ -2,7 +2,7 @@ using System;
 using MoMoney.Presentation.Core;
 using momoney.presentation.model.eventing;
 using momoney.presentation.model.menu.file;
-using MoMoney.Presentation.Views;
+using momoney.presentation.views;
 using MoMoney.Service.Infrastructure.Eventing;
 
 namespace momoney.presentation.presenters
@@ -11,13 +11,9 @@ namespace momoney.presentation.presenters
     {
         IExitCommand command;
 
-        Action shutdown = () =>
-                          {
-                          };
+        Action shutdown = () => {};
 
-        protected ApplicationShellPresenter()
-        {
-        }
+        protected ApplicationShellPresenter() {}
 
         public ApplicationShellPresenter(IExitCommand command)
         {
@@ -27,9 +23,9 @@ namespace momoney.presentation.presenters
         public virtual void present(Shell shell)
         {
             shutdown = () =>
-                       {
-                           shell.close_all_windows();
-                       };
+            {
+                shell.close_all_windows();
+            };
         }
 
         public virtual void notify(ClosingProjectEvent message)
product/client/presentation/Presenters/CheckForUpdatesPresenter.cs
@@ -1,65 +1,67 @@
-using Gorilla.Commons.Infrastructure.Logging;
-using gorilla.commons.utility;
-using Gorilla.Commons.Utility;
-using MoMoney.Presentation.Core;
-using MoMoney.Presentation.Presenters;
-using momoney.presentation.views;
-using MoMoney.Presentation.Views;
-using momoney.service.infrastructure.updating;
-
-namespace momoney.presentation.presenters
-{
-    public class CheckForUpdatesPresenter : DialogPresenter, Callback<Percent>
-    {
-        readonly ICheckForUpdatesView view;
-        readonly ICommandPump pump;
-
-        public CheckForUpdatesPresenter(ICheckForUpdatesView view, ICommandPump pump)
-        {
-            this.pump = pump;
-            this.view = view;
-        }
-
-        public void present(Shell shell)
-        {
-            pump.run<ApplicationVersion, IWhatIsTheAvailableVersion>(view);
-            view.display();
-        }
-
-        public void begin_update()
-        {
-            pump.run<IDownloadTheLatestVersion, Callback<Percent>>(this);
-        }
-
-        public void cancel_update()
-        {
-            pump.run<ICancelUpdate>();
-            view.close();
-        }
-
-        public void restart()
-        {
-            pump.run<IRestartCommand>();
-        }
-
-        public void do_not_update()
-        {
-            view.close();
-        }
-
-        public void run(Percent completed)
-        {
-            if (completed.Equals(new Percent(100)))
-            {
-                this.log().debug("completed download");
-                view.update_complete();
-                restart();
-            }
-            else
-            {
-                this.log().debug("completed {0}", completed);
-                view.downloaded(completed);
-            }
-        }
-    }
+using System;
+using Gorilla.Commons.Infrastructure.Logging;
+using gorilla.commons.utility;
+using Gorilla.Commons.Utility;
+using MoMoney.Presentation.Core;
+using MoMoney.Presentation.Presenters;
+using momoney.presentation.views;
+using MoMoney.Presentation.Views;
+using momoney.service.infrastructure.updating;
+
+namespace momoney.presentation.presenters
+{
+    public class CheckForUpdatesPresenter : DialogPresenter, Callback<Percent>
+    {
+        readonly ICheckForUpdatesView view;
+        readonly ICommandPump pump;
+
+        public CheckForUpdatesPresenter(ICheckForUpdatesView view, ICommandPump pump)
+        {
+            this.pump = pump;
+            this.view = view;
+        }
+
+        public void present(Shell shell)
+        {
+            pump.run<ApplicationVersion, IWhatIsTheAvailableVersion>(view);
+        }
+
+        public void begin_update()
+        {
+            pump.run<IDownloadTheLatestVersion, Callback<Percent>>(this);
+        }
+
+        public void cancel_update()
+        {
+            pump.run<ICancelUpdate>();
+            close();
+        }
+
+        public void restart()
+        {
+            pump.run<IRestartCommand>();
+        }
+
+        public void do_not_update()
+        {
+            close();
+        }
+
+        public void run(Percent completed)
+        {
+            if (completed.Equals(new Percent(100)))
+            {
+                this.log().debug("completed download");
+                view.update_complete();
+                //restart();
+            }
+            else
+            {
+                this.log().debug("completed {0}", completed);
+                view.downloaded(completed);
+            }
+        }
+
+        public Action close { get; set; }
+    }
 }
\ No newline at end of file
product/client/presentation/Presenters/CheckForUpdatesPresenterSpecs.cs
@@ -1,77 +1,87 @@
-using developwithpassion.bdd.contexts;
-using Gorilla.Commons.Testing;
-using gorilla.commons.utility;
-using Gorilla.Commons.Utility;
-using MoMoney.Presentation.Presenters;
-using momoney.presentation.views;
-using MoMoney.Presentation.Views;
-using momoney.service.infrastructure.updating;
-
-namespace momoney.presentation.presenters
-{
-    [Concern(typeof (CheckForUpdatesPresenter))]
-    public abstract class behaves_like_check_for_updates_presenter : concerns_for< CheckForUpdatesPresenter>
-    {
-        context c = () =>
-        {
-            view = the_dependency<ICheckForUpdatesView>();
-            pump = the_dependency<ICommandPump>();
-        };
-
-        static protected ICheckForUpdatesView view;
-        static protected ICommandPump pump;
-    }
-
-    public class when_attempting_to_check_for_updates : behaves_like_check_for_updates_presenter
-    {
-        it should_tell_the_view_to_display_the_information_on_the_current_version_of_the_application =
-            () => view.was_told_to(x => x.display());
-
-        it should_go_and_find_out_what_the_latest_version_is =
-            () => pump.was_told_to(x => x.run<ApplicationVersion, IWhatIsTheAvailableVersion>(view));
-
-        context c = () =>
-                    {
-                        shell = an<Shell>();
-                    };
-        because b = () => sut.present(shell);
-        static Shell shell;
-    }
-
-    public class when_initiating_an_update_and_one_is_available : behaves_like_check_for_updates_presenter
-    {
-        it should_start_downloading_the_latest_version_of_the_application =
-            () => pump.was_told_to(x => x.run<IDownloadTheLatestVersion, Callback<Percent>>(sut));
-
-        because b = () => sut.begin_update();
-    }
-
-    public class when_downloading_an_update : behaves_like_check_for_updates_presenter
-    {
-        it should_notify_you_of_the_progress_of_the_update = () => view.was_told_to(x => x.downloaded(50));
-
-        because b = () => sut.run(50);
-    }
-
-    public class when_an_update_is_completed : behaves_like_check_for_updates_presenter
-    {
-        it should_notify_the_view_that_the_update_is_complete = () => view.was_told_to(x => x.update_complete());
-
-        because b = () => sut.run(100);
-    }
-
-    public class when_an_update_is_cancelled : behaves_like_check_for_updates_presenter
-    {
-        it should_stop_downloading_the_latest_update = () => pump.was_told_to(x => x.run<ICancelUpdate>());
-
-        because b = () => sut.cancel_update();
-    }
-
-    public class when_an_update_is_complete_and_the_user_agrees_to_restart_the_application :
-        behaves_like_check_for_updates_presenter
-    {
-        it should_restart_the_application = () => pump.was_told_to(x => x.run<IRestartCommand>());
-
-        because b = () => sut.restart();
-    }
+using developwithpassion.bdd.contexts;
+using Gorilla.Commons.Testing;
+using gorilla.commons.utility;
+using Gorilla.Commons.Utility;
+using MoMoney.Presentation.Presenters;
+using momoney.presentation.views;
+using momoney.service.infrastructure.updating;
+
+namespace momoney.presentation.presenters
+{
+    public class CheckForUpdatesPresentersSpecs
+    {
+        [Concern(typeof (CheckForUpdatesPresenter))]
+        public abstract class concern : concerns_for<CheckForUpdatesPresenter>
+        {
+            context c = () =>
+            {
+                view = the_dependency<ICheckForUpdatesView>();
+                pump = the_dependency<ICommandPump>();
+            };
+
+            because b = () =>
+            {
+                sut.close = () => {};
+            };
+
+            static protected ICheckForUpdatesView view;
+            static protected ICommandPump pump;
+        }
+
+        public class when_attempting_to_check_for_updates : concern
+        {
+            it should_go_and_find_out_what_the_latest_version_is =
+                () => pump.was_told_to(x => x.run<ApplicationVersion, IWhatIsTheAvailableVersion>(view));
+
+            context c = () =>
+            {
+                shell = an<Shell>();
+            };
+
+            because b = () =>
+            {
+                sut.close = () => {};
+                sut.present(shell);
+            };
+
+            static Shell shell;
+        }
+
+        public class when_initiating_an_update_and_one_is_available : concern
+        {
+            it should_start_downloading_the_latest_version_of_the_application =
+                () => pump.was_told_to(x => x.run<IDownloadTheLatestVersion, Callback<Percent>>(sut));
+
+            because b = () => sut.begin_update();
+        }
+
+        public class when_downloading_an_update : concern
+        {
+            it should_notify_you_of_the_progress_of_the_update = () => view.was_told_to(x => x.downloaded(50));
+
+            because b = () => sut.run(50);
+        }
+
+        public class when_an_update_is_completed : concern
+        {
+            it should_notify_the_view_that_the_update_is_complete = () => view.was_told_to(x => x.update_complete());
+
+            because b = () => sut.run(100);
+        }
+
+        public class when_an_update_is_cancelled : concern
+        {
+            it should_stop_downloading_the_latest_update = () => pump.was_told_to(x => x.run<ICancelUpdate>());
+
+            because b = () => sut.cancel_update();
+        }
+
+        public class when_an_update_is_complete_and_the_user_agrees_to_restart_the_application :
+            concern
+        {
+            it should_restart_the_application = () => pump.was_told_to(x => x.run<IRestartCommand>());
+
+            because b = () => sut.restart();
+        }
+    }
 }
\ No newline at end of file
product/client/presentation/Presenters/NotificationIconPresenter.cs
@@ -5,7 +5,6 @@ using MoMoney.Presentation.Model.Menu.File;
 using MoMoney.Presentation.Model.Menu.Help;
 using MoMoney.Presentation.Model.Menu.window;
 using momoney.presentation.views;
-using MoMoney.Presentation.Views;
 using MoMoney.Presentation.Winforms.Resources;
 using MoMoney.Service.Infrastructure.Eventing;
 
product/client/presentation/Presenters/RunTheSpecs.cs
@@ -13,7 +13,6 @@ namespace momoney.presentation.presenters
         public class when_initializing_different_regions_of_the_user_interface :
             concerns_for<IRunThe<Presenter>, RunThe<Presenter>>
         {
-            //it should_initialize_the_presenter_that_controls_that_region = () => controller.was_told_to(x => x.run<IPresenter>());
             it should_initialize_the_presenter_that_controls_that_region = () => processor.was_told_to(x => x.add(() => controller.run<Presenter>()));
 
             context c = () =>
product/client/presentation/Presenters/TaskTrayPresenter.cs
@@ -5,7 +5,7 @@ using momoney.presentation.views;
 using MoMoney.Presentation.Views;
 using MoMoney.Service.Infrastructure.Eventing;
 
-namespace momoney.modules
+namespace momoney.presentation.presenters
 {
     public class TaskTrayPresenter :
         Presenter,
product/client/presentation/Presenters/UnhandledErrorPresenter.cs
@@ -1,4 +1,4 @@
-using MoMoney.Presentation;
+using System;
 using MoMoney.Presentation.Core;
 using momoney.presentation.model.eventing;
 using momoney.presentation.views;
@@ -7,10 +7,11 @@ using MoMoney.Service.Infrastructure.Eventing;
 
 namespace momoney.presentation.presenters
 {
-    public class UnhandledErrorPresenter : IModule, DialogPresenter, EventSubscriber<UnhandledErrorOccurred>
+    public class UnhandledErrorPresenter : DialogPresenter, EventSubscriber<UnhandledErrorOccurred>
     {
-        readonly IUnhandledErrorView view;
-        readonly IRestartCommand restart;
+        IUnhandledErrorView view;
+        IRestartCommand restart;
+        Shell shell;
 
         public UnhandledErrorPresenter(IUnhandledErrorView view, IRestartCommand command)
         {
@@ -18,12 +19,16 @@ namespace momoney.presentation.presenters
             restart = command;
         }
 
-        public void present(Shell shell) {}
+        public void present(Shell shell)
+        {
+            this.shell = shell;
+        }
 
         public void notify(UnhandledErrorOccurred message)
         {
             view.attach_to(this);
             view.display(message.error);
+            view.show_dialog(shell);
         }
 
         public void restart_application()
@@ -31,6 +36,6 @@ namespace momoney.presentation.presenters
             restart.run();
         }
 
-        public void run() {}
+        public Action close { get; set; }
     }
 }
\ No newline at end of file
product/client/presentation/Views/Dialog.cs
@@ -1,8 +1,11 @@
 using MoMoney.Presentation.Core;
+using MoMoney.Presentation.Views;
 
 namespace momoney.presentation.views
 {
     public interface Dialog<TPresenter> : View<TPresenter> where TPresenter : DialogPresenter
     {
+        void show_dialog(Shell parent_window);
+        void Close();
     }
 }
\ No newline at end of file
product/client/presentation/Views/IApplicationWindow.cs
@@ -4,9 +4,6 @@ namespace momoney.presentation.views
 {
     public interface IApplicationWindow : View
     {
-        IApplicationWindow titled(string title);
         IApplicationWindow create_tool_tip_for(string title, string caption, Control control);
-        IApplicationWindow try_to_reduce_flickering();
-        IApplicationWindow top_most();
     }
 }
\ No newline at end of file
product/client/presentation/Views/ICheckForUpdatesView.cs
@@ -7,9 +7,7 @@ namespace momoney.presentation.views
 {
     public interface ICheckForUpdatesView : Dialog<CheckForUpdatesPresenter>, Callback<ApplicationVersion>
     {
-        void display();
         void downloaded(Percent percentage_complete);
         void update_complete();
-        void close();
     }
 }
\ No newline at end of file
product/client/presentation/Views/Shell.cs
@@ -1,12 +1,11 @@
 using System.ComponentModel;
 using System.Windows.Forms;
 using momoney.presentation.presenters;
-using momoney.presentation.views;
 
-namespace MoMoney.Presentation.Views
+namespace momoney.presentation.views
 {
     public interface Shell : IWin32Window, ISynchronizeInvoke, IContainerControl, IBindableComponent, IDropTarget,
-                              IRegionManager
+                             IRegionManager
     {
         void attach_to(ApplicationShellPresenter presenter);
         void add(ITab view);
product/client/presentation/Winforms/Views/ApplicationShell.cs
@@ -2,12 +2,10 @@ using System;
 using System.Collections.Generic;
 using System.ComponentModel;
 using System.ComponentModel.Composition;
-using System.Linq;
 using System.Windows.Forms;
 using gorilla.commons.utility;
 using momoney.presentation.presenters;
 using momoney.presentation.views;
-using MoMoney.Presentation.Views;
 using MoMoney.Presentation.Winforms.Helpers;
 
 namespace MoMoney.Presentation.Winforms.Views
@@ -16,7 +14,7 @@ namespace MoMoney.Presentation.Winforms.Views
     public partial class ApplicationShell : ApplicationWindow, Shell
     {
         readonly IDictionary<string, IComponent> regions;
-        ControlAction<EventArgs> closed_action = x => { };
+        ControlAction<EventArgs> closed_action = x => {};
 
         public ApplicationShell()
         {
@@ -63,7 +61,8 @@ namespace MoMoney.Presentation.Winforms.Views
                 };
                 BeginInvoke(safe_action);
             }
-            else {
+            else
+            {
                 action(regions[typeof (Region).FullName].downcast_to<Region>());
             }
         }
product/client/presentation/Winforms/Views/ApplicationShellSpecs.cs
@@ -1,35 +1,33 @@
-using System;
-using developwithpassion.bdd.contexts;
-using Gorilla.Commons.Testing;
-using momoney.presentation.presenters;
-using MoMoney.Presentation.Views;
-using MoMoney.Presentation.Winforms.Helpers;
-
-namespace MoMoney.Presentation.Winforms.Views
-{
-    public class ApplicationShellSpecs
-    {
-        public class concern : concerns_for<Shell, ApplicationShell>
-        {
-        }
-
-        public class when_the_application_shell_is_closed : concern
-        {
-            it should_execute_the_close_command = () => presenter.was_told_to(x => x.shut_down());
-
-            context c = () =>
-                        {
-                            presenter = an<ApplicationShellPresenter>();
-                        };
-
-            after_the_sut_has_been_created a = () =>
-                                               {
-                                                   sut.attach_to(presenter);
-                                               };
-
-            because b = () => EventTrigger.trigger_event<Events.FormEvents>(x => x.OnClosed(new EventArgs()), sut);
-
-            static ApplicationShellPresenter presenter;
-        }
-    }
+using System;
+using developwithpassion.bdd.contexts;
+using Gorilla.Commons.Testing;
+using momoney.presentation.presenters;
+using momoney.presentation.views;
+using MoMoney.Presentation.Winforms.Helpers;
+
+namespace MoMoney.Presentation.Winforms.Views
+{
+    public class ApplicationShellSpecs
+    {
+        public class concern : concerns_for<Shell, ApplicationShell> {}
+
+        public class when_the_application_shell_is_closed : concern
+        {
+            it should_execute_the_close_command = () => presenter.was_told_to(x => x.shut_down());
+
+            context c = () =>
+            {
+                presenter = an<ApplicationShellPresenter>();
+            };
+
+            after_the_sut_has_been_created a = () =>
+            {
+                sut.attach_to(presenter);
+            };
+
+            because b = () => EventTrigger.trigger_event<Events.FormEvents>(x => x.OnClosed(new EventArgs()), sut);
+
+            static ApplicationShellPresenter presenter;
+        }
+    }
 }
\ No newline at end of file
product/client/presentation/Winforms/Views/ApplicationWindow.cs
@@ -38,7 +38,7 @@ namespace MoMoney.Presentation.Winforms.Views
 
         public IApplicationWindow titled(string title)
         {
-            base.Text = "MoMoney (BETA) - " + title;
+            base.Text = @"MoMoney (BETA) - " + title;
             return this;
         }
     }
product/client/presentation/Winforms/Views/CheckForUpdatesView.cs
@@ -1,103 +1,97 @@
-using System;
-using System.Reflection;
-using System.Windows.Forms;
-using Gorilla.Commons.Utility;
-using momoney.presentation.presenters;
-using momoney.presentation.views;
-using MoMoney.Presentation.Views;
-using MoMoney.Presentation.Winforms.Resources;
-using momoney.service.infrastructure.updating;
-
-namespace MoMoney.Presentation.Winforms.Views
-{
-    public partial class CheckForUpdatesView : ApplicationWindow, ICheckForUpdatesView
-    {
-        readonly Shell shell;
-        ControlAction<EventArgs> update_button;
-        ControlAction<EventArgs> dont_update_button;
-        ControlAction<EventArgs> cancel_button;
-
-        public CheckForUpdatesView(Shell shell)
-        {
-            InitializeComponent();
-
-            this.shell = shell;
-            ux_image.Image = ApplicationImages.Splash;
-            ux_image.SizeMode = PictureBoxSizeMode.StretchImage;
-
-            titled("Check For Updates")
-                .create_tool_tip_for("Update", "Update the application, and then re-start it.", ux_update_button)
-                .create_tool_tip_for("Don't Update", "Discard the latest version.", ux_dont_update_button)
-                .create_tool_tip_for("Cancel", "Go back.", ux_cancel_button);
-
-            ux_update_button.Click += (o, e) => update_button(e);
-            ux_dont_update_button.Click += (o, e) => dont_update_button(e);
-            ux_cancel_button.Click += (o, e) => cancel_button(e);
-        }
-
-        public void attach_to(CheckForUpdatesPresenter presenter)
-        {
-            update_button = x =>
-            {
-                ux_update_button.Enabled = false;
-                ux_dont_update_button.Enabled = false;
-                ux_cancel_button.Enabled = true;
-                presenter.begin_update();
-            };
-            dont_update_button = x => presenter.do_not_update();
-            cancel_button = x => presenter.cancel_update();
-        }
-
-        public void display()
-        {
-            ux_update_button.Enabled = false;
-            ux_dont_update_button.Enabled = false;
-            ux_cancel_button.Enabled = false;
-            Show(shell);
-        }
-
-        public void downloaded(Percent percentage_complete)
-        {
-            shell.region<ToolStripProgressBar>(
-                x =>
-                {
-                    while (percentage_complete.is_less_than(x.Value))
-                    {
-                        if (percentage_complete.represents(x.Value)) break;
-                        x.PerformStep();
-                    }
-                });
-        }
-
-        public void update_complete()
-        {
-            downloaded(100);
-        }
-
-        public void close()
-        {
-            Close();
-        }
-
-        public void run(ApplicationVersion information)
-        {
-            if (information.updates_available)
-            {
-                ux_update_button.Enabled = true;
-                ux_dont_update_button.Enabled = true;
-                ux_cancel_button.Enabled = true;
-                ux_update_button.Enabled = information.updates_available;
-                ux_current_version.Text = "Current: " + information.current;
-                ux_new_version.Text = "New: " + information.available_version;
-            }
-            else
-            {
-                ux_update_button.Enabled = false;
-                ux_dont_update_button.Enabled = true;
-                ux_cancel_button.Enabled = false;
-                ux_current_version.Text = "Current: " + Assembly.GetExecutingAssembly().GetName().Version;
-                ux_new_version.Text = "New: " + Assembly.GetExecutingAssembly().GetName().Version;
-            }
-        }
-    }
+using System;
+using System.Reflection;
+using System.Windows.Forms;
+using Gorilla.Commons.Utility;
+using momoney.presentation.presenters;
+using momoney.presentation.views;
+using MoMoney.Presentation.Winforms.Resources;
+using momoney.service.infrastructure.updating;
+
+namespace MoMoney.Presentation.Winforms.Views
+{
+    public partial class CheckForUpdatesView : ApplicationWindow, ICheckForUpdatesView
+    {
+        readonly Shell shell;
+        ControlAction<EventArgs> update_button;
+        ControlAction<EventArgs> dont_update_button;
+        ControlAction<EventArgs> cancel_button;
+
+        public CheckForUpdatesView(Shell shell)
+        {
+            InitializeComponent();
+
+            this.shell = shell;
+            ux_image.Image = ApplicationImages.Splash;
+            ux_image.SizeMode = PictureBoxSizeMode.StretchImage;
+
+            titled("Check For Updates")
+                .create_tool_tip_for("Update", "Update the application, and then re-start it.", ux_update_button)
+                .create_tool_tip_for("Don't Update", "Discard the latest version.", ux_dont_update_button)
+                .create_tool_tip_for("Cancel", "Go back.", ux_cancel_button);
+
+            ux_update_button.Click += (o, e) => update_button(e);
+            ux_dont_update_button.Click += (o, e) => dont_update_button(e);
+            ux_cancel_button.Click += (o, e) => cancel_button(e);
+        }
+
+        public void attach_to(CheckForUpdatesPresenter presenter)
+        {
+            update_button = x =>
+            {
+                ux_update_button.Enabled = false;
+                ux_dont_update_button.Enabled = false;
+                ux_cancel_button.Enabled = true;
+                presenter.begin_update();
+            };
+            dont_update_button = x => presenter.do_not_update();
+            cancel_button = x => presenter.cancel_update();
+        }
+
+        public void downloaded(Percent percentage_complete)
+        {
+            shell.region<ToolStripProgressBar>(
+                                                  x =>
+                                                  {
+                                                      while (percentage_complete.is_less_than(x.Value))
+                                                      {
+                                                          if (percentage_complete.represents(x.Value)) break;
+                                                          x.PerformStep();
+                                                      }
+                                                  });
+        }
+
+        public void update_complete()
+        {
+            downloaded(100);
+        }
+
+        public void run(ApplicationVersion information)
+        {
+            if (information.updates_available)
+            {
+                ux_update_button.Enabled = true;
+                ux_dont_update_button.Enabled = true;
+                ux_cancel_button.Enabled = true;
+                ux_update_button.Enabled = information.updates_available;
+                ux_current_version.Text = "Current: " + information.current;
+                ux_new_version.Text = "New: " + information.available_version;
+            }
+            else
+            {
+                ux_update_button.Enabled = false;
+                ux_dont_update_button.Enabled = true;
+                ux_cancel_button.Enabled = false;
+                ux_current_version.Text = "Current: " + Assembly.GetExecutingAssembly().GetName().Version;
+                ux_new_version.Text = "New: " + Assembly.GetExecutingAssembly().GetName().Version;
+            }
+        }
+
+        public void show_dialog(Shell parent_window)
+        {
+            ux_update_button.Enabled = false;
+            ux_dont_update_button.Enabled = false;
+            ux_cancel_button.Enabled = false;
+            Show(parent_window);
+        }
+    }
 }
\ No newline at end of file
product/client/presentation/Winforms/Views/SaveChangesView.cs
@@ -3,6 +3,7 @@ using System.ComponentModel;
 using System.Windows.Forms;
 using MoMoney.Presentation.Model.Menu.File;
 using momoney.presentation.views;
+using MoMoney.Presentation.Views;
 using MoMoney.Presentation.Winforms.Resources;
 
 namespace MoMoney.Presentation.Winforms.Views
@@ -55,5 +56,10 @@ namespace MoMoney.Presentation.Winforms.Views
             Close();
             action();
         }
+
+        public void show_dialog(Shell parent_window)
+        {
+            ShowDialog(parent_window);
+        }
     }
 }
\ No newline at end of file
product/client/presentation/Winforms/Views/SplashScreenView.cs
@@ -1,51 +1,63 @@
-using System;
-using System.Windows.Forms;
-using momoney.presentation.views;
-using MoMoney.Presentation.Winforms.Resources;
-
-namespace MoMoney.Presentation.Winforms.Views
-{
-    public partial class SplashScreenView : ApplicationWindow, ISplashScreenView
-    {
-        public SplashScreenView()
-        {
-            InitializeComponent();
-        }
-
-        protected override void OnLoad(EventArgs e)
-        {
-            Opacity = 0;
-            BackgroundImage = ApplicationImages.Splash;
-            ClientSize = BackgroundImage.Size;
-            FormBorderStyle = FormBorderStyle.None;
-            StartPosition = FormStartPosition.CenterScreen;
-            top_most();
-        }
-
-        public void increment_the_opacity()
-        {
-            Opacity += 0.2;
-        }
-
-        public double current_opacity()
-        {
-            return Opacity;
-        }
-
-        public void decrement_the_opacity()
-        {
-            Opacity -= .1;
-        }
-
-        public void close_the_screen()
-        {
-            Close();
-            Dispose();
-        }
-
-        public void display()
-        {
-            Show();
-        }
-    }
+using System;
+using System.Windows.Forms;
+using momoney.presentation.views;
+using MoMoney.Presentation.Winforms.Resources;
+
+namespace MoMoney.Presentation.Winforms.Views
+{
+    public partial class SplashScreenView : ApplicationWindow, ISplashScreenView
+    {
+        public SplashScreenView()
+        {
+            InitializeComponent();
+        }
+
+        protected override void OnLoad(EventArgs e)
+        {
+            Opacity = 0;
+            BackgroundImage = ApplicationImages.Splash;
+            ClientSize = BackgroundImage.Size;
+            FormBorderStyle = FormBorderStyle.None;
+            StartPosition = FormStartPosition.CenterScreen;
+            top_most();
+        }
+
+        public void increment_the_opacity()
+        {
+            safely(() =>
+            {
+                Opacity += 0.2;
+            });
+        }
+
+        public double current_opacity()
+        {
+            return Opacity;
+        }
+
+        public void decrement_the_opacity()
+        {
+            safely(() =>
+            {
+                Opacity -= .1;
+            });
+        }
+
+        public void close_the_screen()
+        {
+            Close();
+            Dispose();
+        }
+
+        public void display()
+        {
+            Show();
+        }
+
+        void safely(Action action)
+        {
+            if (InvokeRequired) BeginInvoke(action);
+            else action();
+        }
+    }
 }
\ No newline at end of file
product/client/presentation/Winforms/Views/UnhandledErrorView.cs
@@ -1,42 +1,45 @@
-using System;
-using System.Windows.Forms;
-using momoney.presentation.presenters;
-using momoney.presentation.views;
-using MoMoney.Presentation.Winforms.Resources;
-
-namespace MoMoney.Presentation.Winforms.Views
-{
-    public partial class UnhandledErrorView : ApplicationWindow, IUnhandledErrorView
-    {
-        ControlAction<EventArgs> close_action = x => { };
-        ControlAction<EventArgs> restart_action = x => { };
-        readonly IWin32Window window;
-
-        public UnhandledErrorView(IWin32Window window)
-        {
-            InitializeComponent();
-            ux_image.Image = ApplicationImages.Splash;
-            ux_image.SizeMode = PictureBoxSizeMode.StretchImage;
-            titled("Aw snap... something went wrong!")
-                .create_tool_tip_for("Ignore", "Ignore the error and continue working.", close_button)
-                .create_tool_tip_for("Restart", "Discard any unsaved changes and restart the application.",
-                                     restart_button);
-
-            close_button.Click += (sender, args) => close_action(args);
-            restart_button.Click += (sender, args) => restart_action(args);
-            this.window = window;
-        }
-
-        public void attach_to(UnhandledErrorPresenter presenter)
-        {
-            close_action = x => Close();
-            restart_action = x => presenter.restart_application();
-        }
-
-        public void display(Exception exception)
-        {
-            ux_message.Text = exception.ToString();
-            ShowDialog(window);
-        }
-    }
+using System;
+using System.Windows.Forms;
+using momoney.presentation.presenters;
+using momoney.presentation.views;
+using MoMoney.Presentation.Views;
+using MoMoney.Presentation.Winforms.Resources;
+
+namespace MoMoney.Presentation.Winforms.Views
+{
+    public partial class UnhandledErrorView : ApplicationWindow, IUnhandledErrorView
+    {
+        ControlAction<EventArgs> close_action = x => { };
+        ControlAction<EventArgs> restart_action = x => { };
+
+        public UnhandledErrorView()
+        {
+            InitializeComponent();
+            ux_image.Image = ApplicationImages.Splash;
+            ux_image.SizeMode = PictureBoxSizeMode.StretchImage;
+            titled("Aw snap... something went wrong!")
+                .create_tool_tip_for("Ignore", "Ignore the error and continue working.", close_button)
+                .create_tool_tip_for("Restart", "Discard any unsaved changes and restart the application.",
+                                     restart_button);
+
+            close_button.Click += (sender, args) => close_action(args);
+            restart_button.Click += (sender, args) => restart_action(args);
+        }
+
+        public void attach_to(UnhandledErrorPresenter presenter)
+        {
+            close_action = x => presenter.close();
+            restart_action = x => presenter.restart_application();
+        }
+
+        public void display(Exception exception)
+        {
+            ux_message.Text = exception.ToString();
+        }
+
+        public void show_dialog(Shell parent_window)
+        {
+            ShowDialog(parent_window);
+        }
+    }
 }
\ No newline at end of file
product/client/presentation/Presentation.csproj
@@ -121,6 +121,7 @@
     <Compile Include="core\CachedPresenterFactory.cs" />
     <Compile Include="core\CachingViewFactory.cs" />
     <Compile Include="core\DialogPresenter.cs" />
+    <Compile Include="core\IApplicationController.cs" />
     <Compile Include="core\PresenterFactory.cs" />
     <Compile Include="core\ViewFactory.cs" />
     <Compile Include="model\eventing\FinishedRunningCommand.cs" />
product/commons/utility/PercentSpecs.cs
@@ -1,6 +1,7 @@
 using developwithpassion.bdd.contexts;
-using Gorilla.Commons.Testing;
-
+using Gorilla.Commons.Testing;
+using gorilla.commons.utility;
+
 namespace Gorilla.Commons.Utility
 {
     [Concern(typeof (Percent))]