Commit 8cb7d35
Changed files (8)
trunk
product
MyMoney
Presentation
Views
trunk/product/MyMoney/boot/bootstrap.cs
@@ -1,29 +1,14 @@
using System;
-using MoMoney.boot.container;
-using MoMoney.Infrastructure.Extensions;
-using MoMoney.Presentation.Presenters.Startup;
-using MoMoney.Utility.Extensions;
-using MoMoney.windows.ui;
-using display_the_splash_screen=MoMoney.Presentation.Presenters.Commands.display_the_splash_screen;
+using MoMoney.Presentation.Views.Shell;
namespace MoMoney.boot
{
- static internal class bootstrap
+ public class bootstrap : WindowsFormsApplication<ApplicationShell>
{
[STAThread]
static void Main()
{
- Func<ISplashScreenPresenter> presenter = () => new SplashScreenPresenter();
- presenter = presenter.memorize();
-
- var startup_screen = new display_the_splash_screen(presenter).on_a_background_thread();
- hookup
- .the<global_error_handling>()
- .then(startup_screen)
- .then<wire_up_the_container>()
- .then(startup_screen.Dispose)
- .then<start_the_application>()
- .run();
+ new bootstrap().run();
}
}
}
\ No newline at end of file
trunk/product/MyMoney/boot/global_error_handling.cs
@@ -1,6 +1,4 @@
using System;
-using System.Globalization;
-using System.Threading;
using System.Windows.Forms;
using MoMoney.Infrastructure.Container;
using MoMoney.Infrastructure.eventing;
@@ -15,14 +13,14 @@ namespace MoMoney.boot
{
public void run()
{
- Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
- Application.EnableVisualStyles();
- Application.SetCompatibleTextRenderingDefault(false);
- Application.ThreadException += (sender, e) => handle_error(e.Exception);
- AppDomain.CurrentDomain.UnhandledException += (sender, e) => handle_error(e.ExceptionObject.downcast_to<Exception>());
+ //Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
+ //Application.EnableVisualStyles();
+ //Application.SetCompatibleTextRenderingDefault(false);
+ Application.ThreadException += (sender, e) => handle(e.Exception);
+ AppDomain.CurrentDomain.UnhandledException += (o, e) => handle(e.ExceptionObject.downcast_to<Exception>());
}
- static void handle_error(Exception e)
+ void handle(Exception e)
{
e.add_to_log();
resolve.dependency_for<IEventAggregator>().publish(new unhandled_error_occurred(e));
trunk/product/MyMoney/boot/start_the_application.cs
@@ -1,15 +1,9 @@
using System;
using System.ComponentModel;
using System.ComponentModel.Design;
-using System.Windows.Forms;
-using MoMoney.Infrastructure.Container;
-using MoMoney.Infrastructure.eventing;
-using MoMoney.Infrastructure.Extensions;
using MoMoney.Infrastructure.interceptors;
using MoMoney.Infrastructure.Threading;
using MoMoney.Modules.Core;
-using MoMoney.Presentation.Model.messages;
-using MoMoney.Presentation.Views.Shell;
using MoMoney.Utility.Core;
namespace MoMoney.boot
@@ -32,17 +26,8 @@ namespace MoMoney.boot
public void run()
{
- try
- {
- processor.run();
- command.run();
- Application.Run(resolve.dependency_for<ApplicationShell>());
- }
- catch (Exception e)
- {
- this.log().error(e);
- resolve.dependency_for<IEventAggregator>().publish(new unhandled_error_occurred(e));
- }
+ processor.run();
+ command.run();
}
}
trunk/product/MyMoney/boot/WindowsFormsApplication.cs
@@ -0,0 +1,60 @@
+using System;
+using System.Globalization;
+using System.Security.Principal;
+using System.Threading;
+using System.Windows.Forms;
+using MoMoney.boot.container;
+using MoMoney.Infrastructure.Container;
+using MoMoney.Infrastructure.eventing;
+using MoMoney.Infrastructure.Extensions;
+using MoMoney.Presentation.Model.messages;
+using MoMoney.Presentation.Presenters.Startup;
+using MoMoney.Utility.Core;
+using MoMoney.Utility.Extensions;
+using MoMoney.windows.ui;
+using display_the_splash_screen=MoMoney.Presentation.Presenters.Commands.display_the_splash_screen;
+
+namespace MoMoney.boot
+{
+ public class WindowsFormsApplication<Shell> : ICommand where Shell : Form
+ {
+ public WindowsFormsApplication()
+ {
+ Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
+ Application.EnableVisualStyles();
+ Application.SetCompatibleTextRenderingDefault(false);
+ }
+
+ public void run()
+ {
+ Func<ISplashScreenPresenter> presenter = () => new SplashScreenPresenter();
+ presenter = presenter.memorize();
+
+ var startup_screen = new display_the_splash_screen(presenter).on_a_background_thread();
+
+ AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal);
+ hookup
+ .the<global_error_handling>()
+ .then(startup_screen)
+ .then<wire_up_the_container>()
+ .then(startup_screen.Dispose)
+ .then<start_the_application>()
+ .run();
+
+ start();
+ }
+
+ protected void start()
+ {
+ try
+ {
+ Application.Run(resolve.dependency_for<Shell>());
+ }
+ catch (Exception e)
+ {
+ this.log().error(e);
+ resolve.dependency_for<IEventAggregator>().publish(new unhandled_error_occurred(e));
+ }
+ }
+ }
+}
\ No newline at end of file
trunk/product/MyMoney/Presentation/Views/core/ApplicationDockedWindow.cs
@@ -31,7 +31,9 @@ namespace MoMoney.Presentation.Views.core
public IApplicationDockedWindow create_tool_tip_for(string title, string caption, Control control)
{
- new ToolTip {IsBalloon = true, ToolTipTitle = title}.SetToolTip(control, caption);
+ var tip = new ToolTip {IsBalloon = true, ToolTipTitle = title};
+ tip.SetToolTip(control, caption);
+ control.Controls.Add(adapt(tip));
return this;
}
@@ -99,8 +101,29 @@ namespace MoMoney.Presentation.Views.core
{
//if (InvokeRequired) BeginInvoke(action);
//else action();
-
+
action();
}
+
+ Control adapt(ToolTip item)
+ {
+ return new ControlAdapter(item);
+ }
+
+ internal class ControlAdapter : Control
+ {
+ readonly IDisposable item;
+
+ public ControlAdapter(IDisposable item)
+ {
+ this.item = item;
+ }
+
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing) item.Dispose();
+ base.Dispose(disposing);
+ }
+ }
}
}
\ No newline at end of file
trunk/product/MyMoney/Presentation/Views/core/ApplicationWindow.cs
@@ -19,7 +19,7 @@ namespace MoMoney.Presentation.Views.core
{
InitializeComponent();
Icon = ApplicationIcons.Application;
- //this.log().debug("created {0}", GetType());
+ this.log().debug("created {0}", GetType());
}
public IApplicationWindow create_tool_tip_for(string title, string caption, Control control)
trunk/product/MyMoney/Presentation/Views/updates/CheckForUpdatesView.cs
@@ -5,14 +5,16 @@ using MoMoney.Presentation.Model.updates;
using MoMoney.Presentation.Presenters.updates;
using MoMoney.Presentation.Resources;
using MoMoney.Presentation.Views.core;
+using MoMoney.Presentation.Views.Shell;
namespace MoMoney.Presentation.Views.updates
{
public partial class CheckForUpdatesView : ApplicationWindow, ICheckForUpdatesView
{
ICheckForUpdatesPresenter the_presenter;
+ IShell shell;
- public CheckForUpdatesView()
+ public CheckForUpdatesView(IShell shell)
{
InitializeComponent();
ux_image.Image = ApplicationImages.Splash;
@@ -22,6 +24,7 @@ namespace MoMoney.Presentation.Views.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);
+ this.shell = shell;
}
public void attach_to(ICheckForUpdatesPresenter presenter)
@@ -48,7 +51,7 @@ namespace MoMoney.Presentation.Views.updates
ux_update_button.Enabled = false;
ux_dont_update_button.Enabled = false;
ux_cancel_button.Enabled = false;
- Show();
+ Show(shell);
});
}
trunk/product/MyMoney/MyMoney.csproj
@@ -173,6 +173,8 @@
<Compile Include="boot\container\registration\wire_up_the_data_access_components_into_the.cs" />
<Compile Include="boot\container\registration\wire_up_the_presentation_modules.cs" />
<Compile Include="boot\container\registration\wire_up_the_services_in_to_the.cs" />
+ <Compile Include="boot\global_error_handling.cs" />
+ <Compile Include="boot\WindowsFormsApplication.cs" />
<Compile Include="DataAccess\db40\ConnectionFactory.cs" />
<Compile Include="DataAccess\db40\DetachedSession.cs" />
<Compile Include="DataAccess\db40\ObjectDatabaseGateway.cs" />
@@ -840,7 +842,6 @@
<Compile Include="Testing\MetaData\ConcernAttribute.cs" />
<Compile Include="boot\start_the_application.cs" />
<Compile Include="boot\container\wire_up_the_container.cs" />
- <Compile Include="boot\global_error_handling.cs" />
<Compile Include="boot\container\registration\run_mass_component_registration_in_to_the.cs" />
<Compile Include="boot\container\registration\wire_up_the_essential_services_into_the.cs" />
<Compile Include="boot\container\registration\wire_up_the_mappers_in_to_the.cs" />