Commit 6bc4c9f

mokhan <mokhan@ce5e1baf-6525-42e4-a1b2-857ea38da20a>
2009-03-24 21:05:01
got the presentation modules loading, but a lot of file menu commands are not working.
git-svn-id: https://svn.xp-dev.com/svn/mokhan-mo.money@100 ce5e1baf-6525-42e4-a1b2-857ea38da20a
1 parent 16c764c
trunk/product/MyMoney/boot/container/registration/wire_up_the_presentation_modules.cs
@@ -1,4 +1,3 @@
-using System;
 using System.Reflection;
 using MoMoney.Infrastructure.Container.Windsor;
 using MoMoney.Presentation.Core;
@@ -21,15 +20,16 @@ namespace MoMoney.boot.container.registration
             Assembly
                 .GetExecutingAssembly()
                 .GetTypes()
-                //.Where(x => typeof (IPresentationModule).IsAssignableFrom(x))
                 .where(x => typeof (IPresenter).IsAssignableFrom(x))
                 .where(x => !x.IsInterface)
-                .each(register);
-        }
+                .each(type => registry.transient(typeof (IPresenter), type));
 
-        void register(Type type)
-        {
-            registry.transient(typeof (IPresenter), type);
+            Assembly
+                .GetExecutingAssembly()
+                .GetTypes()
+                .where(x => typeof (IPresentationModule).IsAssignableFrom(x))
+                .where(x => !x.IsInterface)
+                .each(type => registry.transient(typeof (IPresentationModule), type));
         }
     }
 }
\ No newline at end of file
trunk/product/MyMoney/boot/start_the_application.cs
@@ -7,7 +7,7 @@ using MoMoney.Presentation.Context;
 using MoMoney.Presentation.Model.messages;
 using MoMoney.Utility.Core;
 
-namespace MoMoney.windows.ui
+namespace MoMoney.boot
 {
     internal class start_the_application : ICommand
     {
trunk/product/MyMoney/Infrastructure/Container/dependency_resolution_exception.cs → trunk/product/MyMoney/Infrastructure/Container/DependencyResolutionException.cs
@@ -3,10 +3,11 @@ using MoMoney.Utility.Extensions;
 
 namespace MoMoney.Infrastructure.Container
 {
-    public class dependency_resolution_exception<T> : Exception
+    public class DependencyResolutionException<T> : Exception
     {
-        public dependency_resolution_exception(Exception innerException)
+        public DependencyResolutionException(Exception innerException)
             : base("Could not resolve {0}".formatted_using(typeof (T).FullName), innerException)
-        {}
+        {
+        }
     }
 }
\ No newline at end of file
trunk/product/MyMoney/Infrastructure/Container/Resolve.cs
@@ -21,7 +21,7 @@ namespace MoMoney.Infrastructure.Container
             }
             catch (Exception e)
             {
-                throw new dependency_resolution_exception<DependencyToResolve>(e);
+                throw new DependencyResolutionException<DependencyToResolve>(e);
             }
         }
 
trunk/product/MyMoney/Infrastructure/Container/ResolveSpecs.cs
@@ -51,7 +51,7 @@ namespace MoMoney.Infrastructure.Container
         after_each_observation a = () => resolve.initialize_with(null);
 
         it should_throw_a_dependency_resolution_exception =
-            () => the_call.should_have_thrown<dependency_resolution_exception<IPresenter>>();
+            () => the_call.should_have_thrown<DependencyResolutionException<IPresenter>>();
 
         static IDependencyRegistry registry;
         static Action the_call;
trunk/product/MyMoney/Presentation/Views/Shell/ApplicationShell.cs
@@ -1,5 +1,6 @@
 using System;
 using System.Collections.Generic;
+using System.ComponentModel;
 using System.ComponentModel.Composition;
 using System.Windows.Forms;
 using MoMoney.Presentation.Views.core;
@@ -10,21 +11,30 @@ namespace MoMoney.Presentation.Views.Shell
     [Export(typeof (IShell))]
     public partial class ApplicationShell : ApplicationWindow, IShell
     {
-        readonly IDictionary<string, Control> regions;
+        readonly IDictionary<string, IComponent> regions;
+        readonly NotifyIcon ux_notification_icon;
 
         public ApplicationShell()
         {
             InitializeComponent();
-            regions = new Dictionary<string, Control>
+            ux_notification_icon = new NotifyIcon
+                                       {
+                                           BalloonTipIcon = ToolTipIcon.Info,
+                                           BalloonTipText = "Thanks for trying out this sample application",
+                                           Visible = true,
+                                       };
+            regions = new Dictionary<string, IComponent>
                           {
                               {GetType().FullName, this},
                               {ux_main_menu_strip.GetType().FullName, ux_main_menu_strip},
                               {ux_dock_panel.GetType().FullName, ux_dock_panel},
                               {ux_tool_bar_strip.GetType().FullName, ux_tool_bar_strip},
                               {ux_status_bar.GetType().FullName, ux_status_bar},
+                              {ux_notification_icon.GetType().FullName, ux_notification_icon},
                           };
         }
 
+
         protected override void OnLoad(EventArgs e)
         {
             try_to_reduce_flickering();
@@ -38,7 +48,7 @@ namespace MoMoney.Presentation.Views.Shell
             on_ui_thread(() => view.add_to(ux_dock_panel));
         }
 
-        public void region<Region>(Action<Region> action) where Region : Control
+        public void region<Region>(Action<Region> action) where Region : IComponent
         {
             ensure_that_the_region_exists<Region>();
             on_ui_thread(() => action(regions[typeof (Region).FullName].downcast_to<Region>()));
trunk/product/MyMoney/Presentation/Views/Shell/IShell.cs
@@ -9,7 +9,7 @@ namespace MoMoney.Presentation.Views.Shell
     {
         string Text { get; set; }
         void add(IDockedContentView view);
-        void region<T>(Action<T> action) where T : Control;
+        void region<T>(Action<T> action) where T : IComponent;
         void close_the_active_window();
         void close_all_windows();
     }
trunk/product/MyMoney/Presentation/Views/Shell/NotificationIconView.cs
@@ -11,14 +11,15 @@ namespace MoMoney.Presentation.Views.Shell
 {
     public class NotificationIconView : INotificationIconView
     {
-        NotifyIcon ux_notification_icon;
         readonly IFileMenu file_menu;
         readonly IWindowMenu window_menu;
         readonly IHelpMenu help_menu;
+        readonly IShell shell;
 
-        public NotificationIconView(IFileMenu file_menu, IWindowMenu window_menu, IHelpMenu help_menu)
+        public NotificationIconView(IFileMenu file_menu, IWindowMenu window_menu, IHelpMenu help_menu, IShell shell)
         {
             this.file_menu = file_menu;
+            this.shell = shell;
             this.window_menu = window_menu;
             this.help_menu = help_menu;
             Application.ApplicationExit += (sender, e) => Dispose();
@@ -26,24 +27,20 @@ namespace MoMoney.Presentation.Views.Shell
 
         public void display(ApplicationIcon icon_to_display, string text_to_display)
         {
-            ux_notification_icon =
-                new NotifyIcon
-                    {
-                        BalloonTipIcon = ToolTipIcon.Info,
-                        BalloonTipText = "Thanks for trying out this sample application",
-                        Icon = icon_to_display,
-                        Text = text_to_display,
-                        Visible = true,
-                        ContextMenu = new ContextMenu
-                                          {
-                                              MenuItems =
-                                                  {
-                                                      map_from(file_menu),
-                                                      map_from(window_menu),
-                                                      map_from(help_menu)
-                                                  }
-                                          }
-                    };
+            shell.region<NotifyIcon>(x =>
+                                         {
+                                             x.Icon = icon_to_display;
+                                             x.Text = text_to_display;
+                                             x.ContextMenu = new ContextMenu
+                                                                 {
+                                                                     MenuItems =
+                                                                         {
+                                                                             map_from(file_menu),
+                                                                             map_from(window_menu),
+                                                                             map_from(help_menu)
+                                                                         }
+                                                                 };
+                                         });
         }
 
         public void opened_new_project()
@@ -53,7 +50,7 @@ namespace MoMoney.Presentation.Views.Shell
 
         public void show_popup_message(string message)
         {
-            ux_notification_icon.ShowBalloonTip(100, message, message, ToolTipIcon.Info);
+            shell.region<NotifyIcon>(x => x.ShowBalloonTip(100, message, message, ToolTipIcon.Info));
         }
 
         MenuItem map_from(ISubMenu item)
@@ -65,12 +62,14 @@ namespace MoMoney.Presentation.Views.Shell
 
         public void Dispose()
         {
-            if (ux_notification_icon != null)
-            {
-                ux_notification_icon.Visible = false;
-                ux_notification_icon.Dispose();
-                ux_notification_icon = null;
-            }
+            shell.region<NotifyIcon>(x =>
+                                         {
+                                             if (x != null)
+                                             {
+                                                 x.Visible = false;
+                                                 x.Dispose();
+                                             }
+                                         });
         }
     }
 }
\ No newline at end of file
trunk/product/MyMoney/MyMoney.csproj
@@ -669,7 +669,7 @@
     <Compile Include="boot\hookup.cs" />
     <Compile Include="Presentation\Model\Menu\ISubMenu.cs" />
     <Compile Include="Utility\Core\IRegistry.cs" />
-    <Compile Include="Infrastructure\Container\dependency_resolution_exception.cs" />
+    <Compile Include="Infrastructure\Container\DependencyResolutionException.cs" />
     <Compile Include="Infrastructure\Container\Resolve.cs" />
     <Compile Include="Infrastructure\Container\ResolveSpecs.cs" />
     <Compile Include="Infrastructure\Container\Windsor\WindsorDependencyRegistry.cs" />