支持聊天框复制功能

This commit is contained in:
ZouJin 2024-03-10 13:11:09 +08:00
parent 1f2b295365
commit cca4992ba4
2 changed files with 29 additions and 7 deletions

View File

@ -3,20 +3,27 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:pu="https://opensource.panuon.com/wpf-ui"
xmlns:local="clr-namespace:VPet_Simulator.Core" mc:Ignorable="d" Height="500" Width="500"
xmlns:ll="clr-namespace:LinePutScript.Localization.WPF;assembly=LinePutScript.Localization.WPF"
MouseDoubleClick="UserControl_MouseDoubleClick">
<UserControl.Resources>
<ResourceDictionary Source="Theme.xaml" d:IsDataSource="True" />
</UserControl.Resources>
<Border x:Name="BorderMain" Background="{DynamicResource Primary}" BorderBrush="{DynamicResource DARKPrimaryDark}" BorderThickness="5"
VerticalAlignment="Bottom" Padding="10" Margin="5" CornerRadius="5" MouseEnter="Border_MouseEnter"
MouseLeave="Border_MouseLeave">
<UserControl.ContextMenu>
<ContextMenu Opened="ContextMenu_Opened" Closed="ContextMenu_Closed">
<MenuItem Header="{ll:Str 复制全文}" Click="MenuItemCopy_Click" />
<MenuItem Header="{ll:Str 关闭}" Click="MenuItemClose_Click" />
</ContextMenu>
</UserControl.ContextMenu>
<Border x:Name="BorderMain" Background="{DynamicResource Primary}" BorderBrush="{DynamicResource DARKPrimaryDark}"
BorderThickness="5" VerticalAlignment="Bottom" Padding="10" Margin="5" CornerRadius="5"
MouseEnter="Border_MouseEnter" MouseLeave="Border_MouseLeave">
<StackPanel>
<Label x:Name="LName" Content="虚拟桌宠名字:" Foreground="{DynamicResource PrimaryText}"
HorizontalAlignment="Left" Padding="0" FontWeight="Bold" Margin="0,0,0,6" FontSize="32"
Background="{x:Null}" />
<ScrollViewer MaxHeight="400">
<TextBlock x:Name="TText" Text="我说话长这样,这是我说的话巴拉巴拉巴拉巴拉巴拉巴拉巴拉巴拉巴拉巴拉巴拉巴拉巴拉巴拉"
TextWrapping="WrapWithOverflow" FontSize="24" x:FieldModifier="public" />
<TextBox x:Name="TText" Text="我说话长这样,这是我说的话巴拉巴拉巴拉巴拉巴拉巴拉巴拉巴拉巴拉巴拉巴拉巴拉巴拉巴拉" IsReadOnly="True"
TextWrapping="WrapWithOverflow" FontSize="24" x:FieldModifier="public" Background="{x:Null}" />
</ScrollViewer>
<Grid x:Name="MessageBoxContent" x:FieldModifier="public">

View File

@ -91,6 +91,7 @@ namespace VPet_Simulator.Core
public Action EndAction;
private void EndTimer_Elapsed(object sender, ElapsedEventArgs e)
{
if (--timeleft <= 0)
{
EndTimer.Stop();
@ -169,5 +170,19 @@ namespace VPet_Simulator.Core
BorderMain.VerticalAlignment = VerticalAlignment.Top;
Margin = new Thickness(0, 500, 0, 0);
}
private void MenuItemCopy_Click(object sender, RoutedEventArgs e)
{
Clipboard.SetText(TText.Text);
}
private void MenuItemClose_Click(object sender, RoutedEventArgs e)
{
ForceClose();
}
private void ContextMenu_Opened(object sender, RoutedEventArgs e) => Border_MouseEnter(null, null);
private void ContextMenu_Closed(object sender, RoutedEventArgs e) => Border_MouseLeave(null, null);
}
}