1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- using InABox.Core;
- using InABox.Database;
- using InABox.DynamicGrid;
- using InABox.Wpf;
- using System;
- using System.Collections.Generic;
- using System.Globalization;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Data;
- using System.Windows.Documents;
- using System.Windows.Input;
- using System.Windows.Media;
- using System.Windows.Media.Imaging;
- using System.Windows.Shapes;
- using static System.Windows.Forms.VisualStyles.VisualStyleElement.ListView;
- namespace PRSServer.Forms
- {
- /// <summary>
- /// Interaction logic for ViewDeletionWindow.xaml
- /// </summary>
- public partial class ViewDeletionWindow : ThemableWindow
- {
- private Deletion Deletion { get; set; }
- private DeletionData DeletionData { get; set; }
- private HashSet<DynamicTabItem> _loaded = new();
- public ViewDeletionWindow(Deletion deletion)
- {
- InitializeComponent();
- Deletion = deletion;
- DeletionData = Serialization.Deserialize<DeletionData>(deletion.Data) ?? new();
- Pages.SelectionChanged += PagesSelectionChanged;
- LoadPages();
- }
- private void PagesSelectionChanged(object sender, SelectionChangedEventArgs e)
- {
- var tab = Pages.SelectedItem as DynamicTabItem;
- if (!_loaded.Contains(tab))
- {
- var grid = tab.Content as IDynamicGrid;
- grid.Refresh(true, true);
- _loaded.Add(tab);
- }
- }
- private void LoadPages()
- {
- foreach(var (entityName, cascade) in DeletionData.Cascades)
- {
- if (!CoreUtils.TryGetEntity(entityName, out var entityType)) continue;
- var title = new Inflector.Inflector(new CultureInfo("en")).Pluralize(CoreUtils.GetCaption(entityType));
- var tab = new DynamicTabItem() { Header = title };
- var grid = Activator.CreateInstance(typeof(DeletedEntityGrid<>).MakeGenericType(entityType), cascade) as IDynamicGrid;
- grid.Refresh(true, true);
- tab.Content = grid;
- Pages.Items.Add(tab);
- }
- }
- }
- }
|