|
@@ -1,4 +1,5 @@
|
|
|
using InABox.Core;
|
|
|
+using InABox.Wpf;
|
|
|
using InABox.WPF;
|
|
|
using Syncfusion.Data.Extensions;
|
|
|
using System;
|
|
@@ -72,6 +73,35 @@ public class TagsEditorControl : DynamicEditorControl<string, TagsEditor>
|
|
|
TagList = new ListBox();
|
|
|
TagList.Width = Editor.ActualWidth;
|
|
|
TagList.Height = 100;
|
|
|
+ TagList.HorizontalContentAlignment = HorizontalAlignment.Stretch;
|
|
|
+ TagList.ItemTemplate = TemplateGenerator.CreateDataTemplate(() =>
|
|
|
+ {
|
|
|
+ var panel = new DockPanel();
|
|
|
+
|
|
|
+ var item = new TextBlock();
|
|
|
+ item.Bind<string, string>(TextBlock.TextProperty, x => x);
|
|
|
+ DockPanel.SetDock(item, Dock.Left);
|
|
|
+
|
|
|
+ var btn = new Button();
|
|
|
+ btn.Content = "X";
|
|
|
+ btn.Width = 15;
|
|
|
+ btn.Height = 15;
|
|
|
+ btn.Padding = new();
|
|
|
+ btn.FontSize = 10;
|
|
|
+ btn.VerticalAlignment = VerticalAlignment.Center;
|
|
|
+ btn.VerticalContentAlignment = VerticalAlignment.Center;
|
|
|
+ btn.Background = Colors.Transparent.ToBrush();
|
|
|
+ btn.BorderBrush = Colors.Transparent.ToBrush();
|
|
|
+ btn.Bind<string, string>(Button.TagProperty, x => x);
|
|
|
+ btn.Bind(Button.VisibilityProperty, panel, x => x.IsMouseOver, new WPF.BooleanToVisibilityConverter(Visibility.Visible, Visibility.Collapsed));
|
|
|
+ DockPanel.SetDock(btn, Dock.Right);
|
|
|
+ btn.Click += DeleteTag_Click;
|
|
|
+
|
|
|
+ panel.Children.Add(btn);
|
|
|
+ panel.Children.Add(item);
|
|
|
+
|
|
|
+ return panel;
|
|
|
+ });
|
|
|
TagList.ItemsSource = RecentTags;
|
|
|
TagList.MouseUp += TagList_MouseUp;
|
|
|
|
|
@@ -82,6 +112,17 @@ public class TagsEditorControl : DynamicEditorControl<string, TagsEditor>
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private void DeleteTag_Click(object sender, RoutedEventArgs e)
|
|
|
+ {
|
|
|
+ if (sender is not Button btn || btn.Tag is not string tag) return;
|
|
|
+
|
|
|
+ if (RecentTags.Remove(tag))
|
|
|
+ {
|
|
|
+ OnRecentTagsChanged?.Invoke(RecentTags);
|
|
|
+ UpdateTagList();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private void TagList_MouseUp(object sender, MouseButtonEventArgs e)
|
|
|
{
|
|
|
AddSelectedTag();
|