Commit f775664
Changed files (22)
product
client
client.ui
bootstrappers
presenters
views
common
server
handlers
support
unit
client
presenters
product/client/client.ui/bootstrappers/Bootstrapper.cs
@@ -39,6 +39,7 @@ namespace presentation.windows.bootstrappers
// infrastructure
builder.Register<Log4NetLogFactory>().As<LogFactory>().SingletonScoped();
builder.Register<DefaultMapper>().As<Mapper>().SingletonScoped();
+ builder.RegisterGeneric(typeof(Mapper<,>));
var manager = new QueueManager(new IPEndPoint(IPAddress.Loopback, 2201), "client.esent");
manager.CreateQueues("client");
@@ -55,15 +56,14 @@ namespace presentation.windows.bootstrappers
// presenters
builder.Register<StatusBarPresenter>().SingletonScoped();
- builder.Register<CompensationPresenter>().SingletonScoped();
builder.Register<SelectedFamilyMemberPresenter>().SingletonScoped();
builder.Register<AddFamilyMemberPresenter>();
builder.Register<AddFamilyMemberPresenter.SaveCommand>();
builder.Register<AccountPresenter>();
- builder.Register<AccountPresenter.AddNewAccountCommand>();
+ builder.Register<AccountPresenter.ImportTransactionCommand>();
builder.Register<CancelCommand>();
- builder.Register<AddNewAccountPresenter>();
- builder.Register<AddNewAccountPresenter.CreateNewAccount>();
+ builder.Register<AddNewDetailAccountPresenter>();
+ builder.Register<AddNewDetailAccountPresenter.CreateNewAccount>();
// commanding
builder.Register<AsynchronousCommandProcessor>().As<CommandProcessor>().SingletonScoped();
product/client/client.ui/bootstrappers/ComposeShell.cs
@@ -17,14 +17,7 @@ namespace presentation.windows.bootstrappers
public void run()
{
- controller.add_tab<CompensationPresenter, CompensationTab>();
controller.add_tab<AccountPresenter, AccountTab>();
- //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<MainMenu>(x =>
{
@@ -32,8 +25,8 @@ namespace presentation.windows.bootstrappers
{
controller.launch_dialog<AddFamilyMemberPresenter, AddFamilyMemberDialog>();
});
- x.add("_Accounts").add("_Add Detail Account", () => {
- controller.launch_dialog<AddNewAccountPresenter, AddNewAccountDialog>();
+ x.add("_Accounts").add("_Add Account", () => {
+ controller.launch_dialog<AddNewDetailAccountPresenter, AddNewDetailAccountDialog>();
});
});
product/client/client.ui/bootstrappers/StartServiceBus.cs
@@ -13,7 +13,6 @@ namespace presentation.windows.bootstrappers
var handler = new MessageHandler(Resolve.the<DependencyRegistry>());
receiver.register(x =>
{
- // synchronize with ui thread?
handler.handle(x);
});
Resolve.the<CommandProcessor>().add(receiver);
product/client/client.ui/presenters/AccountPresenter.cs
@@ -1,5 +1,3 @@
-using presentation.windows.views;
-
namespace presentation.windows.presenters
{
public class AccountPresenter : TabPresenter
@@ -13,29 +11,28 @@ namespace presentation.windows.presenters
public void present()
{
- AddAccount = ui_builder.build<AddNewAccountCommand>(this);
+ import = ui_builder.build<ImportTransactionCommand>(this);
}
+ public SelectedAccountDetails SelectedAccount { get; set; }
+
+ public IObservableCommand import { get; set; }
+
public string Header
{
get { return "Accounts"; }
}
- IObservableCommand AddAccount { get; set; }
-
- public class AddNewAccountCommand : UICommand<AccountPresenter>
+ public class ImportTransactionCommand : UICommand<AccountPresenter>
{
ApplicationController controller;
- public AddNewAccountCommand(ApplicationController controller)
- {
- this.controller = controller;
- }
-
protected override void run(AccountPresenter presenter)
{
- controller.launch_dialog<AddNewAccountPresenter, AddNewAccountDialog>();
+ //controller.launch_dialog<ImportTransactionsPresenter, ImportTransactionDialog>(presenter.SelectedAccount);
}
}
}
+
+ public class SelectedAccountDetails {}
}
\ No newline at end of file
product/client/client.ui/presenters/AddNewAccountPresenter.cs
@@ -1,47 +0,0 @@
-using System;
-using presentation.windows.common;
-
-namespace presentation.windows.presenters
-{
- public class AddNewAccountPresenter : DialogPresenter
- {
- UICommandBuilder builder;
-
- public AddNewAccountPresenter(UICommandBuilder builder)
- {
- this.builder = builder;
- }
-
- public void present()
- {
- Accept = builder.build<CreateNewAccount>(this);
- Cancel = builder.build<CancelCommand>(this);
- }
-
- public string account_name { get; set; }
- public string currency { get; set; }
- public Action close { get; set; }
- public IObservableCommand Accept { get; set; }
- public IObservableCommand Cancel { get; set; }
-
- public class CreateNewAccount : UICommand<AddNewAccountPresenter>
- {
- ServiceBus bus;
-
- public CreateNewAccount(ServiceBus bus)
- {
- this.bus = bus;
- }
-
- protected override void run(AddNewAccountPresenter presenter)
- {
- bus.publish<common.messages.CreateNewAccount>(x =>
- {
- x.account_name = presenter.account_name;
- x.currency = presenter.currency;
- });
- presenter.close();
- }
- }
- }
-}
\ No newline at end of file
product/client/client.ui/presenters/AddNewDetailAccountPresenter.cs
@@ -0,0 +1,50 @@
+using System;
+using System.Collections.Generic;
+using presentation.windows.common;
+
+namespace presentation.windows.presenters
+{
+ public class AddNewDetailAccountPresenter : DialogPresenter
+ {
+ UICommandBuilder builder;
+
+ public AddNewDetailAccountPresenter(UICommandBuilder builder)
+ {
+ this.builder = builder;
+ }
+
+ public void present()
+ {
+ add = builder.build<CreateNewAccount>(this);
+ cancel = builder.build<CancelCommand>(this);
+ currencies = new[] { "CAD" }.to_observable();
+ }
+
+ public string account_name { get; set; }
+ public string currency { get; set; }
+ public IEnumerable<string> currencies { get; set; }
+ public Action close { get; set; }
+ public IObservableCommand add { get; set; }
+ public IObservableCommand cancel { get; set; }
+
+ public class CreateNewAccount : UICommand<AddNewDetailAccountPresenter>
+ {
+ ServiceBus bus;
+
+ public CreateNewAccount(ServiceBus bus)
+ {
+ this.bus = bus;
+ }
+
+ protected override void run(AddNewDetailAccountPresenter presenter)
+ {
+ bus.publish<common.messages.CreateNewDetailAccount>(x =>
+ {
+ x.account_name = presenter.account_name;
+ x.currency = presenter.currency;
+ });
+ presenter.close();
+ }
+ }
+ }
+}
\ No newline at end of file
product/client/client.ui/presenters/CompensationPresenter.cs
@@ -1,17 +0,0 @@
-using presentation.windows.eventing;
-using presentation.windows.events;
-
-namespace presentation.windows.presenters
-{
- public class CompensationPresenter : TabPresenter, EventSubscriber<SelectedFamilyMember>
- {
- public string Header
- {
- get { return "Compensation"; }
- }
-
- public void present() {}
-
- public void notify(SelectedFamilyMember message) {}
- }
-}
\ No newline at end of file
product/client/client.ui/views/images/cancel.png
Binary file
product/client/client.ui/views/images/save.png
Binary file
product/client/client.ui/views/AccountTab.xaml
@@ -2,8 +2,7 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<StackPanel>
- <Button Command="{Binding AddAccount}">Add New Account</Button>
- <TreeView>
- </TreeView>
+ <Label>Accounts</Label>
+ <Button Command="{Binding import}">Import Transactions</Button>
</StackPanel>
</UserControl>
product/client/client.ui/views/AddNewAccountDialog.xaml
@@ -1,8 +0,0 @@
-<Window x:Class="presentation.windows.views.AddNewAccountDialog"
- xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- Title="AddNewAccountDialog" Height="300" Width="300">
- <Grid>
-
- </Grid>
-</Window>
product/client/client.ui/views/AddNewDetailAccountDialog.xaml
@@ -0,0 +1,27 @@
+<Window x:Class="presentation.windows.views.AddNewDetailAccountDialog" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:views="clr-namespace:presentation.windows.views" Title="Add New Detail Account">
+ <StackPanel>
+ <ListView HorizontalContentAlignment="Stretch" KeyboardNavigation.TabNavigation="Continue">
+ <ListView.ItemContainerStyle>
+ <Style TargetType="{x:Type ListViewItem}">
+ <Setter Property="IsTabStop" Value="False" />
+ </Style>
+ </ListView.ItemContainerStyle>
+ <ListViewItem>
+ <DockPanel HorizontalAlignment="Stretch">
+ <Label Width="150">Name:</Label>
+ <TextBox HorizontalAlignment="Stretch" Text="{Binding Path=account_name}"/>
+ </DockPanel>
+ </ListViewItem>
+ <ListViewItem>
+ <DockPanel>
+ <Label Width="150">Currency:</Label>
+ <ComboBox SelectedItem="{Binding Path=currency}" ItemsSource="{Binding Path=currencies}"></ComboBox>
+ </DockPanel>
+ </ListViewItem>
+ </ListView>
+ <StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
+ <views:ImageButton ImageSource="images\save.png" ToolTip="Add" Label="_Add" Command="{Binding Path=add}" IsDefault="True"/>
+ <views:ImageButton ImageSource="images\cancel.png" ToolTip="Cancel" Label="_Cancel" Command="{Binding Path=cancel}" IsCancel="True" />
+ </StackPanel>
+ </StackPanel>
+</Window>
\ No newline at end of file
product/client/client.ui/views/AddNewAccountDialog.xaml.cs → product/client/client.ui/views/AddNewDetailAccountDialog.xaml.cs
@@ -3,9 +3,9 @@ using presentation.windows.presenters;
namespace presentation.windows.views
{
- public partial class AddNewAccountDialog : Dialog<AddNewAccountPresenter>
+ public partial class AddNewDetailAccountDialog : Dialog<AddNewDetailAccountPresenter>
{
- public AddNewAccountDialog()
+ public AddNewDetailAccountDialog()
{
InitializeComponent();
}
product/client/client.ui/views/CompensationTab.xaml
@@ -1,26 +0,0 @@
-<UserControl x:Class="presentation.windows.views.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>
\ No newline at end of file
product/client/client.ui/views/CompensationTab.xaml.cs
@@ -1,12 +0,0 @@
-using presentation.windows.presenters;
-
-namespace presentation.windows.views
-{
- public partial class CompensationTab : Tab<CompensationPresenter>
- {
- public CompensationTab()
- {
- InitializeComponent();
- }
- }
-}
\ No newline at end of file
product/client/client.ui/views/ImageButton.cs
@@ -0,0 +1,58 @@
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Media;
+
+namespace presentation.windows.views
+{
+ public class ImageButton : System.Windows.Controls.Button
+ {
+ public static readonly DependencyProperty ImageSourceProperty = DependencyProperty.Register("ImageSource", typeof(ImageSource), typeof(ImageButton));
+
+ public static readonly DependencyProperty LabelProperty = DependencyProperty.Register("Label", typeof(string),typeof (ImageButton));
+
+ public ImageSource ImageSource
+ {
+ get { return (ImageSource)GetValue(ImageSourceProperty); }
+ set{SetValue(ImageSourceProperty, value);}
+ }
+
+ public string Label
+ {
+ get { return (string) GetValue(LabelProperty); }
+ set{ SetValue(LabelProperty, value);}
+ }
+
+ private void Configure()
+ {
+ var binding = new Binding
+ {
+ RelativeSource = new RelativeSource(RelativeSourceMode.FindAncestor, typeof(ImageButton), 1),
+ Path = new PropertyPath("IsEnabled")
+ };
+ var dataTrigger = new DataTrigger { Binding = binding, Value = false, Setters = { new Setter(OpacityProperty, 0.25) } };
+ var stackPanel = new StackPanel();
+
+ stackPanel.Children.Add(new Image {Source = ImageSource, Style = new Style { Triggers = { dataTrigger } }, Height = 25, Margin = new Thickness(0)});
+ var label = new Label
+ {
+ HorizontalAlignment = HorizontalAlignment.Center,
+ HorizontalContentAlignment = HorizontalAlignment.Left,
+ Margin = new Thickness(0),
+ Padding = new Thickness(0),
+ };
+ if (!string.IsNullOrEmpty(Label))
+ label.Content = new AccessText{Text = Label, TextWrapping = TextWrapping.Wrap, Margin = new Thickness(0)};
+
+ stackPanel.Children.Add(label);
+ Content = stackPanel;
+ }
+
+ protected override void OnInitialized(System.EventArgs e)
+ {
+ base.OnInitialized(e);
+ Configure();
+ SetValue(ToolTipService.ShowOnDisabledProperty, true);
+ }
+ }
+}
\ No newline at end of file
product/client/client.ui/client.csproj
@@ -108,13 +108,7 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
- <Page Include="views\AddNewAccountDialog.xaml">
- <SubType>Designer</SubType>
- <Generator>MSBuild:Compile</Generator>
- <Generator>MSBuild:Compile</Generator>
- <SubType>Designer</SubType>
- </Page>
- <Page Include="views\CompensationTab.xaml">
+ <Page Include="views\AddNewDetailAccountDialog.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
<Generator>MSBuild:Compile</Generator>
@@ -148,6 +142,7 @@
<Compile Include="eventing\EventAggregator.cs" />
<Compile Include="eventing\EventSubscriber.cs" />
<Compile Include="eventing\SynchronizedEventAggregator.cs" />
+ <Compile Include="views\ImageButton.cs" />
<Compile Include="views\ShellWindow.xaml.cs">
<DependentUpon>ShellWindow.xaml</DependentUpon>
<SubType>Code</SubType>
@@ -164,9 +159,8 @@
<Compile Include="DialogPresenter.cs" />
<Compile Include="presenters\AccountPresenter.cs" />
<Compile Include="presenters\AddFamilyMemberPresenter.cs" />
- <Compile Include="presenters\AddNewAccountPresenter.cs" />
+ <Compile Include="presenters\AddNewDetailAccountPresenter.cs" />
<Compile Include="CancelCommand.cs" />
- <Compile Include="presenters\CompensationPresenter.cs" />
<Compile Include="UICommand.cs" />
<Compile Include="UICommandBuilder.cs" />
<Compile Include="presenters\WpfBindingExtensinos.cs" />
@@ -182,11 +176,8 @@
<Compile Include="views\AddFamilyMemberDialog.xaml.cs">
<DependentUpon>AddFamilyMemberDialog.xaml</DependentUpon>
</Compile>
- <Compile Include="views\AddNewAccountDialog.xaml.cs">
- <DependentUpon>AddNewAccountDialog.xaml</DependentUpon>
- </Compile>
- <Compile Include="views\CompensationTab.xaml.cs">
- <DependentUpon>CompensationTab.xaml</DependentUpon>
+ <Compile Include="views\AddNewDetailAccountDialog.xaml.cs">
+ <DependentUpon>AddNewDetailAccountDialog.xaml</DependentUpon>
</Compile>
<Compile Include="bootstrappers\ComposeShell.cs" />
<Compile Include="Presenter.cs" />
@@ -257,6 +248,8 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
+ <Resource Include="views\images\cancel.png" />
+ <Resource Include="views\images\save.png" />
<Content Include="log4net.config.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
product/client/common/messages/CreateNewAccount.cs → product/client/common/messages/CreateNewDetailAccount.cs
@@ -5,7 +5,7 @@ namespace presentation.windows.common.messages
{
[Serializable]
[ProtoContract]
- public class CreateNewAccount
+ public class CreateNewDetailAccount
{
[ProtoMember(1)]
public string account_name { get; set; }
product/client/common/common.csproj
@@ -87,7 +87,7 @@
<Compile Include="IEvent.cs" />
<Compile Include="MessageHandler.cs" />
<Compile Include="messages\AddedNewFamilyMember.cs" />
- <Compile Include="messages\CreateNewAccount.cs" />
+ <Compile Include="messages\CreateNewDetailAccount.cs" />
<Compile Include="messages\FamilyMemberToAdd.cs" />
<Compile Include="messages\FindAllFamily.cs" />
<Compile Include="messages\NewAccountCreated.cs" />
product/client/common/MessageHandler.cs
@@ -1,7 +1,6 @@
using System;
using System.IO;
using Gorilla.Commons.Infrastructure.Container;
-using Gorilla.Commons.Infrastructure.Logging;
using gorilla.commons.utility;
using ProtoBuf;
using Rhino.Queues.Model;
@@ -20,7 +19,6 @@ namespace presentation.windows.common
public void handle(Message item)
{
var payload = parse_payload_from(item);
- this.log().debug("received: {0}", payload);
registry
.get_all<Handler>()
.each(x => x.handle(payload));
product/client/server/handlers/SaveNewAccountCommand.cs
@@ -5,7 +5,7 @@ using presentation.windows.server.orm;
namespace presentation.windows.server.handlers
{
- public class SaveNewAccountCommand : AbstractHandler<CreateNewAccount>
+ public class SaveNewAccountCommand : AbstractHandler<CreateNewDetailAccount>
{
AccountRepository accounts;
ServiceBus bus;
@@ -16,7 +16,7 @@ namespace presentation.windows.server.handlers
this.bus = bus;
}
- public override void handle(CreateNewAccount item)
+ public override void handle(CreateNewDetailAccount item)
{
accounts.save(Account.New(item.account_name, Currency.named(item.currency)));
bus.publish<NewAccountCreated>(x => x.name = item.account_name);
product/support/unit/client/presenters/WpfCommandBuilderSpecs.cs
@@ -1,4 +1,3 @@
-using Autofac;
using Gorilla.Commons.Infrastructure.Container;
using Machine.Specifications;
using presentation.windows;