From 3f90366caf129cbe0666fefbf8b44dedc961a41d Mon Sep 17 00:00:00 2001 From: Andre Beging Date: Wed, 13 Sep 2017 20:58:17 +0200 Subject: [PATCH] A few visual improvements --- DebtMgr.csproj | 11 +++++ Helper/PrintHelper.cs | 62 +++++++++++++++++++++++++++ View/Dialogs/AddTransactionView.xaml | 24 +++++------ View/MainView.xaml | 6 ++- View/MainView.xaml.cs | 52 +++++++++++++++++++++- ViewModel/MainViewModel.cs | 4 +- sgKey.snk | Bin 0 -> 596 bytes 7 files changed, 142 insertions(+), 17 deletions(-) create mode 100644 Helper/PrintHelper.cs create mode 100644 sgKey.snk diff --git a/DebtMgr.csproj b/DebtMgr.csproj index 9157972..9dffdd9 100644 --- a/DebtMgr.csproj +++ b/DebtMgr.csproj @@ -39,6 +39,15 @@ Content\money_green.ico + + false + + + sgKey.snk + + + false + packages\Costura.Fody.1.6.2\lib\dotnet\Costura.dll @@ -100,6 +109,7 @@ + @@ -172,6 +182,7 @@ SettingsSingleFileGenerator Settings.Designer.cs + diff --git a/Helper/PrintHelper.cs b/Helper/PrintHelper.cs new file mode 100644 index 0000000..6d616af --- /dev/null +++ b/Helper/PrintHelper.cs @@ -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 + { + //////////////////////////////////////////////////////////////////////////////////////////////////// + /// Saves an using encoder. + /// + /// Andre Beging, 13.09.2017. + /// + /// Filename of the file. + /// The element. + //////////////////////////////////////////////////////////////////////////////////////////////////// + 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); + } + + //////////////////////////////////////////////////////////////////////////////////////////////////// + /// Saves an using bitmap target renderer. + /// + /// Andre Beging, 13.09.2017. + /// + /// Filename of the file. + /// The render target bitmap. + /// The bitmap encoder. + //////////////////////////////////////////////////////////////////////////////////////////////////// + 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); + } + } + } +} \ No newline at end of file diff --git a/View/Dialogs/AddTransactionView.xaml b/View/Dialogs/AddTransactionView.xaml index ca4ceb0..b9a68ed 100644 --- a/View/Dialogs/AddTransactionView.xaml +++ b/View/Dialogs/AddTransactionView.xaml @@ -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"> @@ -21,29 +21,29 @@ - - - + + + - - - + + + - + - + - + - + - + diff --git a/View/MainView.xaml b/View/MainView.xaml index 1cc9982..8831618 100644 --- a/View/MainView.xaml +++ b/View/MainView.xaml @@ -61,7 +61,7 @@ - + @@ -88,6 +88,8 @@ + + @@ -130,7 +132,7 @@ - + diff --git a/View/MainView.xaml.cs b/View/MainView.xaml.cs index 0044795..102c717 100644 --- a/View/MainView.xaml.cs +++ b/View/MainView.xaml.cs @@ -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() + + //////////////////////////////////////////////////////////////////////////////////////////////////// + /// + /// Event handler. Called by PersonListView for on mouse double click events. + /// + /// + /// Andre Beging, 13.09.2017. + /// + /// Source of the event. + /// Mouse button event information. + //////////////////////////////////////////////////////////////////////////////////////////////////// + private void PersonListView_OnMouseDoubleClick(object sender, MouseButtonEventArgs e) + { + App.Locator.MainView.EditPersonContextMenuCommand.Execute(null); + } + + #endregion + + #region TransactionHistoryListView_OnMouseDoubleClick() + + //////////////////////////////////////////////////////////////////////////////////////////////////// + /// + /// Event handler. Called by TransactionHistoryListView for on mouse double click events. + /// + /// + /// Andre Beging, 13.09.2017. + /// + /// Source of the event. + /// Mouse button event information. + //////////////////////////////////////////////////////////////////////////////////////////////////// + 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; + } } } diff --git a/ViewModel/MainViewModel.cs b/ViewModel/MainViewModel.cs index 5895389..8e44cc8 100644 --- a/ViewModel/MainViewModel.cs +++ b/ViewModel/MainViewModel.cs @@ -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(); } diff --git a/sgKey.snk b/sgKey.snk new file mode 100644 index 0000000000000000000000000000000000000000..2ef4db854fac45ce8e2f52cf2a290c7a5c4f0a1e GIT binary patch literal 596 zcmV-a0;~N80ssI2Bme+XQ$aES1ONa50097PAj;qL_9caW@brNHh0oFLv-LKM(mKT1 z$<>`j>{wh1+pv7Myu;|=C+kh=XTZD~<=p;bC%yt{Wl9Z&S9`NcQ2L^;Tb4hJ%nEX} z27eTDz?1+tHxYD_nE#@1dHLZTfn^P^mr|$`4ff4{2ZeI_wA)kp;(iwk%EUXd-DBV* z-S7#Y899!H(`5AJnaG09dGN=%kB_8_plrl^X>c~PP=DR#L957Tn@f7WDvDsZ9H@Kz zRO~VUz7A0&_-_6$O`6fN`6(b076|1Q_5{-@f3vM;ouFyru?&VHjJB*y!1#P5$Pq%1 zV2I~mS8c#s(YDMYU%RFrpcOI>i^bs;b3T_5;cq{r>hHTzUj-28va`pVpo5osox|Cz zBOlH=5n+4=yXFh!2N>}h_`BJDm{sUntaTnJtlv7sO8A(wlEeT+GxR_8{a)|GCpMq5 zzCEp0w(te)8TeAm606VIVI@PpnEc^XqDFch98ho^FY4FUu-Kjr9Ys7Sc%9$Z9QoYk z)ZpmWJMAEY8;M5*cX#jR8&INW(sI$CkSm_K09($<65*v)4=^yZt203O2yk$%gES2< zDc17o`FF>W%pLL{&&~1W6nfRI$SeJ;hl$UbtEt!9koMst1~KmqG(uK$ysfy~lJFtz zi!ctRx}lC~$$xaZjM0&C1mKs5i6k3oSoLD#I*n%XUcXc!TSbRd$tR;53T=emB>QzN i8O1l56_GVubqF}uH;k}{INMQS_g>>SdFUg$TS!rMf-YwO literal 0 HcmV?d00001