no message
This commit is contained in:
parent
b5da1a7f7c
commit
67f36bcc4d
|
|
@ -8,30 +8,26 @@
|
|||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="0ae961c9-2aa8-4465-9e53-e04d62044e0d" name="更改" comment="">
|
||||
<change afterPath="$PROJECT_DIR$/ToolsForm/Views/AIWindow.axaml" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/ToolsForm/Views/AIWindow.axaml.cs" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/.idea.ToolsForm/.idea/avalonia.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/.idea.ToolsForm/.idea/avalonia.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/.idea.ToolsForm/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/.idea.ToolsForm/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/ToolsForm/Manager/AppWindowManager.cs" beforeDir="false" afterPath="$PROJECT_DIR$/ToolsForm/Manager/AppWindowManager.cs" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/ToolsForm/ToolsForm.csproj" beforeDir="false" afterPath="$PROJECT_DIR$/ToolsForm/ToolsForm.csproj" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/ToolsForm/App.axaml" beforeDir="false" afterPath="$PROJECT_DIR$/ToolsForm/App.axaml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/ToolsForm/ViewModels/ImageAlignmentConverter.cs" beforeDir="false" afterPath="$PROJECT_DIR$/ToolsForm/ViewModels/ImageAlignmentConverter.cs" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/ToolsForm/Views/AIWindow.axaml" beforeDir="false" afterPath="$PROJECT_DIR$/ToolsForm/Views/AIWindow.axaml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/ToolsForm/Views/AIWindow.axaml.cs" beforeDir="false" afterPath="$PROJECT_DIR$/ToolsForm/Views/AIWindow.axaml.cs" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/ToolsForm/bin/Debug/net8.0/ToolsForm.dll" beforeDir="false" afterPath="$PROJECT_DIR$/ToolsForm/bin/Debug/net8.0/ToolsForm.dll" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/ToolsForm/bin/Debug/net8.0/ToolsForm.exe" beforeDir="false" afterPath="$PROJECT_DIR$/ToolsForm/bin/Debug/net8.0/ToolsForm.exe" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/ToolsForm/bin/Debug/net8.0/ToolsForm.pdb" beforeDir="false" afterPath="$PROJECT_DIR$/ToolsForm/bin/Debug/net8.0/ToolsForm.pdb" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/ToolsForm/obj/Debug/net8.0/Avalonia/Resources.Inputs.cache" beforeDir="false" afterPath="$PROJECT_DIR$/ToolsForm/obj/Debug/net8.0/Avalonia/Resources.Inputs.cache" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/ToolsForm/obj/Debug/net8.0/Avalonia/ToolsForm.dll" beforeDir="false" afterPath="$PROJECT_DIR$/ToolsForm/obj/Debug/net8.0/Avalonia/ToolsForm.dll" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/ToolsForm/obj/Debug/net8.0/Avalonia/ToolsForm.pdb" beforeDir="false" afterPath="$PROJECT_DIR$/ToolsForm/obj/Debug/net8.0/Avalonia/ToolsForm.pdb" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/ToolsForm/obj/Debug/net8.0/Avalonia/resources" beforeDir="false" afterPath="$PROJECT_DIR$/ToolsForm/obj/Debug/net8.0/Avalonia/resources" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/ToolsForm/obj/Debug/net8.0/ToolsForm.AssemblyInfo.cs" beforeDir="false" afterPath="$PROJECT_DIR$/ToolsForm/obj/Debug/net8.0/ToolsForm.AssemblyInfo.cs" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/ToolsForm/obj/Debug/net8.0/ToolsForm.AssemblyInfoInputs.cache" beforeDir="false" afterPath="$PROJECT_DIR$/ToolsForm/obj/Debug/net8.0/ToolsForm.AssemblyInfoInputs.cache" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/ToolsForm/obj/Debug/net8.0/ToolsForm.GeneratedMSBuildEditorConfig.editorconfig" beforeDir="false" afterPath="$PROJECT_DIR$/ToolsForm/obj/Debug/net8.0/ToolsForm.GeneratedMSBuildEditorConfig.editorconfig" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/ToolsForm/obj/Debug/net8.0/ToolsForm.csproj.CoreCompileInputs.cache" beforeDir="false" afterPath="$PROJECT_DIR$/ToolsForm/obj/Debug/net8.0/ToolsForm.csproj.CoreCompileInputs.cache" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/ToolsForm/obj/Debug/net8.0/ToolsForm.csproj.FileListAbsolute.txt" beforeDir="false" afterPath="$PROJECT_DIR$/ToolsForm/obj/Debug/net8.0/ToolsForm.csproj.FileListAbsolute.txt" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/ToolsForm/obj/Debug/net8.0/ToolsForm.dll" beforeDir="false" afterPath="$PROJECT_DIR$/ToolsForm/obj/Debug/net8.0/ToolsForm.dll" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/ToolsForm/obj/Debug/net8.0/ToolsForm.pdb" beforeDir="false" afterPath="$PROJECT_DIR$/ToolsForm/obj/Debug/net8.0/ToolsForm.pdb" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/ToolsForm/obj/Debug/net8.0/apphost.exe" beforeDir="false" afterPath="$PROJECT_DIR$/ToolsForm/obj/Debug/net8.0/apphost.exe" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/ToolsForm/obj/Debug/net8.0/ref/ToolsForm.dll" beforeDir="false" afterPath="$PROJECT_DIR$/ToolsForm/obj/Debug/net8.0/ref/ToolsForm.dll" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/ToolsForm/obj/Debug/net8.0/refint/Avalonia/ToolsForm.dll" beforeDir="false" afterPath="$PROJECT_DIR$/ToolsForm/obj/Debug/net8.0/refint/Avalonia/ToolsForm.dll" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/ToolsForm/obj/Debug/net8.0/refint/ToolsForm.dll" beforeDir="false" afterPath="$PROJECT_DIR$/ToolsForm/obj/Debug/net8.0/refint/ToolsForm.dll" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/ToolsForm/obj/rider.project.model.nuget.info" beforeDir="false" afterPath="$PROJECT_DIR$/ToolsForm/obj/rider.project.model.nuget.info" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
|
|
@ -55,6 +51,8 @@
|
|||
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/DecompilerCache/decompiler/ceb1c14a2cad4d38a6c5bf90e72339c81cc000/c9/cb82c5be/FormattedText.cs" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/DecompilerCache/decompiler/de3edec1170e48a0a2478d8743508635c8e910/7e/a675f6db/SafeFileHandle.cs" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/SourcesCache/2d9e48c78990cecd83446d724e6becca8372160e7da83528c0b6efca8ffb7/Button.cs" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/SourcesCache/57361bc4e5442f644ff63ec7e745da2eb4bbb6c769d1fb683bab5f6f952b1ab/Control.cs" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/SourcesCache/e19a3561362418612f26d627aeb21e9f2065cf15b9986a129ec586d68de23de/Viewbox.cs" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="file://$PROJECT_DIR$/../../ICT_IntelligentICTVirtualSimulation/U.P.A/Assets/Runtime/UnityMainThreadDispatcher.cs" root0="SKIP_HIGHLIGHTING" />
|
||||
</component>
|
||||
<component name="ProjectColorInfo">{
|
||||
|
|
@ -149,6 +147,7 @@
|
|||
<workItem from="1730270228361" duration="42741000" />
|
||||
<workItem from="1730681938757" duration="3441000" />
|
||||
<workItem from="1730699973923" duration="388000" />
|
||||
<workItem from="1730713065050" duration="2110000" />
|
||||
</task>
|
||||
<servers />
|
||||
</component>
|
||||
|
|
@ -226,6 +225,32 @@
|
|||
</properties>
|
||||
<option name="timeStamp" value="8" />
|
||||
</line-breakpoint>
|
||||
<line-breakpoint enabled="true" type="DotNet Breakpoints">
|
||||
<url>file://$PROJECT_DIR$/ToolsForm/Views/AIWindow.axaml.cs</url>
|
||||
<line>49</line>
|
||||
<properties documentPath="E:\Unity Projects\GitLab\2024\ICT_ToolsForm\ToolsForm\ToolsForm\Views\AIWindow.axaml.cs" containingFunctionPresentation="方法 'OnSendButtonClick'">
|
||||
<startOffsets>
|
||||
<option value="1957" />
|
||||
</startOffsets>
|
||||
<endOffsets>
|
||||
<option value="1990" />
|
||||
</endOffsets>
|
||||
</properties>
|
||||
<option name="timeStamp" value="9" />
|
||||
</line-breakpoint>
|
||||
<line-breakpoint enabled="true" type="DotNet Breakpoints">
|
||||
<url>file://$PROJECT_DIR$/ToolsForm/Views/AIWindow.axaml.cs</url>
|
||||
<line>23</line>
|
||||
<properties documentPath="E:\Unity Projects\GitLab\2024\ICT_ToolsForm\ToolsForm\ToolsForm\Views\AIWindow.axaml.cs" containingFunctionPresentation="构造函数 'AIWindow'">
|
||||
<startOffsets>
|
||||
<option value="908" />
|
||||
</startOffsets>
|
||||
<endOffsets>
|
||||
<option value="936" />
|
||||
</endOffsets>
|
||||
</properties>
|
||||
<option name="timeStamp" value="10" />
|
||||
</line-breakpoint>
|
||||
</breakpoints>
|
||||
</breakpoint-manager>
|
||||
</component>
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@
|
|||
<global:MessageBackgroundConverter x:Key="MessageBackgroundConverter" />
|
||||
<global:MessageAlignmentConverter x:Key="MessageAlignmentConverter" />
|
||||
<viewModels:ImageAlignmentConverter x:Key="ImageAlignmentConverter" />
|
||||
<viewModels:BooleanToOpacityConverter x:Key="BooleanToOpacityConverter" />
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -17,3 +17,43 @@ public class ImageAlignmentConverter : IValueConverter
|
|||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
public class BooleanToOpacityConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
return value is bool && (bool)value ? 1.0 : 0.0; // 可见时为1,不可见时为0
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class InverseBooleanToHitTestVisibleConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
return value is bool && !(bool)value; // 反转布尔值
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
public class InverseBooleanToOpacityConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
return value is bool booleanValue && !booleanValue ? 1.0 : 0.0; // 反转布尔值,返回 1.0 或 0.0
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
|
@ -10,6 +10,7 @@
|
|||
xmlns:global="clr-namespace:"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:models="clr-namespace:ToolsForm.Models"
|
||||
xmlns:viewModels="clr-namespace:ToolsForm.ViewModels"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
|
||||
<Window.Styles>
|
||||
|
|
@ -29,6 +30,11 @@
|
|||
<ImageBrush Source="../Assets/img/AI/对话框.png" />
|
||||
</Window.Background>
|
||||
|
||||
<Window.Resources>
|
||||
<viewModels:BooleanToOpacityConverter x:Key="BooleanToOpacityConverter" />
|
||||
<viewModels:InverseBooleanToOpacityConverter x:Key="InverseBooleanToOpacityConverter" />
|
||||
<viewModels:InverseBooleanToHitTestVisibleConverter x:Key="InverseBooleanToHitTestVisibleConverter" />
|
||||
</Window.Resources>
|
||||
|
||||
<Grid
|
||||
Height="150"
|
||||
|
|
@ -39,26 +45,40 @@
|
|||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<ScrollViewer VerticalScrollBarVisibility="Auto">
|
||||
<ScrollViewer Name="DialogueScrollViewer" VerticalScrollBarVisibility="Auto">
|
||||
|
||||
|
||||
<ItemsControl ItemsSource="{Binding Dialogues}" Name="DialogueItems">
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<StackPanel HorizontalAlignment="{Binding IsUserMessage, Converter={StaticResource MessageAlignmentConverter}}" Orientation="Horizontal">
|
||||
<Image
|
||||
Height="20"
|
||||
Height="18"
|
||||
HorizontalAlignment="Left"
|
||||
IsHitTestVisible="{Binding IsUserMessage, Converter={StaticResource InverseBooleanToHitTestVisibleConverter}}"
|
||||
Margin="5"
|
||||
Opacity="{Binding IsUserMessage, Converter={StaticResource InverseBooleanToOpacityConverter}}"
|
||||
Source="{Binding ImageSource}"
|
||||
Width="20" />
|
||||
Width="18" />
|
||||
|
||||
<TextBlock
|
||||
Background="{Binding IsUserMessage, Converter={StaticResource MessageBackgroundConverter}}"
|
||||
HorizontalAlignment="Stretch"
|
||||
Margin="5"
|
||||
MaxWidth="300"
|
||||
MaxWidth="500"
|
||||
Padding="10"
|
||||
Text="{Binding Text}"
|
||||
TextWrapping="Wrap" />
|
||||
|
||||
<Image
|
||||
Height="18"
|
||||
HorizontalAlignment="Left"
|
||||
IsHitTestVisible="{Binding IsUserMessage}"
|
||||
Margin="5"
|
||||
Opacity="{Binding IsUserMessage, Converter={StaticResource BooleanToOpacityConverter}}"
|
||||
Source="{Binding ImageSource}"
|
||||
Width="18" />
|
||||
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
|
|
@ -73,14 +93,21 @@
|
|||
Width="637" />
|
||||
|
||||
<TextBox
|
||||
Background="Transparent"
|
||||
BorderBrush="Transparent"
|
||||
BorderThickness="0"
|
||||
Height="54"
|
||||
KeyDown="OnInputTextBoxKeyDown"
|
||||
Name="InputTextBox"
|
||||
Padding="10,5,50,5"
|
||||
Width="637" />
|
||||
|
||||
|
||||
<Button
|
||||
Background="Transparent"
|
||||
Click="OnSendButtonClick"
|
||||
HorizontalAlignment="Right"
|
||||
Margin="0,20,-10,0"
|
||||
Margin="0,10,10,10"
|
||||
Name="SendButton"
|
||||
VerticalAlignment="Stretch"
|
||||
Width="50">
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
using System.Linq;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Input;
|
||||
using Avalonia.Interactivity;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using ToolsForm.Models; // 引入模型命名空间
|
||||
|
|
@ -11,17 +12,25 @@
|
|||
private DialogueModel dialogueModel;
|
||||
private TextBox inputTextBox;
|
||||
private ItemsControl dialogueItems;
|
||||
|
||||
private ScrollViewer dialogueScrollViewer;
|
||||
public AIWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
// 初始化控件
|
||||
inputTextBox = this.FindControl<TextBox>("InputTextBox");
|
||||
dialogueItems = this.FindControl<ItemsControl>("DialogueItems");
|
||||
dialogueScrollViewer= this.FindControl<ScrollViewer>("DialogueScrollViewer");
|
||||
dialogueModel = new DialogueModel(); // 创建模型实例
|
||||
DataContext = dialogueModel; // 将数据上下文设置为模型
|
||||
}
|
||||
|
||||
private void OnInputTextBoxKeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.Key == Key.Enter) // 检查是否按下 Enter 键
|
||||
{
|
||||
OnSendButtonClick(sender, e); // 调用发送按钮的点击事件处理程序
|
||||
e.Handled = true; // 标记事件已处理,防止进一步处理
|
||||
}
|
||||
}
|
||||
private void OnSendButtonClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var userMessage = inputTextBox.Text;
|
||||
|
|
@ -34,8 +43,13 @@
|
|||
var aiResponse = GenerateAIResponse(userMessage);
|
||||
dialogueModel.AddAIResponse(aiResponse);
|
||||
|
||||
// 自动滚动到最新消息
|
||||
dialogueItems.ScrollIntoView(dialogueModel.Dialogues.Last());
|
||||
// // 自动滚动到最新消息
|
||||
// dialogueItems.ScrollIntoView(dialogueModel.Dialogues.Last());
|
||||
}
|
||||
|
||||
if (dialogueScrollViewer != null)
|
||||
{
|
||||
dialogueScrollViewer.ScrollToEnd();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -13,7 +13,7 @@ using System.Reflection;
|
|||
[assembly: System.Reflection.AssemblyCompanyAttribute("ToolsForm")]
|
||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+9335c4bddabcf0a09ea3730f2caaa72cced78e17")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+b5da1a7f7c82dcd20f0b21f742568b806e389d75")]
|
||||
[assembly: System.Reflection.AssemblyProductAttribute("ToolsForm")]
|
||||
[assembly: System.Reflection.AssemblyTitleAttribute("ToolsForm")]
|
||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
fd2cbd09e17ab485ea9afa360ac92eea22ec11693359a777e90c575aec824f0d
|
||||
7b96760f001b2471081ba691dfa0e836b351bee82672791a362c10b30535dedd
|
||||
|
|
|
|||
|
|
@ -154,6 +154,3 @@ E:\Unity Projects\GitLab\2024\ICT_ToolsForm\ToolsForm\ToolsForm\obj\Debug\net8.0
|
|||
E:\Unity Projects\GitLab\2024\ICT_ToolsForm\ToolsForm\ToolsForm\obj\Debug\net8.0\ToolsForm.csproj.Up2Date
|
||||
E:\Unity Projects\GitLab\2024\ICT_ToolsForm\ToolsForm\ToolsForm\obj\Debug\net8.0\ToolsForm.genruntimeconfig.cache
|
||||
E:\Unity Projects\GitLab\2024\ICT_ToolsForm\ToolsForm\ToolsForm\obj\Debug\net8.0\ref\ToolsForm.dll
|
||||
E:\Unity Projects\GitLab\2024\ICT_ToolsForm\ToolsForm\ToolsForm\obj\Debug\net8.0\ToolsForm.dll
|
||||
E:\Unity Projects\GitLab\2024\ICT_ToolsForm\ToolsForm\ToolsForm\obj\Debug\net8.0\refint\ToolsForm.dll
|
||||
E:\Unity Projects\GitLab\2024\ICT_ToolsForm\ToolsForm\ToolsForm\obj\Debug\net8.0\ToolsForm.pdb
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue