using Avalonia.Controls; using Avalonia.Interactivity; using Avalonia.Threading; using Avalonia.VisualTree; using Prism.Dialogs; using SopHelper.Engine.Sop; using SopHelper.Engine.Recipes; using SopHelper.VVMs.RecipeEditor; internal static class RecipeCloseChecks { public static void Run(string root) { var store = new RecipeWorkspace(root); var config = new SopConfig(); config.Sop.Name = "关闭保存验证"; var savedCalls = 0; RecipeEditorViewModel Create(bool isNew) { var model = new RecipeEditorViewModel(); model.OnDialogOpened(new DialogParameters { { "directory", store.RecipesDirectory }, { "config", config }, { "path", isNew ? "" : store.ConfigPath(config.Sop.Name) }, { "new", isNew }, { "onSaved", new Action(_ => savedCalls++) } }); return model; } var model = Create(true); var view = new RecipeEditor { DataContext = model }; var window = new Window { Content = view, Width = 1040, Height = 800 }; window.Show(); window.Close(); Until(() => window.OwnedWindows.Any()); var prompt = window.OwnedWindows.Single(); var buttons = prompt.GetVisualDescendants().OfType