Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 45e45d44af | |||
| d0d39ccd62 | |||
| ff96d727f1 | |||
| 828430adf8 | |||
| a6b60a4cc8 | |||
| 2fb0e1f73b | |||
| 2a8bbf76bf | |||
| bc5ce3e311 | |||
| 64dc54bb70 | |||
| c6273ed8b3 |
@@ -3,7 +3,7 @@
|
|||||||
; Non-commercial use only
|
; Non-commercial use only
|
||||||
|
|
||||||
#define MyAppName "MayShow"
|
#define MyAppName "MayShow"
|
||||||
#define MyAppVersion "1.1.0"
|
#define MyAppVersion "1.2.0"
|
||||||
#define MyAppPublisher "Quickity Quack Productions"
|
#define MyAppPublisher "Quickity Quack Productions"
|
||||||
#define MyAppExeName "MayShow.exe"
|
#define MyAppExeName "MayShow.exe"
|
||||||
|
|
||||||
|
|||||||
@@ -100,6 +100,9 @@
|
|||||||
<DataTemplate DataType="{x:Type viewModels:WarningViewModel}">
|
<DataTemplate DataType="{x:Type viewModels:WarningViewModel}">
|
||||||
<views:WarningView/>
|
<views:WarningView/>
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
|
<DataTemplate DataType="{x:Type viewModels:ShutdownCheckViewModel}">
|
||||||
|
<views:ShutdownCheckView/>
|
||||||
|
</DataTemplate>
|
||||||
</Application.DataTemplates>
|
</Application.DataTemplates>
|
||||||
<Application.Resources>
|
<Application.Resources>
|
||||||
<ResourceDictionary>
|
<ResourceDictionary>
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ namespace MayShow.Helpers;
|
|||||||
|
|
||||||
class Constants
|
class Constants
|
||||||
{
|
{
|
||||||
public static string AppVersion = "1.1.0";
|
public static string AppVersion = "1.2.0";
|
||||||
|
|
||||||
public static string[] GetQuotes()
|
public static string[] GetQuotes()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace MayShow.Interfaces;
|
||||||
|
|
||||||
|
interface ICanCheckShutdown
|
||||||
|
{
|
||||||
|
Task<bool> CheckIsSafeToShutdown();
|
||||||
|
}
|
||||||
@@ -1,10 +1,9 @@
|
|||||||
using MayShow.ViewModels;
|
using MayShow.ViewModels;
|
||||||
|
|
||||||
namespace MayShow.Interfaces
|
namespace MayShow.Interfaces;
|
||||||
|
|
||||||
|
interface IChangeViewModel
|
||||||
{
|
{
|
||||||
interface IChangeViewModel
|
void PushViewModel(BaseViewModel model);
|
||||||
{
|
void PopViewModel();
|
||||||
void PushViewModel(BaseViewModel model);
|
|
||||||
void PopViewModel();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,9 +1,8 @@
|
|||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
|
|
||||||
namespace MayShow.Interfaces
|
namespace MayShow.Interfaces;
|
||||||
|
|
||||||
|
interface ITopLevelGrabber
|
||||||
{
|
{
|
||||||
interface ITopLevelGrabber
|
TopLevel GetTopLevel();
|
||||||
{
|
|
||||||
TopLevel GetTopLevel();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -13,7 +13,8 @@
|
|||||||
Height="650"
|
Height="650"
|
||||||
MinHeight="550">
|
MinHeight="550">
|
||||||
<dialogHost:DialogHost CloseOnClickAway="False"
|
<dialogHost:DialogHost CloseOnClickAway="False"
|
||||||
Identifier="DialogHost">
|
Identifier="DialogHost"
|
||||||
|
x:Name="WindowDialogHost">
|
||||||
<dialogHost:DialogHost.DialogContent>
|
<dialogHost:DialogHost.DialogContent>
|
||||||
<StackPanel/>
|
<StackPanel/>
|
||||||
</dialogHost:DialogHost.DialogContent>
|
</dialogHost:DialogHost.DialogContent>
|
||||||
|
|||||||
@@ -1,4 +1,9 @@
|
|||||||
|
using System;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Avalonia;
|
||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
|
using Avalonia.Controls.ApplicationLifetimes;
|
||||||
|
using DialogHostAvalonia;
|
||||||
using MayShow.Interfaces;
|
using MayShow.Interfaces;
|
||||||
using MayShow.ViewModels;
|
using MayShow.ViewModels;
|
||||||
|
|
||||||
@@ -10,6 +15,60 @@ public partial class MainWindow : Window, ITopLevelGrabber
|
|||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
DataContext = new MainWindowViewModel(this);
|
DataContext = new MainWindowViewModel(this);
|
||||||
|
|
||||||
|
Closing += WindowIsClosing;
|
||||||
|
|
||||||
|
var lifetime = Application.Current?.ApplicationLifetime as IClassicDesktopStyleApplicationLifetime;
|
||||||
|
// lifetime?.ShutdownRequested += ApplicationIsShuttingDown;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void WindowIsClosing(object? sender, WindowClosingEventArgs e)
|
||||||
|
{
|
||||||
|
e.Cancel = true; // async -> need to cancel immediately
|
||||||
|
if (await CheckIfClosePossible())
|
||||||
|
{
|
||||||
|
Closing -= WindowIsClosing;
|
||||||
|
var lifetime = Application.Current?.ApplicationLifetime as IClassicDesktopStyleApplicationLifetime;
|
||||||
|
lifetime?.ShutdownRequested -= ApplicationIsShuttingDown;
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void ApplicationIsShuttingDown(object? sender, ShutdownRequestedEventArgs e)
|
||||||
|
{
|
||||||
|
e.Cancel = true; // async -> need to cancel immediately
|
||||||
|
if (await CheckIfClosePossible())
|
||||||
|
{
|
||||||
|
Closing -= WindowIsClosing;
|
||||||
|
var lifetime = Application.Current?.ApplicationLifetime as IClassicDesktopStyleApplicationLifetime;
|
||||||
|
lifetime?.ShutdownRequested -= ApplicationIsShuttingDown;
|
||||||
|
lifetime?.TryShutdown();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task<bool> CheckIfClosePossible()
|
||||||
|
{
|
||||||
|
var canShutdown = true;
|
||||||
|
if (DataContext is MainWindowViewModel mwvm)
|
||||||
|
{
|
||||||
|
if (mwvm is ICanCheckShutdown canCheck)
|
||||||
|
{
|
||||||
|
canShutdown = await canCheck.CheckIsSafeToShutdown();
|
||||||
|
}
|
||||||
|
// only checking 1 level but for this app that is OK
|
||||||
|
if (canShutdown && mwvm.CurrentViewModel is ICanCheckShutdown currModel)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
canShutdown = await currModel.CheckIsSafeToShutdown();
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
canShutdown = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return canShutdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TopLevel GetTopLevel()
|
public TopLevel GetTopLevel()
|
||||||
|
|||||||
+1
-1
@@ -12,7 +12,7 @@
|
|||||||
<PublishTrimmed>true</PublishTrimmed>
|
<PublishTrimmed>true</PublishTrimmed>
|
||||||
<PublishAot>true</PublishAot>
|
<PublishAot>true</PublishAot>
|
||||||
<AssemblyName>MayShow</AssemblyName>
|
<AssemblyName>MayShow</AssemblyName>
|
||||||
<AssemblyVersion>1.1.0</AssemblyVersion> <!-- Also update Constants version -->
|
<AssemblyVersion>1.2.0</AssemblyVersion> <!-- Also update Constants version -->
|
||||||
<ApplicationIcon>MayShow-icon.ico</ApplicationIcon>
|
<ApplicationIcon>MayShow-icon.ico</ApplicationIcon>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ class Settings : ChangeNotifier
|
|||||||
{
|
{
|
||||||
var path = Path.Combine(
|
var path = Path.Combine(
|
||||||
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
|
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
|
||||||
"ReceiptPDFBuilder" // legacy name for existing settings prior to app name change
|
"MayShow"
|
||||||
);
|
);
|
||||||
if (!Directory.Exists(path))
|
if (!Directory.Exists(path))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
namespace MayShow.Models;
|
||||||
|
|
||||||
|
enum ShutdownCheckOptions
|
||||||
|
{
|
||||||
|
SaveAndShutdown,
|
||||||
|
NoSaveShutdown,
|
||||||
|
CancelShutdown,
|
||||||
|
}
|
||||||
@@ -23,8 +23,9 @@ using MayShows.Helpers;
|
|||||||
|
|
||||||
namespace MayShow.ViewModels;
|
namespace MayShow.ViewModels;
|
||||||
|
|
||||||
class MainViewModel : BaseViewModel, IFontResolver
|
class MainViewModel : BaseViewModel, IFontResolver, ICanCheckShutdown
|
||||||
{
|
{
|
||||||
|
private bool _isPerformingInitialLoad;
|
||||||
private string _processDir;
|
private string _processDir;
|
||||||
private bool _isCreatingPDF;
|
private bool _isCreatingPDF;
|
||||||
private string _createPDFLog;
|
private string _createPDFLog;
|
||||||
@@ -36,21 +37,24 @@ class MainViewModel : BaseViewModel, IFontResolver
|
|||||||
|
|
||||||
private Settings _settings;
|
private Settings _settings;
|
||||||
|
|
||||||
|
private bool _hasUnsavedWork;
|
||||||
|
|
||||||
public MainViewModel(IChangeViewModel viewModelChanger) : base(viewModelChanger)
|
public MainViewModel(IChangeViewModel viewModelChanger) : base(viewModelChanger)
|
||||||
{
|
{
|
||||||
|
_isPerformingInitialLoad = true;
|
||||||
_processDir = Path.GetDirectoryName(Environment.ProcessPath) ?? "";
|
_processDir = Path.GetDirectoryName(Environment.ProcessPath) ?? "";
|
||||||
Console.WriteLine("Process is running from: {0}", _processDir);
|
Console.WriteLine("Process is running from: {0}", _processDir);
|
||||||
_isCreatingPDF = false;
|
_isCreatingPDF = false;
|
||||||
var quotes = Constants.GetQuotes();
|
var quotes = Constants.GetQuotes();
|
||||||
Random random = new Random();
|
Random random = new Random();
|
||||||
var quoteIndex = random.Next(0, quotes.Length);
|
var quoteIndex = random.Next(0, quotes.Length);
|
||||||
_createPDFLog = "----- MayShow v" + Constants.AppVersion + "------" + Environment.NewLine;
|
_createPDFLog = "----- MayShow v" + Constants.AppVersion + " ------" + Environment.NewLine;
|
||||||
_createPDFLog += quotes[quoteIndex] + Environment.NewLine;
|
_createPDFLog += quotes[quoteIndex] + Environment.NewLine;
|
||||||
_createPDFLog += "---------------------------------------" + Environment.NewLine;
|
_createPDFLog += "---------------------------------------" + Environment.NewLine;
|
||||||
_createPDFLog += "Ready to create PDF!";
|
_createPDFLog += "Loaded and ready to create report!" + Environment.NewLine;
|
||||||
|
_createPDFLog += "Please copy and send this Program Log when reporting any issues with the software.";
|
||||||
_workingFolder = "";
|
_workingFolder = "";
|
||||||
_reportFiles = new ObservableCollection<ReportFile>();
|
ReportFiles = _reportFiles = new ObservableCollection<ReportFile>();
|
||||||
_reportFiles.CollectionChanged += ( sender, e ) => { NotifyPropertyChanged(nameof(IsCreatePDFButtonEnabled)); };
|
|
||||||
_reportTitle = "";
|
_reportTitle = "";
|
||||||
_lastGeneratedTime = null;
|
_lastGeneratedTime = null;
|
||||||
_settings = Settings.LoadSettings();
|
_settings = Settings.LoadSettings();
|
||||||
@@ -59,12 +63,24 @@ class MainViewModel : BaseViewModel, IFontResolver
|
|||||||
LogInfo("Loading data at last used path of {0}", _settings.LastUsedPath);
|
LogInfo("Loading data at last used path of {0}", _settings.LastUsedPath);
|
||||||
ScanFolder(_settings.LastUsedPath);
|
ScanFolder(_settings.LastUsedPath);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LogInfo("Choose a receipt folder to begin...");
|
||||||
|
}
|
||||||
|
HasUnsavedWork = false;
|
||||||
|
_isPerformingInitialLoad = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string ReportTitle
|
public string ReportTitle
|
||||||
{
|
{
|
||||||
get => _reportTitle;
|
get => _reportTitle;
|
||||||
set { _reportTitle = value; NotifyPropertyChanged(); NotifyPropertyChanged(nameof(IsTitleBoxVisible)); }
|
set
|
||||||
|
{
|
||||||
|
_reportTitle = value;
|
||||||
|
NotifyPropertyChanged();
|
||||||
|
NotifyPropertyChanged(nameof(IsTitleBoxVisible));
|
||||||
|
NotifyPropertyChanged(nameof(CanAddItem));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsTitleBoxVisible
|
public bool IsTitleBoxVisible
|
||||||
@@ -72,6 +88,11 @@ class MainViewModel : BaseViewModel, IFontResolver
|
|||||||
get => !string.IsNullOrWhiteSpace(_workingFolder);
|
get => !string.IsNullOrWhiteSpace(_workingFolder);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool CanAddItem
|
||||||
|
{
|
||||||
|
get => IsTitleBoxVisible && !IsCreatingPDF;
|
||||||
|
}
|
||||||
|
|
||||||
public bool IsCreatingPDF
|
public bool IsCreatingPDF
|
||||||
{
|
{
|
||||||
get => _isCreatingPDF;
|
get => _isCreatingPDF;
|
||||||
@@ -81,6 +102,7 @@ class MainViewModel : BaseViewModel, IFontResolver
|
|||||||
NotifyPropertyChanged();
|
NotifyPropertyChanged();
|
||||||
NotifyPropertyChanged(nameof(IsCreatePDFButtonEnabled));
|
NotifyPropertyChanged(nameof(IsCreatePDFButtonEnabled));
|
||||||
NotifyPropertyChanged(nameof(HasWorkingFolderAndNotMakingPDF));
|
NotifyPropertyChanged(nameof(HasWorkingFolderAndNotMakingPDF));
|
||||||
|
NotifyPropertyChanged(nameof(CanAddItem));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -117,6 +139,16 @@ class MainViewModel : BaseViewModel, IFontResolver
|
|||||||
set { _createPDFLog = value; NotifyPropertyChanged(); }
|
set { _createPDFLog = value; NotifyPropertyChanged(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool HasUnsavedWork
|
||||||
|
{
|
||||||
|
get => _hasUnsavedWork;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_hasUnsavedWork = value;
|
||||||
|
NotifyPropertyChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public ObservableCollection<ReportFile> ReportFiles
|
public ObservableCollection<ReportFile> ReportFiles
|
||||||
{
|
{
|
||||||
get => _reportFiles;
|
get => _reportFiles;
|
||||||
@@ -126,7 +158,8 @@ class MainViewModel : BaseViewModel, IFontResolver
|
|||||||
NotifyPropertyChanged();
|
NotifyPropertyChanged();
|
||||||
_reportFiles.CollectionChanged += ( sender, e ) =>
|
_reportFiles.CollectionChanged += ( sender, e ) =>
|
||||||
{
|
{
|
||||||
NotifyPropertyChanged(nameof(IsCreatePDFButtonEnabled));
|
NotifyPropertyChanged(nameof(IsCreatePDFButtonEnabled));
|
||||||
|
HasUnsavedWork = true;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -157,6 +190,7 @@ class MainViewModel : BaseViewModel, IFontResolver
|
|||||||
_settings.LastUsedPath = folder.Path.LocalPath;
|
_settings.LastUsedPath = folder.Path.LocalPath;
|
||||||
await _settings.SaveSettingsAsync();
|
await _settings.SaveSettingsAsync();
|
||||||
ResortPDFItemsByDate();
|
ResortPDFItemsByDate();
|
||||||
|
HasUnsavedWork = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -167,6 +201,7 @@ class MainViewModel : BaseViewModel, IFontResolver
|
|||||||
{
|
{
|
||||||
WorkingFolder = path;
|
WorkingFolder = path;
|
||||||
NotifyPropertyChanged(nameof(IsTitleBoxVisible));
|
NotifyPropertyChanged(nameof(IsTitleBoxVisible));
|
||||||
|
NotifyPropertyChanged(nameof(CanAddItem));
|
||||||
var reportFilePath = Path.Combine(path, GetReportSavedDataFileName());
|
var reportFilePath = Path.Combine(path, GetReportSavedDataFileName());
|
||||||
var successfullyLoadedPriorReport = false;
|
var successfullyLoadedPriorReport = false;
|
||||||
if (File.Exists(reportFilePath))
|
if (File.Exists(reportFilePath))
|
||||||
@@ -195,7 +230,11 @@ class MainViewModel : BaseViewModel, IFontResolver
|
|||||||
{
|
{
|
||||||
AddFileBasedOnPath(filePath);
|
AddFileBasedOnPath(filePath);
|
||||||
}
|
}
|
||||||
ResortPDFItemsByDate();
|
if (!_isPerformingInitialLoad)
|
||||||
|
{
|
||||||
|
ResortPDFItemsByDate();
|
||||||
|
}
|
||||||
|
HasUnsavedWork = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -221,6 +260,7 @@ class MainViewModel : BaseViewModel, IFontResolver
|
|||||||
if (idx != -1)
|
if (idx != -1)
|
||||||
{
|
{
|
||||||
ReportFiles.RemoveAt(idx);
|
ReportFiles.RemoveAt(idx);
|
||||||
|
HasUnsavedWork = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -236,18 +276,20 @@ class MainViewModel : BaseViewModel, IFontResolver
|
|||||||
file.Title = updatedData.Title;
|
file.Title = updatedData.Title;
|
||||||
file.ReceiptDateTime = updatedData.ReceiptDateTime;
|
file.ReceiptDateTime = updatedData.ReceiptDateTime;
|
||||||
file.Notes = updatedData.Notes;
|
file.Notes = updatedData.Notes;
|
||||||
|
HasUnsavedWork = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private string[] GetAllowedFileExtensionPatterns()
|
private string[] GetAllowedFileExtensionPatterns()
|
||||||
{
|
{
|
||||||
|
// update GetAllowedFileExtensionPatternsWithoutStar if this is edited
|
||||||
return [ "*.png", "*.jpg", "*.jpeg", "*.gif", "*.bmp", "*.webp", "*.pdf", "*.heic", ];
|
return [ "*.png", "*.jpg", "*.jpeg", "*.gif", "*.bmp", "*.webp", "*.pdf", "*.heic", ];
|
||||||
}
|
}
|
||||||
|
|
||||||
private string[] GetAllowedFileExtensionPatternsWithoutStar()
|
private string[] GetAllowedFileExtensionPatternsWithoutStar()
|
||||||
{
|
{
|
||||||
var list = GetAllowedFileExtensionPatterns();
|
// update GetAllowedFileExtensionPatterns if this is edited
|
||||||
return list.Select(x => x.Replace("*.", "")).ToArray();
|
return [ "png", "jpg", "jpeg", "gif", "bmp", "webp", "pdf", "heic", ];
|
||||||
}
|
}
|
||||||
|
|
||||||
public async void AddItem()
|
public async void AddItem()
|
||||||
@@ -316,6 +358,7 @@ class MainViewModel : BaseViewModel, IFontResolver
|
|||||||
Notes = "",
|
Notes = "",
|
||||||
FilePath = filePath,
|
FilePath = filePath,
|
||||||
});
|
});
|
||||||
|
HasUnsavedWork = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -351,6 +394,7 @@ class MainViewModel : BaseViewModel, IFontResolver
|
|||||||
{
|
{
|
||||||
var file = files[0];
|
var file = files[0];
|
||||||
reportFile.FilePath = file.Path.LocalPath;
|
reportFile.FilePath = file.Path.LocalPath;
|
||||||
|
HasUnsavedWork = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -389,6 +433,7 @@ class MainViewModel : BaseViewModel, IFontResolver
|
|||||||
{
|
{
|
||||||
LogInfo("Sorting report files list...");
|
LogInfo("Sorting report files list...");
|
||||||
ReportFiles = new ObservableCollection<ReportFile>(ReportFiles.OrderBy(x => x.ReceiptDateTime));
|
ReportFiles = new ObservableCollection<ReportFile>(ReportFiles.OrderBy(x => x.ReceiptDateTime));
|
||||||
|
HasUnsavedWork = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async void BuildPDF()
|
public async void BuildPDF()
|
||||||
@@ -423,7 +468,7 @@ class MainViewModel : BaseViewModel, IFontResolver
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async void SaveInterimReportInfo()
|
public async Task SaveInterimReportInfo()
|
||||||
{
|
{
|
||||||
var report = new PDFReport()
|
var report = new PDFReport()
|
||||||
{
|
{
|
||||||
@@ -447,6 +492,7 @@ class MainViewModel : BaseViewModel, IFontResolver
|
|||||||
var savePath = Path.Combine(_workingFolder, GetReportSavedDataFileName());
|
var savePath = Path.Combine(_workingFolder, GetReportSavedDataFileName());
|
||||||
await File.WriteAllTextAsync(savePath, json);
|
await File.WriteAllTextAsync(savePath, json);
|
||||||
LogInfo("Saved report information to {0}", savePath);
|
LogInfo("Saved report information to {0}", savePath);
|
||||||
|
HasUnsavedWork = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task CreateAndSaveReportObjectAfterReportCreation()
|
private async Task CreateAndSaveReportObjectAfterReportCreation()
|
||||||
@@ -585,14 +631,7 @@ class MainViewModel : BaseViewModel, IFontResolver
|
|||||||
imageTitlePar.Format.Font.Size = 12;
|
imageTitlePar.Format.Font.Size = 12;
|
||||||
imageTitlePar.Format.Font.Bold = true;
|
imageTitlePar.Format.Font.Bold = true;
|
||||||
imageTitlePar.Format.Font.Name = "Noto Sans JP"; // has english letters in it, too
|
imageTitlePar.Format.Font.Name = "Noto Sans JP"; // has english letters in it, too
|
||||||
if (string.IsNullOrWhiteSpace(file.Title))
|
imageTitlePar.AddText(string.IsNullOrWhiteSpace(file.Title) ? file.FileName : file.Title);
|
||||||
{
|
|
||||||
imageTitlePar.AddText(file.FileName);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
imageTitlePar.AddText(file.Title);
|
|
||||||
}
|
|
||||||
var receiptDatePar = section.AddParagraph();
|
var receiptDatePar = section.AddParagraph();
|
||||||
receiptDatePar.Format.Alignment = ParagraphAlignment.Center;
|
receiptDatePar.Format.Alignment = ParagraphAlignment.Center;
|
||||||
receiptDatePar.Format.Font.Size = 12;
|
receiptDatePar.Format.Font.Size = 12;
|
||||||
@@ -698,4 +737,33 @@ class MainViewModel : BaseViewModel, IFontResolver
|
|||||||
OpenFolderForFileInFileViewer(outputPDFFileName);
|
OpenFolderForFileInFileViewer(outputPDFFileName);
|
||||||
IsCreatingPDF = false;
|
IsCreatingPDF = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<bool> CheckIsSafeToShutdown()
|
||||||
|
{
|
||||||
|
if (!HasUnsavedWork || string.IsNullOrWhiteSpace(WorkingFolder))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var result = await DialogHost.Show(new ShutdownCheckViewModel());
|
||||||
|
if (result != null && result is ShutdownCheckOptions opt)
|
||||||
|
{
|
||||||
|
if (opt == ShutdownCheckOptions.SaveAndShutdown)
|
||||||
|
{
|
||||||
|
await SaveInterimReportInfo();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (opt == ShutdownCheckOptions.NoSaveShutdown)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (opt == ShutdownCheckOptions.CancelShutdown)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
#nullable enable
|
||||||
|
|
||||||
|
using DialogHostAvalonia;
|
||||||
|
using MayShow.Models;
|
||||||
|
|
||||||
|
namespace MayShow.ViewModels;
|
||||||
|
|
||||||
|
class ShutdownCheckViewModel
|
||||||
|
{
|
||||||
|
|
||||||
|
public ShutdownCheckViewModel()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SaveAndShutdown()
|
||||||
|
{
|
||||||
|
DialogHost.Close("DialogHost", ShutdownCheckOptions.SaveAndShutdown);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void DoNotSaveAndShutdown()
|
||||||
|
{
|
||||||
|
DialogHost.Close("DialogHost", ShutdownCheckOptions.NoSaveShutdown);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CancelShutdown()
|
||||||
|
{
|
||||||
|
DialogHost.Close("DialogHost", ShutdownCheckOptions.CancelShutdown);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,7 +7,8 @@
|
|||||||
xmlns:models="clr-namespace:MayShow.Models"
|
xmlns:models="clr-namespace:MayShow.Models"
|
||||||
xmlns:vm="clr-namespace:MayShow.ViewModels"
|
xmlns:vm="clr-namespace:MayShow.ViewModels"
|
||||||
xmlns:dialogHost="clr-namespace:DialogHostAvalonia;assembly=DialogHost.Avalonia"
|
xmlns:dialogHost="clr-namespace:DialogHostAvalonia;assembly=DialogHost.Avalonia"
|
||||||
x:DataType="vm:AboutViewModel">
|
x:DataType="vm:AboutViewModel"
|
||||||
|
MaxWidth="450">
|
||||||
<StackPanel Orientation="Vertical"
|
<StackPanel Orientation="Vertical"
|
||||||
Spacing="4">
|
Spacing="4">
|
||||||
<TextBlock Text="MayShow"
|
<TextBlock Text="MayShow"
|
||||||
@@ -16,15 +17,12 @@
|
|||||||
FontSize="18"
|
FontSize="18"
|
||||||
FontWeight="Bold"/>
|
FontWeight="Bold"/>
|
||||||
<TextBlock Text="MayShow (an intentional misspelling of 明証, pronounced may-shō, a Japanese word meaning proof, evidence, or corroboration) is a PDF report creation tool. It was built by MB for A in 2026. May the quacking of ducks always be in your favor. Thanks for using our software!"
|
<TextBlock Text="MayShow (an intentional misspelling of 明証, pronounced may-shō, a Japanese word meaning proof, evidence, or corroboration) is a PDF report creation tool. It was built by MB for A in 2026. May the quacking of ducks always be in your favor. Thanks for using our software!"
|
||||||
MaxWidth="300"
|
|
||||||
TextWrapping="Wrap"
|
TextWrapping="Wrap"
|
||||||
FontSize="14"/>
|
FontSize="14"/>
|
||||||
<TextBlock Text="App icon made using https://gauger.me/fonticon/ with FontAwesome icon 'file-invoice-dollar' and the macOS software Icon Composer."
|
<TextBlock Text="App icon made using https://gauger.me/fonticon/ with FontAwesome icon 'file-invoice-dollar' and the macOS software Icon Composer."
|
||||||
MaxWidth="300"
|
|
||||||
TextWrapping="Wrap"
|
TextWrapping="Wrap"
|
||||||
FontSize="14"/>
|
FontSize="14"/>
|
||||||
<TextBlock Text="Copyright 2026 - Quickity Quack Productions"
|
<TextBlock Text="Copyright 2026 - Quickity Quack Productions"
|
||||||
MaxWidth="300"
|
|
||||||
TextWrapping="Wrap"
|
TextWrapping="Wrap"
|
||||||
HorizontalAlignment="Center"
|
HorizontalAlignment="Center"
|
||||||
Margin="0,4,0,4"
|
Margin="0,4,0,4"
|
||||||
|
|||||||
@@ -9,7 +9,8 @@
|
|||||||
xmlns:models="clr-namespace:MayShow.Models"
|
xmlns:models="clr-namespace:MayShow.Models"
|
||||||
xmlns:vm="clr-namespace:MayShow.ViewModels"
|
xmlns:vm="clr-namespace:MayShow.ViewModels"
|
||||||
xmlns:dialogHost="clr-namespace:DialogHostAvalonia;assembly=DialogHost.Avalonia"
|
xmlns:dialogHost="clr-namespace:DialogHostAvalonia;assembly=DialogHost.Avalonia"
|
||||||
x:DataType="vm:EditFileViewModel">
|
x:DataType="vm:EditFileViewModel"
|
||||||
|
MaxWidth="350">
|
||||||
<ScrollViewer AllowAutoHide="False">
|
<ScrollViewer AllowAutoHide="False">
|
||||||
<StackPanel Orientation="Vertical"
|
<StackPanel Orientation="Vertical"
|
||||||
Spacing="4"
|
Spacing="4"
|
||||||
@@ -33,7 +34,8 @@
|
|||||||
<Label Content="Receipt Date" />
|
<Label Content="Receipt Date" />
|
||||||
<Calendar SelectionMode="SingleDate"
|
<Calendar SelectionMode="SingleDate"
|
||||||
SelectedDate="{Binding ClonedFile.ReceiptDateTime}"
|
SelectedDate="{Binding ClonedFile.ReceiptDateTime}"
|
||||||
DisplayDate="{Binding ClonedFile.ReceiptDateTime}" />
|
DisplayDate="{Binding ClonedFile.ReceiptDateTime}"
|
||||||
|
IsTodayHighlighted="False" />
|
||||||
<StackPanel Orientation="Horizontal"
|
<StackPanel Orientation="Horizontal"
|
||||||
Spacing="12"
|
Spacing="12"
|
||||||
Margin="0,4,0,0"
|
Margin="0,4,0,0"
|
||||||
|
|||||||
@@ -167,7 +167,7 @@
|
|||||||
Margin="2"
|
Margin="2"
|
||||||
IsEnabled="{Binding !$parent[DataGrid].((vm:MainViewModel)DataContext).IsCreatingPDF}">
|
IsEnabled="{Binding !$parent[DataGrid].((vm:MainViewModel)DataContext).IsCreatingPDF}">
|
||||||
<Button.Content>
|
<Button.Content>
|
||||||
<TextBlock><Run Text="" FontFamily="{StaticResource FontAwesomeSolid}"/> Edit</TextBlock>
|
<TextBlock><Run Text="" FontFamily="{StaticResource FontAwesomeSolid}"/> Edit</TextBlock>
|
||||||
</Button.Content>
|
</Button.Content>
|
||||||
</Button>
|
</Button>
|
||||||
<Button Command="{Binding $parent[DataGrid].((vm:MainViewModel)DataContext).RemoveFile}"
|
<Button Command="{Binding $parent[DataGrid].((vm:MainViewModel)DataContext).RemoveFile}"
|
||||||
@@ -223,7 +223,7 @@
|
|||||||
<StackPanel Orientation="Horizontal"
|
<StackPanel Orientation="Horizontal"
|
||||||
Spacing="4">
|
Spacing="4">
|
||||||
<Button Command="{Binding AddItem}"
|
<Button Command="{Binding AddItem}"
|
||||||
IsEnabled="{Binding !IsCreatingPDF}">
|
IsEnabled="{Binding CanAddItem}">
|
||||||
<TextBlock><Run Text="+" FontFamily="{StaticResource FontAwesomeSolid}"/> Add Item(s)</TextBlock>
|
<TextBlock><Run Text="+" FontFamily="{StaticResource FontAwesomeSolid}"/> Add Item(s)</TextBlock>
|
||||||
</Button>
|
</Button>
|
||||||
<Button Command="{Binding SaveInterimReportInfo}"
|
<Button Command="{Binding SaveInterimReportInfo}"
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ using Avalonia;
|
|||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
using Avalonia.Input;
|
using Avalonia.Input;
|
||||||
using Avalonia.Markup.Xaml;
|
using Avalonia.Markup.Xaml;
|
||||||
|
using MayShow.ViewModels;
|
||||||
|
|
||||||
namespace MayShow.Views
|
namespace MayShow.Views
|
||||||
{
|
{
|
||||||
@@ -12,6 +13,7 @@ namespace MayShow.Views
|
|||||||
{
|
{
|
||||||
this.InitializeComponent();
|
this.InitializeComponent();
|
||||||
LogBlock.PropertyChanged += LogBlock_PropertyChanged;
|
LogBlock.PropertyChanged += LogBlock_PropertyChanged;
|
||||||
|
FilesGrid.CellEditEnded += FileCellEditEnded;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LogBlock_PropertyChanged(object? sender, AvaloniaPropertyChangedEventArgs e)
|
private void LogBlock_PropertyChanged(object? sender, AvaloniaPropertyChangedEventArgs e)
|
||||||
@@ -26,6 +28,18 @@ namespace MayShow.Views
|
|||||||
{
|
{
|
||||||
var topLevel = TopLevel.GetTopLevel(this);
|
var topLevel = TopLevel.GetTopLevel(this);
|
||||||
topLevel?.FocusManager?.ClearFocus();
|
topLevel?.FocusManager?.ClearFocus();
|
||||||
|
if (DataContext is MainViewModel mvm)
|
||||||
|
{
|
||||||
|
mvm?.HasUnsavedWork = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FileCellEditEnded(object? sender, DataGridCellEditEndedEventArgs args)
|
||||||
|
{
|
||||||
|
if (args.EditAction == DataGridEditAction.Commit && DataContext is MainViewModel mvm)
|
||||||
|
{
|
||||||
|
mvm?.HasUnsavedWork = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,39 @@
|
|||||||
|
<UserControl xmlns="https://github.com/avaloniaui"
|
||||||
|
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"
|
||||||
|
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||||
|
x:Class="MayShow.Views.ShutdownCheckView"
|
||||||
|
xmlns:models="clr-namespace:MayShow.Models"
|
||||||
|
xmlns:vm="clr-namespace:MayShow.ViewModels"
|
||||||
|
xmlns:dialogHost="clr-namespace:DialogHostAvalonia;assembly=DialogHost.Avalonia"
|
||||||
|
x:DataType="vm:ShutdownCheckViewModel">
|
||||||
|
<StackPanel Orientation="Vertical"
|
||||||
|
Spacing="4">
|
||||||
|
<TextBlock TextAlignment="Center"
|
||||||
|
FontWeight="Bold"
|
||||||
|
FontSize="18"
|
||||||
|
Text="Warning: You have unsaved report data!"/>
|
||||||
|
<TextBlock TextAlignment="Center"
|
||||||
|
FontWeight="Bold"
|
||||||
|
TextWrapping="Wrap"
|
||||||
|
FontSize="14"
|
||||||
|
Text="Do you want to save your data before the program is closed?"/>
|
||||||
|
<StackPanel Orientation="Horizontal"
|
||||||
|
Spacing="8">
|
||||||
|
<Button Command="{Binding SaveAndShutdown}"
|
||||||
|
Classes="accent"
|
||||||
|
Content="Save Data and Close"
|
||||||
|
HorizontalAlignment="Right"
|
||||||
|
Margin="0,4,0,4"/>
|
||||||
|
<Button Command="{Binding DoNotSaveAndShutdown}"
|
||||||
|
Content="Do NOT Save Data and Close"
|
||||||
|
HorizontalAlignment="Right"
|
||||||
|
Margin="0,4,0,4"/>
|
||||||
|
<Button Command="{Binding CancelShutdown}"
|
||||||
|
Content="Cancel Program Shutdown"
|
||||||
|
HorizontalAlignment="Right"
|
||||||
|
Margin="0,4,0,4"/>
|
||||||
|
</StackPanel>
|
||||||
|
</StackPanel>
|
||||||
|
</UserControl>
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
using System;
|
||||||
|
using Avalonia;
|
||||||
|
using Avalonia.Controls;
|
||||||
|
using Avalonia.Markup.Xaml;
|
||||||
|
|
||||||
|
namespace MayShow.Views;
|
||||||
|
|
||||||
|
public partial class ShutdownCheckView : UserControl
|
||||||
|
{
|
||||||
|
public ShutdownCheckView()
|
||||||
|
{
|
||||||
|
this.InitializeComponent();
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
-1
@@ -3,7 +3,7 @@
|
|||||||
<!-- This manifest is used on Windows only.
|
<!-- This manifest is used on Windows only.
|
||||||
Don't remove it as it might cause problems with window transparency and embedded controls.
|
Don't remove it as it might cause problems with window transparency and embedded controls.
|
||||||
For more details visit https://learn.microsoft.com/en-us/windows/win32/sbscs/application-manifests -->
|
For more details visit https://learn.microsoft.com/en-us/windows/win32/sbscs/application-manifests -->
|
||||||
<assemblyIdentity version="1.1.0.0" name="MayShow.Desktop"/>
|
<assemblyIdentity version="1.2.0.0" name="MayShow.Desktop"/>
|
||||||
|
|
||||||
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
|
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
|
||||||
<application>
|
<application>
|
||||||
|
|||||||
Reference in New Issue
Block a user