ExcelHelper/Views/Pages/ImportExcelPage.xaml

208 lines
8.8 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="拖拽Excel文件(.xls)到此处放开" />
</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="200" />
<ColumnDefinition
Width="370"
MinWidth="370"
MaxWidth="600" />
</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"
ShowCloseButton="False"
ShowContextMenu="False">
<hc:TabItem Header="预览">
<DataGrid
x:Name="ExcelDataPreviewGrid"
AutoGenerateColumns="False"
EnableColumnVirtualization="True"
EnableRowVirtualization="True"
IsReadOnly="True"
ItemsSource="{Binding ExcelData, IsAsync=True}"
RowHeight="NaN"
ScrollViewer.CanContentScroll="True"
VirtualizingPanel.IsContainerVirtualizable="True"
VirtualizingPanel.IsVirtualizing="True"
VirtualizingPanel.VirtualizationMode="Recycling" />
</hc:TabItem>
<hc:TabItem Header="Columns2Prompt">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="50" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<ToolBar
Grid.Row="0"
AllowDrop="False"
Header="操作">
<Button Content="导出文件" />
<Label>
<CheckBox Content="示例数据" />
</Label>
</ToolBar>
<hc:TextBox
Grid.Row="1"
Padding="5"
VerticalContentAlignment="Top"
AcceptsReturn="True"
Text="{Binding PromptString}"
TextWrapping="Wrap"
VerticalScrollBarVisibility="Auto" />
</Grid>
</hc:TabItem>
</hc:TabControl>
<GridSplitter
Grid.Column="0"
Width="2"
Margin="0,5" />
<hc:Card
Grid.Column="1"
Width="Auto"
Margin="5"
HorizontalAlignment="Stretch">
<hc:Card.Header>
<hc:SimpleStackPanel
Margin="5"
HorizontalAlignment="Center"
Orientation="Horizontal">
<TextBlock
Margin="5,0"
VerticalAlignment="Center"
Text="参数配置" />
<Button
VerticalAlignment="Center"
Command="{Binding ReLoadExcelCommand}"
Content="重新读取Excel"
Style="{StaticResource ButtonPrimary}" />
</hc:SimpleStackPanel>
</hc:Card.Header>
<hc:SimpleStackPanel SnapsToDevicePixels="True">
<hc:SimpleStackPanel.Resources>
<Style TargetType="{x:Type hc:SimpleStackPanel}">
<Setter Property="Margin" Value="5,5" />
</Style>
</hc:SimpleStackPanel.Resources>
<hc:SimpleStackPanel Orientation="Horizontal">
<Label Content="指定的Sheet" />
<hc:ComboBox
MinWidth="60"
MaxWidth="180"
Margin="0"
ItemsSource="{Binding Sheets}"
SelectedValue="{Binding SelectedSheetName}" />
<Button
Margin="0"
VerticalAlignment="Center"
Command="{Binding ReadSheetsCommand}"
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 Orientation="Horizontal">
<Label Content="结束位置:" />
<hc:TextBox MinWidth="40" Text="{Binding EndCell}" />
</hc:SimpleStackPanel>
<hc:SimpleStackPanel Orientation="Horizontal">
<Label>
<CheckBox Content="合并的单元格进行填充" IsChecked="{Binding FillMergedCells}" />
</Label>
</hc:SimpleStackPanel>
<hc:SimpleStackPanel Orientation="Horizontal">
<Label Content="最大读取行数:" />
<hc:NumericUpDown
MinWidth="40"
Maximum="300"
Minimum="0"
Value="{Binding MaxRow}" />
<TextBlock
Margin="5,0"
VerticalAlignment="Center"
Text="预览时最大读取300行" />
</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 IsEnabled="False" 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>
</hc:Card>
</Grid>
</Page>