mirror of
https://github.com/ajisaacs/OpenNest.git
synced 2026-11-14 10:15:07 -05:00
feat(avalonia): drop Export Nest Report to match WinForms
WinForms removed the direct-save command in ecd0bba4; the system PDF viewer that Nest Report opens already saves and prints the report. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
aea5e9f617
commit
5ead16bffe
4 files changed
+8
-58
No files matched your search
@@ -10,8 +10,8 @@ using OpenNest.Desktop;
|
||||
namespace OpenNest.Avalonia
|
||||
{
|
||||
/// <summary>
|
||||
/// File > Export Plate, Export All Plates, Nest Report and Export Nest Report, and Plate >
|
||||
/// View in CAD, as the WinForms app has them: the same suggested file names and writers
|
||||
/// File > Export Plate, Export All Plates and Nest Report, and Plate > View in CAD, as
|
||||
/// the WinForms app has them: the same suggested file names and writers
|
||||
/// (<see cref="PlateExport"/>, <see cref="NestReportExport"/>). A viewed report opens in the
|
||||
/// system's PDF viewer, which saves and prints it; View in CAD opens the plate's DXF in the
|
||||
/// program the system associates with .dxf.
|
||||
@@ -30,15 +30,11 @@ namespace OpenNest.Avalonia
|
||||
private static readonly FilePickerFileType SvgFiles =
|
||||
new("SVG file") { Patterns = new[] { "*.svg" } };
|
||||
|
||||
private static readonly FilePickerFileType PdfFiles =
|
||||
new("PDF file") { Patterns = new[] { "*.pdf" } };
|
||||
|
||||
private void UpdateExportCommands(bool hasNest)
|
||||
{
|
||||
ExportPlateMenuItem.IsEnabled = hasNest;
|
||||
ExportAllPlatesMenuItem.IsEnabled = hasNest;
|
||||
ViewNestReportMenuItem.IsEnabled = hasNest;
|
||||
ExportNestReportMenuItem.IsEnabled = hasNest;
|
||||
ViewInCadMenuItem.IsEnabled = hasNest;
|
||||
}
|
||||
|
||||
@@ -244,51 +240,6 @@ namespace OpenNest.Avalonia
|
||||
$"The nest report was written to '{path}', but it could not be opened");
|
||||
}
|
||||
|
||||
/// <summary>Saves the nest report as a PDF file the user picks.</summary>
|
||||
private async void OnExportNestReport(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var tab = tabs.Active;
|
||||
if (tab == null || !TryReportFileName(tab, out var fileName))
|
||||
return;
|
||||
if (!CanWrite(tab, "exporting the report"))
|
||||
return;
|
||||
writingFile = true;
|
||||
try
|
||||
{
|
||||
var file = await StorageProvider.SaveFilePickerAsync(new FilePickerSaveOptions
|
||||
{
|
||||
Title = "Export Nest Report",
|
||||
SuggestedFileName = fileName,
|
||||
DefaultExtension = "pdf",
|
||||
ShowOverwritePrompt = true,
|
||||
FileTypeChoices = new[] { PdfFiles },
|
||||
SuggestedStartLocation = await NestFolderAsync(tab),
|
||||
});
|
||||
if (file == null)
|
||||
return;
|
||||
var path = file.TryGetLocalPath();
|
||||
if (path == null)
|
||||
{
|
||||
ShowNotice("The nest report can only be saved to a folder on this computer.");
|
||||
return;
|
||||
}
|
||||
await MachinesLoaded;
|
||||
// Auto Nest may have started on it while the file picker was open.
|
||||
if (IsNesting(tab, "exporting the report"))
|
||||
return;
|
||||
await WriteReportAsync(tab, path);
|
||||
ShowNotice($"Saved nest report to {path}");
|
||||
}
|
||||
catch (Exception ex) when (IsReportFailure(ex))
|
||||
{
|
||||
await ReportFailureAsync(tab, ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
writingFile = false;
|
||||
}
|
||||
}
|
||||
|
||||
// The report's file name, or false (after saying why) when the nest's name cannot be one.
|
||||
private bool TryReportFileName(NestTab tab, out string fileName)
|
||||
{
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
<MenuItem x:Name="ExportAllPlatesMenuItem" Header="Export All _Plates..." Click="OnExportAllPlates" />
|
||||
<Separator />
|
||||
<MenuItem x:Name="ViewNestReportMenuItem" Header="Nest _Report..." Click="OnViewNestReport" />
|
||||
<MenuItem x:Name="ExportNestReportMenuItem" Header="Expor_t Nest Report..." Click="OnExportNestReport" />
|
||||
<Separator />
|
||||
<MenuItem x:Name="CloseMenuItem" Header="_Close" Click="OnCloseNest" />
|
||||
<MenuItem x:Name="CloseAllMenuItem" Header="Close A_ll" Click="OnCloseAll" />
|
||||
|
||||
@@ -8,9 +8,9 @@ using OpenNest.Reporting;
|
||||
namespace OpenNest.Desktop;
|
||||
|
||||
/// <summary>
|
||||
/// File > Export Nest Report and View Nest Report for both desktop apps: the checks before a
|
||||
/// report is written, the report file name, capturing and writing the PDF, and the private
|
||||
/// temporary folders a viewed report is rendered into. Whether the nest is busy (nesting, a fill
|
||||
/// View Nest Report for both desktop apps: the checks before a report is written, the report
|
||||
/// file name, capturing and writing the PDF, and the private temporary folders a viewed report is
|
||||
/// rendered into. Whether the nest is busy (nesting, a fill
|
||||
/// or plate action) is the front end's to say; see docs/nest-reports.md.
|
||||
/// </summary>
|
||||
public static class NestReportExport
|
||||
|
||||
@@ -25,9 +25,9 @@ own: **File -> Nest Report...** writes the PDF to a private folder under the
|
||||
system temp folder's `OpenNest/Reports/` and opens it in the system's PDF viewer
|
||||
(`ExternalFileLauncher`: the Windows shell, `open` on macOS, `xdg-open`
|
||||
elsewhere), which saves and prints it. Because that viewer's closing cannot be
|
||||
seen, each view removes viewed-report folders older than a day instead. **File ->
|
||||
Export Nest Report...** saves the PDF straight to a chosen file. Either refuses
|
||||
while Auto Nest runs on the nest, checked before and after the file picker.
|
||||
seen, each view removes viewed-report folders older than a day instead. Like
|
||||
WinForms it has no separate direct-save command. It refuses while Auto Nest runs
|
||||
on the nest, checked again once the machines are read.
|
||||
|
||||
The same two calls back the command and any future integration:
|
||||
|
||||
|
||||
Reference in new issue
Block a user