Skip to content

Commit 6c7831d

Browse files
committed
Add split after command in ETW
1 parent 61730d3 commit 6c7831d

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

Text-Grab/Views/EditTextWindow.xaml

+8
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@
7575
CanExecute="SplitOnSelectionCmdCanExecute"
7676
Command="{x:Static local:EditTextWindow.SplitOnSelectionCmd}"
7777
Executed="SplitOnSelectionCmdExecuted" />
78+
<CommandBinding
79+
CanExecute="SplitOnSelectionCmdCanExecute"
80+
Command="{x:Static local:EditTextWindow.SplitAfterSelectionCmd}"
81+
Executed="SplitAfterSelectionCmdExecuted" />
7882
<CommandBinding
7983
CanExecute="IsolateSelectionCmdCanExecute"
8084
Command="{x:Static local:EditTextWindow.IsolateSelectionCmd}"
@@ -284,6 +288,10 @@
284288
x:Name="SplitLineBeforeSelectionMI"
285289
Command="{x:Static local:EditTextWindow.SplitOnSelectionCmd}"
286290
Header="Split Lines _Before Each Selection" />
291+
<MenuItem
292+
x:Name="SplitLineAfterSelectionMI"
293+
Command="{x:Static local:EditTextWindow.SplitAfterSelectionCmd}"
294+
Header="Split Lines _After Each Selection" />
287295
<MenuItem
288296
x:Name="IsolateSelectionMI"
289297
Command="{x:Static local:EditTextWindow.IsolateSelectionCmd}"

Text-Grab/Views/EditTextWindow.xaml.cs

+19
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System.Globalization;
66
using System.IO;
77
using System.Linq;
8+
using System.Security.Cryptography;
89
using System.Text;
910
using System.Text.RegularExpressions;
1011
using System.Threading;
@@ -46,6 +47,7 @@ public partial class EditTextWindow : Wpf.Ui.Controls.FluentWindow
4647
public static RoutedCommand ReplaceReservedCmd = new();
4748
public static RoutedCommand SingleLineCmd = new();
4849
public static RoutedCommand SplitOnSelectionCmd = new();
50+
public static RoutedCommand SplitAfterSelectionCmd = new();
4951
public static RoutedCommand ToggleCaseCmd = new();
5052
public static RoutedCommand UnstackCmd = new();
5153
public static RoutedCommand UnstackGroupCmd = new();
@@ -1894,6 +1896,23 @@ private void SplitOnSelectionCmdExecuted(object sender, ExecutedRoutedEventArgs
18941896
PassedTextControl.Text = textToManipulate.ToString();
18951897
}
18961898

1899+
private void SplitAfterSelectionCmdExecuted(object sender, ExecutedRoutedEventArgs e)
1900+
{
1901+
string selectedText = PassedTextControl.SelectedText;
1902+
1903+
if (string.IsNullOrEmpty(selectedText))
1904+
{
1905+
System.Windows.MessageBox.Show("No text selected", "Did not split lines");
1906+
return;
1907+
}
1908+
1909+
StringBuilder textToManipulate = new(PassedTextControl.Text);
1910+
1911+
textToManipulate = textToManipulate.Replace(selectedText, selectedText + Environment.NewLine);
1912+
1913+
PassedTextControl.Text = textToManipulate.ToString();
1914+
}
1915+
18971916
private void ToggleCase(object? sender = null, ExecutedRoutedEventArgs? e = null)
18981917
{
18991918
string textToModify = GetSelectedTextOrAllText();

0 commit comments

Comments
 (0)