Added Ribbon, function to save detail view as screenshot

This commit is contained in:
Andre Beging
2017-09-17 23:17:18 +02:00
parent a2e081ccdb
commit 1f4e3eb1bc
19 changed files with 303 additions and 67 deletions

View File

@@ -13,6 +13,9 @@
<setting name="Database" serializeAs="String"> <setting name="Database" serializeAs="String">
<value /> <value />
</setting> </setting>
<setting name="TelegramPath" serializeAs="String">
<value />
</setting>
</DebtMgr.Properties.Settings> </DebtMgr.Properties.Settings>
</userSettings> </userSettings>
</configuration> </configuration>

BIN
Content/camera.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 361 KiB

BIN
Content/camera.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

BIN
Content/db_info.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 102 KiB

BIN
Content/db_plus.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 102 KiB

BIN
Content/telegram.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 176 KiB

BIN
Content/telegram.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

View File

@@ -85,6 +85,7 @@
</Reference> </Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Data" /> <Reference Include="System.Data" />
<Reference Include="System.Windows.Controls.Ribbon" />
<Reference Include="System.Windows.Interactivity, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> <Reference Include="System.Windows.Interactivity, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>packages\MvvmLightLibs.5.3.0.0\lib\net45\System.Windows.Interactivity.dll</HintPath> <HintPath>packages\MvvmLightLibs.5.3.0.0\lib\net45\System.Windows.Interactivity.dll</HintPath>
</Reference> </Reference>
@@ -138,6 +139,9 @@
<DependentUpon>App.xaml</DependentUpon> <DependentUpon>App.xaml</DependentUpon>
<SubType>Code</SubType> <SubType>Code</SubType>
</Compile> </Compile>
<Compile Include="View\ScreenshotView.xaml.cs">
<DependentUpon>ScreenshotView.xaml</DependentUpon>
</Compile>
<Page Include="View\Dialogs\AddTransactionView.xaml"> <Page Include="View\Dialogs\AddTransactionView.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
@@ -158,6 +162,10 @@
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
<Page Include="View\ScreenshotView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs"> <Compile Include="Properties\AssemblyInfo.cs">
@@ -216,6 +224,24 @@
<Resource Include="Content\money_green.ico" /> <Resource Include="Content\money_green.ico" />
<Resource Include="Content\money_red.ico" /> <Resource Include="Content\money_red.ico" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Resource Include="Content\telegram.ico" />
</ItemGroup>
<ItemGroup>
<Resource Include="Content\telegram.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Content\camera.ico" />
</ItemGroup>
<ItemGroup>
<Resource Include="Content\camera.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Content\db_info.ico" />
</ItemGroup>
<ItemGroup>
<Resource Include="Content\db_plus.ico" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="packages\Fody.2.0.0\build\dotnet\Fody.targets" Condition="Exists('packages\Fody.2.0.0\build\dotnet\Fody.targets')" /> <Import Project="packages\Fody.2.0.0\build\dotnet\Fody.targets" Condition="Exists('packages\Fody.2.0.0\build\dotnet\Fody.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"> <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">

View File

@@ -22,6 +22,9 @@ namespace DebtMgr.Helper
var height = (int)uiElement.ActualHeight; var height = (int)uiElement.ActualHeight;
var width = (int)uiElement.ActualWidth; var width = (int)uiElement.ActualWidth;
var container = VisualTreeHelper.GetParent(uiElement) as UIElement;
var relativeLocation = uiElement.TranslatePoint(new Point(0, 0), container);
// These two line of code make sure that you get completed visual bitmap. // 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 // In case your Framework Element is inside the scroll viewer then some part which is not
// visible gets clip. // visible gets clip.
@@ -41,6 +44,8 @@ namespace DebtMgr.Helper
bitmap.Render(uiElement); bitmap.Render(uiElement);
SaveUsingBitmapTargetRenderer(fileName, bitmap, encoder); SaveUsingBitmapTargetRenderer(fileName, bitmap, encoder);
uiElement.Arrange(new Rect(relativeLocation, new Point(relativeLocation.X+width, relativeLocation.Y+height)));
} }
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////

View File

@@ -34,5 +34,17 @@ namespace DebtMgr.Properties {
this["Database"] = value; this["Database"] = value;
} }
} }
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("")]
public string TelegramPath {
get {
return ((string)(this["TelegramPath"]));
}
set {
this["TelegramPath"] = value;
}
}
} }
} }

View File

@@ -5,5 +5,8 @@
<Setting Name="Database" Type="System.String" Scope="User"> <Setting Name="Database" Type="System.String" Scope="User">
<Value Profile="(Default)" /> <Value Profile="(Default)" />
</Setting> </Setting>
<Setting Name="TelegramPath" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
</Settings> </Settings>
</SettingsFile> </SettingsFile>

View File

@@ -5,8 +5,10 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:converters="clr-namespace:DebtMgr.Converters" xmlns:converters="clr-namespace:DebtMgr.Converters"
mc:Ignorable="d" mc:Ignorable="d"
Name="MainViewWindow"
Icon="../Content/money_green.ico" Icon="../Content/money_green.ico"
Title="Debt Manager" Height="600" MinHeight="600" Width="900" MinWidth="900"> Title="Debt Manager" Height="600" MinHeight="600" Width="900" MinWidth="900"
Background="White">
<Window.Resources> <Window.Resources>
<converters:AmountToColorConverter x:Key="AmountToColorConverter" /> <converters:AmountToColorConverter x:Key="AmountToColorConverter" />
<Style TargetType="ListViewItem"> <Style TargetType="ListViewItem">
@@ -18,17 +20,37 @@
<RowDefinition Height="Auto"></RowDefinition> <RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="*"></RowDefinition> <RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<!-- #region Menu --> <!-- #region Ribbon -->
<Ribbon Grid.Row="0" Loaded="Ribbon_Loaded" Margin="0 -1 0 0">
<DockPanel Grid.Row="0"> <Ribbon.QuickAccessToolBar>
<Menu DockPanel.Dock="Top"> <RibbonQuickAccessToolBar Visibility="Visible">
<MenuItem Header="Menu"> <Label>asd</Label>
<MenuItem Header="_Switch Database" Command="{Binding SwitchDatabaseMenuCommand}" /> </RibbonQuickAccessToolBar>
<MenuItem Header="_Open Database location" Command="{Binding OpenDatabaseLocationMenuCommand}" /> </Ribbon.QuickAccessToolBar>
</MenuItem> <Ribbon.ApplicationMenu>
</Menu> <RibbonApplicationMenu Visibility="Visible"></RibbonApplicationMenu>
</DockPanel> </Ribbon.ApplicationMenu>
<RibbonTab Header="234">
<RibbonGroup Header="Person">
<RibbonButton Label="New Person" SmallImageSource="../Content/addperson.ico" Command="{Binding NewPersonContextMenuCommand}"></RibbonButton>
<RibbonButton Label="Edit Person" SmallImageSource="../Content/addperson.ico" Command="{Binding EditPersonContextMenuCommand}"></RibbonButton>
<RibbonButton Label="Delete Person" SmallImageSource="../Content/delete.ico" Command="{Binding DeletePersonContextMenuCommand}"></RibbonButton>
<RibbonButton Label="Save Screenshot" LargeImageSource="../Content/camera.png" Command="{Binding SaveScreenshotCommand}" CommandParameter="{Binding ElementName=RightPanel}" IsEnabled="{Binding ScreenshotPossible}"></RibbonButton>
<RibbonButton Label="Send via Telegram" LargeImageSource="../Content/telegram.png" Command="{Binding SendViaTelegramCommand}" CommandParameter="{Binding ElementName=RightPanel}" IsEnabled="False"></RibbonButton>
</RibbonGroup>
<RibbonGroup Header="Transaction">
<RibbonButton Label="Edit Transaction" SmallImageSource="../Content/addperson.ico" Command="{Binding EditTransactionContextMenuCommand}"></RibbonButton>
<RibbonButton Label="Delete Transaction" SmallImageSource="../Content/delete.ico" Command="{Binding DeleteTransactionContextMenuCommand}"></RibbonButton>
<RibbonButton Label="Add Charge" LargeImageSource="../Content/money_red.ico" Command="{Binding AddChargeContextMenuCommand}"></RibbonButton>
<RibbonButton Label="Add Deposit" LargeImageSource="../Content/money_green.ico" Command="{Binding AddDepositContextMenuCommand}"></RibbonButton>
</RibbonGroup>
<RibbonGroup Header="Settings">
<RibbonButton Label="Switch Database" SmallImageSource="../Content/db_plus.ico" Command="{Binding SwitchDatabaseMenuCommand}"></RibbonButton>
<RibbonButton Label="Show Database Location" SmallImageSource="../Content/db_info.ico" Command="{Binding OpenDatabaseLocationMenuCommand}"></RibbonButton>
<RibbonButton Label="Select Telegram Path" SmallImageSource="../Content/telegram.png" Command="{Binding SetTelegramLocationCommand}"></RibbonButton>
</RibbonGroup>
</RibbonTab>
</Ribbon>
<!-- #endregion --> <!-- #endregion -->
<Grid Grid.Row="1"> <Grid Grid.Row="1">
@@ -46,31 +68,21 @@
<RowDefinition Height="*"></RowDefinition> <RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Label Grid.Row="0" Content="Overview" FontWeight="Bold" FontSize="22" Margin="0 0 0 -5"></Label> <Label Grid.Row="0" Content="Overview" FontWeight="Bold" FontSize="22" Margin="0 0 0 -5"></Label>
<Grid Grid.Row="1"> <TextBlock Grid.Row="1" FontSize="18" Margin="5 0 0 5" VerticalAlignment="Center">
<Grid.ColumnDefinitions> <TextBlock Text="Overall Balance:"></TextBlock>
<ColumnDefinition Width="*"></ColumnDefinition> <TextBlock Text="{Binding OverallBalanceLabel}" Foreground="{Binding OverallBalanceLabel, Converter={StaticResource AmountToColorConverter}}"></TextBlock>
<ColumnDefinition Width="Auto"></ColumnDefinition> <TextBlock Text="€" Foreground="{Binding OverallBalanceLabel, Converter={StaticResource AmountToColorConverter}}"></TextBlock>
</Grid.ColumnDefinitions> </TextBlock>
<TextBlock Grid.Column="0" FontSize="18" Margin="5 0 0 5" VerticalAlignment="Center"> <ListView Name="PersonListView" Grid.Row="2" ItemsSource="{Binding PersonListViewItemSource}" SelectedItem="{Binding PersonListViewSelectedItem}" MouseDoubleClick="PersonListView_OnMouseDoubleClick" SelectionMode="Single">
<TextBlock Text="Overall Balance:"></TextBlock>
<TextBlock Text="{Binding OverallBalanceLabel}" Foreground="{Binding OverallBalanceLabel, Converter={StaticResource AmountToColorConverter}}"></TextBlock>
<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" Height="30" />
</Button>
</Grid>
<ListView Name="PersonListView" Grid.Row="2" ItemsSource="{Binding PersonListViewItemSource}" SelectedItem="{Binding PersonListViewSelectedItem}" MouseDoubleClick="PersonListView_OnMouseDoubleClick">
<ListView.View> <ListView.View>
<GridView> <GridView>
<GridViewColumn DisplayMemberBinding="{Binding FirstName}" Width="100"> <GridViewColumn DisplayMemberBinding="{Binding FirstName}" Width="120">
<GridViewColumnHeader Command="{Binding SortPersonListViewCommand}" CommandParameter="FirstName">First name</GridViewColumnHeader> <GridViewColumnHeader Command="{Binding SortPersonListViewCommand}" CommandParameter="FirstName">First name</GridViewColumnHeader>
</GridViewColumn> </GridViewColumn>
<GridViewColumn DisplayMemberBinding="{Binding LastName}" Width="100"> <GridViewColumn DisplayMemberBinding="{Binding LastName}" Width="120">
<GridViewColumnHeader Command="{Binding SortPersonListViewCommand}" CommandParameter="LastName">Last name</GridViewColumnHeader> <GridViewColumnHeader Command="{Binding SortPersonListViewCommand}" CommandParameter="LastName">Last name</GridViewColumnHeader>
</GridViewColumn> </GridViewColumn>
<GridViewColumn Width="80"> <GridViewColumn Width="84">
<GridViewColumnHeader Command="{Binding SortPersonListViewCommand}" CommandParameter="Total">Balance</GridViewColumnHeader> <GridViewColumnHeader Command="{Binding SortPersonListViewCommand}" CommandParameter="Total">Balance</GridViewColumnHeader>
<GridViewColumn.CellTemplate> <GridViewColumn.CellTemplate>
<DataTemplate> <DataTemplate>
@@ -88,8 +100,6 @@
<Separator></Separator> <Separator></Separator>
<MenuItem Header="Add _Charge" Command="{Binding AddChargeContextMenuCommand}" /> <MenuItem Header="Add _Charge" Command="{Binding AddChargeContextMenuCommand}" />
<MenuItem Header="Add _Deposit" Command="{Binding AddDepositContextMenuCommand}" /> <MenuItem Header="Add _Deposit" Command="{Binding AddDepositContextMenuCommand}" />
<Separator></Separator>
<MenuItem Header="_Print" Click="PrintContextMenu_OnClick" IsEnabled="False"/>
</ContextMenu> </ContextMenu>
</ListBox.Resources> </ListBox.Resources>
<ListBox.ContextMenu> <ListBox.ContextMenu>
@@ -114,25 +124,12 @@
<ColumnDefinition Width="*"></ColumnDefinition> <ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<Label Grid.Row="0" Content="{Binding DetailViewHeaderLabelContent}" FontWeight="Bold" FontSize="22" Margin="0 0 0 -5"></Label> <Label Grid.Row="0" Content="{Binding DetailViewHeaderLabelContent}" FontWeight="Bold" FontSize="22" Margin="0 0 0 -5"></Label>
<Grid Grid.Row="1"> <TextBlock Grid.Row="1" FontSize="18" Margin="5 0 0 5" VerticalAlignment="Center">
<Grid.ColumnDefinitions> <TextBlock Text="Balance:"></TextBlock>
<ColumnDefinition Width="*"></ColumnDefinition> <TextBlock Text="{Binding DetailViewBalanceLabel}" Foreground="{Binding DetailViewBalanceLabel, Converter={StaticResource AmountToColorConverter}}"></TextBlock>
<ColumnDefinition Width="Auto"></ColumnDefinition> <TextBlock Text="€" Foreground="{Binding DetailViewBalanceLabel, Converter={StaticResource AmountToColorConverter}}"></TextBlock>
<ColumnDefinition Width="Auto"></ColumnDefinition> </TextBlock>
</Grid.ColumnDefinitions> <ListView Name="TransactionHistoryListView" Grid.Row="2" ItemsSource="{Binding TransactionHistoryListViewItemSource}" SelectedItem="{Binding TransactionHistoryListViewSelectedItem}" HorizontalContentAlignment="Stretch" MouseDoubleClick="TransactionHistoryListView_OnMouseDoubleClick" SelectionMode="Single">
<TextBlock Grid.Column="0" FontSize="18" Margin="5 0 0 5" VerticalAlignment="Center">
<TextBlock Text="Balance:"></TextBlock>
<TextBlock Text="{Binding DetailViewBalanceLabel}" Foreground="{Binding DetailViewBalanceLabel, Converter={StaticResource AmountToColorConverter}}"></TextBlock>
<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" 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" Height="30" />
</Button>
</Grid>
<ListView Name="TransactionHistoryListView" Grid.Row="2" ItemsSource="{Binding TransactionHistoryListViewItemSource}" SelectedItem="{Binding TransactionHistoryListViewSelectedItem}" HorizontalContentAlignment="Stretch" MouseDoubleClick="TransactionHistoryListView_OnMouseDoubleClick">
<ListView.View> <ListView.View>
<GridView> <GridView>
<GridView.ColumnHeaderContainerStyle> <GridView.ColumnHeaderContainerStyle>
@@ -148,12 +145,11 @@
</DataTemplate> </DataTemplate>
</GridViewColumn.CellTemplate> </GridViewColumn.CellTemplate>
</GridViewColumn> </GridViewColumn>
<GridViewColumn DisplayMemberBinding="{Binding Description}" Width="357" Header="Description" /> <GridViewColumn DisplayMemberBinding="{Binding Description}" Width="340" Header="Description" />
</GridView> </GridView>
</ListView.View> </ListView.View>
<ListBox.Resources> <ListBox.Resources>
<ContextMenu x:Key="TransactionHistoryListViewContextMenu"> <ContextMenu x:Key="TransactionHistoryListViewContextMenu">
<MenuItem Header="_Edit Transaction" Command="{Binding EditTransactionContextMenuCommand}" CommandParameter="{Binding Path=SelectedItem}" />
<MenuItem Header="Delete Transaction" Command="{Binding DeleteTransactionContextMenuCommand}" CommandParameter="{Binding Path=SelectedItem}" /> <MenuItem Header="Delete Transaction" Command="{Binding DeleteTransactionContextMenuCommand}" CommandParameter="{Binding Path=SelectedItem}" />
<Separator></Separator> <Separator></Separator>
<MenuItem Header="Add _Charge" Command="{Binding AddChargeContextMenuCommand}" /> <MenuItem Header="Add _Charge" Command="{Binding AddChargeContextMenuCommand}" />

View File

@@ -1,9 +1,7 @@
using System.IO; using System.Windows;
using System.Windows; using System.Windows.Controls;
using System.Windows.Input; using System.Windows.Input;
using System.Windows.Media; using System.Windows.Media;
using System.Windows.Media.Imaging;
using DebtMgr.Helper;
namespace DebtMgr.View namespace DebtMgr.View
{ {
@@ -106,12 +104,17 @@ namespace DebtMgr.View
#endregion #endregion
private void PrintContextMenu_OnClick(object sender, RoutedEventArgs e) private void Ribbon_Loaded(object sender, RoutedEventArgs e)
{ {
var targetElement = RightPanel; var grid = VisualTreeHelper.GetChild((DependencyObject)sender, 0) as Grid;
if (grid != null)
{
// Hide Quick Acces Menu
grid.RowDefinitions[0].Height = new GridLength(0);
PrintHelper.SaveUsingEncoder("test.png", targetElement); // Hidde Tab Bar
return; grid.RowDefinitions[1].Height = new GridLength(0);
}
} }
} }
} }

12
View/ScreenshotView.xaml Normal file
View File

@@ -0,0 +1,12 @@
<Window x:Class="DebtMgr.View.ScreenshotView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:DebtMgr.View"
mc:Ignorable="d"
Title="ScreenshotView" Height="300" Width="300">
<Grid>
<Label Content="Heyyyyyyyyyyyy"></Label>
</Grid>
</Window>

View File

@@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Interop;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace DebtMgr.View
{
/// <summary>
/// Interaktionslogik für ScreenshotView.xaml
/// </summary>
public partial class ScreenshotView : Window
{
public ScreenshotView()
{
InitializeComponent();
var h = new WindowInteropHelper(this);
h.EnsureHandle();
}
}
}

View File

@@ -237,7 +237,7 @@ namespace DebtMgr.ViewModel.Dialogs
Type = DialogMode, Type = DialogMode,
Description = DescriptionTextBoxText, Description = DescriptionTextBoxText,
PersonId = person.Id, PersonId = person.Id,
Time = DatePickerSelectedDate.Value Time = DatePickerSelectedDate.Value.AddHours(12)
}); });
App.Database.InsertOrReplaceWithChildren(person); App.Database.InsertOrReplaceWithChildren(person);

View File

@@ -112,7 +112,7 @@ namespace DebtMgr.ViewModel.Dialogs
var saveFileDialog = new SaveFileDialog var saveFileDialog = new SaveFileDialog
{ {
Filter = "Debt Manager Database|*.dmdb|Standard database|*.db", Filter = "Debt Manager Database|*.dmdb|Standard database|*.db",
CreatePrompt = true OverwritePrompt = true
}; };
if (saveFileDialog.ShowDialog() == true) if (saveFileDialog.ShowDialog() == true)
@@ -126,7 +126,5 @@ namespace DebtMgr.ViewModel.Dialogs
} }
#endregion #endregion
} }
} }

View File

@@ -205,7 +205,7 @@ namespace DebtMgr.ViewModel.Dialogs
{ {
transaction.Amount = AmountTextBoxTextNumberRepresentation; transaction.Amount = AmountTextBoxTextNumberRepresentation;
transaction.Description = DescriptionTextBoxText; transaction.Description = DescriptionTextBoxText;
transaction.Time = DatePickerSelectedDate.Value; transaction.Time = DatePickerSelectedDate.Value.AddHours(12);
} }
App.Database.InsertOrReplace(transaction); App.Database.InsertOrReplace(transaction);

View File

@@ -10,6 +10,11 @@ using System;
using System.Threading; using System.Threading;
using System.IO; using System.IO;
using System.Diagnostics; using System.Diagnostics;
using System.Windows.Controls;
using DebtMgr.Helper;
using Microsoft.Win32;
using System.Windows.Markup;
using System.Xml;
namespace DebtMgr.ViewModel namespace DebtMgr.ViewModel
{ {
@@ -57,6 +62,10 @@ namespace DebtMgr.ViewModel
RaisePropertyChanged(() => PersonListViewSelectedItem); RaisePropertyChanged(() => PersonListViewSelectedItem);
DeletePersonContextMenuCommand.RaiseCanExecuteChanged(); DeletePersonContextMenuCommand.RaiseCanExecuteChanged();
EditPersonContextMenuCommand.RaiseCanExecuteChanged(); EditPersonContextMenuCommand.RaiseCanExecuteChanged();
SaveScreenshotCommand.RaiseCanExecuteChanged();
SendViaTelegramCommand.RaiseCanExecuteChanged();
ScreenshotPossible = value != null;
UpdateDetailView(); UpdateDetailView();
} }
@@ -134,6 +143,105 @@ namespace DebtMgr.ViewModel
#endregion #endregion
#region ScreenshotPossible (bool) Property
/// <summary>
/// Privater Teil von <see cref="ScreenshotPossible" />
/// </summary>
private bool _screenshotPossible;
/// <summary>
/// Comment
///</summary>
public bool ScreenshotPossible
{
get { return _screenshotPossible; }
set
{
_screenshotPossible = value;
RaisePropertyChanged(() => ScreenshotPossible);
}
}
#endregion
#region SaveScreenshotCommand Command
/// <summary>
/// Private member backing variable for <see cref="SaveScreenshotCommand" />
/// </summary>
private RelayCommand<Grid> _saveScreenshotCommand = null;
/// <summary>
/// Comment
/// </summary>
public RelayCommand<Grid> SaveScreenshotCommand => _saveScreenshotCommand ?? (_saveScreenshotCommand = new RelayCommand<Grid>(SaveScreenshotCommand_Execute));
private void SaveScreenshotCommand_Execute(Grid grid)
{
if (grid == null) return;
if (grid.ActualHeight == 0 || grid.ActualWidth == 0) return;
var presetFileName = string.Format("{0}_{1}_{2}",
DateTime.Now.ToString("yyyyMMdd"),
PersonListViewSelectedItem.FirstName,
PersonListViewSelectedItem.LastName);
var saveFileDialog = new SaveFileDialog();
saveFileDialog.Filter = "*.png|*.png";
saveFileDialog.OverwritePrompt = true;
saveFileDialog.FileName = presetFileName;
if (saveFileDialog.ShowDialog() == true)
{
PrintHelper.SaveUsingEncoder(saveFileDialog.FileName, grid);
grid.ShowGridLines = false;
}
}
#endregion
#region SendViaTelegramCommand Command
/// <summary>
/// Private member backing variable for <see cref="SendViaTelegramCommand" />
/// </summary>
private RelayCommand<Grid> _sendViaTelegramCommand = null;
/// <summary>
/// Comment
/// </summary>
public RelayCommand<Grid> SendViaTelegramCommand => _sendViaTelegramCommand ?? (_sendViaTelegramCommand = new RelayCommand<Grid>(SendViaTelegramCommand_Execute, SendViaTelegramCommand_CanExecute));
private bool SendViaTelegramCommand_CanExecute(Grid grid)
{
if (grid == null) return false;
if (PersonListViewSelectedItem == null) return false;
var telegramPath = Properties.Settings.Default.TelegramPath;
if (string.IsNullOrWhiteSpace(telegramPath)) return false;
if (!File.Exists(telegramPath)) return false;
return true;
}
private void SendViaTelegramCommand_Execute(Grid grid)
{
if (grid == null) return;
if (grid.ActualHeight == 0 || grid.ActualWidth == 0) return;
var fileName = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString() + ".png");
var parameter = string.Format("-sendpath \"{0}\"", fileName);
//var proc = System.Diagnostics.Process.Start(Properties.Settings.Default.TelegramPath, parameter);
var proc = System.Diagnostics.Process.Start("explorer");
}
#endregion
#region TransactionHistoryListViewItemSource (List<Transaction>) Property #region TransactionHistoryListViewItemSource (List<Transaction>) Property
/// <summary> /// <summary>
@@ -492,6 +600,45 @@ namespace DebtMgr.ViewModel
#endregion #endregion
#region SetTelegramLocationCommand Command
/// <summary>
/// Private member backing variable for <see cref="SetTelegramLocationCommand" />
/// </summary>
private RelayCommand _setTelegramLocationCommand = null;
/// <summary>
/// Comment
/// </summary>
public RelayCommand SetTelegramLocationCommand => _setTelegramLocationCommand ?? (_setTelegramLocationCommand = new RelayCommand(SetTelegramLocationCommand_Execute));
private void SetTelegramLocationCommand_Execute()
{
var checkTelegramPath = Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
"Telegram Desktop");
var openFileDialog = new OpenFileDialog();
if (Directory.Exists(checkTelegramPath))
openFileDialog.InitialDirectory = checkTelegramPath;
else
openFileDialog.RestoreDirectory = true;
if (openFileDialog.ShowDialog() == true)
{
if (Path.GetExtension(openFileDialog.FileName) == "exe" || Path.GetExtension(openFileDialog.FileName) == ".exe")
{
Properties.Settings.Default.TelegramPath = openFileDialog.FileName;
Properties.Settings.Default.Save();
}
}
}
#endregion
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
/// <summary> Initializes a new instance of the MainViewModel class. </summary> /// <summary> Initializes a new instance of the MainViewModel class. </summary>
/// ///