A few visual improvements
This commit is contained in:
@@ -39,6 +39,15 @@
|
||||
<PropertyGroup>
|
||||
<ApplicationIcon>Content\money_green.ico</ApplicationIcon>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<SignAssembly>false</SignAssembly>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<AssemblyOriginatorKeyFile>sgKey.snk</AssemblyOriginatorKeyFile>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<DelaySign>false</DelaySign>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Costura, Version=1.6.2.0, Culture=neutral, PublicKeyToken=9919ef960d84173d, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Costura.Fody.1.6.2\lib\dotnet\Costura.dll</HintPath>
|
||||
@@ -100,6 +109,7 @@
|
||||
<Compile Include="Converters\AmountToColorConverter.cs" />
|
||||
<Compile Include="Data\Database.cs" />
|
||||
<Compile Include="Extensions\ExtensionMethods.cs" />
|
||||
<Compile Include="Helper\PrintHelper.cs" />
|
||||
<Compile Include="Model\Enums.cs" />
|
||||
<Compile Include="Model\Transaction.cs" />
|
||||
<Compile Include="Model\Person.cs" />
|
||||
@@ -172,6 +182,7 @@
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||
</None>
|
||||
<None Include="sgKey.snk" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
|
||||
62
Helper/PrintHelper.cs
Normal file
62
Helper/PrintHelper.cs
Normal file
@@ -0,0 +1,62 @@
|
||||
using System.IO;
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
|
||||
namespace DebtMgr.Helper
|
||||
{
|
||||
public class PrintHelper
|
||||
{
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// <summary> Saves an using encoder. </summary>
|
||||
///
|
||||
/// <remarks> Andre Beging, 13.09.2017. </remarks>
|
||||
///
|
||||
/// <param name="fileName"> Filename of the file. </param>
|
||||
/// <param name="uiElement"> The element. </param>
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
public static void SaveUsingEncoder(string fileName, FrameworkElement uiElement)
|
||||
{
|
||||
var encoder = new PngBitmapEncoder();
|
||||
|
||||
var height = (int)uiElement.ActualHeight;
|
||||
var width = (int)uiElement.ActualWidth;
|
||||
|
||||
// These two line of code make sure that you get completed visual bitmap.
|
||||
// In case your Framework Element is inside the scroll viewer then some part which is not
|
||||
// visible gets clip.
|
||||
uiElement.Measure(new Size(width, height));
|
||||
uiElement.Arrange(new Rect(new Point(), new Point(width, height)));
|
||||
|
||||
var bitmap = new RenderTargetBitmap(width,
|
||||
|
||||
height,
|
||||
96, // These decides the dpi factors
|
||||
96,// The can be changed when we'll have preview options.
|
||||
PixelFormats.Pbgra32);
|
||||
bitmap.Render(uiElement);
|
||||
|
||||
SaveUsingBitmapTargetRenderer(fileName, bitmap, encoder);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// <summary> Saves an using bitmap target renderer. </summary>
|
||||
///
|
||||
/// <remarks> Andre Beging, 13.09.2017. </remarks>
|
||||
///
|
||||
/// <param name="fileName"> Filename of the file. </param>
|
||||
/// <param name="renderTargetBitmap"> The render target bitmap. </param>
|
||||
/// <param name="bitmapEncoder"> The bitmap encoder. </param>
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
private static void SaveUsingBitmapTargetRenderer(string fileName, RenderTargetBitmap renderTargetBitmap, BitmapEncoder bitmapEncoder)
|
||||
{
|
||||
var frame = BitmapFrame.Create(renderTargetBitmap);
|
||||
bitmapEncoder.Frames.Add(frame);
|
||||
// Save file .
|
||||
using (var stream = File.Create(fileName))
|
||||
{
|
||||
bitmapEncoder.Save(stream);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@
|
||||
mc:Ignorable="d"
|
||||
Icon="{Binding WindowIcon}"
|
||||
Name="AddTransactionViewWindow"
|
||||
Title="{Binding WindowTitle}" Height="300" Width="300"
|
||||
Title="{Binding WindowTitle}" Height="325" Width="300"
|
||||
KeyUp="Window_OnKeyUp">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
@@ -21,29 +21,29 @@
|
||||
<StackPanel Grid.Row="0" Orientation="Vertical">
|
||||
<Label Content="{Binding ElementName=AddTransactionViewWindow, Path=Title}" FontWeight="Bold" FontSize="18"></Label>
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Row="1" Orientation="Vertical" Margin="10 0">
|
||||
<c:CurrencyTextBox KeyUp="TextBox_OnKeyUp" Name="Amount" Number="{Binding AmountTextBoxText}" StringFormat="0.00 Eur" FontSize="16" Margin="0 0 0 -5"></c:CurrencyTextBox>
|
||||
<Label Content="Amount in EUR"></Label>
|
||||
<StackPanel Grid.Row="1" Orientation="Vertical" Margin="10 10 10 0">
|
||||
<c:CurrencyTextBox KeyUp="TextBox_OnKeyUp" Name="Amount" Number="{Binding AmountTextBoxText}" StringFormat="0.00 Eur" FontSize="16"></c:CurrencyTextBox>
|
||||
<Label Content="Amount in EUR" Margin="0 -5 0 0"></Label>
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Row="2" Orientation="Vertical" Margin="10 0">
|
||||
<TextBox KeyUp="TextBox_OnKeyUp" Name="Description" Text="{Binding DescriptionTextBoxText, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" FontSize="16" Margin="0 0 0 -5"></TextBox>
|
||||
<Label Content="Description"></Label>
|
||||
<StackPanel Grid.Row="2" Orientation="Vertical" Margin="10 10 10 0">
|
||||
<TextBox KeyUp="TextBox_OnKeyUp" Name="Description" Text="{Binding DescriptionTextBoxText, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" FontSize="16"></TextBox>
|
||||
<Label Content="Description" Margin="0 -5 0 0"></Label>
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Row="3" Orientation="Vertical" Margin="10 0">
|
||||
<StackPanel Grid.Row="3" Orientation="Vertical" Margin="10 10 10 0">
|
||||
<DatePicker KeyUp="TextBox_OnKeyUp" SelectedDate="{Binding DatePickerSelectedDate}"></DatePicker>
|
||||
<Label Content="Date"></Label>
|
||||
<Label Content="Date" Margin="0 -5 0 0"></Label>
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Row="4" Orientation="Vertical" Margin="10 0">
|
||||
<StackPanel Grid.Row="4" Orientation="Vertical" Margin="10 10 10 0">
|
||||
<ComboBox KeyUp="TextBox_OnKeyUp" Name="PersonComboBox" ItemsSource="{Binding PersonComboBoxItemSource}" SelectedItem="{Binding PersonComboBoxSelectedItem}">
|
||||
</ComboBox>
|
||||
<Label Content="Person"></Label>
|
||||
<Label Content="Person" Margin="0 -5 0 0"></Label>
|
||||
</StackPanel>
|
||||
<Grid Grid.Row="5">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"></ColumnDefinition>
|
||||
<ColumnDefinition Width="*"></ColumnDefinition>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Button Grid.Column="1" Content="Add Deposit" FontSize="14" Padding="5" Margin="10 -10" Command="{Binding AddTransactionButtonClickCommand}"></Button>
|
||||
<Button Grid.Column="1" Content="Add" FontSize="14" Padding="5" Margin="10 -10" Command="{Binding AddTransactionButtonClickCommand}"></Button>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Window>
|
||||
|
||||
@@ -61,7 +61,7 @@
|
||||
</Button>
|
||||
|
||||
</Grid>
|
||||
<ListView Name="PersonListView" Grid.Row="2" ItemsSource="{Binding PersonListViewItemSource}" SelectedItem="{Binding PersonListViewSelectedItem}">
|
||||
<ListView Name="PersonListView" Grid.Row="2" ItemsSource="{Binding PersonListViewItemSource}" SelectedItem="{Binding PersonListViewSelectedItem}" MouseDoubleClick="PersonListView_OnMouseDoubleClick">
|
||||
<ListView.View>
|
||||
<GridView>
|
||||
<GridViewColumn DisplayMemberBinding="{Binding FirstName}" Width="100">
|
||||
@@ -88,6 +88,8 @@
|
||||
<Separator></Separator>
|
||||
<MenuItem Header="Add _Charge" Command="{Binding AddChargeContextMenuCommand}" />
|
||||
<MenuItem Header="Add _Deposit" Command="{Binding AddDepositContextMenuCommand}" />
|
||||
<Separator></Separator>
|
||||
<MenuItem Header="_Print" Click="PrintContextMenu_OnClick" IsEnabled="False" />
|
||||
</ContextMenu>
|
||||
</ListBox.Resources>
|
||||
<ListBox.ContextMenu>
|
||||
@@ -130,7 +132,7 @@
|
||||
<Image Source="../Content/money_green.ico" Height="30" />
|
||||
</Button>
|
||||
</Grid>
|
||||
<ListView Name="TransactionHistoryListView" Grid.Row="2" ItemsSource="{Binding TransactionHistoryListViewItemSource}" SelectedItem="{Binding TransactionHistoryListViewSelectedItem}" HorizontalContentAlignment="Stretch">
|
||||
<ListView Name="TransactionHistoryListView" Grid.Row="2" ItemsSource="{Binding TransactionHistoryListViewItemSource}" SelectedItem="{Binding TransactionHistoryListViewSelectedItem}" HorizontalContentAlignment="Stretch" MouseDoubleClick="TransactionHistoryListView_OnMouseDoubleClick">
|
||||
<ListView.View>
|
||||
<GridView>
|
||||
<GridView.ColumnHeaderContainerStyle>
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
using System.Windows;
|
||||
using System.IO;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using DebtMgr.Helper;
|
||||
|
||||
namespace DebtMgr.View
|
||||
{
|
||||
@@ -63,5 +67,51 @@ namespace DebtMgr.View
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region PersonListView_OnMouseDoubleClick()
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// <summary>
|
||||
/// Event handler. Called by PersonListView for on mouse double click events.
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks> Andre Beging, 13.09.2017. </remarks>
|
||||
///
|
||||
/// <param name="sender"> Source of the event. </param>
|
||||
/// <param name="e"> Mouse button event information. </param>
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
private void PersonListView_OnMouseDoubleClick(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
App.Locator.MainView.EditPersonContextMenuCommand.Execute(null);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region TransactionHistoryListView_OnMouseDoubleClick()
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// <summary>
|
||||
/// Event handler. Called by TransactionHistoryListView for on mouse double click events.
|
||||
/// </summary>
|
||||
///
|
||||
/// <remarks> Andre Beging, 13.09.2017. </remarks>
|
||||
///
|
||||
/// <param name="sender"> Source of the event. </param>
|
||||
/// <param name="e"> Mouse button event information. </param>
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
private void TransactionHistoryListView_OnMouseDoubleClick(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
App.Locator.MainView.EditTransactionContextMenuCommand.Execute(null);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private void PrintContextMenu_OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
//var targetElement = TransactionHistoryListView;
|
||||
|
||||
//PrintHelper.SaveUsingEncoder("test.png", targetElement);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -521,7 +521,7 @@ namespace DebtMgr.ViewModel
|
||||
PersonListViewItemSource = personList;
|
||||
|
||||
var overallBalance = personList.Sum(x => x.Total);
|
||||
OverallBalanceLabel = overallBalance.ToString();
|
||||
OverallBalanceLabel = string.Format("{0:0.00}", overallBalance);
|
||||
|
||||
AddChargeContextMenuCommand.RaiseCanExecuteChanged();
|
||||
AddDepositContextMenuCommand.RaiseCanExecuteChanged();
|
||||
@@ -553,7 +553,7 @@ namespace DebtMgr.ViewModel
|
||||
|
||||
DetailViewHeaderLabelContent = string.Format("{0} {1}", PersonListViewSelectedItem.FirstName,
|
||||
PersonListViewSelectedItem.LastName);
|
||||
DetailViewBalanceLabel = PersonListViewSelectedItem.Total.ToString();
|
||||
DetailViewBalanceLabel = string.Format("{0:0.00}", PersonListViewSelectedItem.Total);
|
||||
|
||||
TransactionHistoryListViewItemSource = PersonListViewSelectedItem.Transactions.OrderByDescending(x => x.Time).ToList();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user