Commit 4e88068
Changed files (23)
product
client
presentation.windows
presenters
commons
infrastructure.thirdparty
autofac
product/client/presentation.windows/presenters/CompensationPresenter.cs
@@ -0,0 +1,12 @@
+namespace presentation.windows
+{
+ public class CompensationPresenter : TabPresenter
+ {
+ public string Header
+ {
+ get { return "Compensation"; }
+ }
+
+ public void present() {}
+ }
+}
\ No newline at end of file
product/client/presentation.windows/views/CompensationTab.xaml
@@ -0,0 +1,30 @@
+<UserControl x:Class="presentation.windows.CompensationTab"
+ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" MinWidth="800" MinHeight="600">
+ <DockPanel HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
+ <StackPanel>
+ <TabControl TabStripPlacement="Left">
+ <TabItem Header="Base Pay">
+ <DockPanel>
+ <Label>Enter Salary:</Label>
+ <TextBox></TextBox>
+ </DockPanel>
+ </TabItem>
+ <TabItem Header="Bonus">
+ <DockPanel>
+ <Label>Enter Bonus:</Label>
+ <TextBox></TextBox>
+ </DockPanel>
+
+ </TabItem>
+ <TabItem Header="LTIP">
+ <DockPanel>
+ <Label>Enter Grant:</Label>
+ <TextBox></TextBox>
+ </DockPanel>
+
+ </TabItem>
+ </TabControl>
+ </StackPanel>
+ </DockPanel>
+</UserControl>
product/client/presentation.windows/views/CompensationTab.xaml.cs
@@ -0,0 +1,10 @@
+namespace presentation.windows
+{
+ public partial class CompensationTab : Tab<CompensationPresenter>
+ {
+ public CompensationTab()
+ {
+ InitializeComponent();
+ }
+ }
+}
\ No newline at end of file
product/client/presentation.windows/views/ShellWIndow.xaml
@@ -0,0 +1,32 @@
+<Window x:Class="presentation.windows.ShellWindow"
+ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MoMoney - (ALPHA)" MinHeight="600" MinWidth="800" WindowStartupLocation="CenterScreen" WindowState="Maximized">
+ <DockPanel VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
+ <Menu Name="Menu" DockPanel.Dock="Top">
+ <MenuItem Header="File"></MenuItem>
+ </Menu>
+ <StatusBar Name="StatusBar" HorizontalAlignment="Right" DockPanel.Dock="Bottom">
+ <Label>Test</Label>
+ </StatusBar>
+ <StackPanel>
+ <Expander>
+ <Expander.Header>
+ <DockPanel>
+ <Label>Family Member:</Label>
+ <ComboBox Width="150"></ComboBox>
+ <Button >Test</Button>
+ </DockPanel>
+ </Expander.Header>
+ <UniformGrid>
+ <Label FontWeight="Bold">First Name</Label>
+ <Label>Mo</Label>
+ <Label FontWeight="Bold">Last Name</Label>
+ <Label>Khan</Label>
+ </UniformGrid>
+ </Expander>
+ <TabControl Name="Tabs">
+ <TabItem Header="Test"></TabItem>
+ </TabControl>
+ </StackPanel>
+ </DockPanel>
+</Window>
product/client/presentation.windows/views/ShellWIndow.xaml.cs
@@ -0,0 +1,37 @@
+using System;
+using System.Collections.Generic;
+using System.Windows;
+using gorilla.commons.utility;
+
+namespace presentation.windows
+{
+ public partial class ShellWindow : Shell, RegionManager
+ {
+ readonly IDictionary<Type, UIElement> regions;
+
+ public ShellWindow()
+ {
+ InitializeComponent();
+ regions = new Dictionary<Type, UIElement>
+ {
+ {GetType(), this},
+ {typeof (Window), this},
+ {Tabs.GetType(), Tabs},
+ {StatusBar.GetType(), StatusBar},
+ {Menu.GetType(), Menu},
+ };
+ }
+
+ 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}".formatted_using(typeof (Region)));
+ }
+ }
+}
\ No newline at end of file
product/client/presentation.windows/ApplicationController.cs
@@ -0,0 +1,9 @@
+using System.Windows;
+
+namespace presentation.windows
+{
+ public interface ApplicationController
+ {
+ void add_tab<Presenter, View>() where Presenter : TabPresenter where View : FrameworkElement, Tab<Presenter>, new();
+ }
+}
\ No newline at end of file
product/client/presentation.windows/ComposeShell.cs
@@ -0,0 +1,32 @@
+using System.Threading;
+using System.Windows.Controls;
+using System.Windows.Controls.Primitives;
+
+namespace presentation.windows
+{
+ public class ComposeShell : NeedStartup
+ {
+ RegionManager region_manager;
+ ApplicationController controller;
+
+ public ComposeShell(RegionManager region_manager, ApplicationController controller)
+ {
+ this.region_manager = region_manager;
+ this.controller = controller;
+ }
+
+ public void run()
+ {
+ controller.add_tab<CompensationPresenter, CompensationTab>();
+ region_manager.region<TabControl>(x => x.Items.Add(new TabItem {Header = "Expenses"}));
+ region_manager.region<TabControl>(x => x.Items.Add(new TabItem {Header = "RRSP"}));
+ region_manager.region<TabControl>(x => x.Items.Add(new TabItem {Header = "Party"}));
+ region_manager.region<TabControl>(x => x.Items.Add(new TabItem {Header = "Assets"}));
+ region_manager.region<TabControl>(x => x.Items.Add(new TabItem {Header = "Liabilities"}));
+ region_manager.region<TabControl>(x => x.Items.Add(new TabItem {Header = "Budget"}));
+
+ region_manager.region<StatusBar>(x => x.Items.Add(new Label {Content = Thread.CurrentPrincipal.Identity.Name}));
+ region_manager.region<StatusBar>(x => x.Items.Add(new Label {Content = "Software Developer"}));
+ }
+ }
+}
\ No newline at end of file
product/client/presentation.windows/IncomeTab.xaml
@@ -1,12 +0,0 @@
-<UserControl x:Class="presentation.windows.IncomeTab"
- xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
- <ListView>
- <ListViewItem HorizontalAlignment="Stretch">
- <DockPanel>
- <Label>Add Income</Label>
- <TextBox></TextBox>
- </DockPanel>
- </ListViewItem>
- </ListView>
-</UserControl>
product/client/presentation.windows/IncomeTab.xaml.cs
@@ -1,10 +0,0 @@
-namespace presentation.windows
-{
- public partial class IncomeTab
- {
- public IncomeTab()
- {
- InitializeComponent();
- }
- }
-}
\ No newline at end of file
product/client/presentation.windows/NeedStartup.cs
@@ -0,0 +1,6 @@
+using gorilla.commons.utility;
+
+namespace presentation.windows
+{
+ public interface NeedStartup : Command {}
+}
\ No newline at end of file
product/client/presentation.windows/presentation.windows.csproj
@@ -33,6 +33,10 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
+ <Reference Include="Autofac, Version=1.0.0.0, Culture=neutral, PublicKeyToken=17863af14b0044da, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\..\..\build\lib\app\auto.fac\Autofac.dll</HintPath>
+ </Reference>
<Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
@@ -59,23 +63,31 @@
</Reference>
</ItemGroup>
<ItemGroup>
- <Page Include="IncomeTab.xaml">
+ <Page Include="views\CompensationTab.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
- <Page Include="ShellWIndow.xaml">
+ <Page Include="views\ShellWIndow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
- <Compile Include="ShellWIndow.xaml.cs">
+ <Compile Include="views\ShellWIndow.xaml.cs">
<DependentUpon>ShellWIndow.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
</ItemGroup>
<ItemGroup>
- <Compile Include="IncomeTab.xaml.cs">
- <DependentUpon>IncomeTab.xaml</DependentUpon>
+ <Compile Include="ApplicationController.cs" />
+ <Compile Include="presenters\CompensationPresenter.cs" />
+ <Compile Include="views\CompensationTab.xaml.cs">
+ <DependentUpon>CompensationTab.xaml</DependentUpon>
</Compile>
+ <Compile Include="ComposeShell.cs" />
+ <Compile Include="NeedStartup.cs" />
+ <Compile Include="Presenter.cs" />
+ <Compile Include="PresenterFactory.cs" />
+ <Compile Include="RegionManager.cs" />
+ <Compile Include="Shell.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType>
@@ -90,6 +102,10 @@
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
+ <Compile Include="Tab.cs" />
+ <Compile Include="TabPresenter.cs" />
+ <Compile Include="WpfApplicationController.cs" />
+ <Compile Include="WpfPresenterFactory.cs" />
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
@@ -100,6 +116,20 @@
</None>
<AppDesigner Include="Properties\" />
</ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\..\commons\infrastructure.thirdparty\infrastructure.thirdparty.csproj">
+ <Project>{04DC09B4-5DF9-44A6-8DD1-05941F0D0228}</Project>
+ <Name>infrastructure.thirdparty</Name>
+ </ProjectReference>
+ <ProjectReference Include="..\..\commons\infrastructure\infrastructure.csproj">
+ <Project>{AA5EEED9-4531-45F7-AFCD-AD9717D2E405}</Project>
+ <Name>infrastructure</Name>
+ </ProjectReference>
+ <ProjectReference Include="..\..\commons\utility\utility.csproj">
+ <Project>{DD8FD29E-7424-415C-9BA3-7D9F6ECBA161}</Project>
+ <Name>utility</Name>
+ </ProjectReference>
+ </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
product/client/presentation.windows/Presenter.cs
@@ -0,0 +1,7 @@
+namespace presentation.windows
+{
+ public interface Presenter
+ {
+ void present();
+ }
+}
\ No newline at end of file
product/client/presentation.windows/PresenterFactory.cs
@@ -0,0 +1,7 @@
+namespace presentation.windows
+{
+ public interface PresenterFactory
+ {
+ T create<T>() where T : Presenter;
+ }
+}
\ No newline at end of file
product/client/presentation.windows/Program.cs
@@ -1,5 +1,11 @@
using System;
+using System.Collections.Generic;
+using System.Security.Principal;
using System.Windows;
+using Autofac.Builder;
+using Gorilla.Commons.Infrastructure.Container;
+using gorilla.commons.infrastructure.thirdparty.Autofac;
+using gorilla.commons.utility;
namespace presentation.windows
{
@@ -8,10 +14,26 @@ namespace presentation.windows
[STAThread]
static public void Main()
{
+ AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal);
var application = new Application();
application.DispatcherUnhandledException += (o, e) => {};
application.ShutdownMode = ShutdownMode.OnMainWindowClose;
- application.Run(new ShellWindow());
+ application.Run(create_window());
+ }
+
+ static ShellWindow create_window()
+ {
+ var builder = new ContainerBuilder();
+ var shell_window = new ShellWindow();
+ builder.Register(x => shell_window).As<RegionManager>();
+ builder.Register<ComposeShell>().As<NeedStartup>();
+ builder.Register<WpfApplicationController>().As<ApplicationController>();
+ builder.Register<WpfPresenterFactory>().As<PresenterFactory>();
+ builder.Register<CompensationPresenter>();
+
+ Resolve.initialize_with(new AutofacDependencyRegistryBuilder(builder).build());
+ Resolve.the<IEnumerable<NeedStartup>>().each(x => x.run());
+ return shell_window;
}
}
}
\ No newline at end of file
product/client/presentation.windows/RegionManager.cs
@@ -0,0 +1,10 @@
+using System;
+using System.Windows;
+
+namespace presentation.windows
+{
+ public interface RegionManager
+ {
+ void region<Control>(Action<Control> configure) where Control : UIElement;
+ }
+}
\ No newline at end of file
product/client/presentation.windows/Shell.cs
@@ -0,0 +1,4 @@
+namespace presentation.windows
+{
+ public interface Shell {}
+}
\ No newline at end of file
product/client/presentation.windows/ShellWIndow.xaml
@@ -1,39 +0,0 @@
-<Window x:Class="presentation.windows.ShellWindow"
- xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:windows="clr-namespace:presentation.windows" Title="MoMoney - (ALPHA)" Height="600" Width="800">
- <StackPanel VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
- <Menu>
- <MenuItem Header="_File">
- <MenuItem Header="_New"></MenuItem>
- <MenuItem Header="_Open"></MenuItem>
- <MenuItem Header="_Save"></MenuItem>
- <MenuItem Header="Save _As..."></MenuItem>
- <MenuItem Header="_Close"></MenuItem>
- <MenuItem Height="10"></MenuItem>
- <MenuItem Header="E_xit"></MenuItem>
- </MenuItem>
- <MenuItem Header="_Window">
- <MenuItem Header="_Close All"></MenuItem>
- </MenuItem>
- <MenuItem Header="_Help">
- <MenuItem Header="_Check For Updates"></MenuItem>
- <MenuItem Header="_About"></MenuItem>
- </MenuItem>
- </Menu>
-
- <TabControl>
- <windows:IncomeTab></windows:IncomeTab>
- <TabItem Header="Expenses"></TabItem>
- <TabItem Header="RRSP"></TabItem>
- <TabItem Header="Party"></TabItem>
- <TabItem Header="Assets"></TabItem>
- <TabItem Header="Liabilities"></TabItem>
- <TabItem Header="Budget"></TabItem>
- </TabControl>
-
- <StatusBar HorizontalAlignment="Right">
- <Label>Mo Khan</Label>
- <Label>Software Developer</Label>
- </StatusBar>
- </StackPanel>
-</Window>
product/client/presentation.windows/ShellWIndow.xaml.cs
@@ -1,10 +0,0 @@
-namespace presentation.windows
-{
- public partial class ShellWindow
- {
- public ShellWindow()
- {
- InitializeComponent();
- }
- }
-}
\ No newline at end of file
product/client/presentation.windows/Tab.cs
@@ -0,0 +1,4 @@
+namespace presentation.windows
+{
+ public interface Tab<Presenter> where Presenter : TabPresenter {}
+}
\ No newline at end of file
product/client/presentation.windows/TabPresenter.cs
@@ -0,0 +1,7 @@
+namespace presentation.windows
+{
+ public interface TabPresenter : Presenter
+ {
+ string Header { get; }
+ }
+}
\ No newline at end of file
product/client/presentation.windows/WpfApplicationController.cs
@@ -0,0 +1,28 @@
+using System.Windows;
+using System.Windows.Controls;
+
+namespace presentation.windows
+{
+ public class WpfApplicationController : ApplicationController
+ {
+ RegionManager region_manager;
+ PresenterFactory factory;
+
+ public WpfApplicationController(RegionManager region_manager, PresenterFactory factory)
+ {
+ this.region_manager = region_manager;
+ this.factory = factory;
+ }
+
+ public void add_tab<Presenter, View>() where Presenter : TabPresenter where View : FrameworkElement, Tab<Presenter>, new()
+ {
+ var presenter = factory.create<Presenter>();
+ presenter.present();
+ region_manager.region<TabControl>(x => x.Items.Add(new TabItem
+ {
+ Header = presenter.Header,
+ Content = new View {DataContext = presenter}
+ }));
+ }
+ }
+}
\ No newline at end of file
product/client/presentation.windows/WpfPresenterFactory.cs
@@ -0,0 +1,12 @@
+using Gorilla.Commons.Infrastructure.Container;
+
+namespace presentation.windows
+{
+ public class WpfPresenterFactory : PresenterFactory
+ {
+ public T create<T>() where T : Presenter
+ {
+ return Resolve.the<T>();
+ }
+ }
+}
\ No newline at end of file
product/commons/infrastructure.thirdparty/autofac/AutofacDependencyRegistry.cs
@@ -5,7 +5,7 @@ using Gorilla.Commons.Infrastructure.Container;
namespace gorilla.commons.infrastructure.thirdparty.autofac
{
- internal class AutofacDependencyRegistry : DependencyRegistry
+ public class AutofacDependencyRegistry : DependencyRegistry
{
readonly Func<IContainer> container;