BioGTK  6.7.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
Filters.cs
1using AForge;
2using Bio;
3using Gtk;
4using System;
5using System.Collections.Generic;
6using System.IO;
7using System.Linq;
8using System.Text;
9using System.Threading.Tasks;
10
11namespace BioGTK
12{
13 public class FiltersView : Window
14 {
15 #region Properties
16 private Builder _builder;
17
18#pragma warning disable 649
19 [Builder.Object]
20 private TreeView tree;
21#pragma warning restore 649
22
23 #endregion
24
25 #region Constructors / Destructors
26 public static FiltersView Create()
27 {
28 Builder builder = new Builder(new FileStream(System.IO.Path.GetDirectoryName(Environment.ProcessPath) + "/" + "Glade/Filters.glade", FileMode.Open));
29 return new FiltersView(builder, builder.GetObject("filters").Handle);
30 }
31 ListStore store;
32
33 /* The code snippet is the constructor for the `FiltersView` class. It takes in a `Builder`
34 object and an `IntPtr` handle as parameters. */
35 protected FiltersView(Builder builder, IntPtr handle) : base(handle)
36 {
37 _builder = builder;
38 builder.Autoconnect(this);
39 InitItems();
40 tree.RowActivated += Tree_RowActivated;
41 App.ApplyStyles(this);
42 }
43
49 private void Tree_RowActivated(object o, RowActivatedArgs args)
50 {
51 if (args.Path.Indices.Length == 1)
52 return;
53 Filt f = Filters.GetFilter(args.Path.Indices[0], args.Path.Indices[1]);
54 if (f == null)
55 return;
56 if (f.type == Filt.Type.Base)
57 {
58 App.applyFilter = ApplyFilter.Create(f, false);
59 }
60 if (f.type == Filt.Type.Base2)
61 {
62 App.applyFilter = ApplyFilter.Create(f,true);
63 }
64 else
65 if (f.type == Filt.Type.InPlace)
66 {
67 App.applyFilter = ApplyFilter.Create(f, false);
68 }
69 else
70 if (f.type == Filt.Type.InPlace2)
71 {
72 App.applyFilter = ApplyFilter.Create(f, true);
73 }
74 else
75 if (f.type == Filt.Type.InPlacePartial)
76 {
77 App.applyFilter = ApplyFilter.Create(f, false);
78 }
79 else
80 if (f.type == Filt.Type.Resize)
81 {
82 App.applyFilter = ApplyFilter.Create(f, false);
83 }
84 else
85 if (f.type == Filt.Type.Rotate)
86 {
87 App.applyFilter = ApplyFilter.Create(f, false);
88 }
89 else
90 if (f.type == Filt.Type.Transformation)
91 {
92 App.applyFilter = ApplyFilter.Create(f, false);
93 }
94 else
95 if (f.type == Filt.Type.Copy)
96 {
97 App.applyFilter = ApplyFilter.Create(f, false);
98 }
99 App.applyFilter.Show();
100 App.applyFilter.Present();
101 }
102
105 public void InitItems()
106 {
107 tree.Model = null;
108 tree.ActivateOnSingleClick = false;
109 Gtk.TreeViewColumn coordCol = new Gtk.TreeViewColumn();
110 coordCol.Title = "Filter";
111 Gtk.CellRendererText coordCell = new Gtk.CellRendererText();
112 coordCol.PackStart(coordCell, true);
113 tree.AppendColumn(coordCol);
114 coordCol.AddAttribute(coordCell, "text", 0);
115 Gtk.TreeStore store = new Gtk.TreeStore(typeof(string));
116 Filters.Init();
117 foreach (Filt.Type f in (Filt.Type[])Enum.GetValues(typeof(Filt.Type)))
118 {
119 Gtk.TreeIter iter = store.AppendValues(f.ToString());
120 foreach (Filt fil in Filters.filters)
121 {
122 if(fil.type == f)
123 {
124 store.AppendValues(iter, fil.name);
125 }
126 }
127 }
128 tree.Model = store;
129 }
131 public void UpdateItems()
132 {
133 Gtk.TreeStore store = new Gtk.TreeStore(typeof(string));
134 foreach (Filt.Type f in (Filt.Type[])Enum.GetValues(typeof(Filt.Type)))
135 {
136 Gtk.TreeIter iter = store.AppendValues(f.ToString());
137 foreach (Filt fil in Filters.filters)
138 {
139 if (fil.type == f)
140 {
141 store.AppendValues(iter, fil.name);
142 }
143 }
144 }
145 }
146 #endregion
147
148 }
149}
static ApplyFilter Create(Filt filter, bool two)
void UpdateItems()
It takes a list of filters and creates a treeview with the filters grouped by type.
Definition Filters.cs:131
Definition ML.cs:17