31 行
972 B
C#
31 行
972 B
C#
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<Window>())
|
|
.Select(window => window?.DataContext)
|
|
.OfType<IMainViewModel>()
|
|
.Select(model => model.Index)
|
|
.DefaultIfEmpty(0)
|
|
.First();
|
|
var states = SettingsBase<YMMSettings>.Default.MainWindowStates;
|
|
return index >= 0 && index < states.Count ? states[index].ProjectPath : null;
|
|
}
|
|
}
|