Files
SzmediTools/Szmedi.AIScriptRunner/RvScript/RoleToDisplayConverter.cs
2025-09-16 16:06:41 +08:00

78 lines
2.6 KiB
C#

using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Data;
using System.Windows.Media;
using LangChain.Providers;
namespace Szmedi.AIScriptRunner.RvScript
{
internal class RoleToDisplayConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is MessageRole role)
{
switch (role)
{
case MessageRole.System:
break;
case MessageRole.Human:
if (targetType == typeof(HorizontalAlignment))
{
return HorizontalAlignment.Right;
}
else if (targetType == typeof(Brush))
{
var UserMessgeBrush = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#785dc8"));
return UserMessgeBrush;
}
else if (targetType == typeof(Visibility))
{
return Visibility.Collapsed;
}
break;
case MessageRole.Ai:
if (targetType == typeof(HorizontalAlignment))
{
return HorizontalAlignment.Left;
}
else if (targetType == typeof(Brush))
{
var ModelMessageBrush = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#292E33"));
return ModelMessageBrush;
}
else if (targetType == typeof(Visibility))
{
return Visibility.Visible;
}
break;
case MessageRole.Chat:
break;
case MessageRole.ToolCall:
break;
case MessageRole.ToolResult:
break;
default:
break;
}
}
return Binding.DoNothing;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}