-
Notifications
You must be signed in to change notification settings - Fork 262
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow clicking filename/FFmpeg parameters to insert into templates (#…
…1198) * Allow clicking template parameters to insert into template text boxes * Replace text selection if present * Remove FilenameTemplateParameters translation * Remove redundant style * Allow clicking ffmpeg templates * Remove FfmpegParameters translation * Return early if null * Add missing initialization check * Reorder date_custom * Reorder trim_start_custom * Add tooltips to filename parameters * Only allow left and middle mouse click * Focus inside *_custom parameter quotation marks when adding with middle mouse click * FileName -> Filename
- Loading branch information
Showing
17 changed files
with
762 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using System.Diagnostics.CodeAnalysis; | ||
using System.Windows.Controls; | ||
|
||
namespace TwitchDownloaderWPF.Extensions | ||
{ | ||
public static class TextBoxExtensions | ||
{ | ||
public static bool TryInsertAtCaret([AllowNull] this TextBox textBox, string textToInsert) | ||
{ | ||
if (textBox is null || string.IsNullOrEmpty(textToInsert)) | ||
{ | ||
return false; | ||
} | ||
|
||
var caretPos = textBox.CaretIndex; | ||
if (caretPos < 0) | ||
{ | ||
return false; | ||
} | ||
|
||
if (textBox.IsSelectionActive) | ||
{ | ||
textBox.Text = textBox.Text.Remove(caretPos, textBox.SelectionLength); | ||
} | ||
|
||
textBox.Text = textBox.Text.Insert(caretPos, textToInsert); | ||
textBox.CaretIndex = caretPos + textToInsert.Length; | ||
return true; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.