Commit bd4c089

mokhan <mokhan@ce5e1baf-6525-42e4-a1b2-857ea38da20a>
2009-02-25 20:30:01
cleaning upt he action tasks presenter.
git-svn-id: https://svn.xp-dev.com/svn/mokhan-mo.money@9 ce5e1baf-6525-42e4-a1b2-857ea38da20a
1 parent e224956
trunk/src/MyMoney/Presentation/Core/presenter_registry.cs
@@ -4,11 +4,12 @@ using MyMoney.Domain.Core;
 namespace MyMoney.Presentation.Core
 {
     public interface IPresenterRegistry : IRegistry<IPresenter>
-    {}
+    {
+    }
 
     public class presenter_registry : IPresenterRegistry
     {
-        private readonly IRegistry<IPresenter> presenters;
+        readonly IRegistry<IPresenter> presenters;
 
         public presenter_registry(IRegistry<IPresenter> presenters)
         {
trunk/src/MyMoney/Presentation/Presenters/Navigation/action_tasks_presenter.cs
@@ -1,5 +1,7 @@
+using MyMoney.Domain.Core;
 using MyMoney.Presentation.Presenters.Shell;
 using MyMoney.Presentation.Views.Navigation;
+using MyMoney.Utility.Extensions;
 
 namespace MyMoney.Presentation.Presenters.Navigation
 {
@@ -9,16 +11,19 @@ namespace MyMoney.Presentation.Presenters.Navigation
 
     public class action_tasks_presenter : IActionTasksPresenter
     {
-        private readonly IActionsTaskView view;
+        readonly IActionsTaskView view;
+        readonly IRegistry<IActionTaskPresenter> registry;
 
-        public action_tasks_presenter(IActionsTaskView view)
+        public action_tasks_presenter(IActionsTaskView view, IRegistry<IActionTaskPresenter> registry)
         {
             this.view = view;
+            this.registry = registry;
         }
 
         public void run()
         {
             view.display();
+            registry.all().each(x => x.run(view));
         }
     }
 }
\ No newline at end of file
trunk/src/MyMoney/Presentation/Presenters/Navigation/Build.cs
@@ -0,0 +1,15 @@
+namespace MyMoney.Presentation.Presenters.Navigation
+{
+    public class Build
+    {
+        public static IExpandoBuilder Expando()
+        {
+            return new ExpandoBuilder();
+        }
+
+        public static IExpandoItemBuilder ExpandoItem()
+        {
+            return new ExpandoItemBuilder();
+        }
+    }
+}
\ No newline at end of file
trunk/src/MyMoney/Presentation/Presenters/Navigation/company_task_presenter.cs
@@ -0,0 +1,34 @@
+using MyMoney.Presentation.Presenters.Commands;
+using MyMoney.Presentation.Resources;
+using MyMoney.Presentation.Views.Navigation;
+using XPExplorerBar;
+
+namespace MyMoney.Presentation.Presenters.Navigation
+{
+    public class company_task_presenter : IActionTaskPresenter
+    {
+        readonly IRunPresenterCommand command;
+
+        public company_task_presenter(IRunPresenterCommand command)
+        {
+            this.command = command;
+        }
+
+        public void run(IActionsTaskView view)
+        {
+            view.Add(create_expando());
+        }
+
+        Expando create_expando()
+        {
+            return Build.Expando()
+                .Named("Company")
+                .WithItem(
+                Build.ExpandoItem()
+                    .Named("Add Company")
+                    .RepresentedByImage(ApplicationImages.ReadingABill)
+                    .WhenClickedExecute(() => command.execute<IAddCompanyPresenter>()))
+                .Build();
+        }
+    }
+}
\ No newline at end of file
trunk/src/MyMoney/Presentation/Presenters/Navigation/ExpandoBuilder.cs
@@ -0,0 +1,68 @@
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Drawing;
+using System.Windows.Forms;
+using MyMoney.Utility.Extensions;
+using XPExplorerBar;
+using Padding=System.Windows.Forms.Padding;
+
+namespace MyMoney.Presentation.Presenters.Navigation
+{
+    public interface IExpandoBuilder
+    {
+        IExpandoBuilder Named(string name);
+        IExpandoBuilder WithItem(IExpandoItemBuilder builder);
+        Expando Build();
+    }
+
+    public class ExpandoBuilder : IExpandoBuilder
+    {
+        readonly IList<IExpandoItemBuilder> builders = new List<IExpandoItemBuilder>();
+        string the_name = "";
+
+        public IExpandoBuilder Named(string name)
+        {
+            the_name = name;
+            return this;
+        }
+
+        public IExpandoBuilder WithItem(IExpandoItemBuilder builder)
+        {
+            builders.Add(builder);
+            return this;
+        }
+
+        public Expando Build()
+        {
+            var pane = new Expando {};
+            ((ISupportInitialize) (pane)).BeginInit();
+            pane.SuspendLayout();
+
+            pane.Anchor = (AnchorStyles.Top | AnchorStyles.Left) | AnchorStyles.Right;
+            pane.Animate = true;
+            pane.AutoLayout = true;
+            pane.ExpandedHeight = 63;
+            pane.Font = new Font("Tahoma", 8.25F);
+            pane.Items.AddRange(create_items());
+            pane.Location = new Point(12, 12);
+            pane.Margin = new Padding(4);
+            pane.Name = "ux_" + the_name;
+            pane.Size = new Size(292, 63);
+            pane.SpecialGroup = true;
+            pane.TabIndex = 5;
+            pane.Text = the_name;
+
+            ((ISupportInitialize) (pane)).EndInit();
+            pane.ResumeLayout(false);
+
+            return pane;
+        }
+
+        TaskItem[] create_items()
+        {
+            var items = new List<TaskItem>();
+            builders.each(x => items.Add(x.Build()));
+            return items.ToArray();
+        }
+    }
+}
\ No newline at end of file
trunk/src/MyMoney/Presentation/Presenters/Navigation/ExpandoItemBuilder.cs
@@ -0,0 +1,60 @@
+using System;
+using System.Drawing;
+using System.Windows.Forms;
+using MyMoney.Presentation.Resources;
+using XPExplorerBar;
+
+namespace MyMoney.Presentation.Presenters.Navigation
+{
+    public interface IExpandoItemBuilder
+    {
+        IExpandoItemBuilder Named(string name);
+        IExpandoItemBuilder RepresentedByImage(ApplicationImage image);
+        IExpandoItemBuilder WhenClickedExecute(Action action);
+        TaskItem Build();
+    }
+
+    public class ExpandoItemBuilder : IExpandoItemBuilder
+    {
+        string the_name = "";
+        ApplicationImage the_image;
+        Action the_action = () => { };
+
+        public IExpandoItemBuilder Named(string name)
+        {
+            the_name = name;
+            return this;
+        }
+
+        public IExpandoItemBuilder RepresentedByImage(ApplicationImage image)
+        {
+            the_image = image;
+            return this;
+        }
+
+        public IExpandoItemBuilder WhenClickedExecute(Action action)
+        {
+            the_action = action;
+            return this;
+        }
+
+        public TaskItem Build()
+        {
+            var item = new TaskItem
+                           {
+                               Anchor = ((AnchorStyles.Top | AnchorStyles.Left) | AnchorStyles.Right),
+                               BackColor = Color.Transparent,
+                               Image = the_image,
+                               Location = new Point(12, 33),
+                               Name = "ux" + the_name,
+                               Size = new Size(266, 19),
+                               TabIndex = 0,
+                               Text = the_name,
+                               TextAlign = ContentAlignment.TopLeft,
+                               UseVisualStyleBackColor = false,
+                           };
+            item.Click += (sender, e) => the_action();
+            return item;
+        }
+    }
+}
\ No newline at end of file
trunk/src/MyMoney/Presentation/Presenters/Navigation/IActionTaskPresenter.cs
@@ -0,0 +1,9 @@
+using MyMoney.Presentation.Views.Navigation;
+using MyMoney.Utility.Core;
+
+namespace MyMoney.Presentation.Presenters.Navigation
+{
+    public interface IActionTaskPresenter : IParameterizedCommand<IActionsTaskView>
+    {
+    }
+}
\ No newline at end of file
trunk/src/MyMoney/Presentation/Views/Navigation/actions_task_list.cs
@@ -1,6 +1,4 @@
-using System;
-using System.IO;
-using MyMoney.Presentation.Presenters;
+using MyMoney.Presentation.Presenters;
 using MyMoney.Presentation.Presenters.billing;
 using MyMoney.Presentation.Presenters.Commands;
 using MyMoney.Presentation.Presenters.income;
@@ -9,18 +7,20 @@ using MyMoney.Presentation.Resources;
 using MyMoney.Presentation.Views.core;
 using MyMoney.Presentation.Views.Shell;
 using WeifenLuo.WinFormsUI.Docking;
+using XPExplorerBar;
 
 namespace MyMoney.Presentation.Views.Navigation
 {
     public interface IActionsTaskView : IDockedContentView
     {
         void display();
+        void Add(Expando expando);
     }
 
     public partial class actions_task_list : DockContent, IActionsTaskView
     {
-        private readonly IShell shell;
-        private readonly IRunPresenterCommand command;
+        readonly IShell shell;
+        readonly IRunPresenterCommand command;
 
         public actions_task_list(IShell shell, IRunPresenterCommand command)
         {
@@ -33,7 +33,7 @@ namespace MyMoney.Presentation.Views.Navigation
             initialize_the_ui();
         }
 
-        private void initialize_the_ui()
+        void initialize_the_ui()
         {
             TabText = "Action Items";
             Icon = ApplicationIcons.FileExplorer;
@@ -70,5 +70,10 @@ namespace MyMoney.Presentation.Views.Navigation
             shell.add(this);
             DockState = DockState.DockLeft;
         }
+
+        public void Add(Expando expando)
+        {
+            ux_system_task_pane.Expandos.Add(expando);
+        }
     }
 }
\ No newline at end of file
trunk/src/MyMoney/Presentation/Views/Shell/window_shell.cs
@@ -1,4 +1,5 @@
 using System.ComponentModel;
+using System.ComponentModel.Composition;
 using System.Linq;
 using System.Windows.Forms;
 using MyMoney.Presentation.Resources;
@@ -18,6 +19,7 @@ namespace MyMoney.Presentation.Views.Shell
         void clear_menu_items();
     }
 
+    [Export(typeof(IShell))]
     public partial class window_shell : Form, IShell
     {
         public window_shell()
trunk/src/MyMoney/MyMoney.csproj
@@ -309,6 +309,11 @@
     <Compile Include="Presentation\Model\messages\new_project_opened.cs" />
     <Compile Include="Presentation\Model\messages\saved_changes_event.cs" />
     <Compile Include="Presentation\Model\messages\unsaved_changes_event.cs" />
+    <Compile Include="Presentation\Presenters\Navigation\Build.cs" />
+    <Compile Include="Presentation\Presenters\Navigation\company_task_presenter.cs" />
+    <Compile Include="Presentation\Presenters\Navigation\ExpandoBuilder.cs" />
+    <Compile Include="Presentation\Presenters\Navigation\ExpandoItemBuilder.cs" />
+    <Compile Include="Presentation\Presenters\Navigation\IActionTaskPresenter.cs" />
     <Compile Include="Presentation\Presenters\Shell\tool_bar_presenter.cs" />
     <Compile Include="Presentation\Presenters\Navigation\action_tasks_presenter.cs" />
     <Compile Include="Presentation\Presenters\Navigation\navigation_presenter.cs" />