Added functionality to edit persons

This commit is contained in:
Andre Beging
2017-09-12 21:01:51 +02:00
parent 4a6c6ef544
commit ffbf5d7be9
8 changed files with 216 additions and 59 deletions

View File

@@ -24,10 +24,6 @@ namespace DebtMgr.View.Dialogs
App.Locator.AddTransactionView.RequestClose += (s, e) => Close();
DataContext = App.Locator.AddTransactionView;
//Uri iconUri = new Uri("pack://application:,,,/Content/money_red.ico", UriKind.RelativeOrAbsolute);
//this.Icon = BitmapFrame.Create(iconUri);
}
#region TextBox_OnKeyUp()

View File

@@ -7,7 +7,7 @@
mc:Ignorable="d"
Name="NewPersonDialogViewWindow"
Icon="../../Content/addperson.ico"
Title="New Person" Height="205" Width="300"
Title="{Binding WindowTitle}" Height="205" Width="300"
KeyUp="Window_KeyUp">
<Grid>
<Grid.RowDefinitions>
@@ -16,7 +16,7 @@
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
</Grid.RowDefinitions>
<Label Grid.Row="0" Content="New Person" FontWeight="Bold" FontSize="18"></Label>
<Label Grid.Row="0" Content="{Binding ElementName=NewPersonDialogViewWindow, Path=Title}" FontWeight="Bold" FontSize="18"></Label>
<StackPanel Grid.Row="1" Orientation="Vertical" Margin="10 0">
<TextBox KeyUp="TextBox_OnKeyUp" Name="FirstNameTextBox" Text="{Binding FirstNameTextBoxText, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" FontSize="16" Margin="0 0 0 -5"></TextBox>
<Label Content="First name"></Label>
@@ -30,7 +30,7 @@
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Button Grid.Column="1" Content="Create Person" FontSize="14" Padding="5" Margin="10 -10" Command="{Binding CreatePersonButtonClickCommand}"></Button>
<Button Grid.Column="1" Content="{Binding SaveButtonText}" FontSize="14" Padding="5" Margin="10 -10" Command="{Binding CreatePersonButtonClickCommand}"></Button>
</Grid>
</Grid>
</Window>

View File

@@ -1,6 +1,8 @@
using System.Windows;
using System;
using System.Windows;
using System.Windows.Input;
using DebtMgr.Extensions;
using DebtMgr.Model;
namespace DebtMgr.View.Dialogs
{
@@ -9,17 +11,24 @@ namespace DebtMgr.View.Dialogs
/// </summary>
public partial class NewPersonDialogView : Window
{
public NewPersonDialogView()
public NewPersonDialogView(PersonDialogMode mode, Guid personId = default(Guid))
{
InitializeComponent();
this.CenterOnParent();
App.Locator.NewPersonDialogView.ClearView();
App.Locator.NewPersonDialogView.DialogMode = mode;
App.Locator.NewPersonDialogView.EditPersonId = personId;
App.Locator.NewPersonDialogView.SetModeSpecifics();
App.Locator.NewPersonDialogView.RequestClose += (s, e) => Close();
DataContext = App.Locator.NewPersonDialogView;
FirstNameTextBox.Focus();
}
#region TextBox_OnKeyUp()
////////////////////////////////////////////////////////////////////////////////////////////////////
/// <summary> Event handler. Called by TextBox for on key up events. </summary>
///
@@ -34,6 +43,10 @@ namespace DebtMgr.View.Dialogs
App.Locator.NewPersonDialogView.CreatePersonButtonClickCommand.Execute(null);
}
#endregion
#region Window_KeyUp()
////////////////////////////////////////////////////////////////////////////////////////////////////
/// <summary> Event handler. Called by Window for key up events. </summary>
///
@@ -47,5 +60,7 @@ namespace DebtMgr.View.Dialogs
if (e.Key.Equals(Key.Escape))
Close();
}
#endregion
}
}

View File

@@ -57,7 +57,7 @@
<TextBlock Text="€" Foreground="{Binding OverallBalanceLabel, Converter={StaticResource AmountToColorConverter}}"></TextBlock>
</TextBlock>
<Button Grid.Column="1" Padding="5" ToolTip="New Person" Margin="5 0 5 5" Command="{Binding NewPersonContextMenuCommand}">
<Image Source="../Content/addperson.ico" Width="30" />
<Image Source="../Content/addperson.ico" Height="30" />
</Button>
</Grid>
@@ -82,10 +82,12 @@
</ListView.View>
<ListBox.Resources>
<ContextMenu x:Key="PersonListViewContextMenu">
<MenuItem Header="Add charge" Command="{Binding AddChargeContextMenuCommand}" />
<MenuItem Header="Add deposit" Command="{Binding AddDepositContextMenuCommand}" />
<MenuItem Header="New Person" Command="{Binding NewPersonContextMenuCommand}" />
<MenuItem Header="Delete Person" Command="{Binding DeletePersonContextMenuCommand}" CommandParameter="{Binding Path=SelectedItem}" />
<MenuItem Header="_Edit Person" Command="{Binding EditPersonContextMenuCommand}" />
<MenuItem Header="Delete Person" Command="{Binding DeletePersonContextMenuCommand}" />
<MenuItem Header="_New Person" Command="{Binding NewPersonContextMenuCommand}" />
<Separator></Separator>
<MenuItem Header="Add _Charge" Command="{Binding AddChargeContextMenuCommand}" />
<MenuItem Header="Add _Deposit" Command="{Binding AddDepositContextMenuCommand}" />
</ContextMenu>
</ListBox.Resources>
<ListBox.ContextMenu>
@@ -122,10 +124,10 @@
<TextBlock Text="€" Foreground="{Binding DetailViewBalanceLabel, Converter={StaticResource AmountToColorConverter}}"></TextBlock>
</TextBlock>
<Button Grid.Column="1" Padding="5" ToolTip="Add Charge" Margin="5 0 0 5" Command="{Binding AddChargeContextMenuCommand}">
<Image Source="../Content/money_red.ico" Width="30" />
<Image Source="../Content/money_red.ico" Height="30" />
</Button>
<Button Grid.Column="2" Padding="5" ToolTip="Add Deposit" Margin="5 0 5 5" Command="{Binding AddDepositContextMenuCommand}">
<Image Source="../Content/money_green.ico" Width="30" />
<Image Source="../Content/money_green.ico" Height="30" />
</Button>
</Grid>
<ListView Name="TransactionHistoryListView" Grid.Row="2" ItemsSource="{Binding TransactionHistoryListViewItemSource}" SelectedItem="{Binding TransactionHistoryListViewSelectedItem}" HorizontalContentAlignment="Stretch">
@@ -149,10 +151,11 @@
</ListView.View>
<ListBox.Resources>
<ContextMenu x:Key="TransactionHistoryListViewContextMenu">
<MenuItem Header="Edit Transaction" Command="{Binding EditTransactionContextMenuCommand}" CommandParameter="{Binding Path=SelectedItem}" />
<MenuItem Header="Add charge" Command="{Binding AddChargeContextMenuCommand}" />
<MenuItem Header="Add deposit" Command="{Binding AddDepositContextMenuCommand}" />
<MenuItem Header="_Edit Transaction" Command="{Binding EditTransactionContextMenuCommand}" CommandParameter="{Binding Path=SelectedItem}" />
<MenuItem Header="Delete Transaction" Command="{Binding DeleteTransactionContextMenuCommand}" CommandParameter="{Binding Path=SelectedItem}" />
<Separator></Separator>
<MenuItem Header="Add _Charge" Command="{Binding AddChargeContextMenuCommand}" />
<MenuItem Header="Add _Deposit" Command="{Binding AddDepositContextMenuCommand}" />
</ContextMenu>
</ListBox.Resources>
<ListBox.ContextMenu>