This commit is contained in:
@@ -95,6 +95,22 @@ public partial class MainWindow : Window
|
||||
catch (Exception ex) { _viewModel.SetStatus($"Bildimport fehlgeschlagen: {ex.Message}", true); }
|
||||
}
|
||||
|
||||
[SupportedOSPlatform("windows")]
|
||||
[SupportedOSPlatform("linux")]
|
||||
[SupportedOSPlatform("macos")]
|
||||
private async void OnImportPdfTemplate(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
var dialog = new PdfImportDialog();
|
||||
var accepted = await dialog.ShowDialog<bool>(this);
|
||||
if (!accepted || dialog.Result is null) return;
|
||||
try
|
||||
{
|
||||
_viewModel.ApplyPdfImport(dialog.Result);
|
||||
_currentPackagePath = null; UpdateDocumentTitle(); OnPreview(sender, e);
|
||||
}
|
||||
catch (Exception ex) { _viewModel.SetStatus($"PDF-Vorschlag konnte nicht übernommen werden: {ex.Message}", true); }
|
||||
}
|
||||
|
||||
private async void OnReplaceSelectedAsset(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
if (_viewModel.SelectedAsset is null) { _viewModel.SetStatus("Bitte zuerst ein Asset auswählen.", true); return; }
|
||||
@@ -132,8 +148,8 @@ public partial class MainWindow : Window
|
||||
{ _viewModel.SetStatus("Bitte zuerst eine Ausgangsvorlage auswählen.", true); return; }
|
||||
try
|
||||
{
|
||||
var (template, layout) = _starterTemplates.Load(selected);
|
||||
_viewModel.Load(template, layout); _currentPackagePath = null; UpdateDocumentTitle(); OnPreview(sender, e);
|
||||
var (template, layout, continuationLayout) = _starterTemplates.LoadWithContinuation(selected);
|
||||
_viewModel.Load(template, layout, continuationLayout); _currentPackagePath = null; UpdateDocumentTitle(); OnPreview(sender, e);
|
||||
}
|
||||
catch (Exception ex) { _viewModel.SetStatus($"Öffnen fehlgeschlagen: {ex.Message}", true); }
|
||||
}
|
||||
@@ -144,9 +160,9 @@ public partial class MainWindow : Window
|
||||
{ _viewModel.SetStatus("Bitte zuerst eine Ausgangsvorlage auswählen.", true); return; }
|
||||
try
|
||||
{
|
||||
var (template, layout) = _starterTemplates.Load(selected);
|
||||
var (template, layout, continuationLayout) = _starterTemplates.LoadWithContinuation(selected);
|
||||
var projectId = _starterTemplates.CreateUniqueId(template.Manifest.Id + "-neu");
|
||||
_viewModel.LoadAsNewProject(template, layout, projectId);
|
||||
_viewModel.LoadAsNewProject(template, layout, continuationLayout, projectId);
|
||||
_currentPackagePath = null; UpdateDocumentTitle(); OnPreview(sender, e);
|
||||
}
|
||||
catch (Exception ex) { _viewModel.SetStatus($"Klonen fehlgeschlagen: {ex.Message}", true); }
|
||||
@@ -157,7 +173,8 @@ public partial class MainWindow : Window
|
||||
try
|
||||
{
|
||||
_viewModel.BuildLoaded();
|
||||
var saved = _starterTemplates.Save(_viewModel.BuildManifest(), _viewModel.LayoutSource, _viewModel.Assets);
|
||||
var saved = _starterTemplates.Save(_viewModel.BuildManifest(), _viewModel.LayoutSource, _viewModel.Assets,
|
||||
_viewModel.UseContinuationLayout ? _viewModel.ContinuationLayoutSource : null);
|
||||
RefreshStarterTemplates(saved.Id);
|
||||
_viewModel.SetStatus($"Ausgangsvorlage „{saved.Name}“ lokal gespeichert/aktualisiert.", false);
|
||||
}
|
||||
@@ -227,8 +244,16 @@ public partial class MainWindow : Window
|
||||
try
|
||||
{
|
||||
var path = files[0].Path.LocalPath; var loaded = new TemplateLoader().LoadFromPackage(path);
|
||||
using var archive = ZipFile.OpenRead(path); using var reader = new StreamReader(archive.GetEntry(loaded.Manifest.LayoutFile)!.Open());
|
||||
_viewModel.Load(loaded, reader.ReadToEnd()); _currentPackagePath = Path.GetFullPath(path);
|
||||
using var archive = ZipFile.OpenRead(path);
|
||||
string layoutSource;
|
||||
using (var reader = new StreamReader(archive.GetEntry(loaded.Manifest.LayoutFile)!.Open())) layoutSource = reader.ReadToEnd();
|
||||
string? continuationLayoutSource = null;
|
||||
if (loaded.Manifest.ContinuationLayoutFile is { } continuationPath)
|
||||
{
|
||||
using var reader = new StreamReader(archive.GetEntry(continuationPath)!.Open());
|
||||
continuationLayoutSource = reader.ReadToEnd();
|
||||
}
|
||||
_viewModel.Load(loaded, layoutSource, continuationLayoutSource); _currentPackagePath = Path.GetFullPath(path);
|
||||
UpdateDocumentTitle(); OnPreview(sender, e);
|
||||
}
|
||||
catch (Exception ex) { _viewModel.SetStatus($"Öffnen fehlgeschlagen: {ex.Message}", true); }
|
||||
@@ -263,7 +288,8 @@ public partial class MainWindow : Window
|
||||
try
|
||||
{
|
||||
_viewModel.BuildLoaded();
|
||||
TemplatePackage.Create(path, _viewModel.BuildManifest(), _viewModel.LayoutSource, _viewModel.Assets);
|
||||
TemplatePackage.Create(path, _viewModel.BuildManifest(), _viewModel.LayoutSource, _viewModel.Assets,
|
||||
_viewModel.UseContinuationLayout ? _viewModel.ContinuationLayoutSource : null);
|
||||
_viewModel.CanExport = true;
|
||||
_viewModel.SetStatus($"Gespeichert: {Path.GetFileName(path)}", false);
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user