|
@@ -13,87 +13,86 @@ using System.Windows.Media.Imaging;
|
|
|
using System.Windows.Navigation;
|
|
|
using System.Windows.Shapes;
|
|
|
|
|
|
-namespace InABox.DynamicGrid
|
|
|
+namespace InABox.DynamicGrid;
|
|
|
+
|
|
|
+/// <summary>
|
|
|
+/// Interaction logic for VerticalDynamicEditorGridLayout.xaml
|
|
|
+/// </summary>
|
|
|
+public partial class VerticalDynamicEditorGridLayout : DynamicEditorGridLayout
|
|
|
{
|
|
|
- /// <summary>
|
|
|
- /// Interaction logic for VerticalDynamicEditorGridLayout.xaml
|
|
|
- /// </summary>
|
|
|
- public partial class VerticalDynamicEditorGridLayout : DynamicEditorGridLayout
|
|
|
+
|
|
|
+ public override bool TabStripVisible
|
|
|
{
|
|
|
-
|
|
|
- public override bool TabStripVisible
|
|
|
- {
|
|
|
- get { return Editors.TabStripVisible; }
|
|
|
- set { Editors.TabStripVisible = value; }
|
|
|
- }
|
|
|
+ get { return Editors.TabStripVisible; }
|
|
|
+ set { Editors.TabStripVisible = value; }
|
|
|
+ }
|
|
|
|
|
|
- private double _totalWidth;
|
|
|
- public override double TotalWidth => _totalWidth;
|
|
|
+ private double _totalWidth;
|
|
|
+ public override double TotalWidth => _totalWidth;
|
|
|
|
|
|
- private double _editorHeight;
|
|
|
- private double _pageHeight;
|
|
|
- public override double TotalHeight => _editorHeight + _pageHeight;
|
|
|
+ private double _editorHeight;
|
|
|
+ private double _pageHeight;
|
|
|
+ public override double TotalHeight => _editorHeight + _pageHeight;
|
|
|
|
|
|
- public VerticalDynamicEditorGridLayout()
|
|
|
- {
|
|
|
- InitializeComponent();
|
|
|
- }
|
|
|
+ public VerticalDynamicEditorGridLayout()
|
|
|
+ {
|
|
|
+ InitializeComponent();
|
|
|
+ }
|
|
|
|
|
|
- public override void LoadPages(IEnumerable<IDynamicEditorPage> pages)
|
|
|
+ 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()))
|
|
|
{
|
|
|
- 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();
|
|
|
- if (page is FrameworkElement element)
|
|
|
- element.Margin = new Thickness(0, 2, 0, 0);
|
|
|
- tab.Content = page;
|
|
|
+ var tab = new DynamicTabItem();
|
|
|
+ tab.Header = page.Caption();
|
|
|
+ if (page is FrameworkElement element)
|
|
|
+ element.Margin = new Thickness(0, 2, 0, 0);
|
|
|
+ tab.Content = page;
|
|
|
|
|
|
- var minSize = page.MinimumSize();
|
|
|
-
|
|
|
- if(page is DynamicEditorGrid.DynamicEditPage)
|
|
|
- {
|
|
|
- Editors.Items.Add(tab);
|
|
|
- _editorHeight = Math.Max(_editorHeight, minSize.Height);
|
|
|
- _totalWidth = Math.Max(_totalWidth, minSize.Width);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- OtherPages.Items.Add(tab);
|
|
|
- _pageHeight = Math.Max(_pageHeight, minSize.Height);
|
|
|
- }
|
|
|
+ var minSize = page.MinimumSize();
|
|
|
|
|
|
+ if(page is DynamicEditorGrid.DynamicEditPage)
|
|
|
+ {
|
|
|
+ Editors.Items.Add(tab);
|
|
|
+ _editorHeight = Math.Max(_editorHeight, minSize.Height);
|
|
|
+ _totalWidth = Math.Max(_totalWidth, minSize.Width);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ OtherPages.Items.Add(tab);
|
|
|
+ _pageHeight = Math.Max(_pageHeight, minSize.Height);
|
|
|
}
|
|
|
|
|
|
- Editors.SelectedIndex = 0;
|
|
|
}
|
|
|
|
|
|
- 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;
|
|
|
+ Editors.SelectedIndex = 0;
|
|
|
+ }
|
|
|
|
|
|
- bChanging = true;
|
|
|
- try
|
|
|
- {
|
|
|
- if (tab is not null && tab.Content is IDynamicEditorPage page)
|
|
|
- {
|
|
|
- SelectPage(page);
|
|
|
- }
|
|
|
- }
|
|
|
- finally
|
|
|
+ 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)
|
|
|
{
|
|
|
- bChanging = false;
|
|
|
+ SelectPage(page);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- private void Grid_SizeChanged(object sender, SizeChangedEventArgs e)
|
|
|
+ finally
|
|
|
{
|
|
|
- EditorRow.MaxHeight = e.NewSize.Height - 50;
|
|
|
+ bChanging = false;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ private void Grid_SizeChanged(object sender, SizeChangedEventArgs e)
|
|
|
+ {
|
|
|
+ EditorRow.MaxHeight = e.NewSize.Height - 50;
|
|
|
+ }
|
|
|
}
|