Commit 03d5a19

mokhan <mokhan@ce5e1baf-6525-42e4-a1b2-857ea38da20a>
2009-02-27 17:02:00
-F
git-svn-id: https://svn.xp-dev.com/svn/mokhan-mo.money@25 ce5e1baf-6525-42e4-a1b2-857ea38da20a
1 parent 5d7a873
Changed files (5)
trunk/src/MyMoney/Presentation/Views/core/ApplicationDockedWindow.cs
@@ -1,5 +1,4 @@
-using System;
-using System.Linq;
+using System.Linq;
 using System.Windows.Forms;
 using MyMoney.Presentation.Resources;
 using WeifenLuo.WinFormsUI.Docking;
@@ -11,20 +10,21 @@ namespace MyMoney.Presentation.Views.core
         IApplicationDockedWindow create_tool_tip_for(string title, string caption, Control control);
         IApplicationDockedWindow titled(string title);
         IApplicationDockedWindow icon(ApplicationIcon icon);
+        IApplicationDockedWindow cannot_be_closed();
+        IApplicationDockedWindow docked_to(DockState state);
     }
 
     public partial class ApplicationDockedWindow : DockContent, IApplicationDockedWindow
     {
+        DockState dock_state;
+
         public ApplicationDockedWindow()
         {
             InitializeComponent();
-            Id = Guid.NewGuid();
-            TabText = "Undefined";
             Icon = ApplicationIcons.Application;
+            dock_state = DockState.Unknown;
         }
 
-        Guid Id { get; set; }
-
         public IApplicationDockedWindow create_tool_tip_for(string title, string caption, Control control)
         {
             new ToolTip {IsBalloon = true, ToolTipTitle = title}.SetToolTip(control, caption);
@@ -43,15 +43,49 @@ namespace MyMoney.Presentation.Views.core
             return this;
         }
 
-        public void AddTo(DockPanel panel)
+        public IApplicationDockedWindow cannot_be_closed()
+        {
+            CloseButton = false;
+            CloseButtonVisible = false;
+            return this;
+        }
+
+        public IApplicationDockedWindow docked_to(DockState state)
         {
-            var panel_to_remove = panel.Documents.SingleOrDefault(x => x.DockHandler.TabText.Equals(TabText));
-            if (panel_to_remove != null)
+            dock_state = state;
+            return this;
+        }
+
+        public void add_to(DockPanel panel)
+        {
+            if (window_is_already_contained_in(panel))
             {
-                panel_to_remove.DockHandler.Close();
-                panel_to_remove.DockHandler.Dispose();
+                remove_from(panel);
             }
             Show(panel);
+            DockState = dock_state;
+        }
+
+        void remove_from(DockPanel panel)
+        {
+            var panel_to_remove = get_window_from(panel);
+            panel_to_remove.DockHandler.Close();
+            panel_to_remove.DockHandler.Dispose();
+        }
+
+        IDockContent get_window_from(DockPanel panel)
+        {
+            return panel.Documents.Single(matches);
+        }
+
+        bool window_is_already_contained_in(DockPanel panel)
+        {
+            return panel.Documents.Count(matches) > 0;
+        }
+
+        bool matches(IDockContent x)
+        {
+            return x.DockHandler.TabText.Equals(TabText);
         }
     }
 }
\ No newline at end of file
trunk/src/MyMoney/Presentation/Views/core/IDockedContentView.cs
@@ -7,6 +7,6 @@ namespace MyMoney.Presentation.Views.core
     public interface IDockedContentView : IDockContent, ISynchronizeInvoke, IDisposable
     {
         string TabText { get; }
-        void AddTo(DockPanel panel);
+        void add_to(DockPanel panel);
     }
 }
\ No newline at end of file
trunk/src/MyMoney/Presentation/Views/income/add_new_income_view.cs
@@ -1,5 +1,7 @@
 using System;
 using System.Collections.Generic;
+using System.Text;
+using System.Windows.Forms;
 using MyMoney.Domain.accounting.billing;
 using MyMoney.Presentation.Model.interaction;
 using MyMoney.Presentation.Presenters.income;
@@ -34,7 +36,9 @@ namespace MyMoney.Presentation.Views.income
 
         public void notify(params notification_message[] messages)
         {
-            throw new NotImplementedException();
+            var builder = new StringBuilder();
+            messages.each(x => builder.AppendLine(x));
+            MessageBox.Show(builder.ToString(), "Ooops...", MessageBoxButtons.OK);
         }
 
         income_submission_dto create_income()
trunk/src/MyMoney/Presentation/Views/Navigation/actions_task_list.cs
@@ -19,8 +19,6 @@ namespace MyMoney.Presentation.Views.Navigation
         public actions_task_list(IShell shell)
         {
             InitializeComponent();
-            CloseButton = false;
-            CloseButtonVisible = false;
             this.shell = shell;
 
             initialize_the_ui();
@@ -29,7 +27,9 @@ namespace MyMoney.Presentation.Views.Navigation
         void initialize_the_ui()
         {
             titled("Actions Items")
-                .icon(ApplicationIcons.FileExplorer);
+                .icon(ApplicationIcons.FileExplorer)
+                .cannot_be_closed()
+                .docked_to(DockState.DockLeft);
 
             ux_system_task_pane.UseClassicTheme();
             //ux_system_task_pane.UseCustomTheme(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "itunes.dat"));
@@ -43,7 +43,6 @@ namespace MyMoney.Presentation.Views.Navigation
         public void display()
         {
             shell.add(this);
-            DockState = DockState.DockLeft;
         }
     }
 }
\ No newline at end of file
trunk/src/MyMoney/Presentation/Views/Shell/window_shell.cs
@@ -44,7 +44,7 @@ namespace MyMoney.Presentation.Views.Shell
             //}
             //view.Show(ux_dock_panel);
 
-            view.AddTo(ux_dock_panel);
+            view.add_to(ux_dock_panel);
         }
 
         public void add_to_main_menu(ToolStripMenuItem item)