99using System . Windows . Interop ;
1010
1111namespace CSharpRegexTools4Npp
12- {
13-
12+ {
1413 public class Main
1514 {
1615 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 ;
1918 //static RegExToolDialog dialog = null;
2019
2120 //Import the FindWindow API to find our window
@@ -30,10 +29,10 @@ public class Main
3029 private static extern IntPtr SetWindowLong ( IntPtr hWnd , int windowLongFlags , IntPtr dwNewLong ) ;
3130
3231 [ 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 ) ;
3433
3534 [ 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 ) ;
3736
3837 public const int GWL_EXSTYLE = - 20 ;
3938 public const int WS_EX_LAYERED = 0x80000 ;
@@ -103,7 +102,7 @@ public static void ShowTheDialog()
103102 {
104103 GetText = ( ) => BNpp . Text ,
105104
106- SetText = ( string text ) =>
105+ SetText = text =>
107106 {
108107 if ( Keyboard . IsKeyDown ( Key . LeftCtrl ) || Keyboard . IsKeyDown ( Key . RightCtrl ) )
109108 {
@@ -113,7 +112,7 @@ public static void ShowTheDialog()
113112 BNpp . Text = text ;
114113 } ,
115114
116- SetTextInNew = ( string text ) =>
115+ SetTextInNew = text =>
117116 {
118117 BNpp . NotepadPP . FileNew ( ) ;
119118
@@ -122,25 +121,27 @@ public static void ShowTheDialog()
122121
123122 GetSelectedText = ( ) => BNpp . SelectedText ,
124123
125- SetPosition = ( int index , int length ) => BNpp . SelectTextAndShow ( index , index + length ) ,
124+ SetPosition = ( index , length ) => BNpp . SelectTextAndShow ( index , index + length ) ,
126125
127- SetSelection = ( int index , int length ) => BNpp . AddSelection ( index , index + length ) ,
126+ SetSelection = ( index , length ) => BNpp . AddSelection ( index , index + length ) ,
128127
129128 GetSelectionStartIndex = ( ) => BNpp . SelectionStart ,
130129
131130 GetSelectionLength = ( ) => BNpp . SelectionLength ,
132131
133132 SaveCurrentDocument = ( ) => BNpp . NotepadPP . SaveCurrentFile ( ) ,
134133
135- TryOpen = ( string fileName , bool onlyIfAlreadyOpen ) =>
134+ TryOpen = ( fileName , onlyIfAlreadyOpen ) =>
136135 {
137136 try
138137 {
139138 bool result = false ;
140139
141- if ( BNpp . NotepadPP . CurrentFileName . ToLower ( ) . Equals ( fileName . ToLower ( ) ) )
140+ if ( BNpp . NotepadPP . CurrentFileName . Equals ( fileName , StringComparison . OrdinalIgnoreCase ) )
141+ {
142142 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 ) ) )
144145 {
145146 BNpp . NotepadPP . ShowOpenedDocument ( fileName ) ;
146147 result = true ;
0 commit comments