From 0a3a69e5e65ed6a5814c133c5c8fba4fa16b3370 Mon Sep 17 00:00:00 2001 From: Anonymous Date: Wed, 9 Oct 2024 02:09:50 +0200 Subject: [PATCH] v3.0.0.42 - Fix blacklist not accepting newline. --- e621 ReBot v3/Windows/Window_Blacklist.xaml | 2 +- .../Windows/Window_Blacklist.xaml.cs | 25 +++++++++++++++++-- e621 ReBot v3/e621 ReBot v3.csproj | 2 +- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/e621 ReBot v3/Windows/Window_Blacklist.xaml b/e621 ReBot v3/Windows/Window_Blacklist.xaml index da7fd41..f9fad3a 100644 --- a/e621 ReBot v3/Windows/Window_Blacklist.xaml +++ b/e621 ReBot v3/Windows/Window_Blacklist.xaml @@ -7,6 +7,6 @@ Title="Blacklist" Height="256" Width="512" WindowStyle="ToolWindow" ResizeMode="NoResize" WindowStartupLocation="CenterOwner" ShowInTaskbar="False" Loaded="Window_Loaded" Closed="Window_Closed"> - + diff --git a/e621 ReBot v3/Windows/Window_Blacklist.xaml.cs b/e621 ReBot v3/Windows/Window_Blacklist.xaml.cs index 02ddcc4..56e0184 100644 --- a/e621 ReBot v3/Windows/Window_Blacklist.xaml.cs +++ b/e621 ReBot v3/Windows/Window_Blacklist.xaml.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Linq; using System.Windows; +using System.Windows.Input; namespace e621_ReBot_v3 { @@ -20,16 +21,36 @@ private void Window_Loaded(object sender, RoutedEventArgs e) { if (AppSettings.Blacklist.Any()) { - Blacklist_TextBox.Text = string.Join(' ', AppSettings.Blacklist); + Blacklist_TextBox.Text = string.Join(Environment.NewLine, AppSettings.Blacklist) + Environment.NewLine; Blacklist_TextBox.SelectionStart = Blacklist_TextBox.Text.Length; } Blacklist_TextBox.Focus(); } + private void Blacklist_TextBox_PreviewKeyDown(object sender, KeyEventArgs e) + { + switch (e.Key) + { + case Key.Enter: + { + if (Blacklist_TextBox.SelectionStart > 2) + { + string NewLineChecker = Blacklist_TextBox.Text.Substring(Blacklist_TextBox.SelectionStart - 2, 2); + if (NewLineChecker.Equals("\r\n")) + { + e.Handled = true; + return; + } + } + break; + } + } + } + private void Window_Closed(object sender, EventArgs e) { List NewBlacklist = new List(); - Blacklist_TextBox.Text = Blacklist_TextBox.Text.ToLower(); + Blacklist_TextBox.Text = Blacklist_TextBox.Text.Trim().ToLower(); for (int i = 0; i < Blacklist_TextBox.LineCount; i++) { string TBLine = Blacklist_TextBox.GetLineText(i).Trim(); diff --git a/e621 ReBot v3/e621 ReBot v3.csproj b/e621 ReBot v3/e621 ReBot v3.csproj index ea77453..952fd65 100644 --- a/e621 ReBot v3/e621 ReBot v3.csproj +++ b/e621 ReBot v3/e621 ReBot v3.csproj @@ -11,7 +11,7 @@ Resources\ReBot_Icon.ico x64 False - 3.0.0.41 + 3.0.0.42 e621_ReBot_v3.App False https://github.com/e621-ReBot/e621-ReBot-v3