ExcelHelper/Views/Pages/ImportExcelPage.xaml

170 lines
7.3 KiB
XML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<Page
x:Class="ExcelHelper.Views.Pages.ImportExcelPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:converter="clr-namespace:ExcelHelper.Converter"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:hc="https://handyorg.github.io/handycontrol"
xmlns:local="clr-namespace:ExcelHelper.Views.Pages"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:utils="clr-namespace:ExcelHelper.Utils"
xmlns:viewmodels="clr-namespace:ExcelHelper.Views.ViewModels"
Title="ImportExcelPage"
d:DataContext="{d:DesignInstance Type=viewmodels:ImportViewModel}"
d:DesignHeight="450"
d:DesignWidth="1200"
mc:Ignorable="d">
<Page.Resources>
<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
<converter:ReBooleanToVisibilityConverter x:Key="ReBooleanToVisibilityConverter" />
<DataTemplate x:Key="Mask">
<Grid Background="#99424242">
<TextBlock
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="20"
Foreground="White"
Text="拖拽到此处放开" />
</Grid>
</DataTemplate>
<DataTemplate x:Key="LoadingMask">
<Grid Background="#99424242">
<hc:CircleProgressBar
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="20"
Foreground="White"
IsIndeterminate="True"
Text="加载中" />
</Grid>
</DataTemplate>
</Page.Resources>
<Grid
AllowDrop="True"
DragEnter="Grid_DragEnter"
DragLeave="Grid_DragLeave"
Drop="Grid_Drop">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" MinWidth="800" />
<ColumnDefinition Width="370" MinWidth="370" />
</Grid.ColumnDefinitions>
<ContentPresenter
x:Name="DropFileMask"
Grid.Column="0"
Grid.ColumnSpan="2"
Panel.ZIndex="10"
Content="{Binding}"
ContentTemplate="{StaticResource Mask}"
Visibility="Collapsed" />
<ContentPresenter
x:Name="LoadingMask"
Grid.Column="0"
Grid.ColumnSpan="2"
Panel.ZIndex="10"
Content="{Binding}"
ContentTemplate="{StaticResource LoadingMask}"
Visibility="{Binding IsLoading, Converter={StaticResource Boolean2VisibilityConverter}}" />
<hc:TabControl Grid.Column="0" Margin="5,5,7,5">
<hc:TabItem Header="预览">
<DataGrid
x:Name="ExcelDataPreviewGrid"
hc:DataGridAttach.ShowRowNumber="True"
AutoGenerateColumns="False"
EnableColumnVirtualization="True"
EnableRowVirtualization="True"
IsReadOnly="True"
ItemsSource="{Binding ExcelData, IsAsync=True}"
ScrollViewer.CanContentScroll="True"
VirtualizingPanel.IsContainerVirtualizable="True"
VirtualizingPanel.IsVirtualizing="True"
VirtualizingPanel.VirtualizationMode="Recycling" />
</hc:TabItem>
<hc:TabItem Header="列信息">
<DataGrid
AutoGenerateColumns="False"
IsReadOnly="True"
ItemsSource="{Binding ExcelColumns, IsAsync=True}">
<DataGrid.Columns>
<DataGridTextColumn Binding="{Binding Header}" Header="列" />
</DataGrid.Columns>
</DataGrid>
</hc:TabItem>
</hc:TabControl>
<GridSplitter
Grid.Column="0"
Width="2"
Margin="0,5" />
<GroupBox
Grid.Column="1"
Margin="5"
Padding="5">
<GroupBox.Header>
<StackPanel Orientation="Horizontal">
<TextBlock
Margin="5,0"
VerticalAlignment="Center"
Text="参数配置" />
<Button
VerticalAlignment="Center"
Command="{Binding ReLoadExcelCommand}"
Content="重新读取Excel" />
</StackPanel>
</GroupBox.Header>
<hc:SimpleStackPanel SnapsToDevicePixels="True">
<hc:SimpleStackPanel.Resources>
<Style TargetType="{x:Type hc:SimpleStackPanel}">
<Setter Property="Margin" Value="5,0" />
</Style>
</hc:SimpleStackPanel.Resources>
<hc:SimpleStackPanel Orientation="Horizontal">
<Label Content="指定的Sheet" />
<hc:ComboBox
MinWidth="60"
Margin="0"
ItemsSource="{Binding Sheets}"
SelectedValue="{Binding SelectedSheetName}" />
<Button
Margin="0"
VerticalAlignment="Center"
Command=""
Content="读取" />
</hc:SimpleStackPanel>
<hc:SimpleStackPanel Height="Auto" Orientation="Horizontal">
<Label Content="起始位置:" />
<hc:TextBox MinWidth="40" Text="{Binding StartCell}" />
<CheckBox Content="包含列头" IsChecked="{Binding UseHeaderRow}" />
</hc:SimpleStackPanel>
<hc:SimpleStackPanel IsEnabled="False" Orientation="Horizontal">
<Label Content="结束位置:" />
<hc:TextBox MinWidth="40" Text="{Binding EndCell}" />
</hc:SimpleStackPanel>
<hc:SimpleStackPanel Orientation="Horizontal">
<Label Content="最大读取行数:" />
<hc:NumericUpDown
MinWidth="40"
Minimum="0"
Value="{Binding MaxRow}" />
</hc:SimpleStackPanel>
<hc:SimpleStackPanel Width="Auto" Orientation="Horizontal">
<Label Content="当前文件路径:" />
<!--<hc:TextBox MinWidth="200" />-->
<hc:ComboBox
MaxWidth="200"
ItemsSource="{Binding ExcelFiles}"
SelectedValue="{Binding CurrentFilePath}" />
</hc:SimpleStackPanel>
<hc:SimpleStackPanel Orientation="Horizontal">
<Label Content="Excel密码" />
<PasswordBox MinWidth="60" utils:PasswordBoxHelper.Password="{Binding ExcelPassword, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
<Button Content="?" ToolTip="未加密留空多个Excel如果不同密码请分批次导入" />
</hc:SimpleStackPanel>
</hc:SimpleStackPanel>
</GroupBox>
</Grid>
</Page>