BioGTK  6.5.0
A .NET library & program for annotating, editing various microscopy imaging formats using Bioformats supported images. Including whole slide, pyramidal, and series.
Loading...
Searching...
No Matches
Plate.cs
1using Gtk;
2using Gdk;
3using System;
4using Bio;
5using System.IO;
6
7namespace BioGTK
8{
9 public class PlateTool : Gtk.Window
10 {
11 #region Properties
12 BioImage.WellPlate.Well.Sample selected = null;
14 private Builder _builder;
15
16#pragma warning disable 649
17 [Builder.Object]
18 private Gtk.DrawingArea pictureBox;
19#pragma warning restore 649
20
21 #endregion
22
23 #region Constructors / Destructors
24
25 public static PlateTool Create()
26 {
27 Builder builder = new Builder(new FileStream(System.IO.Path.GetDirectoryName(Environment.ProcessPath) + "/" + "Glade/Plate.glade", FileMode.Open));
28 PlateTool v = new PlateTool(builder, builder.GetObject("plate").Handle);
29 v.Show();
30 return v;
31 }
32
33 protected PlateTool(Builder builder, IntPtr handle) : base(handle)
34 {
35 _builder = builder;
36 builder.Autoconnect(this);
37 pictureBox.Drawn += PictureBox_Drawn;
38 pictureBox.ButtonPressEvent += PictureBox_ButtonPressEvent;
39 pictureBox.AddEvents((int)
40 (EventMask.ButtonPressMask
41 | EventMask.ButtonReleaseMask
42 | EventMask.KeyPressMask
43 | EventMask.PointerMotionMask | EventMask.ScrollMask));
44 App.ApplyStyles(this);
45 }
46
47 private void PictureBox_ButtonPressEvent(object o, ButtonPressEventArgs args)
48 {
49 if(args.Event.Button == 1)
50 {
51 int l = 15;
52 int i = 0;
53 foreach (BioImage.WellPlate.Well w in ImageView.SelectedImage.Plate.Wells)
54 {
55 int r = 0;
56 foreach (BioImage.WellPlate.Well.Sample s in w.Samples)
57 {
58 Rectangle re = new Rectangle(r, (w.Column - 1) * l, l, l);
59 if(re.IntersectsWith(new Rectangle((int)args.Event.X, (int)args.Event.Y,1,1)))
60 {
61 App.viewer.Level = s.Index;
62 selected = s;
63 App.viewer.UpdateImages();
64 App.viewer.UpdateView();
65 pictureBox.QueueDraw();
66 }
67 r += l;
68 }
69 i++;
70 }
71 }
72 }
73
74 private void PictureBox_Drawn(object o, DrawnArgs args)
75 {
76 int l = 15;
77 int i = 0;
78 foreach (BioImage.WellPlate.Well w in ImageView.SelectedImage.Plate.Wells)
79 {
80 int r = 0;
81 foreach (BioImage.WellPlate.Well.Sample s in w.Samples)
82 {
83 if (s.Index != ImageView.SelectedImage.Level)
84 {
85 args.Cr.SetSourceColor(new Cairo.Color(0, 0, 0));
86 args.Cr.Rectangle(r, (w.Column - 1) * l, l, l);
87 args.Cr.Stroke();
88 }
89 r+=l;
90 }
91 i++;
92 }
93 foreach (BioImage.WellPlate.Well w in ImageView.SelectedImage.Plate.Wells)
94 {
95 int r = 0;
96 foreach (BioImage.WellPlate.Well.Sample s in w.Samples)
97 {
98 if (s.Index == ImageView.SelectedImage.Level)
99 {
100 args.Cr.SetSourceColor(new Cairo.Color(255, 0, 0));
101 args.Cr.Rectangle(r, (w.Column - 1) * l, l, l);
102 args.Cr.Stroke();
103 return;
104 }
105 r += l;
106 }
107 i++;
108 }
109 }
110 #endregion
111
112 }
113}
Definition ML.cs:17