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
NodeView.cs
1using AForge;
2using Gtk;
3using OpenTK.Mathematics;
4using OpenTK.Windowing.Common;
5using OpenTK.Windowing.Desktop;
6using System;
7using System.Collections.Generic;
8using System.IO;
9using System.Linq;
10using System.Text;
11using System.Threading.Tasks;
12
13namespace BioGTK
14{
15 public class NodeView : Window
16 {
17 #region Properties
18
20 private Builder _builder;
21
22#pragma warning disable 649
23 [Builder.Object]
24 private MenuItem newTabsViewMenu;
25 [Builder.Object]
26 private MenuItem aboutMenu;
27 [Builder.Object]
28 private TreeView tree;
29#pragma warning restore 649
30
31 #endregion
32
33 #region Constructors / Destructors
34
43 public static NodeView Create(string[] args)
44 {
45 Builder builder = new Builder(new FileStream(System.IO.Path.GetDirectoryName(Environment.ProcessPath) + "/" + "Glade/NodeView.glade", FileMode.Open));
46 return new NodeView(builder, builder.GetObject("nodeView").Handle,args);
47 }
48 ListStore store;
49 GLWindow window;
50 /* The code you provided is the constructor for the `NodeView` class. */
51 protected NodeView(Builder builder, IntPtr handle, string[] args) : base(handle)
52 {
53 _builder = builder;
54 builder.Autoconnect(this);
55 string st = System.IO.Path.GetDirectoryName(Environment.ProcessPath);
56 //Let's make sure the directories we need for startup exist.
57 Console.WriteLine("Reading start up folders.");
58 System.IO.Directory.CreateDirectory(st + "/Scripts");
59 System.IO.Directory.CreateDirectory(st + "/Functions");
60 System.IO.Directory.CreateDirectory(st + "/Tools");
61 System.IO.Directory.CreateDirectory(st + "/Plugins");
62 System.IO.Directory.CreateDirectory(st + "/Models");
63 App.nodeView = this;
64 App.Initialize();
66 Console.WriteLine("Parsing arguments.");
67 App.tabsView = TabsView.Create();
68 foreach (string item in args)
69 {
70 BioImage.OpenAsync(item, false, true, true, 0).Wait();
71 BioImage bm = Images.GetImage(item);
72 App.tabsView.AddTab(bm);
73 }
74 Console.WriteLine("Initializing nodes.");
75 InitItems();
76 App.MoveToMain(this);
77 App.ApplyStyles(this);
78 Console.WriteLine("NodeView initialized.");
79 }
80
83 public void InitItems()
84 {
85 Gtk.TreeViewColumn coordCol = new Gtk.TreeViewColumn();
86 coordCol.Title = "Coordinate";
87 Gtk.CellRendererText coordCell = new Gtk.CellRendererText();
88 coordCol.PackStart(coordCell, true);
89
90 Gtk.TreeViewColumn expCol = new Gtk.TreeViewColumn();
91 expCol.Title = "Exposure";
92 Gtk.CellRendererText expCell = new Gtk.CellRendererText();
93 expCol.PackStart(expCell, true);
94
95 Gtk.TreeViewColumn deltaCol = new Gtk.TreeViewColumn();
96 deltaCol.Title = "Delta";
97 Gtk.CellRendererText deltaCell = new Gtk.CellRendererText();
98 deltaCol.PackStart(deltaCell, true);
99
100
101 tree.AppendColumn(coordCol);
102 tree.AppendColumn(expCol);
103 tree.AppendColumn(deltaCol);
104
105 coordCol.AddAttribute(coordCell, "text", 0);
106 expCol.AddAttribute(expCell, "text", 1);
107 deltaCol.AddAttribute(deltaCell, "text", 2);
108
109 Gtk.TreeStore store = new Gtk.TreeStore(typeof(string), typeof(string), typeof(string));
110
111 foreach (BioImage b in Images.images)
112 {
113 Gtk.TreeIter iter = store.AppendValues(System.IO.Path.GetFileName(b.Filename));
114 foreach (AForge.Bitmap bit in b.Buffers)
115 {
116 store.AppendValues(iter, bit.Coordinate.ToString(), bit.Plane.Exposure, bit.Plane.Delta);
117 }
118 }
119 tree.Model = store;
120
121 }
122
125 public void UpdateItems()
126 {
127 Gtk.TreeStore store = new Gtk.TreeStore(typeof(string), typeof(string), typeof(string));
128
129 foreach (BioImage b in Images.images)
130 {
131 Gtk.TreeIter iter = store.AppendValues(System.IO.Path.GetFileName(b.Filename));
132 foreach (AForge.Bitmap bit in b.Buffers)
133 {
134 if(bit.Plane != null)
135 store.AppendValues(iter, bit.Coordinate.ToString(), bit.Plane.Exposure, bit.Plane.Delta);
136 else
137 store.AppendValues(iter, bit.Coordinate.ToString(), 0, 0);
138 }
139 }
140 tree.Model = store;
141
142 }
143 #endregion
144
145 #region Handlers
146
148 protected void SetupHandlers()
149 {
150 DeleteEvent += OnLocalDeleteEvent;
151 newTabsViewMenu.ButtonPressEvent += newTabsViewClick;
152 aboutMenu.ButtonPressEvent += aboutClick;
153
154 }
155
159 protected void OnLocalDeleteEvent(object sender, DeleteEventArgs a)
160 {
161 Application.Quit();
162 a.RetVal = true;
163 }
164
168 protected void newTabsViewClick(object sender, EventArgs a)
169 {
171 tabsView.Show();
172
173 }
177 protected void aboutClick(object sender, EventArgs a)
178 {
180 about.Show();
181 }
182 #endregion
183
184 }
185}
static About Create()
Definition About.cs:33
void OnLocalDeleteEvent(object sender, DeleteEventArgs a)
Handle Close of Form, Quit Application.
Definition NodeView.cs:159
void InitItems()
Definition NodeView.cs:83
void aboutClick(object sender, EventArgs a)
Handle Click of Button.
Definition NodeView.cs:177
static NodeView Create(string[] args)
Definition NodeView.cs:43
void newTabsViewClick(object sender, EventArgs a)
Handle Click of Button.
Definition NodeView.cs:168
void SetupHandlers()
Sets up the handlers.
Definition NodeView.cs:148
void UpdateItems()
Definition NodeView.cs:125
static TabsView Create()
Definition TabsView.cs:545
Definition ML.cs:17