Skip to content
This repository was archived by the owner on Sep 21, 2023. It is now read-only.

Commit b8936ca

Browse files
committed
Update fill/clip enable on polygon only
1 parent 2bf7da9 commit b8936ca

File tree

2 files changed

+36
-12
lines changed

2 files changed

+36
-12
lines changed

winforms-image-processor/winforms-image-processor/Forms/DrawForm.Designer.cs

+14-11
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

winforms-image-processor/winforms-image-processor/Forms/DrawForm.cs

+22-1
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,8 @@ void drawMode(
117117
if (!status && index == -1)
118118
{
119119
shapes.Add(currentShape);
120+
if (shapes.Count == 1)
121+
listBox1_SelectedIndexChanged(null, null);
120122
RefreshShapes();
121123
}
122124
else if (!status)
@@ -286,6 +288,8 @@ private void button3_Click(object sender, EventArgs e)
286288

287289
shapes.RemoveAt(listBox1.SelectedIndex);
288290

291+
listBox1_SelectedIndexChanged(null, null);
292+
289293
RefreshShapes();
290294
}
291295

@@ -311,7 +315,6 @@ private void openToolStripMenuItem_Click(object sender, EventArgs e)
311315
if (pictureBox1.Image == null)
312316
pictureBox1.Image = new Bitmap(pictureBox1.Width, pictureBox1.Height);
313317

314-
315318
var filePath = string.Empty;
316319

317320
using (OpenFileDialog openFileDialog = new OpenFileDialog())
@@ -391,6 +394,24 @@ private void showClipBorderToolStripMenuItem_Click(object sender, EventArgs e)
391394
RefreshShapes();
392395
}
393396

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+
}
394405

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+
}
395416
}
396417
}

0 commit comments

Comments
 (0)