Commit a7930d1
Changed files (6)
trunk
product
MyMoney
Domain
Core
Presentation
Presenters
updates
Views
helpers
trunk/product/MyMoney/Domain/Core/Percent.cs
@@ -26,7 +26,6 @@ namespace MoMoney.Domain.Core
public bool is_less_than(Percent other_percent)
{
- //return other_percent.percentage.CompareTo(percentage) > 0;
return percentage.CompareTo(other_percent.percentage) < 0;
}
trunk/product/MyMoney/Presentation/Presenters/updates/CheckForUpdatesPresenter.cs
@@ -68,7 +68,11 @@ namespace MoMoney.Presentation.Presenters.updates
public void run(Percent completed)
{
- if (completed.Equals(new Percent(100))) view.update_complete();
+ if (completed.Equals(new Percent(100)))
+ {
+ view.update_complete();
+ restart();
+ }
else view.downloaded(completed);
}
}
trunk/product/MyMoney/Presentation/Views/helpers/Events.cs
@@ -9,23 +9,18 @@ namespace MoMoney.Presentation.Views.helpers
public interface ControlEvents : IEventTarget
{
void OnEnter(EventArgs args);
-
void OnKeyPress(KeyPressEventArgs args);
void OnKeyUp(KeyEventArgs args);
void OnKeyDown(KeyEventArgs args);
-
void OnClick(EventArgs args);
void OnDoubleClick(EventArgs args);
void OnDragDrop(DragEventArgs args);
void OnDragEnter(DragEventArgs args);
void OnDragLeave(EventArgs args);
void OnDragOver(DragEventArgs args);
-
void OnMouseWheel(MouseEventArgs args);
-
void OnValidated(EventArgs args);
void OnValidating(CancelEventArgs args);
-
}
public interface FormEvents : ControlEvents
trunk/product/MyMoney/Presentation/Views/updates/CheckForUpdatesView.cs
@@ -1,4 +1,5 @@
-using System.Reflection;
+using System;
+using System.Reflection;
using System.Windows.Forms;
using MoMoney.Domain.Core;
using MoMoney.Presentation.Model.updates;
@@ -11,12 +12,16 @@ namespace MoMoney.Presentation.Views.updates
{
public partial class CheckForUpdatesView : ApplicationWindow, ICheckForUpdatesView
{
- ICheckForUpdatesPresenter the_presenter;
readonly IShell shell;
+ ControlAction<EventArgs> update_button;
+ ControlAction<EventArgs> dont_update_button;
+ ControlAction<EventArgs> cancel_button;
public CheckForUpdatesView(IShell shell)
{
InitializeComponent();
+
+ this.shell = shell;
ux_image.Image = ApplicationImages.Splash;
ux_image.SizeMode = PictureBoxSizeMode.StretchImage;
@@ -24,21 +29,23 @@ 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;
+
+ 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(ICheckForUpdatesPresenter presenter)
{
- ux_update_button.Click += (o, e) =>
- {
- ux_update_button.Enabled = false;
- ux_dont_update_button.Enabled = false;
- ux_cancel_button.Enabled = true;
- presenter.begin_update();
- };
- ux_dont_update_button.Click += (o, e) => presenter.do_not_update();
- ux_cancel_button.Click += (o, e) => presenter.cancel_update();
- the_presenter = 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()
@@ -51,24 +58,25 @@ namespace MoMoney.Presentation.Views.updates
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();
- }
- });
+ 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()
{
- the_presenter.restart();
+ downloaded(100);
}
public void close()
{
- on_ui_thread(() => { Close(); });
+ Close();
}
public void run(ApplicationVersion information)
trunk/product/MyMoney/Presentation/Views/updates/ControlAction.cs
@@ -0,0 +1,6 @@
+using System;
+
+namespace MoMoney.Presentation.Views.updates
+{
+ public delegate void ControlAction<T>(T input) where T : EventArgs;
+}
\ No newline at end of file
trunk/product/MyMoney/MyMoney.csproj
@@ -596,6 +596,7 @@
<Compile Include="Presentation\Views\updates\CheckForUpdatesView.Designer.cs">
<DependentUpon>CheckForUpdatesView.cs</DependentUpon>
</Compile>
+ <Compile Include="Presentation\Views\updates\ControlAction.cs" />
<Compile Include="Presentation\Views\updates\ICheckForUpdatesView.cs" />
<Compile Include="Tasks\application\BillingTasks.cs" />
<Compile Include="Tasks\application\CustomerTasks.cs" />