mirror of
https://github.com/LorisYounger/VPet.git
synced 2024-08-30 18:42:36 +00:00
新增 Ctrl+Enter 快捷发送消息
This commit is contained in:
parent
88cd9af244
commit
33c5429a2d
@ -1,25 +1,27 @@
|
|||||||
<UserControl x:Class="VPet_Simulator.Windows.TalkBox"
|
<UserControl x:Class="VPet_Simulator.Windows.TalkBox" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:pu="clr-namespace:Panuon.WPF.UI;assembly=Panuon.WPF.UI" Height="500" Width="500">
|
xmlns:pu="clr-namespace:Panuon.WPF.UI;assembly=Panuon.WPF.UI" Height="500" Width="500">
|
||||||
<Border Background="{DynamicResource PrimaryLighter}" BorderBrush="{DynamicResource Primary}" BorderThickness="5"
|
<Border Background="{DynamicResource PrimaryLighter}" BorderBrush="{DynamicResource Primary}" BorderThickness="5"
|
||||||
VerticalAlignment="Top" Margin="5,50,5,5" CornerRadius="5" Padding="5">
|
VerticalAlignment="Top" Margin="5,50,5,5" CornerRadius="5" Padding="5">
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="4*"/>
|
<ColumnDefinition Width="4*" />
|
||||||
<ColumnDefinition Width="5"/>
|
<ColumnDefinition Width="5" />
|
||||||
<ColumnDefinition Width="1*"/>
|
<ColumnDefinition Width="1*" />
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
<TextBox x:Name="tbTalk" Style="{DynamicResource StandardTextBoxStyle}" Height="Auto"
|
<TextBox x:Name="tbTalk" Style="{DynamicResource StandardTextBoxStyle}" Height="Auto"
|
||||||
pu:TextBoxHelper.Watermark="和桌宠说" FontSize="30" AcceptsReturn="True" TextWrapping="WrapWithOverflow"/>
|
pu:TextBoxHelper.Watermark="和桌宠说" FontSize="30" AcceptsReturn="True" TextWrapping="WrapWithOverflow"
|
||||||
|
PreviewKeyDown="tbTalk_KeyDown" />
|
||||||
<Button pu:ButtonHelper.CornerRadius="4" Content="发送" BorderThickness="2"
|
<Button pu:ButtonHelper.CornerRadius="4" Content="发送" BorderThickness="2"
|
||||||
Background="{DynamicResource SecondaryLight}" Grid.Column="2" BorderBrush="{DynamicResource DARKPrimaryDarker}"
|
Background="{DynamicResource SecondaryLight}" Grid.Column="2"
|
||||||
FontSize="30" Click="SendMessage_Click" />
|
BorderBrush="{DynamicResource DARKPrimaryDarker}" FontSize="30" Click="SendMessage_Click"
|
||||||
<Button x:Name="btn_startup" pu:ButtonHelper.CornerRadius="4" Content="初始化桌宠聊天程序" BorderThickness="2" x:FieldModifier="public"
|
ToolTip="按 Ctrl+Enter 发送" />
|
||||||
Background="{DynamicResource SecondaryLight}" BorderBrush="{DynamicResource DARKPrimaryDarker}"
|
<Button x:Name="btn_startup" pu:ButtonHelper.CornerRadius="4" Content="初始化桌宠聊天程序" BorderThickness="2"
|
||||||
FontSize="30" Click="StartUP_Click" Grid.ColumnSpan="3" />
|
x:FieldModifier="public" Background="{DynamicResource SecondaryLight}"
|
||||||
|
BorderBrush="{DynamicResource DARKPrimaryDarker}" FontSize="30" Click="StartUP_Click"
|
||||||
|
Grid.ColumnSpan="3" />
|
||||||
</Grid>
|
</Grid>
|
||||||
</Border>
|
</Border>
|
||||||
</UserControl>
|
</UserControl>
|
||||||
|
@ -225,5 +225,14 @@ namespace VPet_Simulator.Windows
|
|||||||
Dispatcher.Invoke(() => btn_startup.Visibility = Visibility.Collapsed);
|
Dispatcher.Invoke(() => btn_startup.Visibility = Visibility.Collapsed);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void tbTalk_KeyDown(object sender, KeyEventArgs e)
|
||||||
|
{
|
||||||
|
if (e.Key == Key.Enter && e.KeyboardDevice.Modifiers.HasFlag(ModifierKeys.Control))
|
||||||
|
{
|
||||||
|
SendMessage_Click(sender, e);
|
||||||
|
e.Handled = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,20 +3,21 @@
|
|||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:pu="clr-namespace:Panuon.WPF.UI;assembly=Panuon.WPF.UI" Height="500" Width="500">
|
xmlns:pu="clr-namespace:Panuon.WPF.UI;assembly=Panuon.WPF.UI" Height="500" Width="500">
|
||||||
<Border Background="{DynamicResource SecondaryLighter}" BorderBrush="{DynamicResource Secondary}" BorderThickness="5"
|
<Border Background="{DynamicResource SecondaryLighter}" BorderBrush="{DynamicResource Secondary}"
|
||||||
VerticalAlignment="Top" Margin="5,50,5,5" CornerRadius="5" Padding="5">
|
BorderThickness="5" VerticalAlignment="Top" Margin="5,50,5,5" CornerRadius="5" Padding="5">
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="4*"/>
|
<ColumnDefinition Width="4*" />
|
||||||
<ColumnDefinition Width="5"/>
|
<ColumnDefinition Width="5" />
|
||||||
<ColumnDefinition Width="1*"/>
|
<ColumnDefinition Width="1*" />
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
<TextBox x:Name="tbTalk" Style="{DynamicResource StandardTextBoxStyle}" Height="Auto"
|
<TextBox x:Name="tbTalk" Style="{DynamicResource StandardTextBoxStyle}" Height="Auto"
|
||||||
pu:TextBoxHelper.Watermark="和桌宠说" FontSize="30" AcceptsReturn="True" TextWrapping="WrapWithOverflow"/>
|
pu:TextBoxHelper.Watermark="和桌宠说" FontSize="30" AcceptsReturn="True" TextWrapping="WrapWithOverflow"
|
||||||
|
PreviewKeyDown="tbTalk_KeyDown" />
|
||||||
<Button pu:ButtonHelper.CornerRadius="4" Content="发送" BorderThickness="2"
|
<Button pu:ButtonHelper.CornerRadius="4" Content="发送" BorderThickness="2"
|
||||||
Background="{DynamicResource PrimaryLight}" Grid.Column="2" BorderBrush="{DynamicResource DARKPrimaryDarker}"
|
Background="{DynamicResource PrimaryLight}" Grid.Column="2" ToolTip="按 Ctrl+Enter 发送"
|
||||||
FontSize="30" Click="SendMessage_Click" />
|
BorderBrush="{DynamicResource DARKPrimaryDarker}" FontSize="30" Click="SendMessage_Click" />
|
||||||
</Grid>
|
</Grid>
|
||||||
</Border>
|
</Border>
|
||||||
</UserControl>
|
</UserControl>
|
||||||
|
@ -74,9 +74,23 @@ namespace VPet_Simulator.Windows
|
|||||||
}
|
}
|
||||||
catch (Exception exp)
|
catch (Exception exp)
|
||||||
{
|
{
|
||||||
m.Say("API调用失败,请检查设置和网络连接\n" + exp.ToString(), GraphCore.Helper.SayType.Serious);
|
var e = exp.ToString();
|
||||||
|
string str = "请检查设置和网络连接";
|
||||||
|
if (e.Contains("401"))
|
||||||
|
{
|
||||||
|
str = "请检查API token设置";
|
||||||
|
}
|
||||||
|
m.Say($"API调用失败,{str}\n{e}", GraphCore.Helper.SayType.Serious);
|
||||||
}
|
}
|
||||||
Dispatcher.Invoke(() => this.IsEnabled = true);
|
Dispatcher.Invoke(() => this.IsEnabled = true);
|
||||||
}
|
}
|
||||||
|
private void tbTalk_KeyDown(object sender, KeyEventArgs e)
|
||||||
|
{
|
||||||
|
if (e.Key == Key.Enter && e.KeyboardDevice.Modifiers.HasFlag(ModifierKeys.Control))
|
||||||
|
{
|
||||||
|
SendMessage_Click(sender, e);
|
||||||
|
e.Handled = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user