using Launcher.Next.Application; using Launcher.Next.Autodesk; namespace Launcher.Next.App; public partial class MainWindow : System.Windows.Window { private readonly LegacyConfigurationAdapter adapter=new(); private readonly LocalParityLaunchProfile? localProfile; private readonly LocalParityLaunchService localService=new(); private LocalParityPrepared? prepared; public MainWindow() { InitializeComponent(); RefreshDiscovery(); Status.Text="Ready: choose a legacy Settings.xml to inspect approved configurations."; } internal MainWindow(LocalParityLaunchProfile profile) { localProfile=profile; InitializeComponent(); RefreshDiscovery(); LoadLocalProfile(profile); } private void RefreshDiscovery() { var product=new PlantProductDiscovery(new WindowsRegistryReader()).DiscoverPlant3D(2026); AutodeskStatus.Text=product is null?"Autodesk Plant 3D 2026: Not found":"Autodesk Plant 3D 2026: Found"; ExecutableStatus.Text=product is null?"Discovery diagnostic: ACAD-9117 Plant 3D registry entry or executable unavailable.":$"Executable: {product.ExecutablePath}"; } private void Refresh_Click(object sender,System.Windows.RoutedEventArgs e)=>RefreshDiscovery(); private void OpenSettings_Click(object sender,System.Windows.RoutedEventArgs e) { var dialog=new Microsoft.Win32.OpenFileDialog { Filter="Settings.xml|Settings.xml|XML files|*.xml" }; if(dialog.ShowDialog()!=true)return; try { var settings=adapter.ParseSettings(System.IO.File.ReadAllText(dialog.FileName)); Patterns.ItemsSource=settings.Patterns; ConfigurationStatus.Text=$"Loaded {settings.Patterns.Count} configuration(s) from {System.IO.Path.GetFileName(dialog.FileName)}"; Status.Text="Select a configuration. Exact package preparation remains blocked until an approved compatibility overlay and local verified catalog are supplied."; } catch(System.Exception ex) { ConfigurationStatus.Text="Configuration invalid";Status.Text=$"Blocked: {ex.Message}";Patterns.ItemsSource=null; } } private void Patterns_SelectionChanged(object sender,System.Windows.Controls.SelectionChangedEventArgs e) { if(Patterns.SelectedItem is not LegacyProductPattern pattern)return;PatternDetails.Text=$"Filter: {pattern.Filter}\nRoster: {pattern.Roster}\nLegacy plugins: {pattern.Plugins.Count}";PackageStatus.Text="Exact package requirements are derived only after approved overlay + ordered download_list.xml join.";Status.Text="Configuration selected; provide approved local compatibility inputs to prepare packages."; } private void Diagnostics_Click(object sender,System.Windows.RoutedEventArgs e)=>System.Windows.MessageBox.Show($"{AutodeskStatus.Text}\n{ConfigurationStatus.Text}\n{Status.Text}","Launcher Next diagnostics"); private void LoadLocalProfile(LocalParityLaunchProfile profile) { try { var settings=adapter.ParseSettings(System.IO.File.ReadAllText(profile.SettingsPath)); Patterns.ItemsSource=settings.Patterns; Patterns.SelectedItem=settings.Patterns.Single(x=>x.Name==profile.PatternName); ConfigurationStatus.Text="Controlled Local PXP-OA"; PrepareButton.IsEnabled=true; LaunchButton.IsEnabled=false; Status.Text="Ready: local verified package preparation is available; Launch is disabled until activation succeeds."; } catch(Exception ex) { Status.Text="Blocked: "+ex.Message; } } private async void Prepare_Click(object sender,System.Windows.RoutedEventArgs e) { if(localProfile is null) { Status.Text="Blocked: choose an explicit controlled local configuration."; return; } try { PrepareButton.IsEnabled=false; Status.Text="Preparing verified local package…"; prepared=await localService.PrepareAsync(localProfile,CancellationToken.None); PackageStatus.Text=$"Package: {prepared.Package.PackageId} {prepared.Package.Version}\nState: Active\nValidation: Passed"; LaunchButton.IsEnabled=true; Status.Text="Package active and verified. Launch Plant 3D is enabled."; } catch(Exception ex) { Status.Text="Prepare blocked: "+ex.Message; PrepareButton.IsEnabled=true; } } private async void Launch_Click(object sender,System.Windows.RoutedEventArgs e) { if(prepared is null) { Status.Text="Launch blocked: package is not active."; return; } try { LaunchButton.IsEnabled=false; Status.Text="Launching interactive Plant 3D 2026…"; var result=await localService.LaunchAsync(prepared,CancellationToken.None); Status.Text=result.TerminalState=="Succeeded"?$"Plant 3D started (PID {result.ProcessId}); PXP-OA load confirmed.":$"Launch blocked; evidence written. PID {result.ProcessId}."; LaunchButton.IsEnabled=true; } catch(Exception ex) { Status.Text="Launch failed: "+ex.Message; LaunchButton.IsEnabled=true; } } }