This commit is contained in:
Michael Bucari-Tovo 2023-01-07 23:27:28 -07:00
parent 7fafee804d
commit 452ceef285
2 changed files with 8 additions and 9 deletions

View File

@ -1,4 +1,4 @@
using Avalonia.Markup.Xaml;
using Avalonia.Markup.Xaml;
using Avalonia.Media;
using Dinah.Core;
using LibationFileManager;
@ -50,11 +50,11 @@ namespace LibationAvalonia.Dialogs
{
var dataGrid = sender as DataGrid;
var item = dataGrid.SelectedItem as Tuple<string, string>;
var item = (dataGrid.SelectedItem as Tuple<string, string>).Item1.Replace("\x200C", "").Replace("...", "");
var text = userEditTbox.Text;
userEditTbox.Text = text.Insert(Math.Min(Math.Max(0, userEditTbox.CaretIndex), text.Length), item.Item1);
userEditTbox.CaretIndex += item.Item1.Length;
userEditTbox.Text = text.Insert(Math.Min(Math.Max(0, userEditTbox.CaretIndex), text.Length), item);
userEditTbox.CaretIndex += item.Length;
}
protected override async Task SaveAndCloseAsync()

View File

@ -5,7 +5,6 @@ using System.IO;
using System.Windows.Forms;
using Dinah.Core;
using LibationFileManager;
using System.Windows.Controls;
namespace LibationWinForms.Dialogs
{
@ -60,7 +59,7 @@ namespace LibationWinForms.Dialogs
// populate list view
foreach (var tag in template.GetTemplateTags())
listView1.Items.Add(new System.Windows.Forms.ListViewItem(new[] { $"<{tag.TagName}>", tag.Description }));
listView1.Items.Add(new ListViewItem(new[] { $"<{tag.TagName}>", tag.Description }));
}
private void resetToDefaultBtn_Click(object sender, EventArgs e) => resetTextBox(template.DefaultTemplate);
@ -201,13 +200,13 @@ namespace LibationWinForms.Dialogs
private void listView1_DoubleClick(object sender, EventArgs e)
{
var item = listView1.SelectedItems[0];
var itemText = listView1.SelectedItems[0].Text.Replace("...", "");
var text = templateTb.Text;
var selStart = Math.Min(Math.Max(0, templateTb.SelectionStart), text.Length);
templateTb.Text = text.Insert(selStart, item.Text);
templateTb.SelectionStart = selStart + item.Text.Length;
templateTb.Text = text.Insert(selStart, itemText);
templateTb.SelectionStart = selStart + itemText.Length;
}
}
}