Pointless Waymarks Tools

Artifact [03ca11adeb]
Login

Artifact [03ca11adeb]

Artifact 03ca11adeb9d940210341187edcf97018692db82d52d6ff76e0ef8fd1e4af8c0:


using System.Windows;
using System.Windows.Controls;
using CommunityToolkit.Mvvm.Input;
using PointlessWaymarks.LlamaAspects;

namespace PointlessWaymarks.WpfCommon.Utility;

[NotifyPropertyChanged]
public partial class CurrentSelectedTextTracker
{
    public CurrentSelectedTextTracker()
    {
        SelectedTextChangedCommand = new RelayCommand<RoutedEventArgs>(SelectedTextChanged);
    }

    public string? CurrentSelectedText { get; set; }
    public RelayCommand<RoutedEventArgs> SelectedTextChangedCommand { get; set; }

    private void SelectedTextChanged(RoutedEventArgs? obj)
    {
        if (obj == null) return;

        var source = obj.Source as TextBox;
        CurrentSelectedText = source?.SelectedText;
    }
}