Skip to content

Commit 96fcbf5

Browse files
author
SlavaRa
committed
Remove CodeRefactor.Cotrols.LineEntryDialog
1 parent ffdd268 commit 96fcbf5

File tree

5 files changed

+25
-40
lines changed

5 files changed

+25
-40
lines changed

External/Plugins/CodeRefactor/CodeRefactor.csproj

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,6 @@
9898
<Compile Include="Controls\DividedCheckedListBox.cs">
9999
<SubType>Component</SubType>
100100
</Compile>
101-
<Compile Include="Controls\LineEntryDialog.cs">
102-
<SubType>Form</SubType>
103-
</Compile>
104101
<Compile Include="Controls\ProgressDialog.cs">
105102
<SubType>Form</SubType>
106103
</Compile>

External/Plugins/CodeRefactor/Commands/Rename.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
using PluginCore.Helpers;
1414
using PluginCore.Localization;
1515
using PluginCore.Managers;
16+
using ProjectManager.Helpers;
1617
using ProjectManager.Projects;
1718

1819
namespace CodeRefactor.Commands
@@ -370,8 +371,7 @@ private String GetNewName(String originalName)
370371
{
371372
String label = TextHelper.GetString("Label.NewName");
372373
String title = String.Format(TextHelper.GetString("Title.RenameDialog"), originalName);
373-
String suggestion = originalName;
374-
LineEntryDialog askName = new LineEntryDialog(title, label, suggestion);
374+
LineEntryDialog askName = new LineEntryDialog(title, label, originalName);
375375
DialogResult choice = askName.ShowDialog();
376376
if (choice == DialogResult.OK && askName.Line.Trim().Length > 0 && askName.Line.Trim() != originalName)
377377
{

External/Plugins/CodeRefactor/Controls/LineEntryDialog.cs

Lines changed: 0 additions & 32 deletions
This file was deleted.

External/Plugins/CodeRefactor/PluginMain.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
using PluginCore.Managers;
1717
using PluginCore.Utilities;
1818
using ProjectManager.Actions;
19+
using ProjectManager.Helpers;
1920

2021
namespace CodeRefactor
2122
{

External/Plugins/ProjectManager/Helpers/LineEntryDialog.cs

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,18 @@
33
using System.Collections;
44
using System.ComponentModel;
55
using System.Windows.Forms;
6+
using PluginCore;
67
using PluginCore.Localization;
78

89
namespace ProjectManager.Helpers
910
{
1011
/// <summary>
1112
/// A simple form where a user can enter a text string.
1213
/// </summary>
13-
public class LineEntryDialog : System.Windows.Forms.Form
14+
public class LineEntryDialog : Form
1415
{
16+
readonly Keys shortcutToLowercase;
17+
readonly Keys shortcutToUppercase;
1518
string line;
1619

1720
#region Form Designer Components
@@ -37,12 +40,14 @@ public string Line
3740

3841
public LineEntryDialog(string captionText, string labelText, string defaultLine)
3942
{
43+
shortcutToLowercase = PluginBase.MainForm.GetShortcutItemKeys("EditMenu.ToLowercase");
44+
shortcutToUppercase = PluginBase.MainForm.GetShortcutItemKeys("EditMenu.ToUppercase");
4045
InitializeComponent();
4146
InititalizeLocalization();
42-
this.Font = PluginCore.PluginBase.Settings.DefaultFont;
43-
47+
this.Font = PluginBase.Settings.DefaultFont;
4448
this.Text = " " + captionText;
4549
titleLabel.Text = labelText;
50+
lineBox.KeyDown += OnLineBoxOnKeyDown;
4651
lineBox.Text = (defaultLine != null) ? defaultLine : string.Empty;
4752
lineBox.SelectAll();
4853
lineBox.Focus();
@@ -167,6 +172,20 @@ private void btnCancel_Click(object sender, System.EventArgs e)
167172
this.Close();
168173
}
169174

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+
170189
public void SelectRange(int start, int length)
171190
{
172191
lineBox.Select(start, length);

0 commit comments

Comments
 (0)