| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 | using System;using System.Collections.Concurrent;using System.Collections.Generic;using System.Diagnostics.CodeAnalysis;using System.Linq;using System.Windows;using InABox.Core;namespace InABox.DynamicGrid;public enum PageType{    Editor,    Other}public interface IDynamicEditorPage{    DynamicEditorGrid EditorGrid { get; set; }    PageType PageType { get; }    bool Ready { get; set; }    /// <summary>    /// Is this page visible?    /// </summary>    /// <remarks>    /// Based on security tokens and the likes.    /// </remarks>    bool Visible { get; }    bool ReadOnly { get; set; }    int Order { get; set; }    void Load(object item, Func<Type, CoreTable?>? PageDataHandler);    /// <summary>    /// Called when the "OK" button is clicked on an editor, and before the item is saved.    /// </summary>    /// <param name="item"></param>    void BeforeSave(object item);    /// <summary>    /// Called when the "OK" button is clicked on an editor, and after the item is saved.    /// </summary>    /// <remarks>    /// Generally used to save any child entities that need to be saved, since now the parent has a valid <see cref="Entity.ID"/>.    /// </remarks>    /// <param name="item"></param>    void AfterSave(object item);    event EventHandler OnChanged;    void DoChanged();    void Cancel();    Size MinimumSize();    string Caption();}public class DynamicEditorPages : List<IDynamicEditorPage>{    public DynamicEditorPages() : base()    {            }    public DynamicEditorPages(IEnumerable<IDynamicEditorPage> pages) : this()    {        foreach (var page in pages)            Add(page);    }    public bool TryGetPage<T>([NotNullWhen(true)] out T? page)        where T : IDynamicEditorPage    {        page = this.OfType<T>().FirstOrDefault();        return page is not null;    }}
 |