1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- using System;
- using System.Collections.Generic;
- 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.Navigation;
- using System.Windows.Shapes;
- using static System.Windows.Forms.VisualStyles.VisualStyleElement.ListView;
- namespace InABox.DynamicGrid
- {
- /// <summary>
- /// Interaction logic for VerticalDynamicEditorGridLayout.xaml
- /// </summary>
- public partial class VerticalDynamicEditorGridLayout : DynamicEditorGridLayout
- {
- public VerticalDynamicEditorGridLayout()
- {
- InitializeComponent();
- }
- public override void LoadPages(IEnumerable<IDynamicEditorPage> pages)
- {
- Editors.Items.Clear();
- OtherPages.Items.Clear();
- foreach (var page in pages.OrderBy(x => x.PageType).ThenBy(x => x.Order()).ThenBy(x => x.Caption()))
- {
- var tab = new DynamicTabItem();
- tab.Header = page.Caption();
- tab.Content = page;
- if(page is DynamicEditorGrid.DynamicEditPage)
- {
- Editors.Items.Add(tab);
- }
- else
- {
- OtherPages.Items.Add(tab);
- }
- }
- }
- private bool bChanging;
- private void Editors_SelectionChanged(object sender, SelectionChangedEventArgs e)
- {
- if (bChanging) return;
- if ((e.OriginalSource != Editors && e.OriginalSource != OtherPages) || e.OriginalSource is not DynamicTabControl tabControl) return;
- if (tabControl.SelectedItem is not DynamicTabItem tab) return;
- bChanging = true;
- try
- {
- if (tab is not null && tab.Content is IDynamicEditorPage page)
- {
- SelectPage(page);
- }
- }
- finally
- {
- bChanging = false;
- }
- }
- }
- }
|