diff --git a/src/OneWare.OssCadSuiteIntegration/OssCadSuiteIntegrationModule.cs b/src/OneWare.OssCadSuiteIntegration/OssCadSuiteIntegrationModule.cs index a033b3948..ea1b55bcf 100644 --- a/src/OneWare.OssCadSuiteIntegration/OssCadSuiteIntegrationModule.cs +++ b/src/OneWare.OssCadSuiteIntegration/OssCadSuiteIntegrationModule.cs @@ -501,8 +501,8 @@ await windowService.ShowDialogAsync( l.Add(new MenuItemViewModel("GtkWaveOpen") { Header = "Open with GTKWave", - Command = new RelayCommand(() => - containerProvider.Resolve().OpenInGtkWave(wave.FullPath)) + Command = new AsyncRelayCommand(async () => + await containerProvider.Resolve().OpenInGtkWaveAsync(wave)) }); if (x is [IProjectFile { Extension: ".pcf" } pcf]) { @@ -530,7 +530,7 @@ await windowService.ShowDialogAsync( containerProvider.Resolve().RegisterFileOpenOverwrite(x => { - containerProvider.Resolve().OpenInGtkWave(x.FullPath); + containerProvider.Resolve().OpenInGtkWaveAsync(x).RunSynchronously(); return true; }, ".ghw", ".fst"); } diff --git a/src/OneWare.OssCadSuiteIntegration/Tools/GtkWaveService.cs b/src/OneWare.OssCadSuiteIntegration/Tools/GtkWaveService.cs index b3bd75396..da300ab21 100644 --- a/src/OneWare.OssCadSuiteIntegration/Tools/GtkWaveService.cs +++ b/src/OneWare.OssCadSuiteIntegration/Tools/GtkWaveService.cs @@ -1,12 +1,24 @@ using OneWare.Essentials.Enums; +using OneWare.Essentials.Models; using OneWare.Essentials.Services; +using OneWare.UniversalFpgaProjectSystem.Context; namespace OneWare.OssCadSuiteIntegration.Tools; public class GtkWaveService(IChildProcessService childProcessService) { - public void OpenInGtkWave(string path) + private static readonly string[] GtkProperties = ["GtkwSaveFile", "GtkwWaveArgs"]; + + public async Task OpenInGtkWaveAsync(IFile file) { - childProcessService.StartWeakProcess("gtkwave", [Path.GetFileName(path)], Path.GetDirectoryName(path) ?? ""); + var context = await TestBenchContextManager.LoadContextAsync(file); + List args = [Path.GetFileName(file.FullPath)]; + + foreach (var property in GtkProperties) + if (context.Properties.TryGetPropertyValue(property, out var jsonNode) && jsonNode != null && jsonNode.GetValueKind() == System.Text.Json.JsonValueKind.String) + args.Add(jsonNode.GetValue()); + + // save file has to be provided as second argument without "--save" + childProcessService.StartWeakProcess("gtkwave", args, Path.GetDirectoryName(file.FullPath) ?? ""); } } \ No newline at end of file