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

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

View File

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

View File

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

View File

@@ -10,6 +10,11 @@ using System;
using System.Threading;
using System.IO;
using System.Diagnostics;
using System.Windows.Controls;
using DebtMgr.Helper;
using Microsoft.Win32;
using System.Windows.Markup;
using System.Xml;
namespace DebtMgr.ViewModel
{
@@ -57,6 +62,10 @@ namespace DebtMgr.ViewModel
RaisePropertyChanged(() => PersonListViewSelectedItem);
DeletePersonContextMenuCommand.RaiseCanExecuteChanged();
EditPersonContextMenuCommand.RaiseCanExecuteChanged();
SaveScreenshotCommand.RaiseCanExecuteChanged();
SendViaTelegramCommand.RaiseCanExecuteChanged();
ScreenshotPossible = value != null;
UpdateDetailView();
}
@@ -134,6 +143,105 @@ namespace DebtMgr.ViewModel
#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
/// <summary>
@@ -492,6 +600,45 @@ namespace DebtMgr.ViewModel
#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>
///