feat: added AvaloniaEdit for the text editor with basic highlight an line count, better "about" dialog and adde textmate
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Media.Imaging;
|
||||
@ -627,14 +628,24 @@ public partial class MainWindowViewModel : ViewModelBase
|
||||
[RelayCommand]
|
||||
private void SaveEdit()
|
||||
{
|
||||
if (SelectedNode?.Entry == null || PreviewText == null) return;
|
||||
if (SelectedNode?.Entry == null) return;
|
||||
|
||||
// Get the current text from the AvaloniaEdit editor via the window
|
||||
string? editorText = null;
|
||||
if (_window is GsaEditor.Views.MainWindow mainWindow)
|
||||
{
|
||||
editorText = mainWindow.GetEditorText();
|
||||
}
|
||||
|
||||
if (editorText == null) editorText = PreviewText ?? string.Empty;
|
||||
|
||||
var entry = SelectedNode.Entry;
|
||||
var newData = Encoding.UTF8.GetBytes(PreviewText);
|
||||
var newData = Encoding.UTF8.GetBytes(editorText);
|
||||
entry.SetData(newData, entry.IsCompressed);
|
||||
|
||||
IsDirty = true;
|
||||
IsEditingText = false;
|
||||
PreviewText = editorText;
|
||||
|
||||
var entryVm = new EntryViewModel(entry);
|
||||
entryVm.OnModified = () => { IsDirty = true; NotifyStatusChanged(); };
|
||||
@ -660,8 +671,17 @@ public partial class MainWindowViewModel : ViewModelBase
|
||||
private async Task ShowAbout()
|
||||
{
|
||||
if (_window == null) return;
|
||||
|
||||
var appVersion = Assembly.GetExecutingAssembly().GetName().Version;
|
||||
var versionStr = appVersion != null ? $"{appVersion.Major}.{appVersion.Minor}.{appVersion.Build}" : "1.0.0";
|
||||
var avaloniaVersion = typeof(Avalonia.Application).Assembly.GetName().Version;
|
||||
var avaloniaStr = avaloniaVersion != null ? $"{avaloniaVersion.Major}.{avaloniaVersion.Minor}.{avaloniaVersion.Build}" : "unknown";
|
||||
|
||||
await Dialogs.ShowMessageAsync(_window, "About GsaEditor",
|
||||
"GsaEditor v1.0\n\nGSA Archive Viewer & Editor\nBuilt with Avalonia UI");
|
||||
$"GsaEditor v{versionStr}\n\n" +
|
||||
$"GSA Archive Viewer & Editor\n" +
|
||||
$"By Develter Innovation (Nicolas RACOT)\n\n" +
|
||||
$"Built with Avalonia UI v{avaloniaStr}");
|
||||
}
|
||||
|
||||
// =========================================================================
|
||||
|
||||
Reference in New Issue
Block a user