@@ -117,6 +117,8 @@ void drawMode(
117
117
if ( ! status && index == - 1 )
118
118
{
119
119
shapes . Add ( currentShape ) ;
120
+ if ( shapes . Count == 1 )
121
+ listBox1_SelectedIndexChanged ( null , null ) ;
120
122
RefreshShapes ( ) ;
121
123
}
122
124
else if ( ! status )
@@ -286,6 +288,8 @@ private void button3_Click(object sender, EventArgs e)
286
288
287
289
shapes . RemoveAt ( listBox1 . SelectedIndex ) ;
288
290
291
+ listBox1_SelectedIndexChanged ( null , null ) ;
292
+
289
293
RefreshShapes ( ) ;
290
294
}
291
295
@@ -311,7 +315,6 @@ private void openToolStripMenuItem_Click(object sender, EventArgs e)
311
315
if ( pictureBox1 . Image == null )
312
316
pictureBox1 . Image = new Bitmap ( pictureBox1 . Width , pictureBox1 . Height ) ;
313
317
314
-
315
318
var filePath = string . Empty ;
316
319
317
320
using ( OpenFileDialog openFileDialog = new OpenFileDialog ( ) )
@@ -391,6 +394,24 @@ private void showClipBorderToolStripMenuItem_Click(object sender, EventArgs e)
391
394
RefreshShapes ( ) ;
392
395
}
393
396
397
+ private void listBox1_SelectedIndexChanged ( object sender , EventArgs e )
398
+ {
399
+ if ( shapes . Count < 1 )
400
+ {
401
+ button4 . Enabled = false ;
402
+ button5 . Enabled = false ;
403
+ return ;
404
+ }
394
405
406
+ if ( listBox1 . SelectedIndex == - 1 )
407
+ {
408
+ button4 . Enabled = false ;
409
+ button5 . Enabled = false ;
410
+ return ;
411
+ }
412
+
413
+ button4 . Enabled = ( ( ( Shape ) listBox1 . SelectedItem ) . shapeType == DrawingShape . POLY || ( ( Shape ) listBox1 . SelectedItem ) . shapeType == DrawingShape . CPOLY ) ? true : false ;
414
+ button5 . Enabled = ( ( ( Shape ) listBox1 . SelectedItem ) . shapeType == DrawingShape . POLY || ( ( Shape ) listBox1 . SelectedItem ) . shapeType == DrawingShape . CPOLY ) ? true : false ;
415
+ }
395
416
}
396
417
}
0 commit comments