BioImager  5.0.0
A .NET microscopy imaging application based on Bio library. Supports various microscopes by using imported libraries & GUI automation. Supports XInput game controllers to move stage, take images, run ImageJ macros on images or Bio C# scripts.
Loading...
Searching...
No Matches
Filter.cs
Go to the documentation of this file.
1using System;
2using System.Collections.Generic;
3using System.ComponentModel;
4using System.Data;
5using System.Drawing;
6using System.Linq;
7using System.Text;
8using System.Threading.Tasks;
9using System.Windows.Forms;
10using BioLib;
11namespace BioImager
12{
13 public partial class Filter : Form
14 {
15 /* The constructor of the class. */
16 public Filter()
17 {
18 InitializeComponent();
19 Init();
20 }
22 private void UpdateView()
23 {
25 }
26 /* The Node class is a wrapper class for the TreeNode class. It allows us to add a Filt object
27 to a TreeNode object */
28 public class Node
29 {
30 public TreeNode node;
31 public Filt filt;
32 public Node(TreeNode nod, Filt f)
33 {
34 node = nod;
35 filt = f;
36 }
37 public override string ToString()
38 {
39 return filt.name.ToString();
40 }
41 }
43 public void Init()
44 {
45 foreach (Filt.Type t in (Filt.Type[])Enum.GetValues(typeof(Filt.Type)))
46 {
47 TreeNode gr = new TreeNode();
48 gr.Text = t.ToString();
49 filterView.Nodes.Add(gr);
50 }
51 foreach (Filt f in Filters.filters)
52 {
53 TreeNode nod = new TreeNode();
54 nod.Text = f.name;
55 Node node = new Node(nod, f);
56 nod.Tag = node;
57 filterView.Nodes[(int)f.type].Nodes.Add(nod);
58 }
59 }
60
68 private void ApplyFilter(bool inPlace)
69 {
70 if (filterView.SelectedNode==null)
71 return;
72 Node n = (Node)filterView.SelectedNode.Tag;
73 if (n.filt.type == Filt.Type.Base)
74 {
75 Filters.Base(ImageView.SelectedImage.ID, n.filt.name, false);
76
77 }
78 if (n.filt.type == Filt.Type.Base2)
79 {
80 ApplyFilter two = new ApplyFilter(true);
81 if (two.ShowDialog() != DialogResult.OK)
82 return;
83 Filters.Base2(two.ImageA.ID, two.ImageB.ID, n.filt.name, false);
84
85 }
86 else
87 if (n.filt.type == Filt.Type.InPlace)
88 {
89 Filters.InPlace(ImageView.SelectedImage.ID, n.filt.name, false);
90 }
91 else
92 if (n.filt.type == Filt.Type.InPlace2)
93 {
94 ApplyFilter two = new ApplyFilter(true);
95 if (two.ShowDialog() != DialogResult.OK)
96 return;
97 Filters.InPlace2(two.ImageA.ID, two.ImageB.ID, n.filt.name, false);
98
99 }
100 else
101 if (n.filt.type == Filt.Type.InPlacePartial)
102 {
103 Filters.InPlacePartial(ImageView.SelectedImage.ID, n.filt.name, false);
104
105 }
106 else
107 if (n.filt.type == Filt.Type.Resize)
108 {
109 ApplyFilter two = new ApplyFilter(false);
110 if (two.ShowDialog() != DialogResult.OK)
111 return;
112 Filters.Resize(ImageView.SelectedImage.ID, n.filt.name, false, two.W,two.H);
113 }
114 else
115 if (n.filt.type == Filt.Type.Rotate)
116 {
117 ApplyFilter two = new ApplyFilter(false);
118 if (two.ShowDialog() != DialogResult.OK)
119 return;
120 Filters.Rotate(ImageView.SelectedImage.ID, n.filt.name, false, two.Angle, two.Color.A, two.Color.R, two.Color.G, two.Color.B);
121 }
122 else
123 if (n.filt.type == Filt.Type.Transformation)
124 {
125 ApplyFilter two = new ApplyFilter(false);
126 if (two.ShowDialog() != DialogResult.OK)
127 return;
128 if (n.filt.name == "Crop")
129 {
130 Filters.Crop(two.ImageA.ID, two.Rectangle);
131 }
132 else
133 {
134 Filters.Transformation(ImageView.SelectedImage.ID, n.filt.name, false, two.Angle);
135 }
136 }
137 else
138 if (n.filt.type == Filt.Type.Copy)
139 {
140 Filters.Copy(ImageView.SelectedImage.ID, n.filt.name, false);
141 }
142 UpdateView();
143 }
144
149 private void applyToolStripMenuItem_Click(object sender, EventArgs e)
150 {
151 ApplyFilter(false);
152 }
153
158 private void applyRGBToolStripMenuItem_Click(object sender, EventArgs e)
159 {
160 ApplyFilter(true);
161 }
162
167 private void topMostBox_CheckedChanged(object sender, EventArgs e)
168 {
169 TopMost = topMostBox.Checked;
170 }
171
176 private void filterView_DoubleClick(object sender, EventArgs e)
177 {
178 ApplyFilter(false);
179 }
180 }
181}
static ImageView viewer
Definition App.cs:23
override string ToString()
Definition Filter.cs:37
Node(TreeNode nod, Filt f)
Definition Filter.cs:32
void Init()
It takes a list of filters and adds them to a treeview.
Definition Filter.cs:43
ImageView control for image stacks, pyramidal and whole-slide-images.
static BioImage SelectedImage
Definition ImageView.cs:270