ntwain/samples/Sample.WPF/MainWindow.xaml
2017-02-03 07:06:44 -05:00

118 lines
5.8 KiB
XML

<Window x:Class="Sample.WPF.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:modern="http://modernwpf"
xmlns:proj="clr-namespace:Sample.WPF"
Title="{Binding AppTitle}"
Height="600" Width="900" ResizeMode="CanResizeWithGrip"
x:Name="theWindow"
Style="{StaticResource AppWindow}">
<Window.Resources>
<proj:TwainVM x:Key="vm"></proj:TwainVM>
</Window.Resources>
<Window.DataContext>
<StaticResource ResourceKey="vm"></StaticResource>
</Window.DataContext>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto" />
<ColumnDefinition Width="auto" />
<ColumnDefinition Width="auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Label Content="Sources"></Label>
<ListBox x:Name="SrcList" Grid.Row="1" Grid.RowSpan="2" Width="150"
ItemsSource="{Binding DataSources}"
SelectedItem="{Binding SelectedSource}"
Style="{StaticResource AppListBox}">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel>
<TextBlock Text="{Binding Name}" TextWrapping="Wrap"></TextBlock>
<TextBlock Text="{Binding Version, StringFormat='Version {0}'}" TextWrapping="Wrap" Foreground="{DynamicResource ModernForeground2}"
Margin="8 0 0 0"/>
<TextBlock Text="{Binding Protocol, StringFormat='TWAIN {0}'}" Foreground="{DynamicResource ModernForeground2}"
Margin="8 0 0 0"/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<StackPanel Orientation="Horizontal" Grid.Column="1">
<Label Content="Caps" Grid.Column="1"></Label>
<Button Content="Save Reported" Command="{Binding SaveCapValuesCommand}" DataContext="{Binding SelectedSource}"></Button>
</StackPanel>
<TextBox Text="{Binding CapFilter, UpdateSourceTrigger=PropertyChanged}" DataContext="{Binding SelectedSource}"
Grid.Column="1" Grid.Row="1"
modern:TextBoxUI.WatermarkText="Find cap name"></TextBox>
<ListBox x:Name="CapList" Grid.Row="2" Grid.Column="1" Width="150"
DataContext="{Binding SelectedSource}"
ItemsSource="{Binding Caps}"
SelectionChanged="CapList_SelectionChanged"
Style="{StaticResource AppListBox}">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel>
<TextBlock Text="{Binding Name}" ></TextBlock>
<TextBlock Text="{Binding Supports}" TextWrapping="Wrap" Foreground="{DynamicResource ModernForeground2}"
FontStyle="Italic"/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<Label Content="Cap values" Grid.Column="2"></Label>
<ListBox x:Name="CapDetailList" Grid.Row="1" Grid.RowSpan="2" Grid.Column="2" MinWidth="100"
SelectionChanged="CapDetailList_SelectionChanged"
ScrollViewer.CanContentScroll="True"
Style="{StaticResource AppListBox}">
<ListBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding}"></TextBlock>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<StackPanel Orientation="Horizontal" Grid.Column="3" >
<Label Content="State:"></Label>
<TextBlock Text="{Binding State}"></TextBlock>
<Button Content="S_ettings" Command="{Binding ShowDriverCommand}"></Button>
<Button Content="S_tart" Command="{Binding CaptureCommand}"></Button>
<CheckBox Content="Show _UI" IsChecked="{Binding ShowUI}"></CheckBox>
<Slider Maximum="{Binding MaxThumbnailSize}" Minimum="{Binding MinThumbnailSize}"
Value="{Binding ThumbnailSize}" Width="100" LargeChange="20" SmallChange="10"
VerticalAlignment="Center"
ToolTip="{Binding ThumbnailSize}"></Slider>
<TextBlock Text="{Binding CapturedImages.Count, StringFormat='{}{0} pages'}"></TextBlock>
<Button Content="_Clear pages" Command="{Binding ClearCommand}"></Button>
<!--<Button Content="_Save" Command="{Binding SaveCommand}"></Button>-->
</StackPanel>
<ListBox Grid.Row="1" Grid.RowSpan="2" Grid.Column="3"
ItemsSource="{Binding CapturedImages}">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel ScrollViewer.HorizontalScrollBarVisibility="Disabled"></WrapPanel>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.ItemTemplate>
<DataTemplate>
<Border Padding="4">
<Image Stretch="Uniform"
RenderOptions.BitmapScalingMode="HighQuality"
Width="{Binding ElementName=theWindow, Path=DataContext.ThumbnailSize}"
Height="{Binding ElementName=theWindow, Path=DataContext.ThumbnailSize}"
Source="{Binding}"></Image>
</Border>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
</Window>