<UserControl xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:loc="using:NewLife.XCoder.Services"
xmlns:models="using:NewLife.XCoder.Models"
x:Class="NewLife.XCoder.Tools.Regex.RegexToolView">
<UserControl.Styles>
<Style Selector="ListBox.ResultTable">
<Setter Property="CornerRadius" Value="8" />
<Setter Property="Padding" Value="0" />
</Style>
<Style Selector="ListBox.ResultTable ListBoxItem">
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
<Setter Property="Padding" Value="8,4" />
<Setter Property="MinHeight" Value="26" />
</Style>
<Style Selector="TextBlock.tableHeader">
<Setter Property="FontSize" Value="11" />
<Setter Property="FontWeight" Value="SemiBold" />
<Setter Property="Foreground" Value="{DynamicResource TextTertiary}" />
<Setter Property="Margin" Value="8,0" />
<Setter Property="VerticalAlignment" Value="Center" />
</Style>
<Style Selector="TextBlock.cell">
<Setter Property="FontSize" Value="12" />
<Setter Property="TextTrimming" Value="CharacterEllipsis" />
<Setter Property="VerticalAlignment" Value="Center" />
</Style>
<Style Selector="TextBlock.cellNum">
<Setter Property="FontSize" Value="12" />
<Setter Property="Foreground" Value="{DynamicResource TextSecondary}" />
<Setter Property="HorizontalAlignment" Value="Right" />
<Setter Property="VerticalAlignment" Value="Center" />
</Style>
</UserControl.Styles>
<ScrollViewer Name="PageScroll" Margin="20"
HorizontalScrollBarVisibility="Disabled"
VerticalScrollBarVisibility="Auto">
<Grid Name="PageRoot" RowDefinitions="Auto,*" RowSpacing="12"
MinHeight="{Binding #PageScroll.Viewport.Height}">
<StackPanel Spacing="2">
<TextBlock Text="{loc:Tr 'Regular expression'}" Classes="sectionTitle" />
<TextBlock Text="{loc:Tr 'Match, replace and inspect capture groups; expressions have a 2-second timeout.'}" Classes="dim" TextWrapping="Wrap" />
<TextBlock Text="{loc:Tr 'Right-click the pattern or input box to insert templates'}" Classes="dim" TextWrapping="Wrap" />
</StackPanel>
<Border Grid.Row="1" Classes="panel" Padding="16" MinHeight="560">
<Grid RowDefinitions="Auto,Auto,*,Auto,Auto" RowSpacing="10">
<Grid ColumnDefinitions="*,Auto" ColumnSpacing="8">
<TextBox Name="PatternBox" AcceptsReturn="True" AcceptsTab="True" MinHeight="72"
TextWrapping="NoWrap" FontFamily="{DynamicResource FontMono}"
PlaceholderText="{loc:Tr 'Regular expression, e.g. ([0-9]{4})-([0-9]{2})-([0-9]{2})'}" />
<StackPanel Grid.Column="1" Orientation="Horizontal" Spacing="6" VerticalAlignment="Top">
<Button Name="MatchButton" Classes="primary" Content="{loc:Tr 'Match'}" />
<Button Name="ReplaceButton" Classes="secondary" Content="{loc:Tr 'Replace'}" />
</StackPanel>
</Grid>
<WrapPanel Grid.Row="1" Orientation="Horizontal">
<CheckBox Name="IgnoreCaseBox" Content="{loc:Tr 'Ignore case'}" FontSize="12" Margin="0,0,14,6" />
<CheckBox Name="MultilineBox" Content="{loc:Tr 'Multi-line mode'}" FontSize="12" Margin="0,0,14,6" />
<CheckBox Name="SinglelineBox" Content="{loc:Tr 'Single-line mode'}" FontSize="12" Margin="0,0,14,6" />
<CheckBox Name="IgnorePatternWhitespaceBox" Content="{loc:Tr 'Ignore whitespace'}" FontSize="12" Margin="0,0,14,6" />
<TextBlock Text="{loc:Tr 'Replacement (supports $1)'}" Classes="dim" VerticalAlignment="Center" Margin="0,0,6,6" />
<TextBox Name="ReplacementBox" Width="220" Margin="0,0,0,6" PlaceholderText="$1/$2/$3" />
</WrapPanel>
<Grid Grid.Row="2" ColumnDefinitions="*,*" ColumnSpacing="12" MinHeight="170">
<Grid RowDefinitions="Auto,*" RowSpacing="6">
<TextBlock Text="{loc:Tr 'Input text'}" FontWeight="SemiBold" />
<TextBox Grid.Row="1" Name="InputBox" AcceptsReturn="True" AcceptsTab="True" MinHeight="170"
TextWrapping="Wrap" FontFamily="{DynamicResource FontMono}"
ClearSelectionOnLostFocus="False"
IsInactiveSelectionHighlightEnabled="True"
PlaceholderText="{loc:Tr 'Paste text to match'}" />
</Grid>
<Grid Grid.Column="1" RowDefinitions="Auto,*" RowSpacing="6">
<TextBlock Text="{loc:Tr 'Result'}" FontWeight="SemiBold" />
<TextBox Grid.Row="1" Name="OutputBox" AcceptsReturn="True" MinHeight="170"
TextWrapping="NoWrap" IsReadOnly="True" FontFamily="{DynamicResource FontMono}" />
</Grid>
</Grid>
<Grid Grid.Row="3" ColumnDefinitions="*,4,*" MinHeight="260">
<Grid RowDefinitions="Auto,Auto,*" RowSpacing="4">
<TextBlock Text="{loc:Tr 'Match results'}" FontWeight="SemiBold" />
<Grid Grid.Row="1" ColumnDefinitions="36,*,56,64,56">
<TextBlock Classes="tableHeader" Text="#" />
<TextBlock Grid.Column="1" Classes="tableHeader" Text="{loc:Tr 'Value'}" />
<TextBlock Grid.Column="2" Classes="tableHeader" Text="{loc:Tr 'Line'}" HorizontalAlignment="Right" />
<TextBlock Grid.Column="3" Classes="tableHeader" Text="{loc:Tr 'Index'}" HorizontalAlignment="Right" />
<TextBlock Grid.Column="4" Classes="tableHeader" Text="{loc:Tr 'Length'}" HorizontalAlignment="Right" />
</Grid>
<ListBox Grid.Row="2" Name="MatchList" Classes="ResultTable">
<ListBox.ItemTemplate>
<DataTemplate x:DataType="models:RegexMatchItem">
<Grid ColumnDefinitions="36,*,56,64,56">
<TextBlock Classes="cellNum" HorizontalAlignment="Left" Text="{Binding Index}" />
<TextBlock Grid.Column="1" Classes="cell" FontFamily="{DynamicResource FontMono}" Text="{Binding Display}" />
<TextBlock Grid.Column="2" Classes="cellNum" Text="{Binding Line}" />
<TextBlock Grid.Column="3" Classes="cellNum" Text="{Binding Position}" />
<TextBlock Grid.Column="4" Classes="cellNum" Text="{Binding Length}" />
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
<Grid Grid.Column="2" RowDefinitions="Auto,Auto,*,Auto,Auto,*" RowSpacing="4">
<TextBlock Text="{loc:Tr 'Group'}" FontWeight="SemiBold" />
<Grid Grid.Row="1" ColumnDefinitions="32,76,*,40,52,46,40">
<TextBlock Classes="tableHeader" Text="#" />
<TextBlock Grid.Column="1" Classes="tableHeader" Text="{loc:Tr 'Name'}" />
<TextBlock Grid.Column="2" Classes="tableHeader" Text="{loc:Tr 'Value'}" />
<TextBlock Grid.Column="3" Classes="tableHeader" Text="{loc:Tr 'Line'}" HorizontalAlignment="Right" />
<TextBlock Grid.Column="4" Classes="tableHeader" Text="{loc:Tr 'Index'}" HorizontalAlignment="Right" />
<TextBlock Grid.Column="5" Classes="tableHeader" Text="{loc:Tr 'Length'}" HorizontalAlignment="Right" />
<TextBlock Grid.Column="6" Classes="tableHeader" Text="{loc:Tr 'Success'}" HorizontalAlignment="Center" />
</Grid>
<ListBox Grid.Row="2" Name="GroupList" Classes="ResultTable">
<ListBox.ItemTemplate>
<DataTemplate x:DataType="models:RegexGroupItem">
<Grid ColumnDefinitions="32,76,*,40,52,46,40">
<TextBlock Classes="cellNum" HorizontalAlignment="Left" Text="{Binding Index}" />
<TextBlock Grid.Column="1" Classes="cell" Text="{Binding Name}" />
<TextBlock Grid.Column="2" Classes="cell" FontFamily="{DynamicResource FontMono}" Text="{Binding Display}" />
<TextBlock Grid.Column="3" Classes="cellNum" Text="{Binding Line}" />
<TextBlock Grid.Column="4" Classes="cellNum" Text="{Binding Position}" />
<TextBlock Grid.Column="5" Classes="cellNum" Text="{Binding Length}" />
<TextBlock Grid.Column="6" Classes="cell" HorizontalAlignment="Center" Text="{Binding SuccessText}" />
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<TextBlock Grid.Row="3" Text="{loc:Tr 'Capture'}" FontWeight="SemiBold" />
<Grid Grid.Row="4" ColumnDefinitions="32,*,40,52,46">
<TextBlock Classes="tableHeader" Text="#" />
<TextBlock Grid.Column="1" Classes="tableHeader" Text="{loc:Tr 'Value'}" />
<TextBlock Grid.Column="2" Classes="tableHeader" Text="{loc:Tr 'Line'}" HorizontalAlignment="Right" />
<TextBlock Grid.Column="3" Classes="tableHeader" Text="{loc:Tr 'Index'}" HorizontalAlignment="Right" />
<TextBlock Grid.Column="4" Classes="tableHeader" Text="{loc:Tr 'Length'}" HorizontalAlignment="Right" />
</Grid>
<ListBox Grid.Row="5" Name="CaptureList" Classes="ResultTable">
<ListBox.ItemTemplate>
<DataTemplate x:DataType="models:RegexCaptureItem">
<Grid ColumnDefinitions="32,*,40,52,46">
<TextBlock Classes="cellNum" HorizontalAlignment="Left" Text="{Binding Index}" />
<TextBlock Grid.Column="1" Classes="cell" FontFamily="{DynamicResource FontMono}" Text="{Binding Display}" />
<TextBlock Grid.Column="2" Classes="cellNum" Text="{Binding Line}" />
<TextBlock Grid.Column="3" Classes="cellNum" Text="{Binding Position}" />
<TextBlock Grid.Column="4" Classes="cellNum" Text="{Binding Length}" />
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
</Grid>
<TextBlock Grid.Row="4" Name="StatusText" Classes="dim" Text="{loc:Tr 'Waiting'}" />
</Grid>
</Border>
</Grid>
</ScrollViewer>
</UserControl>
|