From f034e8e08e8c3fbe6b91b2ba1ddc084050ca0965 Mon Sep 17 00:00:00 2001 From: "ADA (OpenClaw Agent)" Date: Wed, 2 Sep 2026 08:59:06 +0200 Subject: [PATCH] fix: improve export dialog and cancellation --- CHANGELOG.md | 7 +++ Helpers/FileHelper.cs | 19 +++++-- MainWindow.xaml.cs | 17 ++++-- OneNoteExporter.csproj | 2 +- README.md | 4 +- RenderedExportWarningWindow.xaml | 87 +++++++++++++++++------------ RenderedExportWarningWindow.xaml.cs | 4 +- Services/OneNoteComWorker.cs | 1 + innosetup.iss | 2 +- release.sh | 2 +- 10 files changed, 93 insertions(+), 52 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9f58c92..2c45a24 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## 1.2.1 + +- Enlarged the large PDF/XPS export dialog so every export option is fully visible. +- Added text wrapping and window resizing for improved display scaling compatibility. +- Tightened safe cancellation before finalizing an export, made local-backup copying + cancellable between files, and clarified cancellation behavior. + ## 1.2.0 - Improved reliability with a serialized OneNote COM worker, safe cancellation, and bounded connection recovery. diff --git a/Helpers/FileHelper.cs b/Helpers/FileHelper.cs index 9acc0b1..db02a78 100644 --- a/Helpers/FileHelper.cs +++ b/Helpers/FileHelper.cs @@ -91,7 +91,9 @@ public static BackupAvailability CheckLocalBackupAvailable() /// /// Copies the entire OneNote local backup folder to . /// - public static ExportResult CopyLocalBackup(string destPath) + public static ExportResult CopyLocalBackup( + string destPath, + CancellationToken ct = default) { var backupPath = GetOneNoteBackupPath(); @@ -100,10 +102,15 @@ public static ExportResult CopyLocalBackup(string destPath) try { + ct.ThrowIfCancellationRequested(); Directory.CreateDirectory(destPath); - CopyDirectory(backupPath, destPath); + CopyDirectory(backupPath, destPath, ct); return new ExportResult { Success = true, Message = "Local backup copied successfully.", ExportedPath = destPath }; } + catch (OperationCanceledException) + { + throw; + } catch (Exception ex) { return new ExportResult @@ -137,20 +144,24 @@ public static void OpenFolder(string path) // ── private helpers ────────────────────────────────────────────────────── - private static void CopyDirectory(string src, string dst) + private static void CopyDirectory(string src, string dst, CancellationToken ct) { + ct.ThrowIfCancellationRequested(); Directory.CreateDirectory(dst); foreach (var file in Directory.GetFiles(src)) { + ct.ThrowIfCancellationRequested(); var dest = Path.Combine(dst, Path.GetFileName(file)); File.Copy(file, dest, overwrite: true); + ct.ThrowIfCancellationRequested(); } foreach (var dir in Directory.GetDirectories(src)) { + ct.ThrowIfCancellationRequested(); var dest = Path.Combine(dst, Path.GetFileName(dir)); - CopyDirectory(dir, dest); + CopyDirectory(dir, dest, ct); } } } diff --git a/MainWindow.xaml.cs b/MainWindow.xaml.cs index 7ae4b48..d85f0d8 100644 --- a/MainWindow.xaml.cs +++ b/MainWindow.xaml.cs @@ -533,7 +533,7 @@ private async void ExportButton_Click(object sender, RoutedEventArgs e) try { if (format == "localbackup") - await RunLocalBackupAsync(destPath); + await RunLocalBackupAsync(destPath, _exportCts.Token); else { var prepared = await ApplyRenderedExportGuardAsync( @@ -565,8 +565,13 @@ private void CancelButton_Click(object sender, RoutedEventArgs e) { if (!_exportInProgress) return; + string cancellationDetails = _isLocalBackupMode + ? "The export will stop safely after the current file copy finishes." + : "The export will stop safely without closing OneNote. If OneNote is currently " + + "rendering, cancellation completes as soon as OneNote returns control."; + var confirm = MessageBox.Show( - "Do you really want to cancel the export?\n\nThe current export will stop without closing OneNote.", + $"Do you really want to cancel the export?\n\n{cancellationDetails}", "Cancel Export", MessageBoxButton.YesNo, MessageBoxImage.Warning); @@ -580,13 +585,13 @@ private void CancelButton_Click(object sender, RoutedEventArgs e) // ── Export implementations ─────────────────────────────────────────────── - private async Task RunLocalBackupAsync(string destPath) + private async Task RunLocalBackupAsync(string destPath, CancellationToken ct) { ShowProgress("Copying local backup files..."); try { - var result = await Task.Run(() => FileHelper.CopyLocalBackup(destPath)); + var result = await Task.Run(() => FileHelper.CopyLocalBackup(destPath, ct), ct); HideProgress(); if (result.Success) @@ -599,6 +604,10 @@ private async Task RunLocalBackupAsync(string destPath) ShowStatus($"❌ Export failed: {result.Message}", StatusKind.Error); } } + catch (OperationCanceledException) + { + throw; + } catch (Exception ex) { HideProgress(); diff --git a/OneNoteExporter.csproj b/OneNoteExporter.csproj index 3502d10..946b166 100644 --- a/OneNoteExporter.csproj +++ b/OneNoteExporter.csproj @@ -12,7 +12,7 @@ OneNoteExporter OneNoteExporter - 1.2.0 + 1.2.1 icon.ico diff --git a/README.md b/README.md index d11dd59..8a33e1a 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ A Windows desktop application to export OneNote notebooks to portable formats. Talks directly to OneNote Desktop via the COM API. -![version](https://img.shields.io/badge/version-1.2.0-blueviolet?style=flat-square) +![version](https://img.shields.io/badge/version-1.2.1-blueviolet?style=flat-square) ![platform](https://img.shields.io/badge/platform-Windows%2010%2F11-0078D7?style=flat-square&logo=windows&logoColor=white) ![license](https://img.shields.io/badge/license-MIT-brightgreen?style=flat-square) ![built with](https://img.shields.io/badge/built%20with-.NET%2010%20%2F%20WPF-512BD4?style=flat-square&logo=dotnet&logoColor=white) @@ -40,7 +40,7 @@ checksum are available as workflow artifacts for 14 days. To publish a release: 1. Update `` in `OneNoteExporter.csproj` and commit the change. -2. Create and push a matching tag, for example `v1.2.0`. +2. Create and push a matching tag, for example `v1.2.1`. 3. GitHub Actions builds the installer, creates the GitHub release with generated notes, and uploads the installer plus checksum automatically. diff --git a/RenderedExportWarningWindow.xaml b/RenderedExportWarningWindow.xaml index 64c8697..0c90b13 100644 --- a/RenderedExportWarningWindow.xaml +++ b/RenderedExportWarningWindow.xaml @@ -3,9 +3,9 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Icon="icon.ico" Title="Large PDF/XPS export" - Width="560" Height="430" - MinWidth="520" MinHeight="410" - ResizeMode="NoResize" + Width="700" Height="555" + MinWidth="620" MinHeight="520" + ResizeMode="CanResizeWithGrip" ShowInTaskbar="False" WindowStartupLocation="CenterOwner" Background="{StaticResource BgPage}"> @@ -29,6 +29,7 @@ x:Name="TitleText" FontSize="18" FontWeight="Bold" + TextWrapping="Wrap" Foreground="{StaticResource PrimaryBlue}"/> - - + + + - - + +