添加项目文件。
This commit is contained in:
74
Views/ChatMdView.xaml
Normal file
74
Views/ChatMdView.xaml
Normal file
@@ -0,0 +1,74 @@
|
||||
<UserControl x:Class="YwxApp.AiChat.Views.ChatMdView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:markdig="clr-namespace:Markdig.Wpf;assembly=Markdig.Wpf"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
<UserControl.Resources >
|
||||
<ResourceDictionary>
|
||||
<!--Resource dictionary:Add control style.-->
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="Style/ButtonStyle.xaml"/>
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
</ResourceDictionary>
|
||||
</UserControl.Resources>
|
||||
<Grid Background="#0F000F">
|
||||
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="200" />
|
||||
<RowDefinition Height="50" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<!--First line: Display output text to "Markdown" container-->
|
||||
<Grid Grid.Row="0">
|
||||
<ScrollViewer Background="#FFFFFF" x:Name="MarkDownScrollViewer">
|
||||
<!--Bind event command to the ScrollViewer-->
|
||||
<i:Interaction.Triggers>
|
||||
<i:EventTrigger EventName="ScrollChanged">
|
||||
<i:InvokeCommandAction Command = "{Binding ScrollToEndCommand}"
|
||||
CommandParameter="{Binding ElementName=MarkDownScrollViewer}" />
|
||||
</i:EventTrigger>
|
||||
</i:Interaction.Triggers>
|
||||
<!--scrollviewer internal container-->
|
||||
<markdig:MarkdownViewer x:Name="MarkdownOutputBox" Markdown="{Binding MarkdownContent}" />
|
||||
</ScrollViewer>
|
||||
</Grid>
|
||||
|
||||
<!-- the second line -->
|
||||
<Grid Grid.Row="1">
|
||||
<TextBox x:Name="InputBox"
|
||||
Text="{Binding InputText , Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
|
||||
Grid.Row="1" Margin="5" AcceptsReturn="True"
|
||||
VerticalScrollBarVisibility="Auto">
|
||||
<!--key binding of "Enter"-->
|
||||
<TextBox.InputBindings>
|
||||
<KeyBinding Command="{Binding SubmitQuestionCommand}" Key="Enter"/>
|
||||
</TextBox.InputBindings>
|
||||
</TextBox>
|
||||
</Grid>
|
||||
|
||||
<!-- The third line: submit button -->
|
||||
<Grid Grid.Row="2">
|
||||
<WrapPanel Grid.Row="2" HorizontalAlignment="Right">
|
||||
|
||||
<Button x:Name="BtnNewChat" Content="新建会话"
|
||||
HorizontalAlignment="Right"
|
||||
Style="{StaticResource RoundCornerButtonStyle}"
|
||||
Command="{Binding NewSessionCommand}"
|
||||
Width="100"
|
||||
Height="30"/>
|
||||
<Button x:Name="BtnSubmit" Content="提交"
|
||||
HorizontalAlignment="Right"
|
||||
Style="{StaticResource RoundCornerButtonStyle}"
|
||||
Command="{Binding SubmitQuestionCommand}"
|
||||
Width="100"
|
||||
Height="30"/>
|
||||
</WrapPanel>
|
||||
</Grid>
|
||||
|
||||
</Grid>
|
||||
</UserControl>
|
||||
37
Views/ChatMdView.xaml.cs
Normal file
37
Views/ChatMdView.xaml.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
using YwxApp.AiChat.ViewModels;
|
||||
|
||||
namespace YwxApp.AiChat.Views
|
||||
{
|
||||
/// <summary>
|
||||
/// ChatMdView.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class ChatMdView : UserControl
|
||||
{
|
||||
public ChatMdView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
ChatMdViewModel viewModel;
|
||||
public ChatMdView(ShareOllamaObject shareOllama)
|
||||
{
|
||||
InitializeComponent();
|
||||
viewModel = new ChatMdViewModel();
|
||||
viewModel.SetOllama(shareOllama);
|
||||
this.DataContext = viewModel;
|
||||
}
|
||||
}
|
||||
}
|
||||
58
Views/SettingView.xaml
Normal file
58
Views/SettingView.xaml
Normal file
@@ -0,0 +1,58 @@
|
||||
<UserControl x:Class="YwxApp.AiChat.Views.SettingView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
|
||||
<UserControl.Resources>
|
||||
<ResourceDictionary>
|
||||
<!--Resource dictionary : add the control style-->
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="Style/ButtonStyle.xaml"/>
|
||||
<ResourceDictionary Source="Style/TextBoxStyle.xaml"/>
|
||||
<ResourceDictionary Source="Style/LabelStyle.xaml"/>
|
||||
<ResourceDictionary Source="Style/ComboBoxStyle.xaml"/>
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
</ResourceDictionary>
|
||||
</UserControl.Resources>
|
||||
|
||||
|
||||
<Grid Background="#FFFFFF" HorizontalAlignment="Stretch">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="50"/>
|
||||
<RowDefinition Height="50"/>
|
||||
<RowDefinition Height="50"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<!-- The first line -->
|
||||
<WrapPanel Grid.Row="0" Margin="5" VerticalAlignment="Center" HorizontalAlignment="Left">
|
||||
<Label Content="Ollama路径:" Margin="5" HorizontalAlignment="Left" VerticalAlignment="Center" />
|
||||
<TextBox x:Name="Tbx_OllamaAppPath" FontSize="12"
|
||||
Text="{Binding OllamaAppPath}"
|
||||
Style="{StaticResource SearchBoxStyle}" Margin="5" />
|
||||
</WrapPanel>
|
||||
|
||||
<!--The second line-->
|
||||
<WrapPanel Grid.Row="1" Margin="5" VerticalAlignment="Center" HorizontalAlignment="Left">
|
||||
<Label Content="Ollama:" VerticalAlignment="Center" Margin="5" />
|
||||
<Label Name="Label_State" Style="{StaticResource RoundLabelStyle}" />
|
||||
<Button Content="打开" Style="{StaticResource RoundCornerButtonStyle}"
|
||||
Command="{Binding StartOllamaServerCommand}"/>
|
||||
</WrapPanel>
|
||||
|
||||
<!--The third line-->
|
||||
<WrapPanel Grid.Row="2" Margin="5" VerticalAlignment="Center" HorizontalAlignment="Left">
|
||||
<Label Content="模型:" VerticalAlignment="Center" Margin="5" />
|
||||
<ComboBox x:Name="Cbx_ModelList" Style="{StaticResource RoundComboBoxStyle}"
|
||||
ItemsSource="{Binding ModelList}"
|
||||
SelectedItem="{Binding SelectedModel}">
|
||||
</ComboBox>
|
||||
<Button Content="刷新" Margin="5" Grid.Row="1"
|
||||
Style="{StaticResource RoundCornerButtonStyle}"
|
||||
Command="{Binding ModelListUpdateCommand}"/>
|
||||
</WrapPanel>
|
||||
<TextBox x:Name="ModelDesciption" Grid.Row="3" IsReadOnly="True"
|
||||
TextWrapping="WrapWithOverflow" Text="{Binding ModelInformation,Mode=OneWay}"/>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
20
Views/SettingView.xaml.cs
Normal file
20
Views/SettingView.xaml.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using System.Windows.Controls;
|
||||
using YwxApp.AiChat.ViewModels;
|
||||
|
||||
namespace YwxApp.AiChat.Views
|
||||
{
|
||||
/// <summary>
|
||||
/// SettingView.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
|
||||
public partial class SettingView : UserControl
|
||||
{
|
||||
SettingViewModel _viewModel;
|
||||
public SettingView(ShareOllamaObject ollama)
|
||||
{
|
||||
InitializeComponent();
|
||||
_viewModel = new SettingViewModel(ollama);
|
||||
this.DataContext = _viewModel;
|
||||
}
|
||||
}
|
||||
}
|
||||
33
Views/Style/ButtonStyle.xaml
Normal file
33
Views/Style/ButtonStyle.xaml
Normal file
@@ -0,0 +1,33 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
|
||||
<Style x:Key="IconButtonStyle">
|
||||
|
||||
<Setter Property="Button.Background" Value="Transparent"/>
|
||||
<Setter Property="Button.BorderBrush" Value="Transparent"/>
|
||||
<Setter Property="Button.BorderThickness" Value="0"/>
|
||||
<Setter Property="Button.Foreground" Value="White"/>
|
||||
<Setter Property="Button.FontSize" Value="12"/>
|
||||
<Setter Property="Button.FontWeight" Value="Bold"/>
|
||||
<Setter Property="Button.Padding" Value="5"/>
|
||||
<Setter Property="Button.Margin" Value="5"/>
|
||||
<Setter Property="Button.Width" Value="150"/>
|
||||
<Setter Property="Button.Height" Value="50"/>
|
||||
<Setter Property="Button.HorizontalAlignment" Value="Left"/>
|
||||
<Setter Property="Button.VerticalAlignment" Value="Center"/>
|
||||
<Setter Property="Button.Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="Button">
|
||||
<Border Background="{TemplateBinding Background}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}">
|
||||
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
<Style x:Key="RoundCornerButtonStyle">
|
||||
|
||||
</Style>
|
||||
</ResourceDictionary>
|
||||
9
Views/Style/ComboBoxStyle.xaml
Normal file
9
Views/Style/ComboBoxStyle.xaml
Normal file
@@ -0,0 +1,9 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<Style x:Key="SearchBoxStyle">
|
||||
|
||||
</Style>
|
||||
<Style x:Key="RoundComboBoxStyle">
|
||||
|
||||
</Style>
|
||||
</ResourceDictionary>
|
||||
6
Views/Style/LabelStyle.xaml
Normal file
6
Views/Style/LabelStyle.xaml
Normal file
@@ -0,0 +1,6 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<Style x:Key="RoundLabelStyle">
|
||||
|
||||
</Style>
|
||||
</ResourceDictionary>
|
||||
4
Views/Style/TextBoxStyle.xaml
Normal file
4
Views/Style/TextBoxStyle.xaml
Normal file
@@ -0,0 +1,4 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
|
||||
</ResourceDictionary>
|
||||
Reference in New Issue
Block a user