using System.Windows; using YukkuriMovieMaker.Commons; using YukkuriMovieMaker.Plugin; using YukkuriMovieMaker.Settings; using YukkuriMovieMaker.ViewModels; namespace UndoTree; internal static class UndoTreeProject { public static string? PathOf() { if (Application.Current is not { } application) return null; return application.Dispatcher.CheckAccess() ? Read(application) : application.Dispatcher.Invoke(() => Read(application)); } static string? Read(Application application) { var index = new ZOrderedWindowEnumerable(application.Windows.OfType()) .Select(window => window?.DataContext) .OfType() .Select(model => model.Index) .DefaultIfEmpty(0) .First(); var states = SettingsBase.Default.MainWindowStates; return index >= 0 && index < states.Count ? states[index].ProjectPath : null; } }