1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- 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;
- /// <summary>
- /// Interaction logic for UserPanel.xaml
- /// </summary>
- public partial class UserPanel : UserControl, IPanel<User>
- {
- 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<string, object[]> Selected()
- {
- return new Dictionary<string, object[]> { { 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<User>(new Filter<User>(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<CanViewPasswords>();
- }
- }
|