91 Commits

Author SHA1 Message Date
mbabienco 1efd9993bf Clean before release in linux build 2026-03-03 11:52:34 +09:00
mbabienco 9dd843ea69 Use process dir to find license file 2026-03-03 11:41:44 +09:00
mbabienco 1132d475b1 Add font license 2026-03-03 11:32:54 +09:00
mbabienco b00ad7669c Copy FontAwesome and LICENSES.txt to output 2026-03-03 11:31:41 +09:00
mbabienco 27aff81016 Fix typo in build-linux.sh 2026-03-03 11:26:39 +09:00
mbabienco 8da9574e2b Bump version number 2026-03-03 11:13:40 +09:00
mbabienco 32228e143f Show licenses in About view
Closes #4
2026-03-03 11:10:56 +09:00
mbabienco 94c8945140 Copy program log to clipboard button
Closes #9
2026-03-03 10:59:29 +09:00
mbabienco 94cf073012 Allow saving report JSON to internal dir
Closes #2
2026-03-03 10:49:06 +09:00
mbabienco abc97eea2b Show error if output dir does not exist 2026-03-03 09:43:47 +09:00
mbabienco 3e91edb457 Downsize MB is now user-configurable
Probably doesn't matter most of the time since we resize down HEIC and PNG anyway...

Closes #7
2026-03-03 09:39:09 +09:00
mbabienco 03da58277e Allow changing output directory
Closes #5
2026-03-03 09:28:03 +09:00
mbabienco 193f57df02 Adjust warning view max width 2026-03-03 09:23:58 +09:00
mbabienco 97edee3ef5 Fix a typo 2026-03-03 09:07:44 +09:00
mbabienco e822963d60 Add version to About screen
Closes #6
2026-03-02 18:35:06 +09:00
mbabienco 03aa1aadc9 Clean up converted directory when done
Closes #1
2026-03-02 18:33:27 +09:00
mbabienco b359c8b15f Use internal data dir for converted files
Closes #3
2026-03-02 18:33:17 +09:00
mbabienco 0f37f189ac Refactor internal data path finding to Utilities 2026-03-02 18:32:44 +09:00
mbabienco 445c7bd353 Remove unneeded using 2026-03-02 18:31:33 +09:00
mbabienco 3be81f136f Update Windows installer script 2026-03-02 18:10:34 +09:00
mbabienco 2f14270379 Improve Linux build script with auto-zip 2026-03-02 17:50:57 +09:00
mbabienco 70e5215ca9 Fix some trimming issues 2026-03-02 17:13:33 +09:00
mbabienco cd5a89e35a Bump version 2026-03-02 16:39:18 +09:00
mbabienco 47fb765239 Sort on load if no prior report 2026-03-02 16:38:32 +09:00
mbabienco 68cf8a4145 Lock aspect ration 2026-03-02 16:34:40 +09:00
mbabienco e80d252b25 Fix image width on PDF 2026-03-02 16:34:27 +09:00
mbabienco fc89854bfc Add settings page for using legacy PDF mode 2026-03-02 16:32:40 +09:00
mbabienco d51017bb73 Allow rendering with Docnet PDF 2026-03-02 16:24:05 +09:00
mbabienco 5f99d0e4eb Fix log message for converted file paths 2026-03-02 14:33:36 +09:00
mbabienco 3720a6a25a Ensure output converted name is always right 2026-03-02 14:30:05 +09:00
mbabienco 6d4e7a7bfe Only open file long enough to read in pages 2026-03-02 14:18:36 +09:00
mbabienco be1fc5ec18 Bump MigraDoc version 2026-03-02 14:16:07 +09:00
mbabienco baaf6f8e2b Swap to Magick.NET-Q8 for faster processing 2026-02-27 17:36:34 +09:00
mbabienco bb6cdf0abf Tweak where height/width loaded/set 2026-02-25 09:33:44 +09:00
mbabienco 3c754dc196 Refine log messages 2026-02-25 09:15:02 +09:00
mbabienco af8cfa31e5 Fix comment 2026-02-25 09:14:28 +09:00
mbabienco f32568c918 Downsize if > 1.5 MB 2026-02-25 07:50:28 +09:00
mbabienco b42da7603b Auto-rotate images based on EXIF data 2026-02-25 07:45:51 +09:00
mbabienco 851772398c If file > 2.5 MB reduce size 2026-02-25 07:37:11 +09:00
mbabienco dfc1c557e0 Refactor extensions to Constants class 2026-02-25 07:35:51 +09:00
mbabienco f927667732 Add remove all button 2026-02-25 07:29:43 +09:00
mbabienco d77f9bab8c Don't show file not added for project json file 2026-02-24 21:03:14 +09:00
mbabienco d508222901 Update AppScreenshot.png 2026-02-24 21:02:16 +09:00
mbabienco 45e45d44af Update app.manifest 2026-02-24 19:48:18 +09:00
mbabienco d0d39ccd62 Add note 2026-02-24 19:47:06 +09:00
mbabienco ff96d727f1 Fix width on edit page 2026-02-24 19:44:58 +09:00
mbabienco 828430adf8 Fix sort not affecting saved status 2026-02-24 19:43:36 +09:00
mbabienco a6b60a4cc8 Bump app version 2026-02-24 19:40:43 +09:00
mbabienco 2fb0e1f73b Adjust max width in about screen 2026-02-24 19:39:11 +09:00
mbabienco 2a8bbf76bf Warn before software closed; fix bug on first run
Also put settings into proper dir
2026-02-24 19:38:20 +09:00
mbabienco bc5ce3e311 Don't highlight today in edit screen 2026-02-24 10:33:22 +09:00
mbabienco 64dc54bb70 Fix spacing of console line 2026-02-24 09:23:30 +09:00
mbabienco c6273ed8b3 Fix edit button icon 2026-02-24 09:14:21 +09:00
mbabienco 16f6aa511c Rename WarningDeleteItemModel to WarningDeleteItemViewModel 2026-02-18 09:49:54 +09:00
mbabienco b2917eda6b Add basic script for Linux building 2026-02-18 09:41:06 +09:00
mbabienco 2075a0be20 Namespace is now MayShow 2026-02-18 09:36:17 +09:00
mbabienco cc821da4da Update Add Item button title 2026-02-18 09:33:30 +09:00
mbabienco a466f04d20 Rename project files and fix installer w.r.t. new paths 2026-02-18 09:33:17 +09:00
mbabienco f4ed36ad38 Restore font files to right place
Moved to wrong folder on accident
2026-02-18 09:30:09 +09:00
mbabienco f6c7a205a8 Restore Windows installer
Accidentally put it in .gitignore folder
2026-02-18 09:28:30 +09:00
mbabienco b197f43341 Move files for better organization 2026-02-18 09:24:20 +09:00
mbabienco 6e23371858 Update README.md 2026-02-17 18:50:12 +09:00
mbabienco 75beb3d584 Fix typo 2026-02-17 18:43:37 +09:00
mbabienco 9ed6755072 Update README.md 2026-02-17 18:17:45 +09:00
mbabienco 820187c19d Update TODO.txt 2026-02-17 18:16:50 +09:00
mbabienco b76ed1e627 Tweak text again 2026-02-17 17:48:23 +09:00
mbabienco 23d1d202d0 Fix typo 2026-02-17 17:47:50 +09:00
mbabienco 615f8e3f61 Update about page 2026-02-17 17:46:04 +09:00
mbabienco 55b5013184 Rename app to MayShow 2026-02-17 17:43:09 +09:00
mbabienco f3dedb0a2e Update LICENSE.md 2026-02-17 17:22:36 +09:00
mbabienco a1b1e24bea Update TODO.txt 2026-02-17 17:21:13 +09:00
mbabienco c9206bb065 Fallback to file name for title if title not set 2026-02-17 17:20:51 +09:00
mbabienco 3b04f73270 Fix word wrapping in DataGrid details 2026-02-17 17:19:44 +09:00
mbabienco dbcbdfe452 Improve tooltips in DataGrid 2026-02-17 17:15:49 +09:00
mbabienco a57c5f7af6 Fix title / files not being reset 2026-02-17 17:05:18 +09:00
mbabienco 96aaa43d1c Fit tall images into report 2026-02-17 17:02:41 +09:00
mbabienco 07a369e462 Only scale image if needed 2026-02-17 16:56:46 +09:00
mbabienco 5b03ab8dc3 Show error if dir does not exist in ScanFolder 2026-02-17 16:40:14 +09:00
mbabienco 4166da1eb2 Tweak min height/width 2026-02-17 16:38:49 +09:00
mbabienco 2531beab05 Show working folder 2026-02-17 16:38:42 +09:00
mbabienco 08f0db97c1 Fix typo 2026-02-17 14:52:24 +09:00
mbabienco b18a8ead6a Bump to version 1.1 2026-02-17 14:51:45 +09:00
mbabienco 0d4c1b90c2 Allow locating file that was moved/renamed 2026-02-17 14:50:59 +09:00
mbabienco 83f2ea88b5 Hit enter to clear focus on textbox; add clear button 2026-02-17 13:38:59 +09:00
mbabienco b501abf447 Unfocus title text box on enter pressed 2026-02-17 13:34:57 +09:00
mbabienco e9eaa0c98c Tweak width and display of receipt date 2026-02-17 13:27:19 +09:00
mbabienco 460da5dda8 Add ReportFile.IsFileFoundOnDisk 2026-02-17 13:24:04 +09:00
mbabienco b3b9aa5c79 Fix file extensions not doing case-insensitive check 2026-02-17 13:22:48 +09:00
mbabienco ff38722e6c Fix more buttons being enabled/disabled issues 2026-02-17 13:22:11 +09:00
mbabienco f9294be2dd Add screenshot to README 2026-02-17 12:11:19 +09:00
mbabienco 4f569c6fa7 Update README 2026-02-17 12:06:46 +09:00
84 changed files with 2933 additions and 932 deletions
+1 -1
View File
@@ -10,7 +10,7 @@
"request": "launch", "request": "launch",
"preLaunchTask": "build", "preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path. // If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/bin/Debug/net10.0/osx-arm64/ReceiptPDFBuilder.dll", "program": "${workspaceFolder}/src/bin/Debug/net10.0/osx-arm64/MayShow.dll",
"args": [], "args": [],
"cwd": "${workspaceFolder}", "cwd": "${workspaceFolder}",
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console // For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
+3 -3
View File
@@ -7,7 +7,7 @@
"type": "process", "type": "process",
"args": [ "args": [
"build", "build",
"${workspaceFolder}/ReceiptPDFBuilder.csproj", "${workspaceFolder}/src/MayShow.csproj",
"/property:GenerateFullPaths=true", "/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary;ForceNoAlign" "/consoleloggerparameters:NoSummary;ForceNoAlign"
], ],
@@ -19,7 +19,7 @@
"type": "process", "type": "process",
"args": [ "args": [
"publish", "publish",
"${workspaceFolder}/ReceiptPDFBuilder.csproj", "${workspaceFolder}/src/MayShow.csproj",
"/property:GenerateFullPaths=true", "/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary;ForceNoAlign" "/consoleloggerparameters:NoSummary;ForceNoAlign"
], ],
@@ -33,7 +33,7 @@
"watch", "watch",
"run", "run",
"--project", "--project",
"${workspaceFolder}/ReceiptPDFBuilder.csproj" "${workspaceFolder}/src/MayShow.csproj"
], ],
"problemMatcher": "$msCompile" "problemMatcher": "$msCompile"
} }
-10
View File
@@ -1,10 +0,0 @@
using ReceiptPDFBuilder.ViewModels;
namespace ReceiptPDFBuilder.Interfaces
{
interface IChangeViewModel
{
void PushViewModel(BaseViewModel model);
void PopViewModel();
}
}
-9
View File
@@ -1,9 +0,0 @@
using Avalonia.Controls;
namespace ReceiptPDFBuilder.Interfaces
{
interface ITopLevelGrabber
{
TopLevel GetTopLevel();
}
}
+20 -5
View File
@@ -1,11 +1,26 @@
The MIT with no AI License MIT NON-AI License
Copyright (c) 2026 Deadpikle Copyright (c) 2026, Deadpikle
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: Permission is hereby granted, free of charge, to any person obtaining a copy of the software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions.
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. In addition, the following restrictions apply:
Under no circumstances can this software, its builds, its information, or its code be used for any AI-related training, code, programs, etc. 1. The Software and any modifications made to it may not be used for the purpose of training or improving machine learning algorithms,
including but not limited to artificial intelligence, natural language processing, or data mining. This condition applies to any derivatives,
modifications, or updates based on the Software code. Any usage of the Software in an AI-training dataset is considered a breach of this License.
2. The Software may not be included in any dataset used for training or improving machine learning algorithms,
including but not limited to artificial intelligence, natural language processing, or data mining.
3. Any person or organization found to be in violation of these restrictions will be subject to legal action and may be held liable
for any damages resulting from such use.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-19
View File
@@ -1,19 +0,0 @@
using Avalonia.Controls;
using ReceiptPDFBuilder.Interfaces;
using ReceiptPDFBuilder.ViewModels;
namespace ReceiptPDFBuilder;
public partial class MainWindow : Window, ITopLevelGrabber
{
public MainWindow()
{
InitializeComponent();
DataContext = new MainWindowViewModel(this);
}
public TopLevel GetTopLevel()
{
return this;
}
}
-77
View File
@@ -1,77 +0,0 @@
using System;
using System.IO;
using System.Text;
using System.Text.Json;
using System.Text.Json.Serialization;
using System.Threading.Tasks;
using ReceiptPDFBuilder.Helpers;
using ReceiptPDFBuilders.Helpers;
namespace ReceiptPDFBuilder.Models;
class Settings : ChangeNotifier
{
private string _lastUsedPath;
public Settings()
{
_lastUsedPath = "";
}
[JsonInclude]
public string LastUsedPath
{
get => _lastUsedPath;
set { _lastUsedPath = value; NotifyPropertyChanged(); }
}
public static string GetSettingsFileName()
{
return "settings.json";
}
public static string GetSettingsPath()
{
var path = Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
"ReceiptPDFBuilder"
);
if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
}
return Path.Combine(path, GetSettingsFileName());
}
public async Task<string> SaveSettingsAsync()
{
var jsonContext = new SourceGenerationContext(Utilities.GetSerializerOptions());
using MemoryStream memoryStream = new MemoryStream();
await JsonSerializer.SerializeAsync(memoryStream, this, jsonContext.Settings);
memoryStream.Position = 0;
using var reader = new StreamReader(memoryStream);
var json = await reader.ReadToEndAsync();
await File.WriteAllTextAsync(GetSettingsPath(), json);
return json;
}
public static Settings LoadSettings()
{
var path = GetSettingsPath();
if (!File.Exists(path))
{
return new Settings();
}
var json = File.ReadAllText(GetSettingsPath());
var jsonContext = new SourceGenerationContext(Utilities.GetSerializerOptions());
return JsonSerializer.Deserialize<Settings>(json, jsonContext.Settings) ?? new Settings();
}
public static async Task<Settings> LoadSettingsAsync()
{
using FileStream fileStream = File.OpenRead(GetSettingsPath());
var jsonContext = new SourceGenerationContext(Utilities.GetSerializerOptions());
var output = await JsonSerializer.DeserializeAsync<Settings>(fileStream, jsonContext.Settings) ?? new Settings();
return output;
}
}
+9 -1
View File
@@ -1,3 +1,11 @@
# MayShow
MayShow (an intentional misspelling of 明証, pronounced may-shō, a Japanese word meaning proof, evidence, or corroboration) is a PDF report creation tool.
Throws a folder of images and PDFs into a single PDF. Simple tool for my own use, really, but maybe helpful to someone else. Throws a folder of images and PDFs into a single PDF. Simple tool for my own use, really, but maybe helpful to someone else.
Icon from [Font Awesome](https://fontawesome.com/license/free). ![App screenshot](graphics/AppScreenshot.png)
Icon is from [Font Awesome](https://fontawesome.com/license/free) and generated via [Gauger's FontAwesome icon tool](https://gauger.me/fonticon/) and the macOS software [Icon Composer](https://developer.apple.com/icon-composer/).
Most contributions are welcome; however, no contributions made from AI tools or related software are allowed.
+36
View File
@@ -1,3 +1,32 @@
magick "2026-01-29 — \$210 — WORK PERMIT.pdf" -background white -alpha background -alpha off -density 288 -resize 25% page-%03d.jpg
https://github.com/dlemstra/Magick.NET/blob/main/docs/ConvertPDF.md
https://stackoverflow.com/questions/65089839/add-an-external-pdf-page-to-pdfsharp-migradoc
https://github.com/mephraim/ghostscriptsharp
https://stackoverflow.com/a/71485279/3938401
need a PDF viewer that works with annotations
https://github.com/BobLd/PdfPig.Rendering.Skia/ works but quality is low for some reason, I don't know why. probably need a bug report or some option that is hidden.
using (var document = UglyToad.PdfPig.PdfDocument.Open(filePath, UglyToad.PdfPig.Rendering.Skia.SkiaRenderingParsingOptions.Instance))
{
document.AddSkiaPageFactory(); // Same as document.AddPageFactory<SKPicture, SkiaPageFactory>() and document.AddPageFactory<PdfPageSize, PageSizeFactory>()
for (int p = 1; p <= document.NumberOfPages; p++)
{
using var skBitmap = document.GetPageAsSKBitmap(p, 1);
using (var fs = new FileStream(Path.Combine(convertedDir, $"{fileName}_{p}PIG.jpeg"), FileMode.Create))
using (var ms = document.GetPageAsPng(p, 1, 4))
{
MemoryStream memoryStream = new MemoryStream();
skBitmap.Encode(memoryStream, SkiaSharp.SKEncodedImageFormat.Jpeg, 100);
memoryStream.Position = 0L;
ms.WriteTo(fs);
}
}
}
https://github.com/GowenGit/docnet -- may need to fork this and publish our own package if some OS doesn't work
*-add more items *-add more items
*-save last opened folder to settings somewhere *-save last opened folder to settings somewhere
@@ -11,6 +40,13 @@
*-add preview or open button or something to each item *-add preview or open button or something to each item
https://gitflic.ru/project/jackhammer/pdf-forge-net/file?commit=7bdce6132a70ab12664a8f2482003836c7af2ab6 https://gitflic.ru/project/jackhammer/pdf-forge-net/file?commit=7bdce6132a70ab12664a8f2482003836c7af2ab6
*-check if last remembered dir exists on auto-load!
*-show working directory
*-set DMG title in publish
*-Get linux publish command working and zip up/publish
dotnet publish -c Release -r linux-x64 -p:StripSymbols=False -p:PublishAot=False
dotnet publish -c Release -r linux-arm64 -p:StripSymbols=False -p:PublishAot=False
---Publishing--- ---Publishing---
*-Published app has unneeded .DSYM file (fixed via .app builder) *-Published app has unneeded .DSYM file (fixed via .app builder)
*-Published app has Assets folder already copied to it; don't want that in output macOS folder but it's being copied there anyway (fixed via .app builder) *-Published app has Assets folder already copied to it; don't want that in output macOS folder but it's being copied there anyway (fixed via .app builder)
-593
View File
@@ -1,593 +0,0 @@
#nullable enable
using System;
using System.Collections.ObjectModel;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text.Json;
using System.Threading.Tasks;
using Avalonia.Platform.Storage;
using Avalonia.Themes.Fluent;
using DialogHostAvalonia;
using ImageMagick;
using MigraDoc.DocumentObjectModel;
using MigraDoc.Rendering;
using PdfSharp.Fonts;
using PdfSharp.Pdf.IO;
using PdfSharp.Snippets.Font;
using ReceiptPDFBuilder.Helpers;
using ReceiptPDFBuilder.Interfaces;
using ReceiptPDFBuilder.Models;
using ReceiptPDFBuilders.Helpers;
namespace ReceiptPDFBuilder.ViewModels;
class MainViewModel : BaseViewModel, IFontResolver
{
private string _processDir;
private bool _isCreatingPDF;
private string _createPDFLog;
private string _workingFolder;
private string _reportTitle;
private ObservableCollection<ReportFile> _reportFiles;
private DateTime? _lastGeneratedTime;
private Settings _settings;
public MainViewModel(IChangeViewModel viewModelChanger) : base(viewModelChanger)
{
_processDir = Path.GetDirectoryName(Environment.ProcessPath) ?? "";
Console.WriteLine("Process is running from: {0}", _processDir);
_isCreatingPDF = false;
var quotes = Constants.GetQuotes();
Random random = new Random();
var quoteIndex = random.Next(0, quotes.Length);
_createPDFLog = "----- Receipt PDF Builder v" + Constants.AppVersion + "------" + Environment.NewLine;
_createPDFLog += quotes[quoteIndex] + Environment.NewLine;
_createPDFLog += "---------------------------------------" + Environment.NewLine;
_createPDFLog += "Ready to create PDF!";
_workingFolder = "";
_reportFiles = new ObservableCollection<ReportFile>();
_reportFiles.CollectionChanged += ( sender, e ) => { NotifyPropertyChanged(nameof(IsCreatePDFButtonEnabled)); };
_reportTitle = "";
_lastGeneratedTime = null;
_settings = Settings.LoadSettings();
if (!string.IsNullOrWhiteSpace(_settings.LastUsedPath))
{
LogInfo("Loading data at last used path of {0}", _settings.LastUsedPath);
ScanFolder(_settings.LastUsedPath);
}
}
public string ReportTitle
{
get => _reportTitle;
set { _reportTitle = value; NotifyPropertyChanged(); NotifyPropertyChanged(nameof(IsTitleBoxVisible)); }
}
public bool IsTitleBoxVisible
{
get => !string.IsNullOrWhiteSpace(_workingFolder);
}
public bool IsCreatingPDF
{
get => _isCreatingPDF;
set { _isCreatingPDF = value; NotifyPropertyChanged(); NotifyPropertyChanged(nameof(IsCreatePDFButtonEnabled)); }
}
public bool IsCreatePDFButtonEnabled
{
get => !_isCreatingPDF && _reportFiles.Count > 0;
}
public string CreatePDFLog
{
get => _createPDFLog;
set { _createPDFLog = value; NotifyPropertyChanged(); }
}
public ObservableCollection<ReportFile> ReportFiles
{
get => _reportFiles;
set { _reportFiles = value; NotifyPropertyChanged(); }
}
private void LogInfo(string message, params object[]? arguments)
{
var timestamp = string.Format("[{0:s}]", DateTime.Now);
Console.WriteLine(timestamp + " " + message, arguments);
CreatePDFLog += Environment.NewLine + string.Format(message, arguments ?? []);
}
public async void ChooseFolder()
{
var topLevel = TopLevelGrabber?.GetTopLevel();
if (topLevel is not null)
{
var folders = await topLevel.StorageProvider.OpenFolderPickerAsync(new FolderPickerOpenOptions()
{
Title = "Pick a folder of files...",
AllowMultiple = false,
});
if (folders.Count == 1)
{
var folder = folders[0];
LogInfo("Clearing existing list and loading items in folder: " + folder.Path.LocalPath);
ReportFiles.Clear();
ScanFolder(folder.Path.LocalPath);
_settings.LastUsedPath = folder.Path.LocalPath;
await _settings.SaveSettingsAsync();
ResortPDFItemsByDate();
}
}
}
private void ScanFolder(string path)
{
if (Directory.Exists(path))
{
_workingFolder = path;
NotifyPropertyChanged(nameof(IsTitleBoxVisible));
var reportFilePath = Path.Combine(path, GetReportSavedDataFileName());
var successfullyLoadedPriorReport = false;
if (File.Exists(reportFilePath))
{
// load prior report
var json = File.ReadAllText(reportFilePath);
var jsonContext = new SourceGenerationContext(Utilities.GetSerializerOptions());
var report = JsonSerializer.Deserialize<PDFReport>(json, jsonContext.PDFReport);
if (report != null && report.Files.Count > 0)
{
ReportFiles = new ObservableCollection<ReportFile>(report.Files);
ReportTitle = report.Title;
_workingFolder = report.BaseFolder;
_lastGeneratedTime = report.LastGenerated ?? null;
LogInfo("Reloaded report last saved at {0}", report.LastSaved);
successfullyLoadedPriorReport = true;
}
}
if (!successfullyLoadedPriorReport)
{
// Scan folder for files and display in DataGrid
var filePaths = Directory.GetFiles(_workingFolder);
foreach (var filePath in filePaths)
{
AddFileBasedOnPath(filePath);
}
ResortPDFItemsByDate();
}
}
}
public void ShowAbout()
{
DialogHost.Show(new AboutViewModel());
}
public void RemoveFile(object f) => RemoveFileImpl((ReportFile)f);
public async void RemoveFileImpl(ReportFile file)
{
var result = await DialogHost.Show(new WarningDeleteItemModel(file));
if (result != null && (bool)result)
{
var idx = ReportFiles.IndexOf(file);
if (idx != -1)
{
ReportFiles.RemoveAt(idx);
}
}
}
// https://github.com/AvaloniaUI/Avalonia/issues/10075
public void EditFileProperties(object f) => EditFilePropertiesImpl((ReportFile)f);
public async void EditFilePropertiesImpl(ReportFile file)
{
var result = await DialogHost.Show(new EditFileViewModel(file, ViewModelChanger));
if (result != null && result is ReportFile updatedData)
{
file.Title = updatedData.Title;
file.ReceiptDateTime = updatedData.ReceiptDateTime;
file.Notes = updatedData.Notes;
}
}
private string[] GetAllowedFileExtensionPatterns()
{
return [ "*.png", "*.jpg", "*.jpeg", "*.gif", "*.bmp", "*.webp", "*.pdf", "*.heic", ];
}
private string[] GetAllowedFileExtensionPatternsWithoutStar()
{
var list = GetAllowedFileExtensionPatterns();
return list.Select(x => x.Replace("*.", "")).ToArray();
}
public async void AddItem()
{
var topLevel = TopLevelGrabber?.GetTopLevel();
if (topLevel is not null)
{
var files = await topLevel.StorageProvider.OpenFilePickerAsync(new FilePickerOpenOptions()
{
Title = "Choose image or PDF files...",
AllowMultiple = true,
FileTypeFilter = [
new FilePickerFileType("All Types")
{
Patterns = GetAllowedFileExtensionPatterns(),
AppleUniformTypeIdentifiers = [ "public.image", "com.adobe.pdf", "public.heic" ],
MimeTypes = [ "image/*", "application/pdf", "image/heic" ]
},
FilePickerFileTypes.ImageAll,
new FilePickerFileType("HEIC Images")
{
Patterns = [ "*.heic" ],
AppleUniformTypeIdentifiers = [ "public.heic" ],
MimeTypes = [ "image/heic" ]
},
FilePickerFileTypes.Pdf,
],
});
if (files.Count > 0)
{
foreach (var file in files)
{
var filePath = file.TryGetLocalPath();
AddFileBasedOnPath(filePath);
}
}
}
}
private void AddFileBasedOnPath(string? filePath)
{
if (!string.IsNullOrWhiteSpace(filePath) && File.Exists(filePath) && !filePath.EndsWith(".DS_Store"))
{
// make sure extensions are OK
var fileExtensions = GetAllowedFileExtensionPatternsWithoutStar();
var didMatch = false;
foreach (var fileExtension in fileExtensions)
{
if (filePath.EndsWith("." + fileExtension))
{
didMatch = true;
break;
}
}
if (!didMatch)
{
LogInfo("File {0} did not match allowed file extension types, so it was not added.", filePath);
}
else
{
var date = Utilities.CheckValidDateInString(filePath);
ReportFiles.Add(new ReportFile()
{
Title = Path.GetFileName(filePath),
ReceiptDateTime = date.HasValue ? date.Value.ToDateTime(TimeOnly.MinValue) : File.GetCreationTime(filePath),
Notes = "",
FilePath = filePath,
});
}
}
}
// https://github.com/AvaloniaUI/Avalonia/issues/10075
public void OpenFile(object f) => OpenFileImpl((ReportFile)f);
public void OpenFileImpl(ReportFile file)
{
var topLevel = TopLevelGrabber?.GetTopLevel();
if (topLevel is not null)
{
var launcher = topLevel.Launcher;
launcher.LaunchUriAsync(new Uri(file.FilePath));
}
}
public void OpenFileLocation(object f) => OpenFileLocationImpl((ReportFile)f);
private void OpenFileLocationImpl(ReportFile file)
{
OpenFolderForFileInFileViewer(file.FilePath);
}
private void OpenFolderForFileInFileViewer(string fullPathToFile)
{
var topLevel = TopLevelGrabber?.GetTopLevel();
var dirName = Path.GetDirectoryName(fullPathToFile);
if (topLevel is not null && dirName != null)
{
var launcher = topLevel.Launcher;
launcher.LaunchUriAsync(new Uri(dirName));
}
}
public void ResortPDFItemsByDate()
{
LogInfo("Sorting report files list...");
ReportFiles = new ObservableCollection<ReportFile>(ReportFiles.OrderBy(x => x.ReceiptDateTime));
}
public async void BuildPDF()
{
if (string.IsNullOrWhiteSpace(ReportTitle))
{
await DialogHost.Show(new WarningViewModel("You must provide a report title!"));
}
else
{
try
{
await Task.Run(() => CreatePDF(_workingFolder));
} catch (Exception e)
{
LogInfo("PDF process failed! Reason: " + e.Message);
if (e.StackTrace != null)
{
LogInfo(e.StackTrace);
}
if (e.InnerException != null)
{
LogInfo("Inner exception: " + e.InnerException.Message);
if (e.InnerException.StackTrace != null)
{
LogInfo(e.InnerException.StackTrace);
}
}
LogInfo("Please report this error to a programmer or fix the issue listed above.");
IsCreatingPDF = false;
}
}
}
public async void SaveInterimReportInfo()
{
var report = new PDFReport()
{
Title = ReportTitle,
Files = ReportFiles.ToList(),
BaseFolder = _workingFolder,
LastSaved = DateTime.Now,
LastGenerated = _lastGeneratedTime,
};
await SavePDFReportDataToDisk(report);
}
private async Task SavePDFReportDataToDisk(PDFReport report)
{
var jsonContext = new SourceGenerationContext(Utilities.GetSerializerOptions());
using var memoryStream = new MemoryStream();
await JsonSerializer.SerializeAsync(memoryStream, report, jsonContext.PDFReport);
memoryStream.Position = 0;
using var reader = new StreamReader(memoryStream);
var json = await reader.ReadToEndAsync();
var savePath = Path.Combine(_workingFolder, GetReportSavedDataFileName());
await File.WriteAllTextAsync(savePath, json);
LogInfo("Saved report information to {0}", savePath);
}
private async Task CreateAndSaveReportObjectAfterReportCreation()
{
var report = new PDFReport()
{
Title = ReportTitle,
Files = ReportFiles.ToList(),
BaseFolder = _workingFolder,
LastSaved = DateTime.Now,
LastGenerated = DateTime.Now,
};
_lastGeneratedTime = DateTime.Now;
await SavePDFReportDataToDisk(report);
}
private string GetReportSavedDataFileName()
{
return "report_data.json";
}
public byte[]? GetFont(string faceName)
{
LogInfo(string.Format("Loading font {0}", faceName));
if (faceName == "Noto Sans JP")
{
var path = Path.Combine(_processDir, "Assets/Fonts/Noto_Sans_JP/static/NotoSansJP-Regular.ttf");
if (!File.Exists(path))
{
path = Path.Combine(_processDir, "../Resources/Assets/Fonts/Noto_Sans_JP/static/NotoSansJP-Regular.ttf");
}
return File.ReadAllBytes(path);
}
if (faceName == "Noto Sans JP Bold")
{
var path = Path.Combine(_processDir, "Assets/Fonts/Noto_Sans_JP/static/NotoSansJP-SemiBold.ttf");
if (!File.Exists(path))
{
path = Path.Combine(_processDir, "../Resources/Assets/Fonts/Noto_Sans_JP/static/NotoSansJP-SemiBold.ttf");
}
return File.ReadAllBytes(path);
}
return null;
}
public FontResolverInfo? ResolveTypeface(string familyName, bool bold, bool italic)
{
// LogInfo(string.Format("Resolving font name {0}", familyName));
if (familyName == "Noto Sans JP")
{
if (bold)
{
return new FontResolverInfo(familyName + " Bold");
}
return new FontResolverInfo(familyName);
}
return null;
}
// https://forum.pdfsharp.net/viewtopic.php?f=2&t=1025
private async Task CreatePDF(string folderPath)
{
// TODO: calculate needed width for images based on page width and margins and all that?
// TODO: resize (non-HEIC) images for smaller size...?
IsCreatingPDF = true;
var pdfDoc = new Document();
var outputFileName = ReportTitle + ".pdf";
var folderName = new DirectoryInfo(folderPath).Name;
const int imageWidth = 425;
if (folderName.Contains('-'))
{
// see if year/month format
var parts = folderName.Split('-');
if (parts[0].Length == 4 &&
parts[1].Length <= 2 &&
int.TryParse(parts[0], out int year) && int.TryParse(parts[1], out int month))
{
outputFileName = string.Format("{0} {1} Receipts.pdf",
CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(month),
year);
LogInfo("Auto-changed output file name to " + outputFileName);
}
}
var section = pdfDoc.AddSection();
section.PageSetup.PageFormat = PageFormat.Letter;
section.PageSetup.PageWidth = "8.5in";
section.PageSetup.PageHeight = "11in";
section.PageSetup.TopMargin = "0.5in";
section.PageSetup.RightMargin = "0.5in";
section.PageSetup.BottomMargin = "0.5in";
section.PageSetup.LeftMargin = "0.5in";
// setup footer for page number
var footerPar = new Paragraph();
footerPar.Format.Alignment = ParagraphAlignment.Center;
footerPar.Format.Font.Size = 10;
footerPar.AddText("--Page ");
footerPar.AddPageField();
footerPar.AddText(" of ");
footerPar.AddNumPagesField();
footerPar.AddText("--");
footerPar.AddLineBreak();
footerPar.AddText("Report generated on " + DateTime.Now.ToString("f"));
section.Footers.Primary.Add(footerPar);
// add report title
var reportTitlePar = section.AddParagraph();
reportTitlePar.Format.Alignment = ParagraphAlignment.Center;
reportTitlePar.Format.Font.Size = 16;
reportTitlePar.Format.Font.Bold = true;
reportTitlePar.Format.Font.Name = "Noto Sans JP"; // has english letters in it, too
reportTitlePar.AddText(ReportTitle);
//
GlobalFontSettings.FontResolver = this;
GlobalFontSettings.FallbackFontResolver = new FailsafeFontResolver();
var hasAddedData = false;
for (var i = 0; i < ReportFiles.Count; i++)
{
var file = ReportFiles[i];
var fileName = file.FileName;
var filePath = file.FilePath;
if (!File.Exists(filePath))
{
LogInfo("ERROR: File \"{0}\" does not exist at path \"{1}\". Please remove it from the report or re-add it using the Add Item button if you still want it to be in this report.", file.Title, file.FilePath);
IsCreatingPDF = false;
return;
}
if (fileName == ".DS_Store" || fileName == outputFileName)
{
continue;
}
if (i > 0 && hasAddedData)
{
section.AddPageBreak();
}
var imageTitlePar = section.AddParagraph();
imageTitlePar.Format.Alignment = ParagraphAlignment.Center;
imageTitlePar.Format.Font.Size = 12;
imageTitlePar.Format.Font.Bold = true;
imageTitlePar.Format.Font.Name = "Noto Sans JP"; // has english letters in it, too
imageTitlePar.AddText(file.Title);
var receiptDatePar = section.AddParagraph();
receiptDatePar.Format.Alignment = ParagraphAlignment.Center;
receiptDatePar.Format.Font.Size = 12;
receiptDatePar.Format.Font.Bold = true;
receiptDatePar.Format.Font.Name = "Noto Sans JP"; // has english letters in it, too
receiptDatePar.AddText(file.ReceiptDate.ToString("yyyy-MM-dd"));
if (!string.IsNullOrWhiteSpace(file.Notes))
{
var imageNotesPar = section.AddParagraph();
imageNotesPar.Format.Alignment = ParagraphAlignment.Center;
imageNotesPar.Format.Font.Size = 10;
imageNotesPar.Format.Font.Bold = false;
imageNotesPar.Format.Font.Name = "Noto Sans JP";
imageNotesPar.AddText(file.Notes);
}
section.AddParagraph(); // add empty line for spacing
// now add the image
var isPDF = fileName.EndsWith(".pdf");
// convert heic, webp, or png to JPEG for size and ease of use
// (and probably compat reasons too, though I haven't tested that...)
var lowerName = fileName.ToLower();
var isHEIC = lowerName.EndsWith(".heic");
var isWebp = lowerName.EndsWith(".webp");
var isPNG = lowerName.EndsWith(".png");
if (isHEIC || isWebp || isPNG)
{
var convertedDir = Path.Combine(folderPath, "converted");
if (!Directory.Exists(convertedDir))
{
Directory.CreateDirectory(convertedDir);
}
var info = new FileInfo(file.FilePath);
using var mImage = new MagickImage(info.FullName);
// Save frame as jpg
var outputPath = Path.Combine(convertedDir, info.Name + ".jpg");
mImage.Quality = 80;
mImage.Scale((uint)Math.Floor(mImage.Width * 0.5), (uint)Math.Floor(mImage.Height * 0.5));
await mImage.WriteAsync(outputPath);
filePath = Path.Combine("Converted", info.Name + ".jpg");
LogInfo(string.Format("Converted image to JPEG; fileName is now {0}", file.FilePath));
}
var paragraph = section.AddParagraph();
paragraph.Format.Alignment = ParagraphAlignment.Center;
var image = paragraph.AddImage(filePath);
image.LockAspectRatio = true;
image.Width = imageWidth; // can't be too wide now...not sure why...maybe due to margins...
LogInfo(string.Format("Added image: {0} ({1})", file.Title, filePath));
if (isPDF)
{
// add other PDF pages
// see: https://stackoverflow.com/a/65091204/3938401
var pdfFileToAdd = PdfReader.Open(filePath);
imageTitlePar.AddText(string.Format(" (PDF with {0} page{1}) ",
pdfFileToAdd.PageCount,
pdfFileToAdd.PageCount == 1 ? "" : "s"));
for (var j = 2; j <= pdfFileToAdd.PageCount; j++)
{
section.AddPageBreak();
paragraph = section.AddParagraph();
paragraph.Format.Alignment = ParagraphAlignment.Center;
image = paragraph.AddImage(filePath + "#" + j);
image.LockAspectRatio = true;
image.Width = imageWidth;
}
}
hasAddedData = true;
}
var pdfRenderer = new PdfDocumentRenderer
{
Document = pdfDoc,
WorkingDirectory = folderPath
};
LogInfo("Rendering document...");
pdfRenderer.RenderDocument();
string outputPDFFileName = Path.Join(folderPath, outputFileName);
LogInfo("Saving document to disk...");
pdfRenderer.PdfDocument.Save(outputPDFFileName);
LogInfo("Saved PDF output to: " + outputPDFFileName);
await CreateAndSaveReportObjectAfterReportCreation();
OpenFolderForFileInFileViewer(outputPDFFileName);
IsCreatingPDF = false;
}
}
-32
View File
@@ -1,32 +0,0 @@
<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="ReceiptPDFBuilder.Views.AboutView"
xmlns:models="clr-namespace:ReceiptPDFBuilder.Models"
xmlns:vm="clr-namespace:ReceiptPDFBuilder.ViewModels"
xmlns:dialogHost="clr-namespace:DialogHostAvalonia;assembly=DialogHost.Avalonia"
x:DataType="vm:AboutViewModel">
<StackPanel Orientation="Vertical"
Spacing="4">
<TextBlock Text="Receipt PDF Builder"
HorizontalAlignment="Center"
TextWrapping="Wrap"
FontSize="18"
FontWeight="Bold"/>
<TextBlock Text="Receipt PDF Builder was built by MB for A in 2026. May the quacking of ducks always be in your favor. Thanks for using!"
MaxWidth="300"
TextWrapping="Wrap"
FontSize="14"/>
<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"
FontSize="14"/>
<Button Command="{Binding Close}"
Classes="accent"
Content="Close"
HorizontalAlignment="Right"
Margin="0,0,4,4"/>
</StackPanel>
</UserControl>
-15
View File
@@ -1,15 +0,0 @@
using System;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
namespace ReceiptPDFBuilder.Views
{
public partial class AboutView : UserControl
{
public AboutView()
{
this.InitializeComponent();
}
}
}
-24
View File
@@ -1,24 +0,0 @@
using System;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
namespace ReceiptPDFBuilder.Views
{
public partial class MainView : UserControl
{
public MainView()
{
this.InitializeComponent();
LogBlock.PropertyChanged += LogBlock_PropertyChanged;
}
private void LogBlock_PropertyChanged(object? sender, AvaloniaPropertyChangedEventArgs e)
{
if (e.Property.ToString() == "Text")
{
LogScrollView.ScrollToEnd();
}
}
}
}
-15
View File
@@ -1,15 +0,0 @@
using System;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
namespace ReceiptPDFBuilder.Views
{
public partial class WarningView : UserControl
{
public WarningView()
{
this.InitializeComponent();
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 236 KiB

Before

Width:  |  Height:  |  Size: 1.9 MiB

After

Width:  |  Height:  |  Size: 1.9 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

+27
View File
@@ -0,0 +1,27 @@
{
"fill" : "system-dark",
"groups" : [
{
"layers" : [
{
"image-name" : "favicon(2).png",
"name" : "favicon(2)"
}
],
"shadow" : {
"kind" : "neutral",
"opacity" : 0.5
},
"translucency" : {
"enabled" : true,
"value" : 0.5
}
}
],
"supported-platforms" : {
"circles" : [
"watchOS"
],
"squares" : "shared"
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 MiB

@@ -2,10 +2,10 @@
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES! ; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
; Non-commercial use only ; Non-commercial use only
#define MyAppName "Receipt PDF Builder" #define MyAppName "MayShow"
#define MyAppVersion "1.0.0" #define MyAppVersion "1.4.0"
#define MyAppPublisher "Quickity Quack Productions" #define MyAppPublisher "Quickity Quack Productions"
#define MyAppExeName "ReceiptPDFBuilder.exe" #define MyAppExeName "MayShow.exe"
[Setup] [Setup]
; NOTE: The value of AppId uniquely identifies this application. Do not use the same AppId value in installers for other applications. ; NOTE: The value of AppId uniquely identifies this application. Do not use the same AppId value in installers for other applications.
@@ -31,8 +31,8 @@ DisableProgramGroupPage=yes
OutputBaseFilename=Install {#MyAppName} {#MyAppVersion} OutputBaseFilename=Install {#MyAppName} {#MyAppVersion}
SolidCompression=yes SolidCompression=yes
WizardStyle=modern dynamic WizardStyle=modern dynamic
SetupIconFile=ReceiptPDFBuilder-icon.ico SetupIconFile=../src/MayShow-icon.ico
OutputDir=bin OutputDir=..\src\bin
[Languages] [Languages]
Name: "english"; MessagesFile: "compiler:Default.isl" Name: "english"; MessagesFile: "compiler:Default.isl"
@@ -41,12 +41,14 @@ Name: "english"; MessagesFile: "compiler:Default.isl"
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
[Files] [Files]
Source: "bin\Release\net10.0\win-x64\publish\{#MyAppExeName}"; DestDir: "{app}"; Flags: ignoreversion Source: "..\src\bin\Release\net10.0\win-x64\publish\{#MyAppExeName}"; DestDir: "{app}"; Flags: ignoreversion
Source: "bin\Release\net10.0\win-x64\publish\av_libglesv2.dll"; DestDir: "{app}"; Flags: ignoreversion Source: "..\src\bin\Release\net10.0\win-x64\publish\av_libglesv2.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "bin\Release\net10.0\win-x64\publish\libHarfBuzzSharp.dll"; DestDir: "{app}"; Flags: ignoreversion Source: "..\src\bin\Release\net10.0\win-x64\publish\libHarfBuzzSharp.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "bin\Release\net10.0\win-x64\publish\libSkiaSharp.dll"; DestDir: "{app}"; Flags: ignoreversion Source: "..\src\bin\Release\net10.0\win-x64\publish\libSkiaSharp.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "bin\Release\net10.0\win-x64\publish\Magick.Native-Q16-x64.dll"; DestDir: "{app}"; Flags: ignoreversion Source: "..\src\bin\Release\net10.0\win-x64\publish\LICENSE"; DestDir: "{app}"; DestName: "PDFium-license.txt"; Flags: ignoreversion
Source: "bin\Release\net10.0\win-x64\publish\Assets\*"; DestDir: "{app}\Assets"; Flags: ignoreversion recursesubdirs createallsubdirs Source: "..\src\bin\Release\net10.0\win-x64\publish\Magick.Native-Q8-x64.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\src\bin\Release\net10.0\win-x64\publish\pdfium.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "..\src\bin\Release\net10.0\win-x64\publish\Assets\*"; DestDir: "{app}\Assets"; Flags: ignoreversion recursesubdirs createallsubdirs
; NOTE: Don't use "Flags: ignoreversion" on any shared system files ; NOTE: Don't use "Flags: ignoreversion" on any shared system files
[Icons] [Icons]
+26
View File
@@ -0,0 +1,26 @@
#!/bin/bash
VERSION="1.4.0"
SRC_DIR="src" # user ran script from main folder
if [ ! -d "$SRC_DIR" ]; then
SRC_DIR= "../src" # try
fi
if [ ! -d "$SRC_DIR" ]; then
echo "Please run from "installers" dir or from main repo directory"
exit 1
fi
cd "$SRC_DIR"
echo "Building release for linux-x64..."
dotnet clean -c Release
dotnet publish -c Release -r linux-x64 -p:StripSymbols=False -p:PublishAot=False
echo "Zipping up linux-x64..."
cd bin/Release/net10.0/linux-x64/publish
zip -r "../../../../MayShow $VERSION linux-x64.zip" .
cd ../../../../../
# -----
echo "Building release for linux-arm64..."
dotnet clean -c Release
dotnet publish -c Release -r linux-arm64 -p:StripSymbols=False -p:PublishAot=False
cd bin/Release/net10.0/linux-arm64/publish
zip -r "../../../../MayShow $VERSION linux-arm64.zip" .
cd ../../../../../
+17 -8
View File
@@ -1,13 +1,13 @@
<Application xmlns="https://github.com/avaloniaui" <Application xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="ReceiptPDFBuilder.App" x:Class="MayShow.App"
xmlns:viewModels="clr-namespace:ReceiptPDFBuilder.ViewModels" xmlns:viewModels="clr-namespace:MayShow.ViewModels"
xmlns:views="clr-namespace:ReceiptPDFBuilder.Views" xmlns:views="clr-namespace:MayShow.Views"
xmlns:dialogHostAvalonia="clr-namespace:DialogHostAvalonia;assembly=DialogHost.Avalonia" xmlns:dialogHostAvalonia="clr-namespace:DialogHostAvalonia;assembly=DialogHost.Avalonia"
xmlns:behaviors="clr-namespace:DialogHostAvalonia;assembly=DialogHost.Avalonia" xmlns:behaviors="clr-namespace:DialogHostAvalonia;assembly=DialogHost.Avalonia"
xmlns:helpers="clr-namespace:ReceiptPDFBuilder.Helpers" xmlns:helpers="clr-namespace:MayShow.Helpers"
RequestedThemeVariant="Default" RequestedThemeVariant="Default"
Name="Receipt PDF Builder"> Name="MayShow">
<Application.Styles> <Application.Styles>
<FluentTheme /> <FluentTheme />
<StyleInclude Source="avares://AvaloniaProgressRing/Styles/ProgressRing.xaml"/> <StyleInclude Source="avares://AvaloniaProgressRing/Styles/ProgressRing.xaml"/>
@@ -88,7 +88,7 @@
<DataTemplate DataType="{x:Type viewModels:MainViewModel}"> <DataTemplate DataType="{x:Type viewModels:MainViewModel}">
<views:MainView/> <views:MainView/>
</DataTemplate> </DataTemplate>
<DataTemplate DataType="{x:Type viewModels:WarningDeleteItemModel}"> <DataTemplate DataType="{x:Type viewModels:WarningDeleteItemViewModel}">
<views:WarningDeleteItem/> <views:WarningDeleteItem/>
</DataTemplate> </DataTemplate>
<DataTemplate DataType="{x:Type viewModels:EditFileViewModel}"> <DataTemplate DataType="{x:Type viewModels:EditFileViewModel}">
@@ -100,6 +100,15 @@
<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>
<DataTemplate DataType="{x:Type viewModels:ConfirmViewModel}">
<views:ConfirmView/>
</DataTemplate>
<DataTemplate DataType="{x:Type viewModels:SettingsViewModel}">
<views:SettingsView/>
</DataTemplate>
</Application.DataTemplates> </Application.DataTemplates>
<Application.Resources> <Application.Resources>
<ResourceDictionary> <ResourceDictionary>
@@ -116,8 +125,8 @@
<PathGeometry x:Key="IconGrabberGeometry">M15 18a1 1 0 100-2 1 1 0 000 2zm1-6a1 1 0 11-2 0 1 1 0 012 0zm-7 6a1 1 0 100-2 1 1 0 000 2zm0-5a1 1 0 100-2 1 1 0 000 2zm7-6a1 1 0 11-2 0 1 1 0 012 0zM9 8a1 1 0 100-2 1 1 0 000 2z</PathGeometry> <PathGeometry x:Key="IconGrabberGeometry">M15 18a1 1 0 100-2 1 1 0 000 2zm1-6a1 1 0 11-2 0 1 1 0 012 0zm-7 6a1 1 0 100-2 1 1 0 000 2zm0-5a1 1 0 100-2 1 1 0 000 2zm7-6a1 1 0 11-2 0 1 1 0 012 0zM9 8a1 1 0 100-2 1 1 0 000 2z</PathGeometry>
<GeometryDrawing x:Key="IconGrabber" Brush="{DynamicResource DragDropBrush}" Geometry="{StaticResource IconGrabberGeometry}" /> <GeometryDrawing x:Key="IconGrabber" Brush="{DynamicResource DragDropBrush}" Geometry="{StaticResource IconGrabberGeometry}" />
<FontFamily x:Key="FontAwesomeRegular">avares://ReceiptPDFBuilder/Assets/Fonts/FontAwesome/Font Awesome 7 Free-Regular-400.otf#Font Awesome 7 Free Regular</FontFamily> <FontFamily x:Key="FontAwesomeRegular">avares://MayShow/Assets/Fonts/FontAwesome/Font Awesome 7 Free-Regular-400.otf#Font Awesome 7 Free Regular</FontFamily>
<FontFamily x:Key="FontAwesomeSolid">avares://ReceiptPDFBuilder/Assets/Fonts/FontAwesome/Font Awesome 7 Free-Solid-900.otf#Font Awesome 7 Free Solid</FontFamily> <FontFamily x:Key="FontAwesomeSolid">avares://MayShow/Assets/Fonts/FontAwesome/Font Awesome 7 Free-Solid-900.otf#Font Awesome 7 Free Solid</FontFamily>
</ResourceDictionary> </ResourceDictionary>
</Application.Resources> </Application.Resources>
<NativeMenu.Menu> <NativeMenu.Menu>
+3 -3
View File
@@ -4,10 +4,10 @@ using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Interactivity; using Avalonia.Interactivity;
using Avalonia.Markup.Xaml; using Avalonia.Markup.Xaml;
using DialogHostAvalonia; using DialogHostAvalonia;
using ReceiptPDFBuilder; using MayShow;
using ReceiptPDFBuilder.ViewModels; using MayShow.ViewModels;
namespace ReceiptPDFBuilder; namespace MayShow;
public partial class App : Application public partial class App : Application
{ {
+785
View File
@@ -0,0 +1,785 @@
--Avalonia--
The MIT License (MIT)
Copyright (c) AvaloniaUI OÜ All Rights Reserved
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
--PDFsharp-MigraDoc--
Copyright (c) 2001-2026 empira Software GmbH, Troisdorf (Cologne Area), Germany
http://docs.pdfsharp.net
MIT License
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
--ImageMagick--
Terms and Conditions for Use, Reproduction, and Distribution
The legally binding and authoritative terms and conditions for use, reproduction, and distribution of ImageMagick follow:
Copyright © 1999 ImageMagick Studio LLC, a non-profit organization dedicated to making software imaging solutions freely available.
1. Definitions.
License shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
Licensor shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
Legal Entity shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, control means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
You (or Your) shall mean an individual or Legal Entity exercising permissions granted by this License.
Source form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
Object form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
Work shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
Derivative Works shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
Contribution shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as Not a Contribution.
Contributor shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
You must give any other recipients of the Work or Derivative Works a copy of this License; and
You must cause any modified files to carry prominent notices stating that You changed the files; and
You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
--Magick.NET--
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
--Deadpikle.AvaloniaProgressRing--
MIT License
Copyright (c) 2020 Deadpikle
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
--DialogHost.Avalonia--
MIT License
Copyright (c) 2021 SKProCH
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
--Xaml.Behaviors--
The MIT License (MIT)
Copyright (c) Wiesław Šoltés
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
--Docnet.Core--
MIT License
Copyright (c) 2018 Modestas Petravicius
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
--SixLabors.ImageSharp--
(Note: MayShow is open source and thus is licensed to use SixLabors.ImageSharp under the Apache License, Version 2.0)
Six Labors Split License
Version 1.0, June 2022
Copyright (c) Six Labors
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications, including but not limited to software source
code, documentation source, and configuration files.
"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including
but not limited to compiled object code, generated documentation, and conversions to other media types.
"Work" (or "Works") shall mean any Six Labors software made available under the License, as indicated by a
copyright notice that is included in or attached to the work.
"Direct Package Dependency" shall mean any Work in Source or Object form that is installed directly by You.
"Transitive Package Dependency" shall mean any Work in Object form that is installed indirectly by a third party
dependency unrelated to Six Labors.
2. License
Works in Source or Object form are split licensed and may be licensed under the Apache License, Version 2.0 or a
Six Labors Commercial Use License.
Licenses are granted based upon You meeting the qualified criteria as stated. Once granted,
You must reference the granted license only in all documentation.
Works in Source or Object form are licensed to You under the Apache License, Version 2.0 if.
- You are consuming the Work in for use in software licensed under an Open Source or Source Available license.
- You are consuming the Work as a Transitive Package Dependency.
- You are consuming the Work as a Direct Package Dependency in the capacity of a For-profit company/individual with
less than 1M USD annual gross revenue.
- You are consuming the Work as a Direct Package Dependency in the capacity of a Non-profit organization
or Registered Charity.
For all other scenarios, Works in Source or Object form are licensed to You under the Six Labors Commercial License
which may be purchased by visiting https://sixlabors.com/pricing/.
--FontAwesome--
Fonticons, Inc. (https://fontawesome.com)
--------------------------------------------------------------------------------
Font Awesome Free License
Font Awesome Free is free, open source, and GPL friendly. You can use it for
commercial projects, open source projects, or really almost whatever you want.
Full Font Awesome Free license: https://fontawesome.com/license/free.
--------------------------------------------------------------------------------
# Icons: CC BY 4.0 License (https://creativecommons.org/licenses/by/4.0/)
The Font Awesome Free download is licensed under a Creative Commons
Attribution 4.0 International License and applies to all icons packaged
as SVG and JS file types.
--------------------------------------------------------------------------------
# Fonts: SIL OFL 1.1 License
In the Font Awesome Free download, the SIL OFL license applies to all icons
packaged as web and desktop font files.
Copyright (c) 2026 Fonticons, Inc. (https://fontawesome.com)
with Reserved Font Name: "Font Awesome".
This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at:
http://scripts.sil.org/OFL
SIL OPEN FONT LICENSE
Version 1.1 - 26 February 2007
PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.
The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.
DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.
"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).
"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).
"Modified Version" refers to any derivative made by adding to, deleting,
or substituting — in part or in whole — any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.
"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.
PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:
1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.
2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.
3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.
5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.
TERMINATION
This license becomes null and void if any of the above conditions are
not met.
DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.
--------------------------------------------------------------------------------
# Code: MIT License (https://opensource.org/licenses/MIT)
In the Font Awesome Free download, the MIT license applies to all non-font and
non-icon files.
Copyright 2026 Fonticons, Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in the
Software without restriction, including without limitation the rights to use, copy,
modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
and to permit persons to whom the Software is furnished to do so, subject to the
following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
--------------------------------------------------------------------------------
# Attribution
Attribution is required by MIT, SIL OFL, and CC BY licenses. Downloaded Font
Awesome Free files already contain embedded comments with sufficient
attribution, so you shouldn't need to do anything additional when using these
files normally.
We've kept attribution comments terse, so we ask that you do not actively work
to remove them from files, especially code. They're a great way for folks to
learn about Font Awesome.
--------------------------------------------------------------------------------
# Brand Icons
All brand icons are trademarks of their respective owners. The use of these
trademarks does not indicate endorsement of the trademark holder by Font
Awesome, nor vice versa. **Please do not use brand logos for any purpose except
to represent the company, product, or service to which they refer.**
--Noto Sans Font--
Copyright 2022 The Noto Project Authors (https://github.com/notofonts/latin-greek-cyrillic)
This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at:
https://openfontlicense.org
-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------
PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.
The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.
DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.
"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).
"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).
"Modified Version" refers to any derivative made by adding to, deleting,
or substituting -- in part or in whole -- any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.
"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.
PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:
1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.
2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.
3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.
5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.
TERMINATION
This license becomes null and void if any of the above conditions are
not met.
DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.
--Noto Sans JP Font--
Copyright 2014-2021 Adobe (http://www.adobe.com/), with Reserved Font Name 'Source'
This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at:
https://openfontlicense.org
-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------
PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.
The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.
DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.
"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).
"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).
"Modified Version" refers to any derivative made by adding to, deleting,
or substituting -- in part or in whole -- any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.
"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.
PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:
1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.
2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.
3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.
5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.
TERMINATION
This license becomes null and void if any of the above conditions are
not met.
DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.
@@ -4,7 +4,7 @@ using System.ComponentModel;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Text; using System.Text;
namespace ReceiptPDFBuilder.Helpers namespace MayShow.Helpers
{ {
// https://docs.microsoft.com/en-us/dotnet/api/system.componentmodel.inotifypropertychanged?view=netframework-4.7.2 // https://docs.microsoft.com/en-us/dotnet/api/system.componentmodel.inotifypropertychanged?view=netframework-4.7.2
@@ -1,11 +1,14 @@
using System; namespace MayShow.Helpers;
namespace ReceiptPDFBuilder.Helpers;
class Constants class Constants
{ {
public static string AppVersion = "1.0.0"; public static string AppVersion = "1.4.0";
public static string[] AllowedFileExtensionPatterns = [ "*.png", "*.jpg", "*.jpeg", "*.gif", "*.bmp", "*.webp", "*.pdf", "*.heic", ];
public static string[] AllowedFileExtensionsNoStar = [ "png", "jpg", "jpeg", "gif", "bmp", "webp", "pdf", "heic", ];
public static string ReportSavedDataFileName = "report_data.json";
public static string[] GetQuotes() public static string[] GetQuotes()
{ {
@@ -17,7 +20,7 @@ class Constants
return [ return [
"When in the crucible of life, always remember to take your friends with you.", "When in the crucible of life, always remember to take your friends with you.",
"What do you call a paper airplane that won't fly? Stationary.", "What do you call a paper airplane that won't fly? Stationary.",
"I used to be addicted to Dad jokes, but now I'm all groan up.", "I used to be addicted to dad jokes, but now I'm all groan up.",
"I used to have a phobia about speed bumps. But I'm slowly getting over it.", "I used to have a phobia about speed bumps. But I'm slowly getting over it.",
"Be careful trusting stairs. They're always up to something.", "Be careful trusting stairs. They're always up to something.",
"What do you call a fish with no eye? A fsh", "What do you call a fish with no eye? A fsh",
@@ -3,10 +3,10 @@ using Avalonia.Controls;
using Avalonia.Input; using Avalonia.Input;
using Avalonia.VisualTree; using Avalonia.VisualTree;
using Avalonia.Xaml.Interactions.DragAndDrop; using Avalonia.Xaml.Interactions.DragAndDrop;
using ReceiptPDFBuilder.Models; using MayShow.Models;
using ReceiptPDFBuilder.ViewModels; using MayShow.ViewModels;
namespace ReceiptPDFBuilder.Helpers; namespace MayShow.Helpers;
class DataGridDropHandler : BaseDataGridDropHandler<ReportFile> class DataGridDropHandler : BaseDataGridDropHandler<ReportFile>
{ {
@@ -2,7 +2,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading; using System.Threading;
namespace ReceiptPDFBuilders.Helpers; namespace MayShows.Helpers;
public static class ThreadSafeRandom public static class ThreadSafeRandom
{ {
@@ -1,7 +1,7 @@
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
using ReceiptPDFBuilder.Models; using MayShow.Models;
namespace ReceiptPDFBuilder.Helpers; namespace MayShow.Helpers;
[JsonSerializable(typeof(Settings))] [JsonSerializable(typeof(Settings))]
[JsonSerializable(typeof(ReportFile))] [JsonSerializable(typeof(ReportFile))]
@@ -1,11 +1,12 @@
using System; using System;
using System.Globalization; using System.Globalization;
using System.IO;
using System.Text.Json; using System.Text.Json;
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
namespace ReceiptPDFBuilders.Helpers; namespace MayShows.Helpers;
class Utilities class Utilities
{ {
@@ -35,4 +36,17 @@ class Utilities
} }
return null; return null;
} }
public static string GetInternalDataPath()
{
var path = Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
"MayShow"
);
if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
}
return path;
}
} }
+8
View File
@@ -0,0 +1,8 @@
using System.Threading.Tasks;
namespace MayShow.Interfaces;
interface ICanCheckShutdown
{
Task<bool> CheckIsSafeToShutdown();
}
+9
View File
@@ -0,0 +1,9 @@
using MayShow.ViewModels;
namespace MayShow.Interfaces;
interface IChangeViewModel
{
void PushViewModel(BaseViewModel model);
void PopViewModel();
}
+8
View File
@@ -0,0 +1,8 @@
using Avalonia.Controls;
namespace MayShow.Interfaces;
interface ITopLevelGrabber
{
TopLevel GetTopLevel();
}
+7 -6
View File
@@ -3,17 +3,18 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="ReceiptPDFBuilder.MainWindow" x:Class="MayShow.MainWindow"
Title="Receipt PDF Builder" Title="MayShow"
xmlns:vm="clr-namespace:ReceiptPDFBuilder.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:MainWindowViewModel" x:DataType="vm:MainWindowViewModel"
Width="800" Width="800"
MinWidth="400" MinWidth="550"
Height="650" Height="650"
MinHeight="450"> 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>
+78
View File
@@ -0,0 +1,78 @@
using System;
using System.Threading.Tasks;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Controls.ApplicationLifetimes;
using DialogHostAvalonia;
using MayShow.Interfaces;
using MayShow.ViewModels;
namespace MayShow;
public partial class MainWindow : Window, ITopLevelGrabber
{
public MainWindow()
{
InitializeComponent();
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()
{
return this;
}
}

Before

Width:  |  Height:  |  Size: 401 KiB

After

Width:  |  Height:  |  Size: 401 KiB

@@ -11,13 +11,18 @@
<SelfContained>true</SelfContained> <SelfContained>true</SelfContained>
<PublishTrimmed>true</PublishTrimmed> <PublishTrimmed>true</PublishTrimmed>
<PublishAot>true</PublishAot> <PublishAot>true</PublishAot>
<AssemblyName>ReceiptPDFBuilder</AssemblyName> <AssemblyName>MayShow</AssemblyName>
<AssemblyVersion>1.0.0</AssemblyVersion> <!-- Also update Constants version --> <AssemblyVersion>1.4.0</AssemblyVersion> <!-- Also update Constants version -->
<ApplicationIcon>ReceiptPDFBuilder-icon.ico</ApplicationIcon> <ApplicationIcon>MayShow-icon.ico</ApplicationIcon>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<TrimmerRootAssembly Include="MigraDoc.DocumentObjectModel" />
<TrimmerRootAssembly Include="MigraDoc.Rendering" />
<TrimmerRootAssembly Include="MigraDoc.RtfRendering" />
<TrimmerRootAssembly Include="PdfSharp" /> <TrimmerRootAssembly Include="PdfSharp" />
<TrimmerRootAssembly Include="Avalonia.Controls.DataGrid" /> <TrimmerRootAssembly Include="Avalonia.Controls.DataGrid" />
<!-- <TrimmerRootAssembly Include="Docnet.Core" />
<TrimmerRootAssembly Include="SixLabors.ImageSharp" /> -->
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<AvaloniaResource Include="Assets\**" /> <AvaloniaResource Include="Assets\**" />
@@ -35,6 +40,12 @@
<Content Include="Assets\Fonts\Noto_Sans_JP\static\*.*"> <Content Include="Assets\Fonts\Noto_Sans_JP\static\*.*">
<CopyToOutputDirectory>Always</CopyToOutputDirectory> <CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content> </Content>
<Content Include="Assets\Fonts\FontAwesome\*.*">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Assets\LICENSES.txt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Avalonia" Version="$(AvaloniaVersion)" /> <PackageReference Include="Avalonia" Version="$(AvaloniaVersion)" />
@@ -46,10 +57,12 @@
<IncludeAssets Condition="'$(Configuration)' != 'Debug'">None</IncludeAssets> <IncludeAssets Condition="'$(Configuration)' != 'Debug'">None</IncludeAssets>
<PrivateAssets Condition="'$(Configuration)' != 'Debug'">All</PrivateAssets> <PrivateAssets Condition="'$(Configuration)' != 'Debug'">All</PrivateAssets>
</PackageReference> </PackageReference>
<PackageReference Include="PDFsharp-MigraDoc" Version="6.2.3" /> <PackageReference Include="PDFsharp-MigraDoc" Version="6.2.4" />
<PackageReference Include="Magick.NET-Q16-AnyCPU" Version="14.10.2" /> <PackageReference Include="Magick.NET-Q8-AnyCPU" Version="14.10.3" />
<PackageReference Include="Deadpikle.AvaloniaProgressRing" Version="0.10.11-preview20251127001" /> <PackageReference Include="Deadpikle.AvaloniaProgressRing" Version="0.10.11-preview20251127001" />
<PackageReference Include="DialogHost.Avalonia" Version="0.10.4" /> <PackageReference Include="DialogHost.Avalonia" Version="0.10.4" />
<PackageReference Include="Xaml.Behaviors.Interactions.DragAndDrop.DataGrid" Version="11.3.9.5" /> <PackageReference Include="Xaml.Behaviors.Interactions.DragAndDrop.DataGrid" Version="11.3.9.5" />
<PackageReference Include="Docnet.Core" Version="2.6.0" />
<PackageReference Include="SixLabors.ImageSharp" Version="3.1.12" />
</ItemGroup> </ItemGroup>
</Project> </Project>
@@ -5,9 +5,9 @@ using System.Text;
using System.Text.Json; using System.Text.Json;
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
using System.Threading.Tasks; using System.Threading.Tasks;
using ReceiptPDFBuilder.Helpers; using MayShow.Helpers;
namespace ReceiptPDFBuilder.Models; namespace MayShow.Models;
class PDFReport : ChangeNotifier class PDFReport : ChangeNotifier
{ {
@@ -1,9 +1,9 @@
using System; using System;
using System.IO; using System.IO;
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
using ReceiptPDFBuilder.Helpers; using MayShow.Helpers;
namespace ReceiptPDFBuilder.Models; namespace MayShow.Models;
class ReportFile : ChangeNotifier class ReportFile : ChangeNotifier
{ {
@@ -60,7 +60,13 @@ class ReportFile : ChangeNotifier
public string FilePath public string FilePath
{ {
get => _filePath; get => _filePath;
set { _filePath = value; NotifyPropertyChanged(); } set
{
_filePath = value;
NotifyPropertyChanged();
NotifyPropertyChanged(nameof(FileName));
NotifyPropertyChanged(nameof(IsFileFoundOnDisk));
}
} }
[JsonIgnore] [JsonIgnore]
@@ -68,4 +74,10 @@ class ReportFile : ChangeNotifier
{ {
get => Path.GetFileName(_filePath); get => Path.GetFileName(_filePath);
} }
[JsonIgnore]
public bool IsFileFoundOnDisk
{
get => File.Exists(FilePath);
}
} }
+157
View File
@@ -0,0 +1,157 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Text.Json;
using System.Text.Json.Serialization;
using System.Threading.Tasks;
using MayShow.Helpers;
using MayShows.Helpers;
namespace MayShow.Models;
class Settings : ChangeNotifier
{
private string _lastUsedPath;
private bool _useDocnetPDFImageRendering;
private bool _saveOutputPdfInWorkingDir;
private string _outputPdfDir;
private decimal _imageResizeThreshold;
private bool _saveReportJsonDataInInternalDir;
private Dictionary<string, string> _workingFolderToInternalFolderName;
public int _settingsVersion;
public Settings()
{
_lastUsedPath = "";
_useDocnetPDFImageRendering = true;
_saveOutputPdfInWorkingDir = true;
_outputPdfDir = "";
_imageResizeThreshold = 1.5m;
_saveReportJsonDataInInternalDir = false;
_workingFolderToInternalFolderName = [];
_settingsVersion = 1;
}
public Settings(Settings other)
{
_lastUsedPath = other.LastUsedPath;
_useDocnetPDFImageRendering = other.UseDocnetPDFImageRendering;
_saveOutputPdfInWorkingDir = other.SaveOutputPdfInWorkingDir;
_outputPdfDir = other.OutputPdfDir;
_imageResizeThreshold = other.ImageResizeThreshold;
_saveReportJsonDataInInternalDir = other.SaveReportJsonDataInInternalDir;
_workingFolderToInternalFolderName = other.WorkingFolderToInternalFolderName;
_settingsVersion = other.SettingsVersion;
}
[JsonInclude]
public string LastUsedPath
{
get => _lastUsedPath;
set { _lastUsedPath = value; NotifyPropertyChanged(); }
}
[JsonInclude]
[JsonPropertyName("UseDocnetPFDImageRendering")] // ...this typo now has to live because people have this saved on disk...
public bool UseDocnetPDFImageRendering
{
get => _useDocnetPDFImageRendering;
set { _useDocnetPDFImageRendering = value; NotifyPropertyChanged(); }
}
[JsonInclude]
public bool SaveOutputPdfInWorkingDir
{
get => _saveOutputPdfInWorkingDir;
set { _saveOutputPdfInWorkingDir = value; NotifyPropertyChanged(); }
}
[JsonInclude]
public string OutputPdfDir
{
get => _outputPdfDir;
set { _outputPdfDir = value; NotifyPropertyChanged(); }
}
[JsonInclude]
public decimal ImageResizeThreshold
{
get => _imageResizeThreshold;
set { _imageResizeThreshold = value; NotifyPropertyChanged(); }
}
[JsonInclude]
public bool SaveReportJsonDataInInternalDir
{
get => _saveReportJsonDataInInternalDir;
set { _saveReportJsonDataInInternalDir = value; NotifyPropertyChanged(); }
}
[JsonInclude]
public Dictionary<string, string> WorkingFolderToInternalFolderName
{
get => _workingFolderToInternalFolderName;
set { _workingFolderToInternalFolderName = value; NotifyPropertyChanged(); }
}
[JsonInclude]
public int SettingsVersion
{
get => _settingsVersion;
set { _settingsVersion = value; NotifyPropertyChanged(); }
}
public static string SettingsFileName = "settings.json";
public static string GetSettingsPath()
{
var path = Utilities.GetInternalDataPath();
return Path.Combine(path, SettingsFileName);
}
public string SaveSettingsNotAsync()
{
var jsonContext = new SourceGenerationContext(Utilities.GetSerializerOptions());
using MemoryStream memoryStream = new MemoryStream();
JsonSerializer.Serialize(memoryStream, this, jsonContext.Settings);
memoryStream.Position = 0;
using var reader = new StreamReader(memoryStream);
var json = reader.ReadToEnd();
File.WriteAllText(GetSettingsPath(), json);
return json;
}
public async Task<string> SaveSettingsAsync()
{
var jsonContext = new SourceGenerationContext(Utilities.GetSerializerOptions());
using MemoryStream memoryStream = new MemoryStream();
await JsonSerializer.SerializeAsync(memoryStream, this, jsonContext.Settings);
memoryStream.Position = 0;
using var reader = new StreamReader(memoryStream);
var json = await reader.ReadToEndAsync();
await File.WriteAllTextAsync(GetSettingsPath(), json);
return json;
}
public static Settings LoadSettings()
{
var path = GetSettingsPath();
if (!File.Exists(path))
{
return new Settings();
}
var json = File.ReadAllText(GetSettingsPath());
var jsonContext = new SourceGenerationContext(Utilities.GetSerializerOptions());
return JsonSerializer.Deserialize<Settings>(json, jsonContext.Settings) ?? new Settings();
}
public static async Task<Settings> LoadSettingsAsync()
{
using FileStream fileStream = File.OpenRead(GetSettingsPath());
var jsonContext = new SourceGenerationContext(Utilities.GetSerializerOptions());
var output = await JsonSerializer.DeserializeAsync<Settings>(fileStream, jsonContext.Settings) ?? new Settings();
return output;
}
}
+8
View File
@@ -0,0 +1,8 @@
namespace MayShow.Models;
enum ShutdownCheckOptions
{
SaveAndShutdown,
NoSaveShutdown,
CancelShutdown,
}
+1 -1
View File
@@ -1,7 +1,7 @@
using Avalonia; using Avalonia;
using System; using System;
namespace ReceiptPDFBuilder; namespace MayShow;
class Program class Program
{ {
@@ -15,10 +15,10 @@ using MigraDoc.Rendering;
using PdfSharp.Fonts; using PdfSharp.Fonts;
using PdfSharp.Pdf.IO; using PdfSharp.Pdf.IO;
using PdfSharp.Snippets.Font; using PdfSharp.Snippets.Font;
using ReceiptPDFBuilder.Interfaces; using MayShow.Interfaces;
using ReceiptPDFBuilder.Models; using MayShow.Models;
namespace ReceiptPDFBuilder.ViewModels; namespace MayShow.ViewModels;
class AboutViewModel class AboutViewModel
{ {
@@ -1,11 +1,11 @@
using Avalonia.Controls; using Avalonia.Controls;
using ReceiptPDFBuilder.Helpers; using MayShow.Helpers;
using ReceiptPDFBuilder.Interfaces; using MayShow.Interfaces;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
namespace ReceiptPDFBuilder.ViewModels namespace MayShow.ViewModels
{ {
class BaseViewModel : ChangeNotifier class BaseViewModel : ChangeNotifier
{ {
+52
View File
@@ -0,0 +1,52 @@
#nullable enable
using DialogHostAvalonia;
using MayShow.Helpers;
namespace MayShow.ViewModels;
class ConfirmViewModel
{
private string _title;
private string _message;
private string _confirmTitle;
private string _declineTitle;
public ConfirmViewModel(string title, string message, string confirmTitle = "Yes", string declineTitle = "No")
{
_title = title;
_message = message;
_confirmTitle = confirmTitle;
_declineTitle = declineTitle;
}
public string Title
{
get => _title;
}
public string Message
{
get => _message;
}
public string ConfirmTitle
{
get => _confirmTitle;
}
public string DeclineTitle
{
get => _declineTitle;
}
public void Confirm()
{
DialogHost.Close("DialogHost", true);
}
public void Decline()
{
DialogHost.Close("DialogHost", false);
}
}
@@ -15,10 +15,10 @@ using MigraDoc.Rendering;
using PdfSharp.Fonts; using PdfSharp.Fonts;
using PdfSharp.Pdf.IO; using PdfSharp.Pdf.IO;
using PdfSharp.Snippets.Font; using PdfSharp.Snippets.Font;
using ReceiptPDFBuilder.Interfaces; using MayShow.Interfaces;
using ReceiptPDFBuilder.Models; using MayShow.Models;
namespace ReceiptPDFBuilder.ViewModels; namespace MayShow.ViewModels;
class EditFileViewModel : BaseViewModel class EditFileViewModel : BaseViewModel
{ {
+920
View File
@@ -0,0 +1,920 @@
#nullable enable
using System;
using System.Collections.ObjectModel;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text.Json;
using System.Threading.Tasks;
using Avalonia.Platform.Storage;
using Avalonia.Themes.Fluent;
using DialogHostAvalonia;
using ImageMagick;
using MigraDoc.DocumentObjectModel;
using MigraDoc.Rendering;
using PdfSharp.Fonts;
using PdfSharp.Pdf.IO;
using PdfSharp.Snippets.Font;
using MayShow.Helpers;
using MayShow.Interfaces;
using MayShow.Models;
using MayShows.Helpers;
using Docnet.Core.Models;
using Docnet.Core;
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing;
using System.Reflection.Metadata.Ecma335;
using Docnet.Core.Readers;
namespace MayShow.ViewModels;
class MainViewModel : BaseViewModel, IFontResolver, ICanCheckShutdown
{
private bool _isPerformingInitialLoad;
private string _processDir;
private bool _isCreatingPDF;
private string _programLog;
private string _workingFolder;
private string _reportTitle;
private ObservableCollection<ReportFile> _reportFiles;
private DateTime? _lastGeneratedTime;
private Settings _settings;
private bool _hasUnsavedWork;
public MainViewModel(IChangeViewModel viewModelChanger) : base(viewModelChanger)
{
_isPerformingInitialLoad = true;
_processDir = Path.GetDirectoryName(Environment.ProcessPath) ?? "";
Console.WriteLine("Internal storage directory is: {0}", Utilities.GetInternalDataPath());
_isCreatingPDF = false;
var quotes = Constants.GetQuotes();
Random random = new Random();
var quoteIndex = random.Next(0, quotes.Length);
_programLog = "----- MayShow v" + Constants.AppVersion + " ------" + Environment.NewLine;
_programLog += quotes[quoteIndex] + Environment.NewLine;
_programLog += "---------------------------------------" + Environment.NewLine;
_programLog += "Loaded and ready to create report!" + Environment.NewLine;
_programLog += "Please copy and send this Program Log when reporting any issues with the software.";
_workingFolder = "";
ReportFiles = _reportFiles = new ObservableCollection<ReportFile>();
_reportTitle = "";
_lastGeneratedTime = null;
_settings = Settings.LoadSettings();
if (!string.IsNullOrWhiteSpace(_settings.LastUsedPath))
{
LogInfo("Loading data at last used path of {0}", _settings.LastUsedPath);
ScanFolder(_settings.LastUsedPath);
}
else
{
LogInfo("Choose a receipt folder to begin...");
}
HasUnsavedWork = false;
_isPerformingInitialLoad = false;
}
public string ReportTitle
{
get => _reportTitle;
set
{
_reportTitle = value;
NotifyPropertyChanged();
NotifyPropertyChanged(nameof(IsTitleBoxVisible));
NotifyPropertyChanged(nameof(CanAddItem));
}
}
public bool IsTitleBoxVisible
{
get => !string.IsNullOrWhiteSpace(WorkingFolder);
}
public bool CanAddItem
{
get => IsTitleBoxVisible && !IsCreatingPDF;
}
public bool IsCreatingPDF
{
get => _isCreatingPDF;
set
{
_isCreatingPDF = value;
NotifyPropertyChanged();
NotifyPropertyChanged(nameof(IsCreatePDFButtonEnabled));
NotifyPropertyChanged(nameof(HasWorkingFolderAndNotMakingPDF));
NotifyPropertyChanged(nameof(CanAddItem));
}
}
public bool IsCreatePDFButtonEnabled
{
get => !_isCreatingPDF && _reportFiles.Count > 0;
}
public bool HasWorkingFolder
{
get => !string.IsNullOrWhiteSpace(WorkingFolder) && Directory.Exists(WorkingFolder);
}
public bool HasWorkingFolderAndNotMakingPDF
{
get => !string.IsNullOrWhiteSpace(WorkingFolder) && Directory.Exists(WorkingFolder) && !_isCreatingPDF;
}
public string WorkingFolder
{
get => _workingFolder;
set
{
_workingFolder = value;
NotifyPropertyChanged();
NotifyPropertyChanged(nameof(HasWorkingFolder));
NotifyPropertyChanged(nameof(HasWorkingFolderAndNotMakingPDF));
}
}
public string ProgramLog
{
get => _programLog;
set { _programLog = value; NotifyPropertyChanged(); }
}
public bool HasUnsavedWork
{
get => _hasUnsavedWork;
set
{
_hasUnsavedWork = value;
NotifyPropertyChanged();
}
}
public ObservableCollection<ReportFile> ReportFiles
{
get => _reportFiles;
set
{
_reportFiles = value;
NotifyPropertyChanged();
_reportFiles.CollectionChanged += ( sender, e ) =>
{
NotifyPropertyChanged(nameof(IsCreatePDFButtonEnabled));
HasUnsavedWork = true;
};
}
}
private void LogInfo(string message, params object[]? arguments)
{
var timestamp = string.Format("[{0:s}]", DateTime.Now);
Console.WriteLine(timestamp + " " + message, arguments);
ProgramLog += Environment.NewLine + string.Format(message, arguments ?? []);
}
public async void ChooseFolder()
{
var topLevel = TopLevelGrabber?.GetTopLevel();
if (topLevel is not null)
{
var folders = await topLevel.StorageProvider.OpenFolderPickerAsync(new FolderPickerOpenOptions()
{
Title = "Pick a folder of files...",
AllowMultiple = false,
});
if (folders.Count == 1)
{
var folder = folders[0];
LogInfo("Clearing existing list and loading items in folder: " + folder.Path.LocalPath);
ReportFiles.Clear();
ScanFolder(folder.Path.LocalPath);
_settings.LastUsedPath = folder.Path.LocalPath;
await _settings.SaveSettingsAsync();
ResortPDFItemsByDate();
HasUnsavedWork = true;
}
}
}
private string GetReportSavedDataPath(string folderPath)
{
if (_settings.SaveReportJsonDataInInternalDir)
{
var internalPath = Utilities.GetInternalDataPath();
if (!_settings.WorkingFolderToInternalFolderName.ContainsKey(folderPath))
{
var uuid = "";
var potentialPath = "";
var isDone = false;
// make sure uuid not already used...just in case...because paranoia...
do
{
uuid = Guid.NewGuid().ToString();
potentialPath = Path.Combine(internalPath, uuid);
isDone = !Directory.Exists(potentialPath);
} while (!isDone);
// make internal dir -- using dir so we have option to copy data into dir later if needed
// (if we ever implement a more robust report system where we keep all files)
Directory.CreateDirectory(potentialPath);
_settings.WorkingFolderToInternalFolderName[folderPath] = uuid;
_settings.SaveSettingsNotAsync(); // save new key/value pair
}
return Path.Combine(
internalPath,
_settings.WorkingFolderToInternalFolderName[folderPath],
Constants.ReportSavedDataFileName
);
}
else
{
return Path.Combine(folderPath, Constants.ReportSavedDataFileName);
}
}
private void ScanFolder(string path)
{
if (Directory.Exists(path))
{
WorkingFolder = path;
NotifyPropertyChanged(nameof(IsTitleBoxVisible));
NotifyPropertyChanged(nameof(CanAddItem));
var reportFilePath = GetReportSavedDataPath(path);
var successfullyLoadedPriorReport = false;
if (File.Exists(reportFilePath))
{
// load prior report
var json = File.ReadAllText(reportFilePath);
var jsonContext = new SourceGenerationContext(Utilities.GetSerializerOptions());
var report = JsonSerializer.Deserialize<PDFReport>(json, jsonContext.PDFReport);
if (report != null && report.Files.Count > 0)
{
Console.WriteLine("Loading prior report data at {0}", reportFilePath);
ReportFiles = new ObservableCollection<ReportFile>(report.Files);
ReportTitle = report.Title;
WorkingFolder = report.BaseFolder;
_lastGeneratedTime = report.LastGenerated ?? null;
LogInfo("Reloaded report last saved at {0}", report.LastSaved);
successfullyLoadedPriorReport = true;
}
}
if (!successfullyLoadedPriorReport)
{
// Scan folder for files and display in DataGrid
ReportFiles.Clear();
ReportTitle = "";
var filePaths = Directory.GetFiles(WorkingFolder);
foreach (var filePath in filePaths)
{
AddFileBasedOnPath(filePath);
}
ResortPDFItemsByDate();
HasUnsavedWork = true;
}
}
else
{
LogInfo("Error: The directory {0} does not exist. Please select another folder.", path);
}
NotifyPropertyChanged(nameof(IsCreatePDFButtonEnabled));
}
public void ShowAbout()
{
DialogHost.Show(new AboutViewModel());
}
public async Task ShowSettings()
{
var updatedSettings = await DialogHost.Show(new SettingsViewModel(_settings, TopLevelGrabber));
if (updatedSettings != null)
{
_settings = (Settings)updatedSettings;
await _settings.SaveSettingsAsync();
LogInfo("Saved updated settings!");
}
}
public void RemoveFile(object f) => RemoveFileImpl((ReportFile)f);
public async void RemoveFileImpl(ReportFile file)
{
var result = await DialogHost.Show(new WarningDeleteItemViewModel(file));
if (result != null && (bool)result)
{
var idx = ReportFiles.IndexOf(file);
if (idx != -1)
{
ReportFiles.RemoveAt(idx);
HasUnsavedWork = true;
}
}
}
// https://github.com/AvaloniaUI/Avalonia/issues/10075
public void EditFileProperties(object f) => EditFilePropertiesImpl((ReportFile)f);
public async void EditFilePropertiesImpl(ReportFile file)
{
var result = await DialogHost.Show(new EditFileViewModel(file, ViewModelChanger));
if (result != null && result is ReportFile updatedData)
{
file.Title = updatedData.Title;
file.ReceiptDateTime = updatedData.ReceiptDateTime;
file.Notes = updatedData.Notes;
HasUnsavedWork = true;
}
}
public async void AddItem()
{
var topLevel = TopLevelGrabber?.GetTopLevel();
if (topLevel is not null)
{
var files = await topLevel.StorageProvider.OpenFilePickerAsync(new FilePickerOpenOptions()
{
Title = "Choose image or PDF files...",
AllowMultiple = true,
FileTypeFilter = [
new FilePickerFileType("All Types")
{
Patterns = Constants.AllowedFileExtensionPatterns,
AppleUniformTypeIdentifiers = [ "public.image", "com.adobe.pdf", "public.heic" ],
MimeTypes = [ "image/*", "application/pdf", "image/heic" ]
},
FilePickerFileTypes.ImageAll,
new FilePickerFileType("HEIC Images")
{
Patterns = [ "*.heic" ],
AppleUniformTypeIdentifiers = [ "public.heic" ],
MimeTypes = [ "image/heic" ]
},
FilePickerFileTypes.Pdf,
],
});
if (files.Count > 0)
{
foreach (var file in files)
{
var filePath = file.TryGetLocalPath();
AddFileBasedOnPath(filePath);
}
}
}
}
private void AddFileBasedOnPath(string? filePath)
{
if (!string.IsNullOrWhiteSpace(filePath) && File.Exists(filePath) && !filePath.EndsWith(".DS_Store"))
{
// make sure extensions are OK
var fileExtensions = Constants.AllowedFileExtensionsNoStar;
var didMatch = false;
foreach (var fileExtension in fileExtensions)
{
if (filePath.ToLower().EndsWith("." + fileExtension.ToLower()))
{
didMatch = true;
break;
}
}
if (!didMatch)
{
if (!filePath.EndsWith(Constants.ReportSavedDataFileName))
{
LogInfo("File {0} did not match allowed file extension types, so it was not added.", filePath);
}
}
else
{
var date = Utilities.CheckValidDateInString(filePath);
ReportFiles.Add(new ReportFile()
{
Title = Path.GetFileName(filePath),
ReceiptDateTime = date.HasValue ? date.Value.ToDateTime(TimeOnly.MinValue) : File.GetCreationTime(filePath),
Notes = "",
FilePath = filePath,
});
HasUnsavedWork = true;
}
}
}
public async void RemoveAllItems()
{
var result = await DialogHost.Show(new ConfirmViewModel("Warning!", "Are you sure you want to remove all items from this report?", "Remove All Items", "Cancel"));
if (result != null && (bool)result)
{
ReportFiles.Clear();
HasUnsavedWork = true;
NotifyPropertyChanged(nameof(IsCreatePDFButtonEnabled));
}
}
public void LocateFile(object f) => LocateFileImpl((ReportFile) f);
public async void LocateFileImpl(ReportFile reportFile)
{
var topLevel = TopLevelGrabber?.GetTopLevel();
if (topLevel is not null)
{
var files = await topLevel.StorageProvider.OpenFilePickerAsync(new FilePickerOpenOptions()
{
Title = "Choose image or PDF file...",
AllowMultiple = false,
FileTypeFilter = [
new FilePickerFileType("All Types")
{
Patterns = Constants.AllowedFileExtensionPatterns,
AppleUniformTypeIdentifiers = [ "public.image", "com.adobe.pdf", "public.heic" ],
MimeTypes = [ "image/*", "application/pdf", "image/heic" ]
},
FilePickerFileTypes.ImageAll,
new FilePickerFileType("HEIC Images")
{
Patterns = [ "*.heic" ],
AppleUniformTypeIdentifiers = [ "public.heic" ],
MimeTypes = [ "image/heic" ]
},
FilePickerFileTypes.Pdf,
],
});
if (files.Count > 0)
{
var file = files[0];
reportFile.FilePath = file.Path.LocalPath;
HasUnsavedWork = true;
}
}
}
// https://github.com/AvaloniaUI/Avalonia/issues/10075
public void OpenFile(object f) => OpenFileImpl((ReportFile)f);
public void OpenFileImpl(ReportFile file)
{
var topLevel = TopLevelGrabber?.GetTopLevel();
if (topLevel is not null)
{
var launcher = topLevel.Launcher;
launcher.LaunchUriAsync(new Uri(file.FilePath));
}
}
public void OpenFileLocation(object f) => OpenFileLocationImpl((ReportFile)f);
private void OpenFileLocationImpl(ReportFile file)
{
OpenFolderForFileInFileViewer(file.FilePath);
}
private void OpenFolderForFileInFileViewer(string fullPathToFile)
{
var topLevel = TopLevelGrabber?.GetTopLevel();
var dirName = Path.GetDirectoryName(fullPathToFile);
if (topLevel is not null && dirName != null)
{
var launcher = topLevel.Launcher;
launcher.LaunchUriAsync(new Uri(dirName));
}
}
public void ResortPDFItemsByDate()
{
LogInfo("Sorting report files list...");
ReportFiles = new ObservableCollection<ReportFile>(ReportFiles.OrderBy(x => x.ReceiptDateTime));
HasUnsavedWork = true;
}
public async void BuildPDF()
{
if (string.IsNullOrWhiteSpace(ReportTitle))
{
await DialogHost.Show(new WarningViewModel("You must provide a report title!"));
}
else
{
try
{
await Task.Run(() => CreatePDF(WorkingFolder));
} catch (Exception e)
{
LogInfo("PDF process failed! Reason: " + e.Message);
if (e.StackTrace != null)
{
LogInfo(e.StackTrace);
}
if (e.InnerException != null)
{
LogInfo("Inner exception: " + e.InnerException.Message);
if (e.InnerException.StackTrace != null)
{
LogInfo(e.InnerException.StackTrace);
}
}
LogInfo("Please report this error to a programmer or fix the issue listed above.");
IsCreatingPDF = false;
}
}
}
public async Task SaveInterimReportInfo()
{
var report = new PDFReport()
{
Title = ReportTitle,
Files = ReportFiles.ToList(),
BaseFolder = WorkingFolder,
LastSaved = DateTime.Now,
LastGenerated = _lastGeneratedTime,
};
await SavePDFReportDataToDisk(report);
}
private async Task SavePDFReportDataToDisk(PDFReport report)
{
var jsonContext = new SourceGenerationContext(Utilities.GetSerializerOptions());
using var memoryStream = new MemoryStream();
await JsonSerializer.SerializeAsync(memoryStream, report, jsonContext.PDFReport);
memoryStream.Position = 0;
using var reader = new StreamReader(memoryStream);
var json = await reader.ReadToEndAsync();
var savePath = GetReportSavedDataPath(WorkingFolder);
await File.WriteAllTextAsync(savePath, json);
LogInfo("Saved report information to {0}", savePath);
HasUnsavedWork = false;
}
private async Task CreateAndSaveReportObjectAfterReportCreation()
{
var report = new PDFReport()
{
Title = ReportTitle,
Files = ReportFiles.ToList(),
BaseFolder = WorkingFolder,
LastSaved = DateTime.Now,
LastGenerated = DateTime.Now,
};
_lastGeneratedTime = DateTime.Now;
await SavePDFReportDataToDisk(report);
}
public async Task CopyLogToClipboard()
{
var clipboard = TopLevelGrabber?.GetTopLevel().Clipboard;
if (clipboard != null)
{
await clipboard.SetTextAsync(ProgramLog);
LogInfo("Program log has been copied to the clipboard!");
}
}
public byte[]? GetFont(string faceName)
{
LogInfo(string.Format("Loading font {0}", faceName));
if (faceName == "Noto Sans JP")
{
var path = Path.Combine(_processDir, "Assets/Fonts/Noto_Sans_JP/static/NotoSansJP-Regular.ttf");
if (!File.Exists(path))
{
path = Path.Combine(_processDir, "../Resources/Assets/Fonts/Noto_Sans_JP/static/NotoSansJP-Regular.ttf");
}
return File.ReadAllBytes(path);
}
if (faceName == "Noto Sans JP Bold")
{
var path = Path.Combine(_processDir, "Assets/Fonts/Noto_Sans_JP/static/NotoSansJP-SemiBold.ttf");
if (!File.Exists(path))
{
path = Path.Combine(_processDir, "../Resources/Assets/Fonts/Noto_Sans_JP/static/NotoSansJP-SemiBold.ttf");
}
return File.ReadAllBytes(path);
}
return null;
}
public FontResolverInfo? ResolveTypeface(string familyName, bool bold, bool italic)
{
// LogInfo(string.Format("Resolving font name {0}", familyName));
if (familyName == "Noto Sans JP")
{
if (bold)
{
return new FontResolverInfo(familyName + " Bold");
}
return new FontResolverInfo(familyName);
}
return null;
}
// https://forum.pdfsharp.net/viewtopic.php?f=2&t=1025
private async Task CreatePDF(string folderPath)
{
// TODO: calculate needed width for images based on page width and margins and all that?
// TODO: resize (non-HEIC) images for smaller size...?
// safety checks
var outputDir = _settings.SaveOutputPdfInWorkingDir ? folderPath : _settings.OutputPdfDir;
if (!Directory.Exists(outputDir))
{
await DialogHost.Show(new WarningViewModel("Output directory not found! Please adjust your application Settings before continuing. Output directory: " + outputDir));
return;
}
// start making PDF!
IsCreatingPDF = true;
var pdfDoc = new Document();
var outputFileName = ReportTitle + ".pdf";
var folderName = new DirectoryInfo(folderPath).Name;
const int imageWidth = 425;
if (folderName.Contains('-'))
{
// see if year/month format
var parts = folderName.Split('-');
if (parts[0].Length == 4 &&
parts[1].Length <= 2 &&
int.TryParse(parts[0], out int year) && int.TryParse(parts[1], out int month))
{
outputFileName = string.Format("{0} {1} Receipts.pdf",
CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(month),
year);
LogInfo("Auto-changed output file name to " + outputFileName);
}
}
var section = pdfDoc.AddSection();
section.PageSetup.PageFormat = PageFormat.Letter;
section.PageSetup.PageWidth = "8.5in";
section.PageSetup.PageHeight = "11in";
section.PageSetup.TopMargin = "0.5in";
section.PageSetup.RightMargin = "0.5in";
section.PageSetup.BottomMargin = "0.5in";
section.PageSetup.LeftMargin = "0.5in";
// setup footer for page number
var footerPar = new Paragraph();
footerPar.Format.Alignment = ParagraphAlignment.Center;
footerPar.Format.Font.Size = 10;
footerPar.AddText("--Page ");
footerPar.AddPageField();
footerPar.AddText(" of ");
footerPar.AddNumPagesField();
footerPar.AddText("--");
footerPar.AddLineBreak();
footerPar.AddText("Report generated on " + DateTime.Now.ToString("f"));
section.Footers.Primary.Add(footerPar);
// add report title
var reportTitlePar = section.AddParagraph();
reportTitlePar.Format.Alignment = ParagraphAlignment.Center;
reportTitlePar.Format.Font.Size = 16;
reportTitlePar.Format.Font.Bold = true;
reportTitlePar.Format.Font.Name = "Noto Sans JP"; // has english letters in it, too
reportTitlePar.AddText(ReportTitle);
// get converted files directory path and create it if necessary
var convertedDir = Path.Combine(Utilities.GetInternalDataPath(), "converted");
if (!Directory.Exists(convertedDir))
{
Directory.CreateDirectory(convertedDir);
}
//
GlobalFontSettings.FontResolver = this;
GlobalFontSettings.FallbackFontResolver = new FailsafeFontResolver();
var hasAddedData = false;
for (var i = 0; i < ReportFiles.Count; i++)
{
var file = ReportFiles[i];
var fileName = file.FileName;
var filePath = file.FilePath;
if (!File.Exists(filePath))
{
LogInfo("ERROR: File \"{0}\" does not exist at path \"{1}\". Please remove it from the report or re-add it using the Add Item button if you still want it to be in this report.", file.Title, file.FilePath);
IsCreatingPDF = false;
return;
}
if (fileName == ".DS_Store" || fileName == outputFileName)
{
continue;
}
if (i > 0 && hasAddedData)
{
section.AddPageBreak();
}
var imageTitlePar = section.AddParagraph();
imageTitlePar.Format.Alignment = ParagraphAlignment.Center;
imageTitlePar.Format.Font.Size = 12;
imageTitlePar.Format.Font.Bold = true;
imageTitlePar.Format.Font.Name = "Noto Sans JP"; // has english letters in it, too
imageTitlePar.AddText(string.IsNullOrWhiteSpace(file.Title) ? file.FileName : file.Title);
var receiptDatePar = section.AddParagraph();
receiptDatePar.Format.Alignment = ParagraphAlignment.Center;
receiptDatePar.Format.Font.Size = 12;
receiptDatePar.Format.Font.Bold = true;
receiptDatePar.Format.Font.Name = "Noto Sans JP"; // has english letters in it, too
receiptDatePar.AddText(file.ReceiptDate.ToString("yyyy-MM-dd"));
if (!string.IsNullOrWhiteSpace(file.Notes))
{
var imageNotesPar = section.AddParagraph();
imageNotesPar.Format.Alignment = ParagraphAlignment.Center;
imageNotesPar.Format.Font.Size = 10;
imageNotesPar.Format.Font.Bold = false;
imageNotesPar.Format.Font.Name = "Noto Sans JP";
imageNotesPar.AddText(file.Notes);
}
section.AddParagraph(); // add empty line for spacing
// now add the image
var lowerName = fileName.ToLower();
var isPDF = lowerName.EndsWith(".pdf");
// convert heic, webp, or png to JPEG for size and ease of use
// (and probably compat reasons too, though I haven't tested that...)
var isHEIC = lowerName.EndsWith(".heic");
var isWebp = lowerName.EndsWith(".webp");
var isPNG = lowerName.EndsWith(".png");
var info = new FileInfo(file.FilePath);
uint loadedImageWidth = 0;
uint loadedImageHeight = 0;
if (!isPDF)
{
using var mImage = new MagickImage(info.FullName);
loadedImageWidth = mImage.Width;
loadedImageHeight = mImage.Height;
var convertedOutputPath = Path.Combine(convertedDir, info.Name + ".jpg");
var didAdjust = false;
LogInfo("Image orientation of {0} is {1}", fileName, mImage.Orientation);
if (mImage.Orientation != OrientationType.TopLeft)
{
LogInfo("Auto-adjusted image orientation of {0}", fileName);
mImage.AutoOrient();
didAdjust = true;
}
// perform needed image manipulations
if (isHEIC || isWebp || isPNG || (!isPDF && info.Length > _settings.ImageResizeThreshold * 1024 * 1024))
{
// Save image as jpg
mImage.Quality = 80;
if (mImage.Width >= 400 || mImage.Height >= 400)
{
loadedImageWidth = (uint)Math.Floor(mImage.Width * 0.5);
loadedImageHeight = (uint)Math.Floor(mImage.Height * 0.5);
mImage.Scale(loadedImageWidth, loadedImageHeight);
LogInfo("Image {2} scaled to {0}x{1}", loadedImageWidth, loadedImageHeight, fileName);
}
didAdjust = true;
LogInfo("Converted image {0} to JPEG", fileName);
}
else
{
// load height/width
loadedImageWidth = mImage.Width;
loadedImageHeight = mImage.Height;
}
if (didAdjust)
{
await mImage.WriteAsync(convertedOutputPath);
filePath = convertedOutputPath;
LogInfo(string.Format("Saved adjusted image to JPEG; file path is now {0}", filePath));
}
// write to PDF
var paragraph = section.AddParagraph();
paragraph.Format.Alignment = ParagraphAlignment.Center;
var image = paragraph.AddImage(filePath);
image.LockAspectRatio = true;
if (!isPDF && loadedImageHeight > 600)
{
image.Height = 550; // make sure it will fit on one page
}
else
{
image.Width = imageWidth; // can't be too wide now...not sure why...maybe due to margins...
}
}
else
{
// need to render PDF to images
if (_settings.UseDocnetPDFImageRendering)
{
// render using Docnet library (which utilizes pdfium, the chrome renderer)
string RenderPdfPageToImage(IDocReader docReader, int pgNum)
{
Console.WriteLine("Rendering pg " + pgNum);
using var pageReader = docReader.GetPageReader(pgNum);
Console.WriteLine("Getting image for page " + pgNum);
var rawBytes = pageReader.GetImage(RenderFlags.RenderAnnotations);
Console.WriteLine("Getting width & height for page " + pgNum);
var width = pageReader.GetPageWidth();
var height = pageReader.GetPageHeight();
Console.WriteLine("Loading pixel data for page " + pgNum);
using var img = Image.LoadPixelData<Bgra32>(rawBytes, width, height);
// you are likely going to want this as well otherwise you might end up with transparent parts.
img.Mutate(x => x.BackgroundColor(SixLabors.ImageSharp.Color.White));
var pdfPageImageOutputPath = Path.Combine(convertedDir, info.Name + "-Page-"
+ (pgNum + 1).ToString().PadLeft(3, '0') + ".jpg");
img.Save(pdfPageImageOutputPath);
Console.WriteLine("Done rendering pg " + pgNum);
return pdfPageImageOutputPath;
}
// render all pages to images
var docReader = DocLib.Instance.GetDocReader(
filePath,
new PageDimensions(1080, 1920)); // TODO: are these dims right?
// add to document
var pgCount = docReader.GetPageCount();
if (pgCount > 0)
{
var convertedPdfImagePath = RenderPdfPageToImage(docReader, 0);
imageTitlePar.AddText(string.Format(" (PDF with {0} page{1}) ",
pgCount,
pgCount == 1 ? "" : "s"));
var paragraph = section.AddParagraph();
paragraph.Format.Alignment = ParagraphAlignment.Center;
var image = paragraph.AddImage(convertedPdfImagePath);
image.Width = imageWidth;
image.LockAspectRatio = true;
for (var j = 1; j < pgCount; j++)
{
section.AddPageBreak();
paragraph = section.AddParagraph();
paragraph.Format.Alignment = ParagraphAlignment.Center;
convertedPdfImagePath = RenderPdfPageToImage(docReader, j);
image = paragraph.AddImage(convertedPdfImagePath);
image.LockAspectRatio = true;
image.Width = imageWidth;
}
}
}
else
{
// render first page (eventually need to improve code to just do everything in a loop)
var paragraph = section.AddParagraph();
paragraph.Format.Alignment = ParagraphAlignment.Center;
var image = paragraph.AddImage(filePath);
image.LockAspectRatio = true;
image.Width = imageWidth; // can't be too wide now...not sure why...maybe due to margins...
// render other PDF pages, if any
// see: https://stackoverflow.com/a/65091204/3938401
var pdfFileToAdd = PdfReader.Open(filePath, PdfDocumentOpenMode.Import);
var pgCount = pdfFileToAdd.PageCount;
imageTitlePar.AddText(string.Format(" (PDF with {0} page{1}) ",
pgCount,
pgCount == 1 ? "" : "s"));
for (var j = 2; j <= pgCount; j++)
{
section.AddPageBreak();
paragraph = section.AddParagraph();
paragraph.Format.Alignment = ParagraphAlignment.Center;
image = paragraph.AddImage(filePath + "#" + j);
image.LockAspectRatio = true;
image.Width = imageWidth;
}
}
}
LogInfo(string.Format("Added image: {0} ({1})", file.Title, filePath));
hasAddedData = true;
}
var pdfRenderer = new PdfDocumentRenderer
{
Document = pdfDoc,
WorkingDirectory = folderPath
};
LogInfo("Rendering document to PDF file...");
pdfRenderer.RenderDocument();
string outputPDFFilePath = Path.Join(outputDir, outputFileName);
LogInfo("Saving PDF document to disk...");
pdfRenderer.PdfDocument.Save(outputPDFFilePath);
LogInfo("Finished saving PDF output to: " + outputPDFFilePath);
await CreateAndSaveReportObjectAfterReportCreation();
// clean up data dir
Directory.Delete(convertedDir, true);
// show output folder to user
OpenFolderForFileInFileViewer(outputPDFFilePath);
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;
}
}
@@ -1,10 +1,10 @@
using ReceiptPDFBuilder.Helpers; using MayShow.Helpers;
using ReceiptPDFBuilder.Interfaces; using MayShow.Interfaces;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
namespace ReceiptPDFBuilder.ViewModels namespace MayShow.ViewModels
{ {
class MainWindowViewModel : ChangeNotifier, IChangeViewModel class MainWindowViewModel : ChangeNotifier, IChangeViewModel
{ {
+146
View File
@@ -0,0 +1,146 @@
#nullable enable
using System;
using System.Collections.ObjectModel;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Avalonia.Platform.Storage;
using Avalonia.Themes.Fluent;
using DialogHostAvalonia;
using ImageMagick;
using MigraDoc.DocumentObjectModel;
using MigraDoc.Rendering;
using PdfSharp.Fonts;
using PdfSharp.Pdf.IO;
using PdfSharp.Snippets.Font;
using MayShow.Interfaces;
using MayShow.Models;
using MayShow.Helpers;
namespace MayShow.ViewModels;
class SettingsViewModel: ChangeNotifier
{
private Settings _previousSettings;
private Settings _settings;
private string _errorMessage;
private ITopLevelGrabber? _topLevelGrabber;
public SettingsViewModel(Settings settingsToEdit, ITopLevelGrabber? topLevelGrabber)
{
_previousSettings = settingsToEdit;
_settings = new Settings(settingsToEdit); // clone it
_errorMessage = "";
_topLevelGrabber = topLevelGrabber;
}
public bool UseDocnetPDFImageRendering
{
get => _settings.UseDocnetPDFImageRendering;
set
{
_settings.UseDocnetPDFImageRendering = value;
NotifyPropertyChanged();
}
}
public bool SaveOutputPdfInWorkingDir
{
get => _settings.SaveOutputPdfInWorkingDir;
set
{
_settings.SaveOutputPdfInWorkingDir = value;
NotifyPropertyChanged();
}
}
public string OutputPdfDirPath
{
get => _settings.OutputPdfDir;
set
{
_settings.OutputPdfDir = value;
NotifyPropertyChanged();
NotifyPropertyChanged(nameof(IsOutputPdfDirValid));
}
}
public bool IsOutputPdfDirValid
{
get => SaveOutputPdfInWorkingDir || (!SaveOutputPdfInWorkingDir && Directory.Exists(OutputPdfDirPath));
}
public bool HasErrorMessage
{
get => !string.IsNullOrWhiteSpace(_errorMessage);
}
public string ErrorMessage
{
get => _errorMessage;
set
{
_errorMessage = value;
NotifyPropertyChanged();
NotifyPropertyChanged(nameof(HasErrorMessage));
}
}
public decimal ImageResizeThreshold
{
get => _settings.ImageResizeThreshold;
set
{
_settings.ImageResizeThreshold = value;
NotifyPropertyChanged();
}
}
public bool SaveReportJsonDataInInternalDir
{
get => _settings.SaveReportJsonDataInInternalDir;
set
{
_settings.SaveReportJsonDataInInternalDir = value;
NotifyPropertyChanged();
}
}
public async void ChooseOutputFolder()
{
var topLevel = _topLevelGrabber?.GetTopLevel();
if (topLevel != null)
{
var folders = await topLevel.StorageProvider.OpenFolderPickerAsync(new FolderPickerOpenOptions()
{
Title = "Choose where to save your report file...",
AllowMultiple = false,
});
if (folders.Count == 1)
{
var folder = folders[0];
OutputPdfDirPath = folder.Path.LocalPath;
}
}
}
public void Cancel()
{
DialogHost.Close("DialogHost", null);
}
public void Save()
{
if (!IsOutputPdfDirValid)
{
ErrorMessage = "Output directory cannot be found!";
}
else
{
ErrorMessage = "";
DialogHost.Close("DialogHost", _settings);
}
}
}
+29
View File
@@ -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);
}
}
@@ -1,14 +1,14 @@
using DialogHostAvalonia; using DialogHostAvalonia;
using ReceiptPDFBuilder.Helpers; using MayShow.Helpers;
using ReceiptPDFBuilder.Models; using MayShow.Models;
namespace ReceiptPDFBuilder.ViewModels namespace MayShow.ViewModels
{ {
class WarningDeleteItemModel : ChangeNotifier class WarningDeleteItemViewModel : ChangeNotifier
{ {
ReportFile _file; ReportFile _file;
public WarningDeleteItemModel(ReportFile file) public WarningDeleteItemViewModel(ReportFile file)
{ {
_file = file; _file = file;
} }
@@ -2,7 +2,7 @@
using DialogHostAvalonia; using DialogHostAvalonia;
namespace ReceiptPDFBuilder.ViewModels; namespace MayShow.ViewModels;
class WarningViewModel class WarningViewModel
{ {
+48
View File
@@ -0,0 +1,48 @@
<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.AboutView"
xmlns:models="clr-namespace:MayShow.Models"
xmlns:vm="clr-namespace:MayShow.ViewModels"
xmlns:dialogHost="clr-namespace:DialogHostAvalonia;assembly=DialogHost.Avalonia"
x:DataType="vm:AboutViewModel"
MaxWidth="450">
<StackPanel Orientation="Vertical"
Spacing="4">
<TextBlock Text="MayShow 1.4.0"
HorizontalAlignment="Center"
TextWrapping="Wrap"
FontSize="18"
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!"
TextWrapping="Wrap"
FontSize="14"/>
<TextBlock Text="App icon made using https://gauger.me/fonticon/ with FontAwesome icon 'file-invoice-dollar' and the macOS software Icon Composer."
TextWrapping="Wrap"
FontSize="14"/>
<Label Content="Open Source Licenses:"/>
<ScrollViewer Margin="2"
Grid.Row="4"
x:Name="LogScrollView"
VerticalScrollBarVisibility="Visible"
AllowAutoHide="False"
MaxHeight="250">
<SelectableTextBlock Margin="2"
TextWrapping="Wrap"
FontSize="10"
x:Name="LicenseTextBlock"/>
</ScrollViewer>
<TextBlock Text="Copyright 2026 - Quickity Quack Productions"
TextWrapping="Wrap"
HorizontalAlignment="Center"
Margin="0,4,0,4"
FontSize="12"/>
<Button Command="{Binding Close}"
Classes="accent"
Content="Close"
HorizontalAlignment="Right"
Margin="0,0,4,4"/>
</StackPanel>
</UserControl>
+39
View File
@@ -0,0 +1,39 @@
using System;
using System.Diagnostics;
using System.IO;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
namespace MayShow.Views
{
public partial class AboutView : UserControl
{
public AboutView()
{
this.InitializeComponent();
// set license text
var processDir = Path.GetDirectoryName(Environment.ProcessPath) ?? "";
var licenseFileName = Path.Combine(processDir, "Assets", "LICENSES.txt");
var licenseText = "";
if (File.Exists(licenseFileName))
{
licenseText = File.ReadAllText(licenseFileName);
}
else
{
licenseFileName = Path.Combine(processDir, "../Resources/Assets/LICENSES.txt");
if (File.Exists(licenseFileName))
{
licenseText = File.ReadAllText(licenseFileName);
}
else
{
licenseText = "Error: Unable to find license file!";
}
}
LicenseTextBlock.Text = licenseText.Trim();
}
}
}
+35
View File
@@ -0,0 +1,35 @@
<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.ConfirmView"
xmlns:models="clr-namespace:MayShow.Models"
xmlns:vm="clr-namespace:MayShow.ViewModels"
x:DataType="vm:ConfirmViewModel">
<StackPanel Orientation="Vertical"
Spacing="4">
<TextBlock TextAlignment="Center"
FontWeight="Bold"
FontSize="18"
Text="{Binding Title}"/>
<TextBlock TextAlignment="Center"
FontWeight="Bold"
TextWrapping="Wrap"
FontSize="14"
MaxWidth="350"
Text="{Binding Message}"/>
<StackPanel Orientation="Horizontal"
Spacing="12"
HorizontalAlignment="Right"
Margin="4">
<Button Command="{Binding Decline}"
Content="{Binding DeclineTitle}"
HorizontalAlignment="Right"/>
<Button Command="{Binding Confirm}"
Classes="accent"
Content="{Binding ConfirmTitle}"
HorizontalAlignment="Right"/>
</StackPanel>
</StackPanel>
</UserControl>
+14
View File
@@ -0,0 +1,14 @@
using System;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
namespace MayShow.Views;
public partial class ConfirmView : UserControl
{
public ConfirmView()
{
this.InitializeComponent();
}
}
@@ -5,11 +5,12 @@
mc:Ignorable="d" mc:Ignorable="d"
d:DesignWidth="800" d:DesignWidth="800"
d:DesignHeight="450" d:DesignHeight="450"
x:Class="ReceiptPDFBuilder.Views.EditFile" x:Class="MayShow.Views.EditFile"
xmlns:models="clr-namespace:ReceiptPDFBuilder.Models" xmlns:models="clr-namespace:MayShow.Models"
xmlns:vm="clr-namespace:ReceiptPDFBuilder.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"
@@ -3,7 +3,7 @@ using Avalonia;
using Avalonia.Controls; using Avalonia.Controls;
using Avalonia.Markup.Xaml; using Avalonia.Markup.Xaml;
namespace ReceiptPDFBuilder.Views namespace MayShow.Views
{ {
public partial class EditFile : UserControl public partial class EditFile : UserControl
{ {
+135 -42
View File
@@ -3,36 +3,61 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="ReceiptPDFBuilder.Views.MainView" x:Class="MayShow.Views.MainView"
xmlns:helpers="clr-namespace:ReceiptPDFBuilder.Helpers" xmlns:helpers="clr-namespace:MayShow.Helpers"
xmlns:models="clr-namespace:ReceiptPDFBuilder.Models" xmlns:models="clr-namespace:MayShow.Models"
xmlns:vm="clr-namespace:ReceiptPDFBuilder.ViewModels" xmlns:views="clr-namespace:MayShow.Views"
xmlns:vm="clr-namespace:MayShow.ViewModels"
xmlns:progRing="clr-namespace:AvaloniaProgressRing;assembly=AvaloniaProgressRing" xmlns:progRing="clr-namespace:AvaloniaProgressRing;assembly=AvaloniaProgressRing"
x:DataType="vm:MainViewModel"> x:DataType="vm:MainViewModel">
<Grid ColumnDefinitions="*" <Grid ColumnDefinitions="*"
RowDefinitions="Auto, 2*, Auto, Auto, *"> RowDefinitions="Auto, 2*, Auto, Auto, *">
<Button Command="{Binding ShowSettings}"
Grid.Row="0"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Margin="4,4,0,4">
<TextBlock><Run Text="&#xf013;" FontFamily="{StaticResource FontAwesomeSolid}"/> Settings</TextBlock>
</Button>
<Button Command="{Binding ShowAbout}" <Button Command="{Binding ShowAbout}"
Grid.Row="0" Grid.Row="0"
HorizontalAlignment="Right" HorizontalAlignment="Right"
VerticalAlignment="Top" VerticalAlignment="Top"
Margin="0,2,4,0"> Margin="0,4,4,4">
<TextBlock><Run Text="&#xf059;" FontFamily="{StaticResource FontAwesomeSolid}"/> About</TextBlock> <TextBlock><Run Text="&#xf059;" FontFamily="{StaticResource FontAwesomeSolid}"/> About</TextBlock>
</Button> </Button>
<StackPanel Orientation="Vertical" <StackPanel Orientation="Vertical"
Spacing="2"> Spacing="2"
<Label Content="Easy Receipt Folder -> PDF Builder" Margin="0,4,0,0">
<Label Content="MayShow: Report Builder"
FontSize="20" FontSize="20"
FontWeight="Bold" FontWeight="Bold"
HorizontalAlignment="Center"/> HorizontalAlignment="Center"/>
<Button Content="Choose Receipt Folder" <Grid ColumnDefinitions="Auto, *"
Command="{Binding ChooseFolder}" Margin="4,0,0,0">
IsEnabled="{Binding !IsCreatingPDF}" /> <Button Content="Choose Receipt Folder"
Command="{Binding ChooseFolder}"
IsEnabled="{Binding !IsCreatingPDF}"
Grid.Column="0" />
<TextBlock Text="{Binding WorkingFolder}"
VerticalAlignment="Center"
TextWrapping="NoWrap"
Margin="4,0,4,0"
TextTrimming="PrefixCharacterEllipsis"
Grid.Column="1"/>
</Grid>
<Label Content="Report Title" <Label Content="Report Title"
IsVisible="{Binding IsTitleBoxVisible}" /> IsVisible="{Binding IsTitleBoxVisible}" />
<TextBox Text="{Binding ReportTitle}" <TextBox Text="{Binding ReportTitle}"
IsVisible="{Binding IsTitleBoxVisible}" IsVisible="{Binding IsTitleBoxVisible}"
Watermark="Receipts December 2024" Watermark="Receipts December 2024"
Margin="2,0,2,4"/> Margin="2,0,2,4"
Classes="clearButton"
Name="TitleTextBox">
<TextBox.KeyBindings>
<KeyBinding Command="{Binding $parent[views:MainView].UnfocusTextbox}" Gesture="Enter" />
</TextBox.KeyBindings>
</TextBox>
</StackPanel> </StackPanel>
<DataGrid x:Name="FilesGrid" <DataGrid x:Name="FilesGrid"
Classes="DragAndDrop ItemsDragAndDrop" Classes="DragAndDrop ItemsDragAndDrop"
@@ -61,19 +86,60 @@
<Style Selector="TextBox"> <Style Selector="TextBox">
<Setter Property="TextWrapping" Value="NoWrap" /> <Setter Property="TextWrapping" Value="NoWrap" />
</Style> </Style>
<Style Selector="ToolTip">
<Setter Property="MaxWidth" Value="1000" />
</Style>
</DataGrid.Styles> </DataGrid.Styles>
<DataGrid.Columns> <DataGrid.Columns>
<DataGridTextColumn Header="Title" <DataGridTemplateColumn Header="Title"
Binding="{Binding Title}" IsReadOnly="False"
IsReadOnly="False" Width="*">
Width="*"/> <DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Grid ColumnDefinitions="Auto, *">
<Button Command="{Binding $parent[DataGrid].((vm:MainViewModel)DataContext).LocateFile}"
CommandParameter="{Binding}"
IsVisible="{Binding !IsFileFoundOnDisk}"
Margin="2"
Content="&#xf071;"
VerticalContentAlignment="Center"
Background="Transparent"
Grid.Column="0"
FontFamily="{StaticResource FontAwesomeSolid}"
ToolTip.Tip="File not found; click to locate..."
IsEnabled="{Binding !$parent[DataGrid].((vm:MainViewModel)DataContext).IsCreatingPDF}"/>
<TextBlock Text="{Binding Title}"
TextTrimming="CharacterEllipsis"
TextWrapping="NoWrap"
ToolTip.Tip="{Binding Title}"
Grid.Column="1"
Margin="8,0,4,0"
VerticalAlignment="Center"/>
</Grid>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
<DataGridTemplateColumn.CellEditingTemplate>
<DataTemplate DataType="models:ReportFile">
<TextBox Text="{Binding Title}"
Watermark="Title"
ToolTip.Tip="{Binding Title}"
Classes="clearButton">
<TextBox.KeyBindings>
<KeyBinding Command="{Binding $parent[views:MainView].UnfocusTextbox}" Gesture="Enter" />
</TextBox.KeyBindings>
</TextBox>
</DataTemplate>
</DataGridTemplateColumn.CellEditingTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Header="Receipt Date" <DataGridTemplateColumn Header="Receipt Date"
IsReadOnly="False" IsReadOnly="False"
Width="*"> Width="125">
<DataGridTemplateColumn.CellTemplate> <DataGridTemplateColumn.CellTemplate>
<DataTemplate> <DataTemplate>
<Label Content="{Binding ReceiptDate}" <Label Content="{Binding ReceiptDate}"
VerticalAlignment="Center"/> VerticalAlignment="Center"
Margin="8,0,8,0"
HorizontalAlignment="Left"/>
</DataTemplate> </DataTemplate>
</DataGridTemplateColumn.CellTemplate> </DataGridTemplateColumn.CellTemplate>
<DataGridTemplateColumn.CellEditingTemplate> <DataGridTemplateColumn.CellEditingTemplate>
@@ -83,10 +149,19 @@
</DataTemplate> </DataTemplate>
</DataGridTemplateColumn.CellEditingTemplate> </DataGridTemplateColumn.CellEditingTemplate>
</DataGridTemplateColumn> </DataGridTemplateColumn>
<DataGridTextColumn Header="File Name" <DataGridTemplateColumn Header="File Name"
Binding="{Binding FileName}" IsReadOnly="True"
IsReadOnly="True" Width="*">
Width="*" /> <DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding FileName}"
VerticalAlignment="Center"
ToolTip.Tip="{Binding FileName}"
Margin="8,0,8,0"
HorizontalAlignment="Left"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Header="" <DataGridTemplateColumn Header=""
IsReadOnly="True" IsReadOnly="True"
Width="*"> Width="*">
@@ -100,7 +175,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="&#xf1f8;" FontFamily="{StaticResource FontAwesomeSolid}"/> Edit</TextBlock> <TextBlock><Run Text="&#xf044;" 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}"
@@ -119,11 +194,18 @@
</DataGrid.Columns> </DataGrid.Columns>
<DataGrid.RowDetailsTemplate> <DataGrid.RowDetailsTemplate>
<DataTemplate x:DataType="models:ReportFile"> <DataTemplate x:DataType="models:ReportFile">
<TextBlock TextWrapping="Wrap" Margin="4,4,4,0"> <Grid ColumnDefinitions="*"
<Run FontWeight="Bold" Text="File Path"/>: <Run Text="{Binding FilePath}"/> RowDefinitions="Auto, Auto, Auto">
<LineBreak/> <TextBlock TextWrapping="Wrap" Margin="4" Grid.Row="0">
<Run FontWeight="Bold" Text="File Path"/>: <Run Text="{Binding FilePath}"/>
</TextBlock>
<TextBlock TextWrapping="Wrap" Margin="4" Grid.Row="1">
<Run FontWeight="Bold" Text="Notes"/>: <Run Text="{Binding Notes}"/>
</TextBlock>
<StackPanel Orientation="Horizontal" <StackPanel Orientation="Horizontal"
Spacing="8"> Spacing="8"
Margin="4"
Grid.Row="2">
<Button Command="{Binding $parent[DataGrid].((vm:MainViewModel)DataContext).OpenFileLocation}" <Button Command="{Binding $parent[DataGrid].((vm:MainViewModel)DataContext).OpenFileLocation}"
CommandParameter="{Binding}"> CommandParameter="{Binding}">
<Button.Content> <Button.Content>
@@ -137,9 +219,7 @@
</Button.Content> </Button.Content>
</Button> </Button>
</StackPanel> </StackPanel>
<LineBreak/> </Grid>
<Run FontWeight="Bold" Text="Notes"/>: <Run Text="{Binding Notes}"/>
</TextBlock>
</DataTemplate> </DataTemplate>
</DataGrid.RowDetailsTemplate> </DataGrid.RowDetailsTemplate>
</DataGrid> </DataGrid>
@@ -151,27 +231,31 @@
<StackPanel Orientation="Horizontal" <StackPanel Orientation="Horizontal"
Spacing="4"> Spacing="4">
<Button Command="{Binding AddItem}" <Button Command="{Binding AddItem}"
IsEnabled="{Binding IsCreatePDFButtonEnabled}"> IsEnabled="{Binding CanAddItem}">
<TextBlock><Run Text="&#x002b;" FontFamily="{StaticResource FontAwesomeSolid}"/> Add Item</TextBlock> <TextBlock><Run Text="&#x002b;" FontFamily="{StaticResource FontAwesomeSolid}"/> Add Item(s)</TextBlock>
</Button> </Button>
<Button Command="{Binding SaveInterimReportInfo}" <Button Command="{Binding RemoveAllItems}"
IsEnabled="{Binding IsCreatePDFButtonEnabled}"> IsEnabled="{Binding IsCreatePDFButtonEnabled}"
<TextBlock><Run Text="&#xf0c7;" FontFamily="{StaticResource FontAwesomeSolid}"/> Save Report Info</TextBlock> Classes="Danger">
<TextBlock><Run Text="&#xf1f8;" FontFamily="{StaticResource FontAwesomeSolid}"/> Remove All Items</TextBlock>
</Button> </Button>
<Button Command="{Binding ResortPDFItemsByDate}" <Button Command="{Binding ResortPDFItemsByDate}"
IsEnabled="{Binding IsCreatePDFButtonEnabled}"> IsEnabled="{Binding IsCreatePDFButtonEnabled}">
<TextBlock><Run Text="&#xf162;" FontFamily="{StaticResource FontAwesomeSolid}"/> Re-sort PDF Items</TextBlock> <TextBlock><Run Text="&#xf162;" FontFamily="{StaticResource FontAwesomeSolid}"/> Re-sort PDF Items</TextBlock>
</Button> </Button>
<Button Command="{Binding BuildPDF}" <Button Command="{Binding SaveInterimReportInfo}"
Classes="accent" IsEnabled="{Binding HasWorkingFolderAndNotMakingPDF}">
IsEnabled="{Binding IsCreatePDFButtonEnabled}"> <TextBlock><Run Text="&#xf0c7;" FontFamily="{StaticResource FontAwesomeSolid}"/> Save Report Info</TextBlock>
<TextBlock><Run Text="&#xf1c1;" FontFamily="{StaticResource FontAwesomeSolid}"/> Create Report PDF</TextBlock>
</Button> </Button>
</StackPanel> </StackPanel>
<StackPanel Orientation="Horizontal" <StackPanel Orientation="Horizontal"
IsVisible="{Binding IsCreatingPDF}"
Spacing="6" Spacing="6"
HorizontalAlignment="Center"> HorizontalAlignment="Center">
<Button Command="{Binding BuildPDF}"
Classes="accent"
IsEnabled="{Binding IsCreatePDFButtonEnabled}">
<TextBlock><Run Text="&#xf1c1;" FontFamily="{StaticResource FontAwesomeSolid}"/> Create Report PDF</TextBlock>
</Button>
<Label Content="Creating PDF..." <Label Content="Creating PDF..."
IsVisible="{Binding IsCreatingPDF}" IsVisible="{Binding IsCreatingPDF}"
VerticalAlignment="Center"/> VerticalAlignment="Center"/>
@@ -186,14 +270,23 @@
Spacing="2" Spacing="2"
Grid.Row="3"> Grid.Row="3">
<Rectangle Fill="Gray" Height="3" HorizontalAlignment="Stretch"/> <Rectangle Fill="Gray" Height="3" HorizontalAlignment="Stretch"/>
<Label Content="Program Log" FontSize="14" FontWeight="Bold"/> <Grid ColumnDefinitions="Auto, *">
<Label Content="Program Log" FontSize="14" FontWeight="Bold" Grid.Column="0"/>
<Button Command="{Binding CopyLogToClipboard}"
FontSize="10"
Grid.Column="1"
HorizontalAlignment="Right"
Margin="0,2,8,2">
<TextBlock><Run Text="&#xf0c5;" FontFamily="{StaticResource FontAwesomeSolid}"/> Copy Program Log to Clipboard</TextBlock>
</Button>
</Grid>
</StackPanel> </StackPanel>
<ScrollViewer Margin="2" <ScrollViewer Margin="2"
Grid.Row="4" Grid.Row="4"
x:Name="LogScrollView" x:Name="LogScrollView"
VerticalScrollBarVisibility="Visible" VerticalScrollBarVisibility="Visible"
AllowAutoHide="False"> AllowAutoHide="False">
<SelectableTextBlock Text="{Binding CreatePDFLog}" <SelectableTextBlock Text="{Binding ProgramLog}"
Margin="2" Margin="2"
TextWrapping="Wrap" TextWrapping="Wrap"
x:Name="LogBlock"/> x:Name="LogBlock"/>
+45
View File
@@ -0,0 +1,45 @@
using System;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Input;
using Avalonia.Markup.Xaml;
using MayShow.ViewModels;
namespace MayShow.Views
{
public partial class MainView : UserControl
{
public MainView()
{
this.InitializeComponent();
LogBlock.PropertyChanged += LogBlock_PropertyChanged;
FilesGrid.CellEditEnded += FileCellEditEnded;
}
private void LogBlock_PropertyChanged(object? sender, AvaloniaPropertyChangedEventArgs e)
{
if (e.Property.ToString() == "Text")
{
LogScrollView.ScrollToEnd();
}
}
public void UnfocusTextbox()
{
var topLevel = TopLevel.GetTopLevel(this);
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;
}
}
}
}
+72
View File
@@ -0,0 +1,72 @@
<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.SettingsView"
xmlns:models="clr-namespace:MayShow.Models"
xmlns:vm="clr-namespace:MayShow.ViewModels"
x:DataType="vm:SettingsViewModel"
MaxWidth="450">
<ScrollViewer AllowAutoHide="False">
<StackPanel Orientation="Vertical"
Spacing="8"
Margin="12,4,12,4">
<Label Content="Settings"
HorizontalAlignment="Center"
FontSize="16"
FontWeight="Bold" />
<TextBlock TextWrapping="Wrap"
HorizontalAlignment="Left"
Width="350">
Always reduce size of images if above this file size in megabytes (MB):
</TextBlock>
<NumericUpDown Value="{Binding ImageResizeThreshold}"
Increment="0.1"
Minimum="0.5"
FormatString="0.00"
Maximum="10"
Width="150"
HorizontalAlignment="Left"
Margin="0,0,0,4" />
<CheckBox IsChecked="{Binding !UseDocnetPDFImageRendering}">Use legacy PDF handling (does not work with macOS annotations)</CheckBox>
<CheckBox IsChecked="{Binding SaveOutputPdfInWorkingDir}">Always save report PDF in working directory</CheckBox>
<Grid ColumnDefinitions="Auto, *"
IsVisible="{Binding !SaveOutputPdfInWorkingDir}">
<Button Content="Choose report output folder..."
Grid.Column="0"
Command="{Binding ChooseOutputFolder}"
VerticalAlignment="Top"/>
<TextBlock Text="{Binding OutputPdfDirPath}"
Margin="4,0,0,0"
TextWrapping="Wrap"
Grid.Column="1"
HorizontalAlignment="Left"
VerticalAlignment="Top"/>
</Grid>
<CheckBox IsChecked="{Binding SaveReportJsonDataInInternalDir}">Save report data (names, notes, etc.) in MayShow settings directory (saves in working directory by default)</CheckBox>
<TextBlock TextWrapping="Wrap"
Foreground="Red"
Text="{Binding ErrorMessage}"
IsVisible="{Binding HasErrorMessage}"/>
<StackPanel Orientation="Horizontal"
Spacing="12"
Margin="0,4,0,0"
HorizontalAlignment="Right">
<Button Command="{Binding Cancel}">
<TextBlock>
<Run Text="&#xf0e2;"
FontFamily="{StaticResource FontAwesomeSolid}" /> Cancel</TextBlock>
</Button>
<Button Command="{Binding Save}"
Classes="accent">
<TextBlock>
<Run Text="&#xf0c7;"
FontFamily="{StaticResource FontAwesomeSolid}" /> Save</TextBlock>
</Button>
</StackPanel>
</StackPanel>
</ScrollViewer>
</UserControl>
+14
View File
@@ -0,0 +1,14 @@
using System;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
namespace MayShow.Views;
public partial class SettingsView : UserControl
{
public SettingsView()
{
this.InitializeComponent();
}
}
+39
View File
@@ -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>
+14
View File
@@ -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();
}
}
@@ -3,11 +3,11 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="ReceiptPDFBuilder.Views.WarningDeleteItem" x:Class="MayShow.Views.WarningDeleteItem"
xmlns:models="clr-namespace:ReceiptPDFBuilder.Models" xmlns:models="clr-namespace:MayShow.Models"
xmlns:vm="clr-namespace:ReceiptPDFBuilder.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:WarningDeleteItemModel"> x:DataType="vm:WarningDeleteItemViewModel">
<StackPanel HorizontalAlignment="Center" <StackPanel HorizontalAlignment="Center"
Margin="6" Margin="6"
Spacing="8"> Spacing="8">
@@ -3,7 +3,7 @@ using Avalonia;
using Avalonia.Controls; using Avalonia.Controls;
using Avalonia.Markup.Xaml; using Avalonia.Markup.Xaml;
namespace ReceiptPDFBuilder.Views namespace MayShow.Views
{ {
public partial class WarningDeleteItem : UserControl public partial class WarningDeleteItem : UserControl
{ {
@@ -3,9 +3,9 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="ReceiptPDFBuilder.Views.WarningView" x:Class="MayShow.Views.WarningView"
xmlns:models="clr-namespace:ReceiptPDFBuilder.Models" xmlns:models="clr-namespace:MayShow.Models"
xmlns:vm="clr-namespace:ReceiptPDFBuilder.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:WarningViewModel"> x:DataType="vm:WarningViewModel">
<StackPanel Orientation="Vertical" <StackPanel Orientation="Vertical"
@@ -18,7 +18,7 @@
FontWeight="Bold" FontWeight="Bold"
TextWrapping="Wrap" TextWrapping="Wrap"
FontSize="14" FontSize="14"
MaxWidth="350" MaxWidth="400"
Text="{Binding Error}"/> Text="{Binding Error}"/>
<Button Command="{Binding Close}" <Button Command="{Binding Close}"
Classes="accent" Classes="accent"
+14
View File
@@ -0,0 +1,14 @@
using System;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
namespace MayShow.Views;
public partial class WarningView : UserControl
{
public WarningView()
{
this.InitializeComponent();
}
}
+1 -1
View File
@@ -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.0.0.0" name="ReceiptPDFBuilder.Desktop"/> <assemblyIdentity version="1.4.0.0" name="MayShow.Desktop"/>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1"> <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application> <application>