ux: Add default terminal settings UI.

This commit is contained in:
walterlv 2024-04-08 18:49:47 +08:00
parent acbf3605fd
commit 41f7aa84ac
5 changed files with 101 additions and 6 deletions

View file

@ -6,9 +6,12 @@ using System.Threading.Tasks;
using Avalonia.Collections;
using Avalonia.Controls;
using Avalonia.Data.Converters;
using Avalonia.Input;
using Avalonia.Interactivity;
using Avalonia.Media;
using Avalonia.Media.Imaging;
using Avalonia.Platform;
using Avalonia.Platform.Storage;
using Avalonia.Threading;
@ -242,4 +245,42 @@ namespace SourceGit.Views
}
}
}
public sealed class TerminalOrShellNameToBitmapConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is string terminalName && !string.IsNullOrWhiteSpace(terminalName))
{
var icon = AssetLoader.Open(new Uri($"avares://SourceGit/Resources/ExternalTerminalIcons/{terminalName}.png", UriKind.RelativeOrAbsolute));
return new Bitmap(icon);
}
return null;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotSupportedException();
}
}
public sealed class TerminalOrShellNameToLocalizedNameConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is string terminalName && !string.IsNullOrWhiteSpace(terminalName))
{
var name = App.Text($"Text.Preference.General.DefaultTerminalOrShell.{terminalName}");
return name;
}
return null;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotSupportedException();
}
}
}