4using System.Collections.Generic;
7using System.Threading.Tasks;
8using System.Windows.Forms;
16 public static TabsView tabsView =
null;
17 public static NodeView nodeView =
null;
19 public static Recorder recorder =
null;
20 public static Imager imager =
null;
21 public static Tools tools =
null;
25 public static Series seriesTool =
null;
32 public static Light lightTool =
null;
33 public static Library lib =
null;
34 public static List<string> recent =
new List<string>();
37 public static void UpdateImages()
42 foreach (var item
in Images.images)
44 if(
App.tabsView!=
null)
45 if (
App.tabsView.HasTab(item.Filename))
54 public static BioImage Image
59 return tabsView.Image;
63 public static List<Channel> Channels
65 get {
return Image.Channels; }
68 public static List<ROI> Annotations
70 get {
return Image.Annotations; }
75 BioImage.Initialize(
ImageJ.ImageJPath);
76 Thread th =
new Thread(UpdateImages);
81 }
while (!BioImage.Initialized);
83 Microscope.Initialize();
97 if (!Properties.Settings.Default.PycroManager && !Properties.Settings.Default.PMicroscope)
99 lightTool =
new Light();
124 private static IEnumerable<ToolStripMenuItem> GetItems(ToolStripMenuItem item)
126 foreach (var dropDownItem
in item.DropDownItems)
128 if (dropDownItem.GetType() == typeof(ToolStripMenuItem))
130 if (((ToolStripMenuItem)dropDownItem).HasDropDownItems)
132 foreach (ToolStripMenuItem subItem
in GetItems((ToolStripMenuItem)dropDownItem))
133 yield
return subItem;
135 yield
return (ToolStripMenuItem)dropDownItem;
144 List<ToolStripMenuItem> allItems =
new List<ToolStripMenuItem>();
145 foreach (ToolStripMenuItem toolItem
in tabsView.MainMenuStrip.Items)
147 allItems.Add(toolItem);
148 allItems.AddRange(GetItems(toolItem));
157 List<ToolStripMenuItem> allItems =
new List<ToolStripMenuItem>();
160 allItems.Add(toolItem);
161 allItems.AddRange(GetItems(toolItem));
174 if (s ==
"" || s ==
null)
176 string[] sts = s.Split(
'/');
181 ToolStripMenuItem item =
null;
183 for (
int t = 0; t < sts.Length; t++)
186 for (
int i = 0; i < allItems.Count; i++)
188 if (allItems[i].Text == sts[t])
192 if (t == sts.Length - 1)
200 tabsView.MainMenuStrip.Items.Add(sts[t]);
203 else if(t > 0 && t < sts.Length)
205 ToolStripMenuItem itm =
new ToolStripMenuItem();
208 item.DropDownItems.Add(f.Name,
null, ItemClicked);
213 item.DropDownItems.Add(sts[t]);
228 if (s ==
"" || s ==
null)
230 string[] sts = s.Split(
'/');
235 ToolStripMenuItem item =
null;
237 for (
int t = 0; t < sts.Length; t++)
240 for (
int i = 0; i < allItems.Count; i++)
242 if (allItems[i].Text == sts[t])
246 if (t == sts.Length - 1)
257 else if (t > 0 && t < sts.Length)
259 ToolStripMenuItem itm =
new ToolStripMenuItem();
262 item.DropDownItems.Add(f.Name,
null, ItemClicked);
267 item.DropDownItems.Add(sts[t]);
283 if (s ==
"" || s ==
null)
285 string[] sts = s.Split(
'/');
290 ToolStripMenuItem item =
null;
292 for (
int t = 0; t < sts.Length; t++)
295 for (
int i = 0; i < allItems.Count; i++)
297 if (allItems[i].Text == sts[t])
301 if (t == sts.Length - 1)
309 tabsView.MainMenuStrip.Items.Add(sts[t]);
312 else if (t > 0 && t < sts.Length)
314 ToolStripMenuItem itm =
new ToolStripMenuItem();
315 itm.Text = Path.GetFileName(s);
316 item.DropDownItems.Add(Path.GetFileName(s),
null, ItemClicked);
321 item.DropDownItems.Add(sts[t]);
336 if (s ==
"" || s ==
null)
338 string[] sts = s.Split(
'/');
343 ToolStripMenuItem item =
null;
345 for (
int t = 0; t < sts.Length; t++)
348 for (
int i = 0; i < allItems.Count; i++)
350 if (allItems[i].Text == sts[t])
354 if (t == sts.Length - 1)
365 else if (t > 0 && t < sts.Length)
367 ToolStripMenuItem itm =
new ToolStripMenuItem();
368 itm.Name = Path.GetFileName(s);
369 item.DropDownItems.Add(Path.GetFileName(s),
null, ItemClicked);
374 item.DropDownItems.Add(sts[t]);
423 private static void ItemClicked(
object sender, EventArgs e)
425 ToolStripMenuItem ts = (ToolStripMenuItem)sender;
426 if(ts.Text.EndsWith(
".dll"))
430 Plugin.Plugins[ts.Text].Execute(
new string[] { });
434 Console.WriteLine(ex.ToString());
438 else if(ts.Text.EndsWith(
".ijm"))
440 string st = File.ReadAllText(Path.GetDirectoryName(
ImageJ.ImageJPath) +
"/macros/" + ts.Text);
443 else if(ts.Text.EndsWith(
".pt") || ts.Text.EndsWith(
".onnx"))
447 ML.ML.Run(ts.Text,
ImageView.SelectedImage);
451 Console.WriteLine(ex.Message.ToString());
457 f.PerformFunction(
true);
465 Annotations.Add(BioImage.StringToROI(an));
466 Recorder.AddLine(
"App.AddROI(" +
'"' + an +
"'" +
");");
static void AddMenu(string menu, Function f)
static void Hide()
Hide() hides all the tools.
static ToolStripItem GetMenuItemFromPath(string s)
static ToolStripItem GetContextMenuItemFromPath(string s, Function f)
static ToolStripItem GetMenuItemFromPath(string s, Function f)
static List< ToolStripMenuItem > GetContextItems()
static ToolStripItem GetContextMenuItemFromPath(string s)
static void AddContextMenu(string menu)
static List< ToolStripMenuItem > GetMenuItems()
static void Initialize()
Initialize() is a function that initializes the BioImager UI.
static void AddROI(string an)
static void AddMenu(string menu)
static void AddContextMenu(string menu, Function f)
static void RunOnImage(string con, bool headless, bool onTab, bool bioformats, bool newTab)
ImageView control for image stacks, pyramidal and whole-slide-images.
ContextMenuStrip ViewContextMenu
A property that returns a ContextMenuStrip object. */.