3 public partial class ROIManager : Form
9 foreach (ROI.Type item in Enum.GetValues(typeof(ROI.Type)))
11 typeBox.Items.Add(item);
14 public ROI
anno =
new ROI();
22 roiView.Items.Clear();
25 ListViewItem it =
new ListViewItem();
27 it.Text = an.ToString();
28 roiView.Items.Add(it);
57 private void xBox_ValueChanged(
object sender, EventArgs e)
59 if (roiView.SelectedItems.Count == 0)
61 if (
anno.type == ROI.Type.Rectangle ||
anno.type == ROI.Type.Ellipse)
62 anno = ROI.CreateRectangle(
new AForge.ZCT((
int)zBox.Value, (
int)cBox.Value, (
int)tBox.Value), (
double)xBox.Value, (
double)yBox.Value, (
double)wBox.Value, (
double)hBox.Value);
72 private void yBox_ValueChanged(
object sender, EventArgs e)
74 if (roiView.SelectedItems.Count == 0)
76 if (
anno.type == ROI.Type.Rectangle ||
anno.type == ROI.Type.Ellipse)
77 anno = ROI.CreateRectangle(
new AForge.ZCT((
int)zBox.Value, (
int)cBox.Value, (
int)tBox.Value),(
double)xBox.Value, (
double)yBox.Value, (
double)wBox.Value, (
double)hBox.Value);
87 private void wBox_ValueChanged(
object sender, EventArgs e)
89 if (roiView.SelectedItems.Count == 0)
91 if (
anno.type == ROI.Type.Rectangle ||
anno.type == ROI.Type.Ellipse)
92 anno = ROI.CreateRectangle(
new AForge.ZCT((
int)zBox.Value, (
int)cBox.Value, (
int)tBox.Value), (
double)xBox.Value, (
double)yBox.Value, (
double)wBox.Value, (
double)hBox.Value);
101 private void hBox_ValueChanged(
object sender, EventArgs e)
103 if (roiView.SelectedItems.Count == 0)
105 if (
anno.type == ROI.Type.Rectangle ||
anno.type == ROI.Type.Ellipse)
106 anno = ROI.CreateRectangle(
new AForge.ZCT((
int)zBox.Value, (
int)cBox.Value, (
int)tBox.Value), (
double)xBox.Value, (
double)yBox.Value, (
double)wBox.Value, (
double)hBox.Value);
117 private void sBox_ValueChanged(
object sender, EventArgs e)
119 if (roiView.SelectedItems.Count == 0)
130 private void zBox_ValueChanged(
object sender, EventArgs e)
132 if (roiView.SelectedItems.Count == 0)
134 anno.coord.Z = (int)zBox.Value;
144 private void cBox_ValueChanged(
object sender, EventArgs e)
146 if (roiView.SelectedItems.Count == 0)
148 anno.coord.C = (int)cBox.Value;
158 private void tBox_ValueChanged(
object sender, EventArgs e)
160 if (roiView.SelectedItems.Count == 0)
162 anno.coord.T = (int)cBox.Value;
172 private void rBox_ValueChanged(
object sender, EventArgs e)
174 if (roiView.SelectedItems.Count == 0)
176 anno.strokeColor = AForge.Color.FromArgb((
byte)rBox.Value,
anno.strokeColor.G,
anno.strokeColor.B);
186 private void gBox_ValueChanged(
object sender, EventArgs e)
188 if (roiView.SelectedItems.Count == 0)
190 anno.strokeColor = AForge.Color.FromArgb(
anno.strokeColor.R, (
byte)gBox.Value,
anno.strokeColor.B);
199 private void bBox_ValueChanged(
object sender, EventArgs e)
201 if (roiView.SelectedItems.Count == 0)
203 anno.strokeColor = AForge.Color.FromArgb(
anno.strokeColor.R,
anno.strokeColor.G, (
byte)bBox.Value);
212 private void typeBox_SelectedIndexChanged(
object sender, EventArgs e)
214 if (roiView.SelectedItems.Count == 0)
216 anno.type = (ROI.Type)typeBox.SelectedItem;
226 private void textBox_TextChanged(
object sender, EventArgs e)
228 if (roiView.SelectedItems.Count == 0)
230 anno.Text = textBox.Text;
239 private void idBox_TextChanged(
object sender, EventArgs e)
241 if (roiView.SelectedItems.Count == 0)
243 anno.id = idBox.Text;
253 private void ROIManager_Activated(
object sender, EventArgs e)
255 if (ImageView.SelectedImage ==
null)
257 string n = System.IO.Path.GetFileName(ImageView.SelectedImage.ID);
258 if (imageNameLabel.Text != n)
259 imageNameLabel.Text = n;
270 private void roiView_SelectedIndexChanged(
object sender, EventArgs e)
272 if (roiView.SelectedItems.Count == 0)
274 ListViewItem it = roiView.SelectedItems[0];
276 if (App.viewer !=
null)
277 App.viewer.SetCoordinate(
anno.coord.Z,
anno.coord.C,
anno.coord.T);
278 if (
anno.type == ROI.Type.Line ||
anno.type == ROI.Type.Polygon ||
279 anno.type == ROI.Type.Polyline)
281 xBox.Enabled =
false;
282 yBox.Enabled =
false;
283 wBox.Enabled =
false;
284 hBox.Enabled =
false;
293 if (
anno.type == ROI.Type.Rectangle ||
anno.type == ROI.Type.Ellipse)
295 pointIndexBox.Enabled =
false;
296 pointXBox.Enabled =
false;
297 pointYBox.Enabled =
false;
301 pointIndexBox.Enabled =
true;
302 pointXBox.Enabled =
true;
303 pointYBox.Enabled =
true;
305 xBox.Value = (decimal)
anno.X;
306 yBox.Value = (decimal)
anno.Y;
307 wBox.Value = (decimal)
anno.W;
308 hBox.Value = (decimal)
anno.H;
309 zBox.Value =
anno.coord.Z;
310 cBox.Value =
anno.coord.C;
311 tBox.Value =
anno.coord.T;
312 rBox.Value =
anno.strokeColor.R;
313 gBox.Value =
anno.strokeColor.G;
314 bBox.Value =
anno.strokeColor.B;
315 strokeWBox.Value = (decimal)
anno.strokeWidth;
316 idBox.Text =
anno.id;
317 textBox.Text =
anno.Text;
318 typeBox.SelectedIndex = (int)
anno.type;
328 private void updateBut_Click(
object sender, EventArgs e)
330 if (roiView.SelectedItems.Count == 0)
332 if (ImageView.SelectedImage ==
null)
334 ImageView.SelectedImage.Annotations[roiView.SelectedIndices[0]] =
anno;
341 private void addButton_Click(
object sender, EventArgs e)
343 ImageView.SelectedImage.Annotations.Add(
anno);
351 private void showBoundsBox_CheckedChanged(
object sender, EventArgs e)
353 ImageView.showBounds = showBoundsBox.Checked;
361 private void showTextBox_CheckedChanged(
object sender, EventArgs e)
363 ImageView.showText = showTextBox.Checked;
373 private void pointXBox_ValueChanged(
object sender, EventArgs e)
377 if (
anno.type == ROI.Type.Rectangle ||
anno.type == ROI.Type.Ellipse)
379 anno.UpdatePoint(
new PointD((
double)pointXBox.Value, (
double)pointYBox.Value), (
int)pointIndexBox.Value);
389 private void pointYBox_ValueChanged(
object sender, EventArgs e)
393 if (
anno.type == ROI.Type.Rectangle ||
anno.type == ROI.Type.Ellipse)
395 anno.UpdatePoint(
new PointD((
double)pointXBox.Value, (
double)pointYBox.Value), (
int)pointIndexBox.Value);
406 PointD d =
anno.GetPoint((
int)pointIndexBox.Value);
407 pointXBox.Value = (int)d.X;
408 pointYBox.Value = (int)d.Y;
414 private void pointIndexBox_ValueChanged(
object sender, EventArgs e)
425 private void fontBut_Click(
object sender, EventArgs e)
429 if (fontDialog.ShowDialog() != DialogResult.OK)
431 anno.family = fontDialog.Font.FontFamily.ToString();
432 anno.fontSize = fontDialog.Font.Size;
441 private void strokeWBox_ValueChanged(
object sender, EventArgs e)
445 anno.strokeWidth = (int)strokeWBox.Value;
453 private void selectBoxSize_ValueChanged(
object sender, EventArgs e)
455 App.viewer.UpdateSelectBoxSize((
float)selectBoxSize.Value);
464 private void rChBox_CheckedChanged(
object sender, EventArgs e)
466 if (App.viewer ==
null)
468 App.viewer.showRROIs = rChBox.Checked;
477 private void gChBox_CheckedChanged(
object sender, EventArgs e)
479 if (App.viewer ==
null)
481 App.viewer.showGROIs = gChBox.Checked;
490 private void bChBox_CheckedChanged(
object sender, EventArgs e)
492 if (App.viewer ==
null)
494 App.viewer.showBROIs = bChBox.Checked;
502 private void ROIManager_FormClosing(
object sender, FormClosingEventArgs e)
505 this.WindowState = FormWindowState.Minimized;
512 private void deleteToolStripMenuItem_Click(
object sender, EventArgs e)
514 for (
int i = 0; i < roiView.SelectedItems.Count; i++)
516 ImageView.SelectedImage.Annotations.Remove((ROI)roiView.SelectedItems[i].Tag);
528 private void copyToolStripMenuItem_Click(
object sender, EventArgs e)
530 List<ROI> annotations =
new List<ROI>();
531 ROI an = (ROI)roiView.SelectedItems[0].Tag;
532 Clipboard.SetText(BioImage.ROIToString(an));
535 private void saveToolStripMenuItem_Click(
object sender, EventArgs e)
545 private void topMostBox_CheckedChanged(
object sender, EventArgs e)
547 TopMost = topMostBox.Checked;
ImageView control for image stacks, pyramidal and whole-slide-images.
static BioImage SelectedImage
void UpdateAnnotationList()
void updateROI(int index, ROI an)