Commit ec9a08d
Changed files (6)
product
desktop.ui
product/desktop.ui/bootstrappers/ComposeShell.cs
@@ -36,6 +36,11 @@ namespace solidware.financials.windows.ui.bootstrappers
controller.load_region<StatusBarPresenter, StatusBarRegion>();
controller.load_region<SelectedFamilyMemberPresenter, SelectedFamilyMemberRegion>();
+ region_manager.region<SelectedFamilyMemberRegion>(x =>
+ {
+ x.AddCommand("Add Family Member", launch<AddFamilyMemberPresenter, AddFamilyMemberDialog>, UIIcon.Plus);
+ x.AddCommand("Add Income", launch<AddNewIncomeViewModel, AddNewIncomeDialog>, UIIcon.Plus);
+ });
}
void launch<Presenter, Dialog>() where Presenter : DialogPresenter
product/desktop.ui/views/ButtonExpression.cs
@@ -0,0 +1,45 @@
+using System.Windows.Controls;
+using System.Windows.Controls.Primitives;
+using gorilla.utility;
+
+namespace solidware.financials.windows.ui.views
+{
+ public class ButtonExpression
+ {
+ readonly ButtonBase button;
+
+ public ButtonExpression(ButtonBase button)
+ {
+ this.button = button;
+ }
+
+ public void Text(string text)
+ {
+ var panel = new StackPanel
+ {
+ Orientation = Orientation.Horizontal
+ };
+ var image = button.Content.downcast_to<Image>();
+ button.Content = panel;
+ panel.Children.Add(image);
+ panel.Children.Add(new Label
+ {
+ Content = text
+ });
+ }
+
+ public ButtonExpression SmallerImages()
+ {
+ var image = button.Content as Image ?? button.Content.downcast_to<StackPanel>().Children[0].downcast_to<Image>();
+ image.Width = image.Height = 16;
+
+ return this;
+ }
+
+ public ButtonExpression DoesNotAcceptTab()
+ {
+ button.TabIndex = int.MaxValue;
+ return this;
+ }
+ }
+}
\ No newline at end of file
product/desktop.ui/views/SelectedFamilyMemberRegion.xaml
@@ -1,18 +1,7 @@
-<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">
-<Expander>
- <Expander.Header>
- <DockPanel>
- <Label>Family Member:</Label>
- <ComboBox ItemsSource="{Binding family_members}" SelectedItem="{Binding SelectedMember}" Width="150"></ComboBox>
- </DockPanel>
- </Expander.Header>
- <UniformGrid>
- <Label FontWeight="Bold">First Name</Label>
- <Label Content="{Binding Path=SelectedMember.first_name, Mode=OneWay}"/>
- <Label FontWeight="Bold">Last Name</Label>
- <Label Content="{Binding Path=SelectedMember.last_name, Mode=OneWay}"/>
- </UniformGrid>
-</Expander>
+<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">
+<DockPanel Name="DockPanel" Background="Silver">
+ <ComboBox ItemsSource="{Binding family_members}" SelectedItem="{Binding SelectedMember}" Width="150"></ComboBox>
+ <Label Content="{Binding Path=SelectedMember.first_name, Mode=OneWay}"/>
+ <Label Content="{Binding Path=SelectedMember.last_name, Mode=OneWay}"/>
+</DockPanel>
</UserControl>
product/desktop.ui/views/SelectedFamilyMemberRegion.xaml.cs
@@ -1,4 +1,9 @@
+using System;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Input;
using solidware.financials.windows.ui.presenters;
+using solidware.financials.windows.ui.views.icons;
namespace solidware.financials.windows.ui.views
{
@@ -8,5 +13,42 @@ namespace solidware.financials.windows.ui.views
{
InitializeComponent();
}
+
+ public void AddCommand(string text, Action action)
+ {
+ DockPanel.Add<Button>(x =>
+ {
+ x.VerticalAlignment = VerticalAlignment.Stretch;
+ x.Content = text;
+ x.Click += action.ToRoutedHandler();
+ x.Height = 30;
+ x.Margin = new Thickness(5, 0, 5, 0);
+ x.HorizontalAlignment = HorizontalAlignment.Right;
+ });
+ }
+
+ public void AddCommand(string text, Action action, UIIcon icon)
+ {
+ DockPanel.Add<Button>(x =>
+ {
+ x.ToIconButton(icon, new SimpleCommand(action)).Text(text);
+ x.VerticalAlignment = VerticalAlignment.Stretch;
+ x.Height = 30;
+ x.Margin = new Thickness(5, 0, 5, 0);
+ x.HorizontalAlignment = HorizontalAlignment.Right;
+ });
+ }
+
+ public void AddCommand(string text, ICommand command, UIIcon icon)
+ {
+ DockPanel.Add<Button>(x =>
+ {
+ x.ToIconButton(icon, command).Text(text);
+ x.VerticalAlignment = VerticalAlignment.Stretch;
+ x.Height = 30;
+ x.Margin = new Thickness(5, 0, 5, 0);
+ x.HorizontalAlignment = HorizontalAlignment.Right;
+ });
+ }
}
}
\ No newline at end of file
product/desktop.ui/views/WPFExtensions.cs
@@ -0,0 +1,59 @@
+using System;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Controls.Primitives;
+using System.Windows.Input;
+using solidware.financials.windows.ui.views.icons;
+
+namespace solidware.financials.windows.ui.views
+{
+ static public class WPFExtensions
+ {
+ static public T Add<T>(this Panel panel, Action<T> action) where T : UIElement, new()
+ {
+ var element = panel.Add<T>();
+ action(element);
+ return element;
+ }
+
+ static public T Add<T>(this Panel panel) where T : UIElement, new()
+ {
+ var t = new T();
+ panel.Children.Add(t);
+ return t;
+ }
+
+ static public StackPanel Horizontal(this StackPanel panel)
+ {
+ panel.Orientation = Orientation.Horizontal;
+ return panel;
+ }
+
+ static public ButtonExpression ToIconButton(this ButtonBase button, UIIcon icon, ICommand command)
+ {
+ button.Command = command;
+ return button.ToIconButton(icon);
+ }
+
+ static public ButtonExpression ToIconButton(this ButtonBase button, UIIcon icon)
+ {
+ button.ClickMode = ClickMode.Release;
+ var image = button.Content as Image;
+ if (image == null)
+ {
+ image = new Image();
+ button.Content = image;
+
+ image.Width = 25;
+ image.Height = 25;
+ }
+ image.apply_icon(icon);
+ return new ButtonExpression(button);
+ }
+
+ static public RoutedEventHandler ToRoutedHandler(this Action action)
+ {
+ return (s, e) => action();
+ }
+ }
+}
\ No newline at end of file
product/desktop.ui/solidware.financials.csproj
@@ -152,6 +152,7 @@
<Compile Include="views\AddNewIncomeDialog.xaml.cs">
<DependentUpon>AddNewIncomeDialog.xaml</DependentUpon>
</Compile>
+ <Compile Include="views\ButtonExpression.cs" />
<Compile Include="views\DisplayCanadianTaxInformationDialog.xaml.cs">
<DependentUpon>DisplayCanadianTaxInformationDialog.xaml</DependentUpon>
</Compile>
@@ -178,6 +179,7 @@
<Compile Include="views\TaxSummaryTab.xaml.cs">
<DependentUpon>TaxSummaryTab.xaml</DependentUpon>
</Compile>
+ <Compile Include="views\WPFExtensions.cs" />
<Compile Include="WPFDialog.cs" />
<Compile Include="WPFApplication.cs" />
<Compile Include="WPFApplicationController.cs" />