123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- <UserControl
- x:Class="PDF_Master.CustomControl.WritableComboBox"
- xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
- xmlns:local="clr-namespace:PDF_Master.CustomControl"
- xmlns:help="clr-namespace:PDF_Master.Helper"
- xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
- xmlns:convert="clr-namespace:PDF_Master.DataConvert"
- d:DesignHeight="24"
- d:DesignWidth="200"
- Loaded="UserControl_Loaded"
- mc:Ignorable="d">
- <UserControl.Resources>
- <convert:BoolToVisible x:Key="BoolToVisible"/>
- <Style x:Key="WarkTextBoxStyle" TargetType="{x:Type TextBox}">
- <Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.WindowBrushKey}}"/>
- <Setter Property="BorderBrush" Value="#FFABADB3"/>
- <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
- <Setter Property="BorderThickness" Value="1"/>
- <Setter Property="KeyboardNavigation.TabNavigation" Value="None"/>
- <Setter Property="HorizontalContentAlignment" Value="Left"/>
- <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
- <Setter Property="AllowDrop" Value="True"/>
- <Setter Property="ScrollViewer.PanningMode" Value="VerticalFirst"/>
- <Setter Property="Stylus.IsFlicksEnabled" Value="False"/>
- <Setter Property="Template">
- <Setter.Value>
- <ControlTemplate TargetType="{x:Type TextBox}">
- <Border x:Name="border" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" SnapsToDevicePixels="True">
- <Grid >
- <ScrollViewer x:Name="PART_ContentHost" Focusable="False" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden"/>
- <TextBlock x:Name="WARKTEXT" Text="{TemplateBinding Tag}" Foreground="#7F2F2F2F" Visibility="Collapsed" Padding="8,6,0,0"/>
- </Grid>
- </Border>
- <ControlTemplate.Triggers>
- <Trigger Property="IsEnabled" Value="False">
- <Setter Property="Opacity" TargetName="border" Value="0.56"/>
- </Trigger>
- <Trigger Property="IsMouseOver" Value="True">
- <Setter Property="BorderBrush" TargetName="border" Value="#FF7EB4EA"/>
- </Trigger>
- <Trigger Property="IsKeyboardFocused" Value="True">
- <Setter Property="BorderBrush" TargetName="border" Value="#FF569DE5"/>
- </Trigger>
- <MultiTrigger>
- <MultiTrigger.Conditions>
- <Condition Property="Text" Value=""/>
- <!--<Condition Property="IsFocused" Value="False"/>-->
- </MultiTrigger.Conditions>
- <Setter Property="Visibility" TargetName="WARKTEXT" Value="Visible"/>
- </MultiTrigger>
- </ControlTemplate.Triggers>
- </ControlTemplate>
- </Setter.Value>
- </Setter>
- <Style.Triggers>
- <MultiTrigger>
- <MultiTrigger.Conditions>
- <Condition Property="IsInactiveSelectionHighlightEnabled" Value="True"/>
- <Condition Property="IsSelectionActive" Value="False"/>
- </MultiTrigger.Conditions>
- <Setter Property="SelectionBrush" Value="{DynamicResource {x:Static SystemColors.InactiveSelectionHighlightBrushKey}}"/>
- </MultiTrigger>
- </Style.Triggers>
- </Style>
- </UserControl.Resources>
- <Grid>
- <ComboBox
- x:Name="writableComboBox"
- Grid.Column="1"
- MinWidth="58"
- MinHeight="24"
- MouseLeave="writableComboBox_MouseLeave"
- MouseEnter="writableComboBox_MouseEnter"
- VerticalContentAlignment="Center"
- SelectedIndex="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=local:WritableComboBox}, Path=SelectedIndex}"
- SelectionChanged="writableComboBox_SelectionChanged"
- Visibility="Visible">
- <ComboBoxItem x:Name="AllPageItem" Tag="AllPage" Visibility="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=local:WritableComboBox}, Path=IsAllPageVisible}"/>
- <ComboBoxItem x:Name="OddPageItem" Tag="OddPage"/>
- <ComboBoxItem x:Name="EvenPageItem" IsEnabled="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=local:WritableComboBox}, Path=EvenPageIsEnabled}" Tag="EvenPage"/>
- <ComboBoxItem x:Name="CustomPageItem" Tag="CustomPage"/>
- </ComboBox>
- <Border MinWidth="58" Grid.Column="1"
- MinHeight="24" BorderBrush="{StaticResource color.field.border.focus}" Effect="{StaticResource shadow.blue-0-4}" Visibility="{Binding ElementName=writableTextBox, Path=IsFocused, Converter={StaticResource BoolToVisible}}" BorderThickness="1" CornerRadius="4" Panel.ZIndex="1">
- </Border>
- <Border x:Name="ErrorBorder" MinWidth="58" Grid.Column="1"
- MinHeight="24" BorderBrush="{StaticResource color.field.border.error}" Effect="{StaticResource shadow.error.s}" Visibility="Collapsed" BorderThickness="1" CornerRadius="4" Panel.ZIndex="2">
- </Border>
- <TextBox
- x:Name="writableTextBox"
- Grid.Column="0"
- MinHeight="{Binding ElementName=writableComboBox, Path=MinHeight}"
- BorderBrush="{x:Null}"
- BorderThickness="0"
- Margin="2"
- HorizontalAlignment="Left"
- VerticalContentAlignment="Center"
- Panel.ZIndex="2"
- GotFocus="writableTextBox_GotFocus"
- LostFocus="writableTextBox_LostFocus"
- PreviewKeyDown="writableTextBox_PreviewKeyDown"
- InputMethod.IsInputMethodEnabled="False"
- PreviewTextInput="writableTextBox_PreviewTextInput"
- Text="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=local:WritableComboBox}, Path=Text}"
- TextChanged="writableTextBox_TextChange"
- Visibility="Hidden" Style="{StaticResource WarkTextBoxStyle}" Tag="例如1,3-5,10">
- <!--<TextBox.CaretBrush>
- <SolidColorBrush Color="#FF7EB4EA"/>
- </TextBox.CaretBrush>-->
- </TextBox>
- </Grid>
- </UserControl>
|