Commit c78c07f

mo <email@solidware.ca>
2011-03-26 19:17:17
create a new shell using avalon dock.
1 parent 609370c
product/desktop.ui/bootstrappers/Bootstrapper.cs
@@ -1,5 +1,6 @@
 using System.Collections.Generic;
 using System.Threading;
+using System.Windows;
 using System.Windows.Threading;
 using Autofac;
 using gorilla.infrastructure.container;
@@ -20,11 +21,12 @@ namespace solidware.financials.windows.ui.bootstrappers
 {
     static public class Bootstrapper
     {
-        static public ShellWindow create_window()
+        static public Window create_window()
         {
             var builder = new ContainerBuilder();
 
-            var shell_window = new ShellWindow();
+            //var shell_window = new ShellWindow();
+            var shell_window = new Shell();
             builder.Register(x => shell_window).SingleInstance();
             builder.Register(x => shell_window).As<RegionManager>().SingleInstance();
 
@@ -61,7 +63,7 @@ namespace solidware.financials.windows.ui.bootstrappers
         static void register_presentation_infrastructure(ContainerBuilder builder)
         {
             SynchronizationContext.SetSynchronizationContext(new DispatcherSynchronizationContext());
-            builder.RegisterType<WpfApplicationController>().As<ApplicationController>().SingleInstance();
+            builder.RegisterType<WPFApplicationController>().As<ApplicationController>().SingleInstance();
             builder.RegisterType<WPFPresenterFactory>().As<PresenterFactory>().SingleInstance();
             builder.RegisterType<SynchronizedEventAggregator>().As<EventAggregator>().SingleInstance();
             //builder.Register(x => AsyncOperationManager.SynchronizationContext);
product/desktop.ui/views/SelectedFamilyMemberRegion.xaml
@@ -1,6 +1,6 @@
 <UserControl x:Class="solidware.financials.windows.ui.views.SelectedFamilyMemberRegion"
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
-    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" MinWidth="1024">
+    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
 <Expander>
     <Expander.Header>
         <DockPanel>
product/desktop.ui/views/Shell.xaml
@@ -0,0 +1,56 @@
+<Window x:Class="solidware.financials.windows.ui.views.Shell"
+  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:ad="clr-namespace:AvalonDock;assembly=AvalonDock" xmlns:views="clr-namespace:solidware.financials.windows.ui.views" Title="MoMoney - (ALPHA)" MinWidth="1024" MinHeight="768" WindowStartupLocation="CenterScreen" WindowState="Maximized">
+  <Grid>
+    <Grid.RowDefinitions>
+      <RowDefinition Height="24"/>
+      <RowDefinition Height="32"/>
+      <RowDefinition Height="*"/>
+      <RowDefinition Height="32"/>
+    </Grid.RowDefinitions>
+    <views:MainMenu x:Name="Menu"></views:MainMenu>
+    <views:SelectedFamilyMemberRegion x:Name="SelectedFamilyMember" Grid.Row="1"></views:SelectedFamilyMemberRegion>
+    <ad:DockingManager x:Name="DockManager" Grid.Row="2">
+      <ad:ResizingPanel Orientation="Vertical">
+        <ad:ResizingPanel Orientation="Horizontal">
+          <ad:DockablePane ad:ResizingPanel.ResizeWidth="150">
+            <ad:DockableContent x:Name="classesContent" Title="Classes">
+              <TreeView>
+                <TreeViewItem Header="Class1"/>
+                <TreeViewItem Header="Class2"/>
+              </TreeView>
+            </ad:DockableContent>
+            <ad:DockableContent x:Name="toolsContent" Title="Tools">
+              <ListBox>
+                <ListBoxItem Content="Tool1"/>
+                <ListBoxItem Content="Tool2"/>
+                <ListBoxItem Content="Tool3"/>
+              </ListBox>
+            </ad:DockableContent>
+          </ad:DockablePane>
+          <ad:DocumentPane Name="Tabs"></ad:DocumentPane>
+        </ad:ResizingPanel>
+        <ad:DockablePane ad:ResizingPanel.ResizeHeight="100">
+          <ad:DockableContent Title="Errors" x:Name="errorsContent">
+            <ListView>
+              <ListView.View>
+                <GridView>
+                  <GridView.Columns>
+                    <GridViewColumn Header="Error"/>
+                    <GridViewColumn Header="Page"/>
+                    <GridViewColumn Header="File"/>
+                    <GridViewColumn Header="Row"/>
+                  </GridView.Columns>
+                </GridView>
+              </ListView.View>
+            </ListView>
+          </ad:DockableContent>
+          <ad:DockableContent Title="Output" x:Name="output">
+            <TextBox IsReadOnly="True" AcceptsReturn="True"/>
+          </ad:DockableContent>
+        </ad:DockablePane>
+      </ad:ResizingPanel>
+    </ad:DockingManager>
+    <views:StatusBarRegion x:Name="StatusBar" Grid.Row="3"></views:StatusBarRegion>
+  </Grid>
+</Window>
product/desktop.ui/views/Shell.xaml.cs
@@ -0,0 +1,39 @@
+using System;
+using System.Collections.Generic;
+using System.Windows;
+using gorilla.utility;
+
+namespace solidware.financials.windows.ui.views
+{
+    public partial class Shell : RegionManager
+    {
+        public Shell()
+        {
+            InitializeComponent();
+            regions = new Dictionary<Type, UIElement>
+                      {
+                          {GetType(), this},
+                          {typeof (Window), this},
+                          {StatusBar.GetType(), StatusBar},
+                          {Menu.GetType(), Menu},
+                          {DockManager.GetType(), DockManager},
+                          {Tabs.GetType(), Tabs},
+                          {SelectedFamilyMember.GetType(), SelectedFamilyMember},
+                      };
+        }
+
+        public void region<Region>(Action<Region> configure) where Region : UIElement
+        {
+            ensure_that_the_region_exists<Region>();
+            configure(regions[typeof (Region)].downcast_to<Region>());
+        }
+
+        void ensure_that_the_region_exists<Region>()
+        {
+            if (!regions.ContainsKey(typeof (Region)))
+                throw new Exception("Could not find region: {0}".format(typeof (Region)));
+        }
+
+        readonly IDictionary<Type, UIElement> regions;
+    }
+}
\ No newline at end of file
product/desktop.ui/solidware.financials.csproj
@@ -63,6 +63,12 @@
     <Reference Include="Autofac.Configuration">
       <HintPath>..\..\packages\Autofac.2.4.5.724\lib\NET40\Autofac.Configuration.dll</HintPath>
     </Reference>
+    <Reference Include="AvalonDock">
+      <HintPath>..\..\thirdparty\avalon.dock\AvalonDock.dll</HintPath>
+    </Reference>
+    <Reference Include="AvalonDock.Themes">
+      <HintPath>..\..\thirdparty\avalon.dock\AvalonDock.Themes.dll</HintPath>
+    </Reference>
     <Reference Include="Castle.Core, Version=2.5.1.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc, processorArchitecture=MSIL">
       <HintPath>..\..\packages\Castle.Core.2.5.2\lib\NET35\Castle.Core.dll</HintPath>
     </Reference>
@@ -159,6 +165,9 @@
     <Compile Include="views\SelectedFamilyMemberRegion.xaml.cs">
       <DependentUpon>SelectedFamilyMemberRegion.xaml</DependentUpon>
     </Compile>
+    <Compile Include="views\Shell.xaml.cs">
+      <DependentUpon>Shell.xaml</DependentUpon>
+    </Compile>
     <Compile Include="views\ShellWIndow.xaml.cs">
       <DependentUpon>ShellWIndow.xaml</DependentUpon>
     </Compile>
@@ -222,6 +231,10 @@
       <Generator>MSBuild:Compile</Generator>
       <SubType>Designer</SubType>
     </Page>
+    <Page Include="views\Shell.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
     <Page Include="views\ShellWIndow.xaml">
       <Generator>MSBuild:Compile</Generator>
       <SubType>Designer</SubType>
product/desktop.ui/WPFApplicationController.cs
@@ -1,17 +1,18 @@
 using System;
 using System.Windows;
 using System.Windows.Controls;
+using AvalonDock;
 using solidware.financials.infrastructure.eventing;
 
 namespace solidware.financials.windows.ui
 {
-    public class WpfApplicationController : ApplicationController
+    public class WPFApplicationController : ApplicationController
     {
         RegionManager region_manager;
         PresenterFactory factory;
         EventAggregator event_aggregator;
 
-        public WpfApplicationController(RegionManager region_manager, PresenterFactory factory,
+        public WPFApplicationController(RegionManager region_manager, PresenterFactory factory,
                                         EventAggregator event_aggregator)
         {
             this.region_manager = region_manager;
@@ -23,9 +24,14 @@ namespace solidware.financials.windows.ui
             where View : FrameworkElement, Tab<Presenter>, new()
         {
             var presenter = open<Presenter>();
-            configure_region<TabControl>(x => x.Items.Add(new TabItem
+            //configure_region<TabControl>(x => x.Items.Add(new TabItem
+            //{
+            //    Header = presenter.Header,
+            //    Content = new View {DataContext = presenter}
+            //}));
+            configure_region<DocumentPane>(x => x.Items.Add(new DocumentContent
             {
-                Header = presenter.Header,
+                Title = presenter.Header,
                 Content = new View {DataContext = presenter}
             }));
         }