30 行
941 B
C#
30 行
941 B
C#
using System.Windows;
|
|
using YukkuriMovieMaker.Plugin;
|
|
using YukkuriMovieMaker.Settings;
|
|
using YukkuriMovieMaker.ViewModels;
|
|
|
|
namespace UndoTree;
|
|
|
|
internal static class UndoTreeProject
|
|
{
|
|
public static string? PathOfOnlyWindow()
|
|
{
|
|
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 indexes = application.Windows.OfType<Window>()
|
|
.Select(window => window.DataContext)
|
|
.OfType<IMainViewModel>()
|
|
.Select(model => model.Index)
|
|
.Distinct()
|
|
.ToArray();
|
|
var states = SettingsBase<YMMSettings>.Default.MainWindowStates;
|
|
return indexes is [var index] && index >= 0 && index < states.Count ? states[index].ProjectPath : null;
|
|
}
|
|
}
|