3
3
using System . Collections ;
4
4
using System . ComponentModel ;
5
5
using System . Windows . Forms ;
6
+ using PluginCore ;
6
7
using PluginCore . Localization ;
7
8
8
9
namespace ProjectManager . Helpers
9
10
{
10
11
/// <summary>
11
12
/// A simple form where a user can enter a text string.
12
13
/// </summary>
13
- public class LineEntryDialog : System . Windows . Forms . Form
14
+ public class LineEntryDialog : Form
14
15
{
16
+ readonly Keys shortcutToLowercase ;
17
+ readonly Keys shortcutToUppercase ;
15
18
string line ;
16
19
17
20
#region Form Designer Components
18
21
19
- private System . Windows . Forms . TextBox lineBox ;
22
+ protected System . Windows . Forms . TextBox lineBox ;
20
23
private System . Windows . Forms . Button btnOK ;
21
24
private System . Windows . Forms . Button btnCancel ;
22
25
/// <summary>
@@ -37,12 +40,14 @@ public string Line
37
40
38
41
public LineEntryDialog ( string captionText , string labelText , string defaultLine )
39
42
{
43
+ shortcutToLowercase = PluginBase . MainForm . GetShortcutItemKeys ( "EditMenu.ToLowercase" ) ;
44
+ shortcutToUppercase = PluginBase . MainForm . GetShortcutItemKeys ( "EditMenu.ToUppercase" ) ;
40
45
InitializeComponent ( ) ;
41
46
InititalizeLocalization ( ) ;
42
- this . Font = PluginCore . PluginBase . Settings . DefaultFont ;
43
-
47
+ this . Font = PluginBase . Settings . DefaultFont ;
44
48
this . Text = " " + captionText ;
45
49
titleLabel . Text = labelText ;
50
+ lineBox . KeyDown += OnLineBoxOnKeyDown ;
46
51
lineBox . Text = ( defaultLine != null ) ? defaultLine : string . Empty ;
47
52
lineBox . SelectAll ( ) ;
48
53
lineBox . Focus ( ) ;
@@ -167,6 +172,20 @@ private void btnCancel_Click(object sender, System.EventArgs e)
167
172
this . Close ( ) ;
168
173
}
169
174
175
+ void OnLineBoxOnKeyDown ( object sender , KeyEventArgs args )
176
+ {
177
+ string selectedText = lineBox . SelectedText ;
178
+ if ( string . IsNullOrEmpty ( selectedText ) ) return ;
179
+ Keys keys = args . KeyData ;
180
+ if ( keys == shortcutToLowercase ) selectedText = selectedText . ToLower ( ) ;
181
+ else if ( keys == shortcutToUppercase ) selectedText = selectedText . ToUpper ( ) ;
182
+ else return ;
183
+ int selectionStart = lineBox . SelectionStart ;
184
+ int selectionLength = lineBox . SelectionLength ;
185
+ lineBox . Paste ( selectedText ) ;
186
+ SelectRange ( selectionStart , selectionLength ) ;
187
+ }
188
+
170
189
public void SelectRange ( int start , int length )
171
190
{
172
191
lineBox . Select ( start , length ) ;
0 commit comments