@@ -43,7 +43,10 @@ public WordPair(string americanWord, string britishWord, XElement documentNode)
4343 if ( list . Count > 0 || ! _isOk )
4444 {
4545 if ( list . Count == 1 )
46+ {
4647 list . First . Value . BackColor = HighlightColor ;
48+ }
49+
4750 BackColor = HighlightColor ;
4851 }
4952 _pairNode = list . AddLast ( this ) ;
@@ -80,9 +83,14 @@ public override void Remove()
8083 var list = _pairNode . List ;
8184 list . Remove ( _pairNode ) ;
8285 if ( list . Count == 0 )
86+ {
8387 PairsByUs . Remove ( _usWord ) ;
88+ }
8489 else if ( list . Count == 1 && list . First . Value . _isOk )
90+ {
8591 list . First . Value . BackColor = _defaultColor ;
92+ }
93+
8694 _node . Remove ( ) ;
8795 base . Remove ( ) ;
8896 }
@@ -96,7 +104,9 @@ public int Compare(object o1, object o2)
96104 {
97105 cmp = string . Compare ( wp1 . Text , wp2 . Text , StringComparison . InvariantCultureIgnoreCase ) ;
98106 if ( cmp == 0 )
107+ {
99108 cmp = wp1 . _sortIndex . CompareTo ( wp2 . _sortIndex ) ;
109+ }
100110 }
101111 return cmp ;
102112 }
@@ -153,7 +163,10 @@ private void InitializeListView(XDocument xdoc)
153163 private void buttonOK_Click ( object sender , EventArgs e )
154164 {
155165 if ( _path != null && _xdoc != null )
166+ {
156167 _xdoc . Save ( _path ) ;
168+ }
169+
157170 DialogResult = DialogResult . OK ;
158171 }
159172
@@ -216,7 +229,9 @@ private void toolStripMenuItemRemoveSelected_Click(object sender, EventArgs e)
216229 private void contextMenuStrip1_Opening ( object sender , CancelEventArgs e )
217230 {
218231 if ( _path == null )
232+ {
219233 e . Cancel = true ;
234+ }
220235 }
221236
222237 private void ManageWordsForm_FormClosed ( object sender , FormClosedEventArgs e )
@@ -251,9 +266,14 @@ private void textBoxBritishAmerican_KeyDown(object sender, KeyEventArgs e)
251266 {
252267 var caret = tb . SelectionStart ;
253268 if ( caret > 0 )
269+ {
254270 tb . Select ( 0 , caret ) ;
271+ }
255272 else
273+ {
256274 tb . SelectAll ( ) ;
275+ }
276+
257277 tb . Copy ( ) ;
258278 tb . Select ( caret , 0 ) ;
259279 e . SuppressKeyPress = true ;
@@ -266,9 +286,14 @@ private void textBoxBritishAmerican_KeyDown(object sender, KeyEventArgs e)
266286 {
267287 var caret = tb . SelectionStart ;
268288 if ( caret > 0 )
289+ {
269290 tb . Select ( 0 , caret ) ;
291+ }
270292 else
293+ {
271294 tb . SelectAll ( ) ;
295+ }
296+
272297 tb . Cut ( ) ;
273298 tb . Select ( 0 , 0 ) ;
274299 e . SuppressKeyPress = true ;
@@ -282,7 +307,10 @@ private void listView1_KeyDown(object sender, KeyEventArgs e)
282307 {
283308 toolStripMenuItemRemoveSelected_Click ( null , null ) ;
284309 if ( ! string . IsNullOrWhiteSpace ( textBoxAmerican . Text ) )
310+ {
285311 textBoxBritish . Select ( ) ;
312+ }
313+
286314 e . SuppressKeyPress = true ;
287315 }
288316 else if ( e . KeyData == Keys . Right )
@@ -309,7 +337,10 @@ private void SetFocusToHighlighted(int direction)
309337 do
310338 {
311339 if ( ( index = ( index + direction + items . Count ) % items . Count ) == start )
340+ {
312341 return ;
342+ }
343+
313344 item = items [ index ] as WordPair ;
314345 }
315346 while ( item . IsHighlighted ) ;
@@ -320,7 +351,9 @@ private void SetFocusToHighlighted(int direction)
320351 while ( ! ( item = items [ index ] as WordPair ) . IsHighlighted )
321352 {
322353 if ( ( index = ( index + direction + items . Count ) % items . Count ) == start )
354+ {
323355 return ;
356+ }
324357 }
325358 listView1 . SelectedItems . Clear ( ) ;
326359 item . EnsureVisible ( ) ;
0 commit comments