Skip to content

Commit

Permalink
Add split after command in ETW
Browse files Browse the repository at this point in the history
  • Loading branch information
TheJoeFin committed Oct 28, 2024
1 parent 61730d3 commit 6c7831d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Text-Grab/Views/EditTextWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@
CanExecute="SplitOnSelectionCmdCanExecute"
Command="{x:Static local:EditTextWindow.SplitOnSelectionCmd}"
Executed="SplitOnSelectionCmdExecuted" />
<CommandBinding
CanExecute="SplitOnSelectionCmdCanExecute"
Command="{x:Static local:EditTextWindow.SplitAfterSelectionCmd}"
Executed="SplitAfterSelectionCmdExecuted" />
<CommandBinding
CanExecute="IsolateSelectionCmdCanExecute"
Command="{x:Static local:EditTextWindow.IsolateSelectionCmd}"
Expand Down Expand Up @@ -284,6 +288,10 @@
x:Name="SplitLineBeforeSelectionMI"
Command="{x:Static local:EditTextWindow.SplitOnSelectionCmd}"
Header="Split Lines _Before Each Selection" />
<MenuItem
x:Name="SplitLineAfterSelectionMI"
Command="{x:Static local:EditTextWindow.SplitAfterSelectionCmd}"
Header="Split Lines _After Each Selection" />
<MenuItem
x:Name="IsolateSelectionMI"
Command="{x:Static local:EditTextWindow.IsolateSelectionCmd}"
Expand Down
19 changes: 19 additions & 0 deletions Text-Grab/Views/EditTextWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Globalization;
using System.IO;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
Expand Down Expand Up @@ -46,6 +47,7 @@ public partial class EditTextWindow : Wpf.Ui.Controls.FluentWindow
public static RoutedCommand ReplaceReservedCmd = new();
public static RoutedCommand SingleLineCmd = new();
public static RoutedCommand SplitOnSelectionCmd = new();
public static RoutedCommand SplitAfterSelectionCmd = new();
public static RoutedCommand ToggleCaseCmd = new();
public static RoutedCommand UnstackCmd = new();
public static RoutedCommand UnstackGroupCmd = new();
Expand Down Expand Up @@ -1894,6 +1896,23 @@ private void SplitOnSelectionCmdExecuted(object sender, ExecutedRoutedEventArgs
PassedTextControl.Text = textToManipulate.ToString();
}

private void SplitAfterSelectionCmdExecuted(object sender, ExecutedRoutedEventArgs e)
{
string selectedText = PassedTextControl.SelectedText;

if (string.IsNullOrEmpty(selectedText))
{
System.Windows.MessageBox.Show("No text selected", "Did not split lines");
return;
}

StringBuilder textToManipulate = new(PassedTextControl.Text);

textToManipulate = textToManipulate.Replace(selectedText, selectedText + Environment.NewLine);

PassedTextControl.Text = textToManipulate.ToString();
}

private void ToggleCase(object? sender = null, ExecutedRoutedEventArgs? e = null)
{
string textToModify = GetSelectedTextOrAllText();
Expand Down

0 comments on commit 6c7831d

Please sign in to comment.