Bläddra i källkod

Added special layout for Bill screen

Kenric Nugteren 1 år sedan
förälder
incheckning
f1aae0d613

+ 50 - 0
prs.desktop/Panels/Suppliers/Bills/SupplierBillEditLayout.xaml

@@ -0,0 +1,50 @@
+<dynamicGrid:DynamicEditorGridLayout
+    x:Class="PRSDesktop.SupplierBillEditLayout"
+    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
+    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
+    xmlns:local="clr-namespace:PRSDesktop"
+    xmlns:dynamicGrid="clr-namespace:InABox.DynamicGrid;assembly=InABox.Wpf"
+    xmlns:sf="http://schemas.syncfusion.com/wpf"
+    mc:Ignorable="d" 
+    d:DesignHeight="450" d:DesignWidth="800">
+
+    <Grid DataContext="{Binding RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type local:SupplierBillEditLayout}}}">
+        <Grid.RowDefinitions>
+            <RowDefinition Height="Auto"/>
+            <RowDefinition Height="Auto"/>
+            <RowDefinition Height="*"/>
+        </Grid.RowDefinitions>
+        <Grid.ColumnDefinitions>
+            <ColumnDefinition Width="*"/>
+            <ColumnDefinition Width="Auto"/>
+            <ColumnDefinition Width="{Binding DocumentWidth}"/>
+        </Grid.ColumnDefinitions>
+        <dynamicGrid:DynamicTabControl x:Name="Editors"
+                                       Grid.Row="0"
+                                       Grid.Column="0"
+                                       SelectionChanged="Editors_SelectionChanged"/>
+        <sf:SfGridSplitter Grid.Row="1" Grid.Column="0"
+                           Height="4"
+                           HorizontalAlignment="Stretch"
+                           Background="Transparent"
+                           ResizeBehavior="PreviousAndNext"
+                           Template="{StaticResource HorizontalSplitter}"
+                           PreviewStyle="{StaticResource HorizontalSplitterPreview}"/>
+        <dynamicGrid:DynamicTabControl x:Name="OtherPages"
+                                       Grid.Row="2" Grid.Column="0"
+                                       SelectionChanged="Editors_SelectionChanged"
+                                       TabStripPlacement="Bottom"/>
+        <sf:SfGridSplitter Grid.Row="0" Grid.RowSpan="3"
+                           Grid.Column="1"
+                           Width="4"
+                           VerticalAlignment="Stretch"
+                           Background="Transparent"
+                           ResizeBehavior="PreviousAndNext"
+                           Template="{StaticResource VerticalSplitter}"/>
+        <ContentControl x:Name="DocumentControl"
+                        Grid.Row="0" Grid.RowSpan="3"
+                        Grid.Column="2"/>
+    </Grid>
+</dynamicGrid:DynamicEditorGridLayout>

+ 112 - 0
prs.desktop/Panels/Suppliers/Bills/SupplierBillEditLayout.xaml.cs

@@ -0,0 +1,112 @@
+using Comal.Classes;
+using InABox.DynamicGrid;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Linq;
+using System.Runtime.CompilerServices;
+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;
+
+namespace PRSDesktop;
+
+/// <summary>
+/// Interaction logic for SupplierBillEditLayout.xaml
+/// </summary>
+public partial class SupplierBillEditLayout : DynamicEditorGridLayout, INotifyPropertyChanged
+{
+    public override bool TabStripVisible
+    {
+        get { return Editors.TabStripVisible; }
+        set { Editors.TabStripVisible = value; }
+    }
+
+    private double _documentWidth = 400;
+    public double DocumentWidth
+    {
+        get => _documentWidth;
+        set
+        {
+            _documentWidth = value;
+            OnPropertyChanged();
+        }
+    }
+
+    public SupplierBillEditLayout()
+    {
+        InitializeComponent();
+    }
+
+    public override void LoadPages(IEnumerable<IDynamicEditorPage> pages)
+    {
+        Editors.Items.Clear();
+        OtherPages.Items.Clear();
+        DocumentControl.Content = null;
+
+        foreach (var page in pages.OrderBy(x => x.PageType).ThenBy(x => x.Order()).ThenBy(x => x.Caption()))
+        {
+            if(page is DynamicDocumentGrid<BillDocument, Bill, BillLink>)
+            {
+                DocumentControl.Content = page;
+            }
+            else
+            {
+                var tab = new DynamicTabItem();
+                tab.Header = page.Caption();
+                if (page is FrameworkElement element)
+                    element.Margin = new Thickness(0, 2, 0, 0);
+                tab.Content = page;
+
+                if (page is DynamicEditorGrid.DynamicEditPage)
+                {
+                    Editors.Items.Add(tab);
+                }
+                else
+                {
+                    OtherPages.Items.Add(tab);
+                }
+            }
+        }
+
+        Editors.SelectedIndex = 0;
+        OtherPages.SelectedIndex = 0;
+    }
+
+    private bool bChanging;
+
+    public event PropertyChangedEventHandler? PropertyChanged;
+
+    protected void OnPropertyChanged([CallerMemberName] string propertyName = "")
+    {
+        PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
+    }
+
+    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;
+        }
+    }
+}

+ 1 - 1
prs.desktop/Panels/Suppliers/Bills/SupplierBillPanel.xaml.cs

@@ -76,7 +76,7 @@ public partial class SupplierBillPanel : UserControl, IPanel<Bill>
             settings.ViewType == ScreenViewType.Details ? DynamicSplitPanelView.Detail : DynamicSplitPanelView.Combined;
         SplitPanel.AnchorWidth = settings.AnchorWidth;
 
-        Bill.SetLayoutType<VerticalDynamicEditorGridLayout>();
+        Bill.SetLayoutType<SupplierBillEditLayout>();
         Bills.Refresh(true, false);
     }