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
SetTool.cs
1using Gtk;
2using javax.swing.text;
3using System;
4using System.IO;
5using System.Threading;
6
7namespace BioGTK
8{
9 public partial class SetTool : Window
10 {
11 #region Properties
13 private Builder _builder;
14 int line = 0;
15#pragma warning disable 649
16 [Builder.Object]
17 private TreeView tree;
18 [Builder.Object]
19 private Menu contextMenu;
20#pragma warning restore 649
21
22 #endregion
23
24 #region Constructors / Destructors
32 public static SetTool Create()
33 {
34 Builder builder = new Builder(new FileStream(System.IO.Path.GetDirectoryName(Environment.ProcessPath) + "/" + "Glade/SetTool.glade", FileMode.Open));
35 return new SetTool(builder, builder.GetObject("setTool").Handle);
36 }
37 /* The constructor of the class. */
38 protected SetTool(Builder builder, IntPtr handle) : base(handle)
39 {
40 _builder = builder;
41 builder.Autoconnect(this);
42 tree.RowActivated += TreeView_RowActivated;
43 this.FocusActivated += SetTool_FocusActivated;
44 InitItems();
45 App.ApplyStyles(this);
46 }
47
52 private void SetTool_FocusActivated(object sender, EventArgs e)
53 {
55 }
56 #endregion
59 public void InitItems()
60 {
61 Gtk.TreeViewColumn coordCol = new Gtk.TreeViewColumn();
62 coordCol.Title = "Tool";
63 Gtk.CellRendererText coordCell = new Gtk.CellRendererText();
64 coordCol.PackStart(coordCell, true);
65
66 Gtk.TreeViewColumn expCol = new Gtk.TreeViewColumn();
67 expCol.Title = "State";
68 Gtk.CellRendererText expCell = new Gtk.CellRendererText();
69 expCol.PackStart(expCell, true);
70
71 tree.AppendColumn(coordCol);
72 tree.AppendColumn(expCol);
73
74 coordCol.AddAttribute(coordCell, "text", 0);
75 expCol.AddAttribute(expCell, "text", 1);
76
78 }
80 public void UpdateItems()
81 {
82 Gtk.TreeStore store = new Gtk.TreeStore(typeof(string), typeof(string), typeof(string));
83
84 foreach (Scripting.Script s in Scripting.scripts.Values)
85 {
86 if (s.thread == null)
87 store.AppendValues(s.name, ThreadState.Unstarted.ToString());
88 else
89 store.AppendValues(s.name, s.thread.ThreadState.ToString());
90 }
91 tree.Model = store;
92 }
93
102 private void TreeView_RowActivated(object o, RowActivatedArgs args)
103 {
104 TreeView treeView = (TreeView)o;
105 TreePath path = args.Path;
106 TreeIter iter;
107 string s;
108 // Get the TreeIter for the selected row
109 if (treeView.Model.GetIter(out iter, path))
110 {
111 // Get the value of the "Text" column for the selected row
112 s = (string)treeView.Model.GetValue(iter, 0);
113 }
114 else
115 return;
116 if (Scripting.scripts.ContainsKey(s))
117 {
118 Scripting.Script sc = Scripting.scripts[s];
119 if (sc.thread == null)
120 sc.Run();
121 else
122 if(sc.thread.ThreadState == System.Threading.ThreadState.Running || sc.thread.ThreadState!= System.Threading.ThreadState.WaitSleepJoin)
123 {
124 sc.Stop();
125 }
126 else
127 {
128 sc.Run();
129 }
130 }
131 UpdateItems();
132 }
133 }
134}
void UpdateItems()
It updates the treeview with the current state of the scripts.
Definition SetTool.cs:80
void InitItems()
Definition SetTool.cs:59
static SetTool Create()
Definition SetTool.cs:32
Definition ML.cs:17