9
9
using System . Windows . Interop ;
10
10
11
11
namespace CSharpRegexTools4Npp
12
- {
13
-
12
+ {
14
13
public class Main
15
14
{
16
15
internal const string PluginName = "C# Regex Tools 4 Npp" ;
17
- static int idMyDlg = 0 ;
18
- static Bitmap tbBmp = Resources . icon ;
16
+ private static int idMyDlg = 0 ;
17
+ private static readonly Bitmap tbBmp = Resources . icon ;
19
18
//static RegExToolDialog dialog = null;
20
19
21
20
//Import the FindWindow API to find our window
@@ -30,10 +29,10 @@ public class Main
30
29
private static extern IntPtr SetWindowLong ( IntPtr hWnd , int windowLongFlags , IntPtr dwNewLong ) ;
31
30
32
31
[ DllImport ( "user32.dll" , SetLastError = true , CharSet = CharSet . Auto ) ]
33
- static extern int GetWindowLong ( IntPtr hWnd , int nIndex ) ;
32
+ private static extern int GetWindowLong ( IntPtr hWnd , int nIndex ) ;
34
33
35
34
[ DllImport ( "user32.dll" , CharSet = CharSet . Auto ) ]
36
- static extern long SetLayeredWindowAttributes ( IntPtr hwnd , uint crKey , byte bAlpha , uint dwFlags ) ;
35
+ private static extern long SetLayeredWindowAttributes ( IntPtr hwnd , uint crKey , byte bAlpha , uint dwFlags ) ;
37
36
38
37
public const int GWL_EXSTYLE = - 20 ;
39
38
public const int WS_EX_LAYERED = 0x80000 ;
@@ -103,7 +102,7 @@ public static void ShowTheDialog()
103
102
{
104
103
GetText = ( ) => BNpp . Text ,
105
104
106
- SetText = ( string text ) =>
105
+ SetText = text =>
107
106
{
108
107
if ( Keyboard . IsKeyDown ( Key . LeftCtrl ) || Keyboard . IsKeyDown ( Key . RightCtrl ) )
109
108
{
@@ -113,7 +112,7 @@ public static void ShowTheDialog()
113
112
BNpp . Text = text ;
114
113
} ,
115
114
116
- SetTextInNew = ( string text ) =>
115
+ SetTextInNew = text =>
117
116
{
118
117
BNpp . NotepadPP . FileNew ( ) ;
119
118
@@ -122,25 +121,27 @@ public static void ShowTheDialog()
122
121
123
122
GetSelectedText = ( ) => BNpp . SelectedText ,
124
123
125
- SetPosition = ( int index , int length ) => BNpp . SelectTextAndShow ( index , index + length ) ,
124
+ SetPosition = ( index , length ) => BNpp . SelectTextAndShow ( index , index + length ) ,
126
125
127
- SetSelection = ( int index , int length ) => BNpp . AddSelection ( index , index + length ) ,
126
+ SetSelection = ( index , length ) => BNpp . AddSelection ( index , index + length ) ,
128
127
129
128
GetSelectionStartIndex = ( ) => BNpp . SelectionStart ,
130
129
131
130
GetSelectionLength = ( ) => BNpp . SelectionLength ,
132
131
133
132
SaveCurrentDocument = ( ) => BNpp . NotepadPP . SaveCurrentFile ( ) ,
134
133
135
- TryOpen = ( string fileName , bool onlyIfAlreadyOpen ) =>
134
+ TryOpen = ( fileName , onlyIfAlreadyOpen ) =>
136
135
{
137
136
try
138
137
{
139
138
bool result = false ;
140
139
141
- if ( BNpp . NotepadPP . CurrentFileName . ToLower ( ) . Equals ( fileName . ToLower ( ) ) )
140
+ if ( BNpp . NotepadPP . CurrentFileName . Equals ( fileName , StringComparison . OrdinalIgnoreCase ) )
141
+ {
142
142
result = true ;
143
- else if ( BNpp . NotepadPP . GetAllOpenedDocuments . Any ( ( string s ) => s . Equals ( fileName , StringComparison . OrdinalIgnoreCase ) ) )
143
+ }
144
+ else if ( BNpp . NotepadPP . GetAllOpenedDocuments . Any ( s => s . Equals ( fileName , StringComparison . OrdinalIgnoreCase ) ) )
144
145
{
145
146
BNpp . NotepadPP . ShowOpenedDocument ( fileName ) ;
146
147
result = true ;
0 commit comments