using System; using System.Collections.Generic; using System.Linq; using System.Windows; using System.Windows.Controls; using Comal.Classes; using InABox.Core; using InABox.DynamicGrid; namespace PRSDesktop; /// /// Interaction logic for UserPanel.xaml /// public partial class UserPanel : UserControl, IPanel { private readonly UserGrid Users; public UserPanel() { InitializeComponent(); Users = new UserGrid { HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch, Margin = new Thickness(0) }; Users.OnCustomiseEditor += Users_OnCustomiseEditor; AddChild(Users); } public event DataModelUpdateEvent? OnUpdateDataModel; public bool IsReady { get; set; } public Dictionary Selected() { return new Dictionary { { typeof(User).EntityName(), Users.SelectedRows } }; } public void Setup() { Users.Refresh(true, false); } public void Shutdown() { } public void CreateToolbarButtons(IPanelHost host) { } public void Refresh() { Users.Refresh(false, true); } public string SectionName => "Users"; public DataModel DataModel(Selection selection) { var ids = Users.ExtractValues(x => x.ID, selection).ToArray(); return new BaseDataModel(new Filter(x => x.ID).InList(ids)); } public void Heartbeat(TimeSpan time) { } private void Users_OnCustomiseEditor(IDynamicEditorForm sender, User[]? items, DynamicGridColumn column, BaseEditor editor) { if (editor is PasswordEditor pe) pe.ViewButtonVisible = Security.IsAllowed(); } }