<UserControl x:Class="PdmSwPlugin.UI.CustomRichBox"
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:local="clr-namespace:PdmSwPlugin.UI"
|
mc:Ignorable="d"
|
Loaded="UserControl_Loaded"
|
HorizontalAlignment="Stretch"
|
VerticalAlignment="Stretch"
|
x:Name="main"
|
d:DesignHeight="450" d:DesignWidth="800">
|
<UserControl.Resources>
|
<ResourceDictionary>
|
<ResourceDictionary.MergedDictionaries>
|
<ResourceDictionary Source="/PdmSwPlugin.UI;component/Resources/Icons.xaml"/>
|
</ResourceDictionary.MergedDictionaries>
|
</ResourceDictionary>
|
</UserControl.Resources>
|
|
<Grid>
|
<Grid.Resources>
|
<ResourceDictionary>
|
<Style TargetType="Button">
|
<Setter Property="Margin" Value="2"></Setter>
|
<Setter Property="Width" Value="30"></Setter>
|
<Setter Property="Height" Value="30"></Setter>
|
<Setter Property="Background" Value="#fff"></Setter>
|
<Setter Property="Padding" Value="3"></Setter>
|
<Setter Property="BorderBrush" Value="#eeeeee"></Setter>
|
<Setter Property="BorderThickness" Value="1"></Setter>
|
</Style>
|
</ResourceDictionary>
|
</Grid.Resources>
|
<Grid.RowDefinitions>
|
<RowDefinition Height="Auto"></RowDefinition>
|
<RowDefinition></RowDefinition>
|
</Grid.RowDefinitions>
|
<StackPanel x:Name="toolBar" Orientation="Horizontal" Grid.Row="0" MinHeight="25">
|
|
<Button ToolTip="撤销" Command="ApplicationCommands.Undo" CommandTarget="{Binding ElementName=richTextBox}">
|
<Path Data="{StaticResource icon_undo}" Stretch="Fill" Fill="#8a8a8a"></Path>
|
</Button>
|
<Button ToolTip="重做" Command="ApplicationCommands.Redo" CommandTarget="{Binding ElementName=richTextBox}">
|
<Path Data="{StaticResource icon_redo}" Stretch="Fill" Fill="#8a8a8a"></Path>
|
</Button>
|
<GridSplitter Width="1" Margin="3 2 3 2" Background="LightGray" IsEnabled="False"></GridSplitter>
|
<Button ToolTip="加粗" Command="EditingCommands.ToggleBold" CommandTarget="{Binding ElementName=richTextBox}">
|
<Path Data="{StaticResource icon_bold}" Stretch="Fill" Fill="Black"></Path>
|
</Button>
|
<Button ToolTip="斜体" Command="EditingCommands.ToggleItalic" CommandTarget="{Binding ElementName=richTextBox}">
|
<Path Data="{StaticResource icon_italic}" Stretch="Fill" Fill="LightGray"></Path>
|
</Button>
|
<Button ToolTip="下划线" Command="EditingCommands.ToggleUnderline" CommandTarget="{Binding ElementName=richTextBox}">
|
<Path Data="{StaticResource icon_underline}" Stretch="Fill" Fill="Gray"></Path>
|
</Button>
|
<Button ToolTip="删除线" Click="Setting_Click" Tag="StrikeLine">
|
<Path Data="{StaticResource icon_strikeline}" Stretch="Fill" Fill="Black"></Path>
|
</Button>
|
<Button ToolTip="左对齐" Command="EditingCommands.AlignLeft" CommandTarget="{Binding ElementName=richTextBox}">
|
<Path Data="{StaticResource icon_left}" Stretch="Fill" Fill="Black" Stroke="LimeGreen"></Path>
|
</Button>
|
<Button ToolTip="居中对齐" Command="EditingCommands.AlignCenter" CommandTarget="{Binding ElementName=richTextBox}">
|
<Path Data="{StaticResource icon_center}" Stretch="Fill" Fill="Black" Stroke="LimeGreen"></Path>
|
</Button>
|
<Button ToolTip="右对齐" Command="EditingCommands.AlignRight" CommandTarget="{Binding ElementName=richTextBox}">
|
<Path Data="{StaticResource icon_right}" Stretch="Fill" Fill="Black" Stroke="LimeGreen"></Path>
|
</Button>
|
<Button ToolTip="两端对齐" Command="EditingCommands.AlignJustify" CommandTarget="{Binding ElementName=richTextBox}">
|
<Path Data="{StaticResource icon_justify}" Stretch="Fill" Fill="Black" Stroke="LimeGreen"></Path>
|
</Button>
|
<Button ToolTip="缩进" Command="EditingCommands.IncreaseIndentation" CommandTarget="{Binding ElementName=richTextBox}">
|
<Path Data="{StaticResource icon_addident}" Stretch="Fill" Fill="DimGray"></Path>
|
</Button>
|
<Button ToolTip="减少缩进" Command="EditingCommands.DecreaseIndentation" CommandTarget="{Binding ElementName=richTextBox}">
|
<Path Data="{StaticResource icon_lessident}" Stretch="Fill" Fill="DimGray"></Path>
|
</Button>
|
<Button ToolTip="上标" Click="Setting_Click" Tag="Super">
|
<Path Data="{StaticResource icon_upper}" Stretch="Fill" Fill="CadetBlue"></Path>
|
</Button>
|
<Button ToolTip="下标" Click="Setting_Click" Tag="Sub">
|
<Path Data="{StaticResource icon_down}" Stretch="Fill" Fill="CadetBlue"></Path>
|
</Button>
|
<GridSplitter Width="1" Margin="3 2 3 2" Background="LightGray" IsEnabled="False"></GridSplitter>
|
|
<Grid Background="White" Width="42" Height="30" Margin="3">
|
<ComboBox Width="42" Height="30" BorderThickness="0" HorizontalAlignment="Left" VerticalAlignment="Center" BorderBrush="White" Background="White" x:Name="fontSizeComb"
|
SelectionChanged="FontSize_SelectionChanged">
|
<ComboBoxItem Content="12"></ComboBoxItem>
|
<ComboBoxItem Content="14"></ComboBoxItem>
|
<ComboBoxItem Content="16"></ComboBoxItem>
|
<ComboBoxItem Content="32"></ComboBoxItem>
|
<ComboBoxItem Content="48"></ComboBoxItem>
|
<ComboBoxItem Content="64"></ComboBoxItem>
|
</ComboBox>
|
<Button IsEnabled="False" ToolTip="字号" Width="30" Height="30" Padding="0" Margin="0"
|
HorizontalAlignment="Left" VerticalAlignment="Center" Content="{Binding ElementName=fontSizeComb, Path=SelectedItem.Content}">
|
|
</Button>
|
</Grid>
|
|
<Grid Background="White" Width="42" Height="30" Margin="3">
|
<ComboBox Width="42" Height="30" BorderThickness="0" HorizontalAlignment="Left" VerticalAlignment="Center"
|
BorderBrush="White" Background="White" Name="combBackground"
|
SelectionChanged="Color_SelectionChanged">
|
<ComboBoxItem Background="#000000" Content="#000000"></ComboBoxItem>
|
<ComboBoxItem Background="#FF0000" Content="#FF0000"></ComboBoxItem>
|
<ComboBoxItem Background="#00FF00" Content="#00FF00"></ComboBoxItem>
|
<ComboBoxItem Background="#0000FF" Content="#0000FF"></ComboBoxItem>
|
<ComboBoxItem Background="#00AA00" Content="#00AA00"></ComboBoxItem>
|
<ComboBoxItem Background="#AA0000" Content="#AA0000"></ComboBoxItem>
|
<ComboBoxItem Background="#0000AA" Content="#0000AA"></ComboBoxItem>
|
<ComboBoxItem Background="#AA00CC" Content="#AA00CC"></ComboBoxItem>
|
<ComboBoxItem Background="#00BBCC" Content="#00BBCC"></ComboBoxItem>
|
<ComboBoxItem Background="#555555" Content="#555555"></ComboBoxItem>
|
<ComboBoxItem Background="#AAAAAA" Content="#AAAAAA"></ComboBoxItem>
|
<ComboBoxItem Background="#BBBBBB" Content="#BBBBBB"></ComboBoxItem>
|
<ComboBoxItem Background="#CCCCCC" Content="#CCCCCC"></ComboBoxItem>
|
<ComboBoxItem Background="#DDDDDD" Content="#DDDDDD"></ComboBoxItem>
|
<ComboBoxItem Background="#EEEEEE" Content="#EEEEEE"></ComboBoxItem>
|
<ComboBoxItem Background="#FFFFFF" Content="#FFFFFF"></ComboBoxItem>
|
</ComboBox>
|
<Button ToolTip="背景色" Width="30" Height="30" Padding="0" Margin="0" HorizontalAlignment="Left" VerticalAlignment="Center">
|
<Path Data="{StaticResource icon_background}" Stretch="Fill" Fill="{Binding ElementName=combBackground, Path=SelectedItem.Background}" ></Path>
|
</Button>
|
</Grid>
|
<Grid Background="White" Width="42" Height="30" Margin="3">
|
<ComboBox Width="42" Height="30" BorderThickness="0" HorizontalAlignment="Left" VerticalAlignment="Center"
|
BorderBrush="White" Background="White" Name="combForeground"
|
SelectionChanged="Color_SelectionChanged">
|
<ComboBoxItem Background="#000000" Content="#000000"></ComboBoxItem>
|
<ComboBoxItem Background="#FF0000" Content="#FF0000"></ComboBoxItem>
|
<ComboBoxItem Background="#00FF00" Content="#00FF00"></ComboBoxItem>
|
<ComboBoxItem Background="#0000FF" Content="#0000FF"></ComboBoxItem>
|
<ComboBoxItem Background="#00AA00" Content="#00AA00"></ComboBoxItem>
|
<ComboBoxItem Background="#AA0000" Content="#AA0000"></ComboBoxItem>
|
<ComboBoxItem Background="#0000AA" Content="#0000AA"></ComboBoxItem>
|
<ComboBoxItem Background="#AA00CC" Content="#AA00CC"></ComboBoxItem>
|
<ComboBoxItem Background="#00BBCC" Content="#00BBCC"></ComboBoxItem>
|
<ComboBoxItem Background="#555555" Content="#555555"></ComboBoxItem>
|
<ComboBoxItem Background="#AAAAAA" Content="#AAAAAA"></ComboBoxItem>
|
<ComboBoxItem Background="#BBBBBB" Content="#BBBBBB"></ComboBoxItem>
|
<ComboBoxItem Background="#CCCCCC" Content="#CCCCCC"></ComboBoxItem>
|
<ComboBoxItem Background="#DDDDDD" Content="#DDDDDD"></ComboBoxItem>
|
<ComboBoxItem Background="#EEEEEE" Content="#EEEEEE"></ComboBoxItem>
|
<ComboBoxItem Background="#FFFFFF" Content="#FFFFFF"></ComboBoxItem>
|
</ComboBox>
|
<Button ToolTip="前景色" Width="30" Height="30" Padding="0" Margin="0" HorizontalAlignment="Left" VerticalAlignment="Center">
|
<Path Data="{StaticResource icon_foreground}" Stretch="Fill" Fill="{Binding ElementName=combForeground, Path=SelectedItem.Background}"></Path>
|
</Button>
|
</Grid>
|
<Button ToolTip="图像" Click="Setting_Click" Tag="Image">
|
<Path Data="{StaticResource icon_img}" Stretch="Fill" Fill="Goldenrod"></Path>
|
</Button>
|
</StackPanel>
|
<RichTextBox x:Name="richTextBox" AcceptsTab="True" Grid.Row="1" BorderThickness="1"
|
BorderBrush="Black" Margin="2" Padding="2" ScrollViewer.CanContentScroll="True"
|
PreviewKeyDown="UserControl_KeyDown"
|
HorizontalAlignment="Stretch"
|
VerticalScrollBarVisibility="Auto"
|
|
HorizontalScrollBarVisibility="Auto">
|
<RichTextBox.Resources>
|
<Style TargetType="Paragraph">
|
<Setter Property="Margin" Value="0"/>
|
</Style>
|
</RichTextBox.Resources>
|
|
<RichTextBox.ContextMenu>
|
<ContextMenu>
|
<MenuItem Header="复制" Click="Copy_Click"/>
|
<MenuItem Header="粘贴" Click="Paste_Click">
|
<!--<MenuItem.Style>
|
<Style TargetType="{x:Type MenuItem}">
|
<Style.Triggers>
|
<DataTrigger Binding="{Binding Path=PlacementTarget.IsReadOnly}" Value="True">
|
<Setter Property="Visibility" Value="Collapsed"/>
|
</DataTrigger>
|
</Style.Triggers>
|
</Style>
|
</MenuItem.Style>-->
|
</MenuItem>
|
</ContextMenu>
|
</RichTextBox.ContextMenu>
|
</RichTextBox>
|
</Grid>
|
</UserControl>
|