BioImager  4.9.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
Imager.cs
1using System;
2using System.Collections.Generic;
3using System.ComponentModel;
4using System.Drawing;
5using System.Drawing.Imaging;
6using System.Linq;
7using System.Text;
8using System.IO;
9using System.Threading.Tasks;
10using System.Runtime.InteropServices;
11using System.Windows.Forms;
12using System.Diagnostics;
13using System.Globalization;
14using System.Threading;
15using SharpDX.XInput;
16using WindowsInput;
17using System.Configuration;
18using BioImager.Properties;
19using Settings = BioImager.Properties.Settings;
20using AForge;
21using BioLib;
22namespace BioImager
23{
24 public partial class Imager : Form
25 {
26 private static Process AppP = null;
27 public static IntPtr apph;
28 private System.Drawing.Point mainWinDefLocation = new System.Drawing.Point(1473, 509);
29 public static string AppPath = "";
30 public static List<BioImage> StoredImages = new List<BioImage>();
31 public Controller controller;
32 public Gamepad gamepad, previousGamepadState;
33 public bool prevState = false;
34 public bool connected = false;
35 public float leftTrigger, rightTrigger;
36 public int deadzone = 5;
37
38 public string m_ID;
39 public string ID => this.m_ID;
40 public static Process ZenP
41 {
42 get
43 {
44 return AppP;
45 }
46 set
47 {
48 AppP = value;
49 }
50 }
51 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
52 public uint ImagesPerSlice
53 {
54 get
55 {
56 return (uint)imagesPerSliceBox.Value;
57 }
58 set
59 {
60 imagesPerSliceBox.Value = (decimal)value;
61 }
62 }
63 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
64 public uint SliceIncrement
65 {
66 get
67 {
68 return (uint)sliceIncrementBox.Value;
69 }
70 set
71 {
72 sliceIncrementBox.Value = (decimal)value;
73 }
74 }
75 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
76 public uint SlicesPerSlide
77 {
78 get
79 {
80 return (uint)slicesPerSlideBox.Value;
81 }
82 set
83 {
84 slicesPerSlideBox.Value = (decimal)value;
85 }
86 }
87
88 public Profile CurrentProfile = new Profile("Default");
89 /* It's a class that allows you to save and load your application's settings to and from a
90 file. */
91 public class Profile
92 {
93 public string FilePath = "";
94 public string Name = "";
95 public string DirName = "";
96 public void Save(string path)
97 {
98 List<string> sts = new List<string>();
99 foreach (SettingsProperty currentProperty in Settings.Default.Properties)
100 {
101 string s = currentProperty.Name + "=" + Settings.Default[currentProperty.Name].ToString();
102 sts.Add(s);
103 }
104 File.WriteAllLines(path, sts.ToArray());
105 }
106
107 public Profile(string path)
108 {
109 FilePath = path;
110 if (path != "Default")
111 {
112 Name = Path.GetFileNameWithoutExtension(FilePath);
113 DirName = Path.GetDirectoryName(FilePath);
114 }
115 }
116
117 public void Load()
118 {
119 string[] sts = File.ReadAllLines(FilePath);
120 foreach (string s in sts)
121 {
122 string[] ss = s.Split('=');
123 if (Settings.Default[ss[0]].GetType() == typeof(double))
124 {
125 Settings.Default[ss[0]] = double.Parse(ss[1]);
126 }
127 else
128 if (Settings.Default[ss[0]].GetType() == typeof(string))
129 {
130 Settings.Default[ss[0]] = ss[1];
131 }
132 }
133 }
134
135 public override string ToString()
136 {
137 return Name + " " + DirName;
138 }
139
140 }
141 /* Starting the imaging application and then waiting for it to be idle. */
142 public Imager()
143 {
144 InitializeComponent();
145 if (Settings.Default.PycroManager)
146 {
147 topMostCheckBox.Checked = false;
148 dockToApp.Checked = false;
149 }
150 Stopwatch timer = new Stopwatch();
151 timer.Start();
152 TimeSpan st1 = timer.Elapsed;
153 m_ID = "";
154 if (Settings.Default.AppPath != "" && !Settings.Default.AppPath.Contains("ImageJ"))
155 {
156 //We start the imaging application making sure the we have the right path to the executable.
157 AppPath = Settings.Default.AppPath;
158 if (!File.Exists(AppPath))
159 {
160 MessageBox.Show("Error!", "Imaging appplication not found. Please locate the executable.");
161 //path is not default. Let the user find it.
162 if (openExeFileDialog.ShowDialog() != DialogResult.OK)
163 Application.Exit();
164 Settings.Default.AppPath = openExeFileDialog.FileName;
165 }
166 string pn = Path.GetFileNameWithoutExtension(AppPath);
167 Process[] prs = Process.GetProcessesByName(pn);
168 if (prs.Length == 0)
169 {
170 AppP = Process.Start(AppPath);
171 }
172 else
173 AppP = prs[0];
174 apph = AppP.MainWindowHandle;
175 //We use a try block incase of Win32 Access violation error.
176 try
177 {
178 AppP.WaitForInputIdle();
179 }
180 catch (Exception)
181 {
182 }
183 }
184 statusTimer.Start();
185
186 for (UserIndex i = UserIndex.One; i <= UserIndex.Four; i++)
187 {
188 controller = new Controller(i);
189 if (controller.IsConnected)
190 {
191 connected = true;
192 break;
193 }
194 else controller = null;
195 }
196
197 ControllerFuncs.LoadSettings();
198
199 controllerJoystickUpdate.Start();
200
201 controllerButtonUpdate.Start();
202
203
204 if (!Directory.Exists(Application.StartupPath + "\\Profiles"))
205 Directory.CreateDirectory(Application.StartupPath + "\\Profiles");
206 string[] sts = Directory.GetFiles(Application.StartupPath + "\\Profiles");
207 foreach (string s in sts)
208 {
209 Profile p = new Profile(s);
210 profilesBox.Items.Add(p);
211 }
212
213 if (Settings.Default.PreviousProfile != "Default")
214 {
215 CurrentProfile = new Profile(Settings.Default.PreviousProfile);
216 CurrentProfile.Load();
217 int index = 0;
218 foreach (Profile item in profilesBox.Items)
219 {
220 if (item.FilePath == Settings.Default.PreviousProfile)
221 {
222 profilesBox.SelectedIndex = index;
223 break;
224 }
225 index++;
226 }
227 }
228 this.TopMost = topMostCheckBox.Checked;
229
230 if (dockToApp.Checked && !Properties.Settings.Default.PycroManager)
231 {
232 //We set window location based on imaging application location.
233 Win32.Rect r = new Win32.Rect();
234 Win32.GetWindowRect(apph, ref r);
235 System.Drawing.Point pp = new System.Drawing.Point(r.Right - this.Width, r.Bottom - this.Height - 23);
236 this.Location = new System.Drawing.Point((int)pp.X, (int)pp.Y);
237 }
238 this.Show();
239 }
240
247 public void UpdateStatus()
248 {
249 //GetLiveStatus();
250 if (AppP.HasExited)
251 return;
252 Point3D p = Microscope.GetPosition();
253 double f = Microscope.GetFocus();
254 Point3D point = new Point3D(p.X, p.Y, f);
255 statusLabel.Text = "Stage: " + p.X + " , " + p.Y + " Focus: " + f;
256 if (StoredImages.Count > storedImageBox.Items.Count)
257 {
258 int dif = StoredImages.Count - storedImageBox.Items.Count;
259 for (int i = 0; i < dif; i++)
260 {
261 int index = (StoredImages.Count - 1) + dif;
262 storedImageBox.Items.Add(StoredImages[index - 1]);
263 }
264 }
265 }
266
267 public void StoreCoordinate()
268 {
269 Point3D p3 = Microscope.GetPosition();
270 storedCoordsBox.Items.Add(p3);
271 storedCoordsBox.SelectedIndex = storedCoordsBox.Items.Count - 1;
272 }
273
274 public static bool? liveStatus = null;
275 private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
276 {
277 if (App.viewer != null)
278 Properties.Settings.Default.Origin = App.viewer.Origin.ToString();
279 Settings.Default.PreviousProfile = CurrentProfile.FilePath;
280 Settings.Default.Save();
281 if (CurrentProfile.FilePath != "Default")
282 CurrentProfile.Save(CurrentProfile.FilePath);
283 e.Cancel = true;
284 this.Hide();
285 }
286 private void deadzoneBox_ValueChanged(object sender, EventArgs e)
287 {
288 deadzone = (int)deadzoneBox.Value;
289 }
290
291 private void storedCoordsBox_SelectedIndexChanged(object sender, EventArgs e)
292 {
293 Point3D p = (Point3D)storedCoordsBox.SelectedItem;
294 xCoordBox.Value = (decimal)p.X;
295 yCoordBox.Value = (decimal)p.Y;
296 zCoordBox.Value = (decimal)p.Z;
297 }
298
299 private void addCoordBut_Click(object sender, EventArgs e)
300 {
301 StoreCoordinate();
302 }
303
304 private void goToToolStripMenuItem_Click(object sender, EventArgs e)
305 {
306 if (storedImageBox.SelectedIndex == -1)
307 return;
308 BioImage s = (BioImage)storedImageBox.SelectedItem;
309 Microscope.SetPosition(s.Volume.Location);
310 }
311
312 private void deleteToolStripMenuItem_Click(object sender, EventArgs e)
313 {
314 if (storedImageBox.SelectedIndex == -1)
315 return;
316 storedImageBox.Items.RemoveAt(storedImageBox.SelectedIndex);
317 storedImageBox.SelectedIndex = storedImageBox.Items.Count - 1;
318 }
319
320 private void clearBut_Click(object sender, EventArgs e)
321 {
322 //We stop the controller update time so we can clear the list it access without causing problems
323 storedCoordsBox.Items.Clear();
324 }
325
326 private void clearToolStripMenuItem_Click(object sender, EventArgs e)
327 {
328 storedImageBox.Items.Clear();
329 }
330
331 private void clearToolStripMenuItem1_Click(object sender, EventArgs e)
332 {
333 storedCoordsBox.Items.Clear();
334 }
335
336 private void goToToolStripMenuItem1_Click(object sender, EventArgs e)
337 {
338 Point3D p = (Point3D)storedCoordsBox.SelectedItem;
339 Microscope.SetPosition(p);
340 }
341
348 private void deleteToolStripMenuItem1_Click(object sender, EventArgs e)
349 {
350 if (storedCoordsBox.SelectedIndex == -1)
351 return;
352 storedCoordsBox.Items.RemoveAt(storedCoordsBox.SelectedIndex);
353 storedCoordsBox.SelectedIndex = storedCoordsBox.Items.Count - 1;
354 }
355
362 private void controllerJoystickUpdate_Tick(object sender, EventArgs e)
363 {
364 if(AppP!=null)
365 if (AppP.HasExited)
366 {
367 return;
368 }
369 //Here we check the joysticks etc. which should have a high refresh rate to ensure smoothness.
370 if (!connected)
371 return;
372
373 gamepad = controller.GetState().Gamepad;
374
375 //we set the triggers to be percent
376 leftTrigger = ((float)(gamepad.LeftTrigger) / 255) * 100;
377 rightTrigger = ((float)(gamepad.RightTrigger) / 255) * 100;
378
379 #region//TRIGGERS
380 if (rightTrigger > 0)
381 {
382 //We use MTBCmdSetModes.Relative | MTBCmdSetModes.Synchronous so that we wait till the operation finishes
383 double curpos = Microscope.GetFocus();
384 Microscope.SetFocus((((double)triggerFocusBox.Value) * rightTrigger) + curpos);
385 }
386
387 if (leftTrigger > 0)
388 {
389 double curpos = Microscope.GetFocus();
390 Microscope.SetFocus((-1 * (((double)triggerFocusBox.Value) * leftTrigger)) + curpos);
391 }
392 #endregion
393
394 #region//JOYSTICKS
395 //LEFT JOYSTICKS
396 double maxVal = ushort.MaxValue / 2;
397 double minVal = maxVal * -1;
398 if (gamepad.LeftThumbX > deadzone)
399 Microscope.MoveRight((((float)gamepad.LeftThumbX) / maxVal) * (float)LJoystickStageMoveAmountBox.Value);
400 if (gamepad.LeftThumbX < -deadzone)
401 Microscope.MoveLeft((((float)gamepad.LeftThumbX) / minVal) * (float)LJoystickStageMoveAmountBox.Value);
402 if (gamepad.LeftThumbY < -deadzone)
403 Microscope.MoveUp((((float)gamepad.LeftThumbY) / maxVal) * (float)LJoystickStageMoveAmountBox.Value);
404 if (gamepad.LeftThumbY > deadzone)
405 Microscope.MoveDown((((float)gamepad.LeftThumbY) / minVal) * (float)LJoystickStageMoveAmountBox.Value);
406
407 //RIGHT JOYSTICK
408 if (gamepad.RightThumbX > deadzone)
409 Microscope.MoveRight(((float)gamepad.RightThumbX / maxVal) * (float)RJoystickStageMoveAmountBox.Value);
410 if (gamepad.RightThumbX < -deadzone)
411 Microscope.MoveLeft((((float)gamepad.RightThumbX) / minVal) * (float)RJoystickStageMoveAmountBox.Value);
412 if (gamepad.RightThumbY < -deadzone)
413 Microscope.MoveUp((((float)gamepad.RightThumbY) / maxVal) * (float)RJoystickStageMoveAmountBox.Value);
414 if (gamepad.RightThumbY > deadzone)
415 Microscope.MoveDown((((float)gamepad.RightThumbY) / minVal) * (float)RJoystickStageMoveAmountBox.Value);
416 #endregion
417
418 LJoystickLabel.Text = "X: " + gamepad.LeftThumbX.ToString("0.000") + " Y:" + gamepad.LeftThumbY.ToString("0.000");
419 RJoystickLabel.Text = "X: " + gamepad.RightThumbX.ToString("0.000") + " Y:" + gamepad.RightThumbY.ToString("0.000");
420
421 leftTriggerLabel.Text = leftTrigger.ToString();
422 rightTriggerLabel.Text = rightTrigger.ToString();
423
424 //We update distance labels
425 if (storedCoordsBox.Items.Count > 0 && storedCoordsBox.SelectedIndex != -1)
426 {
427 Point3D p0 = (Point3D)storedCoordsBox.Items[storedCoordsBox.Items.Count - 1];
428 Point3D p1 = Microscope.GetPosition();
429 lastCoordDistanceLabel.Text = Point3D.Distance(p0, p1).ToString();
430
431 Point3D pp0 = (Point3D)storedCoordsBox.Items[storedCoordsBox.SelectedIndex];
432 Point3D pp1 = Microscope.GetPosition();
433 lastSelectedCoordsLabel.Text = Point3D.Distance(pp0, pp1).ToString();
434 }
435
436 if (storedImageBox.Items.Count > 0 && storedImageBox.SelectedIndex != -1)
437 {
438 BioImage s = (BioImage)storedImageBox.Items[storedImageBox.Items.Count - 1];
439 Point3D p0 = s.Volume.Location;
440 Point3D p1 = Microscope.GetPosition();
441 lastSnapDistanceLabel.Text = Point3D.Distance(p0, p1).ToString();
442
443 BioImage ss = (BioImage)storedImageBox.Items[storedImageBox.SelectedIndex];
444 Point3D pp0 = ss.Volume.Location;
445 Point3D pp1 = Microscope.GetPosition();
446 lastSelectedSnapDistanceLabel.Text = Point3D.Distance(pp0, pp1).ToString();
447 }
448 }
449
450
458 private void controllerButtonUpdate_Tick(object sender, EventArgs e)
459 {
460 if(AppP!=null)
461 if (AppP.HasExited)
462 return;
463 //AppP.WaitForInputIdle();
464 //Here we check buttons etc. which will have a lower refresh rate to ensure that we do not repeat commands
465 if (!connected)
466 return;
467
468 gamepad = controller.GetState().Gamepad;
469
470 if (prevState)
471 CheckGamepadButtons(gamepad, previousGamepadState);
472
473 previousGamepadState = gamepad;
474 prevState = true;
475 }
476
482 public static int DigitsInString(string str)
483 {
484 int count = 0;
485 for (int i = 0; i < str.Length; i++)
486 {
487 if ((str[i] >= '0') && (str[i] <= '9'))
488 {
489 count++;
490 }
491 }
492 return count;
493 }
499 private void statusTimer_Tick(object sender, EventArgs e)
500 {
501 //We will not dock to pycromanager
502 if (dockToApp.Checked && !Properties.Settings.Default.PycroManager && !Properties.Settings.Default.PMicroscope)
503 {
504 //We set window location based on imaging app location.
505 Win32.Rect r = new Win32.Rect();
506 Win32.GetWindowRect(apph, ref r);
507 System.Drawing.Point pp = new System.Drawing.Point((r.Right) - this.Width, (r.Bottom) - this.Height - 30);
508 this.Location = new System.Drawing.Point((int)pp.X,(int)pp.Y);
509 }
510 string s = Win32.GetActiveWindowTitle();
511 if(Microscope.initialized)
512 statusLabel.Text = Microscope.GetPosition().ToString();
513 if (s != null)
514 if (s.Contains(Settings.Default.AppName))
515 {
516 if (dockToApp.Checked)
517 Show();
518 else
519 {
520 if (!s.Contains("Imager"))
521 {
522 if (dockToApp.Checked)
523 Hide();
524 }
525 }
526 }
527 }
528
529 #region Labels Double Clicked
530
539 private void YPressedLabel_MouseDoubleClick(object sender, MouseEventArgs e)
540 {
541 FunctionForm form = new FunctionForm(ControllerFuncs.Y, "YButton");
542 if (form.ShowDialog() != DialogResult.OK)
543 return;
544 ControllerFuncs.Y = form.Func;
545 Settings.Default.Y = ControllerFuncs.Y.Serialize();
546 Settings.Default.Save();
547 ControllerFuncs.LoadSettings();
548 }
549
557 private void BPressedLabel_MouseDoubleClick(object sender, MouseEventArgs e)
558 {
559 FunctionForm form = new FunctionForm(ControllerFuncs.B, "BButton");
560 if (form.ShowDialog() != DialogResult.OK)
561 return;
562 ControllerFuncs.B = form.Func;
563 Settings.Default.B = ControllerFuncs.B.Serialize();
564 Settings.Default.Save();
565 ControllerFuncs.LoadSettings();
566 }
567
575 private void APressedLabel_MouseDoubleClick(object sender, MouseEventArgs e)
576 {
577 FunctionForm form = new FunctionForm(ControllerFuncs.A, "AButton");
578 if (form.ShowDialog() != DialogResult.OK)
579 return;
580 ControllerFuncs.A = form.Func;
581 Settings.Default.A = ControllerFuncs.A.Serialize();
582 Settings.Default.Save();
583 ControllerFuncs.LoadSettings();
584 }
585
593 private void XPressedLabel_MouseDoubleClick(object sender, MouseEventArgs e)
594 {
595 FunctionForm form = new FunctionForm(ControllerFuncs.X, "XButton");
596 if (form.ShowDialog() != DialogResult.OK)
597 return;
598 ControllerFuncs.X = form.Func;
599 Settings.Default.X = ControllerFuncs.X.Serialize();
600 Settings.Default.Save();
601 ControllerFuncs.LoadSettings();
602 }
603
610 private void BackPressedLabel_MouseDoubleClick(object sender, MouseEventArgs e)
611 {
612 FunctionForm form = new FunctionForm(ControllerFuncs.Back, "BackButton");
613 if (form.ShowDialog() != DialogResult.OK)
614 return;
615 ControllerFuncs.Back = form.Func;
616 Settings.Default.Back = ControllerFuncs.Back.Serialize();
617 Settings.Default.Save();
618 ControllerFuncs.LoadSettings();
619 }
620
627 private void StartPressedLabel_MouseDoubleClick(object sender, MouseEventArgs e)
628 {
629 FunctionForm form = new FunctionForm(ControllerFuncs.Start, "StartButton");
630 if (form.ShowDialog() != DialogResult.OK)
631 return;
632 Settings.Default.Start = ControllerFuncs.Start.Serialize();
633 Settings.Default.Save();
634 ControllerFuncs.LoadSettings();
635 }
636
644 private void DPadUpLabel_MouseDoubleClick(object sender, MouseEventArgs e)
645 {
646 FunctionForm form = new FunctionForm(ControllerFuncs.DPadUp, "DPadUpButton");
647 if (form.ShowDialog() != DialogResult.OK)
648 return;
649 ControllerFuncs.DPadUp = form.Func;
650 Settings.Default.DPadUp = ControllerFuncs.DPadUp.Serialize();
651 Settings.Default.Save();
652 ControllerFuncs.LoadSettings();
653 }
654
662 private void DPadRightLabel_MouseDoubleClick(object sender, MouseEventArgs e)
663 {
664 FunctionForm form = new FunctionForm(ControllerFuncs.DPadRight, "DPadRightButton");
665 if (form.ShowDialog() != DialogResult.OK)
666 return;
667 ControllerFuncs.DPadRight = form.Func;
668 Settings.Default.DPadRight = ControllerFuncs.DPadRight.Serialize();
669 Settings.Default.Save();
670 ControllerFuncs.LoadSettings();
671 }
672
680 private void DPadDownLabel_MouseDoubleClick(object sender, MouseEventArgs e)
681 {
682 FunctionForm form = new FunctionForm(ControllerFuncs.DPadDown, "DPadDownButton");
683 if (form.ShowDialog() != DialogResult.OK)
684 return;
685 ControllerFuncs.DPadDown = form.Func;
686 Settings.Default.DPadDown = ControllerFuncs.DPadDown.Serialize();
687 Settings.Default.Save();
688 ControllerFuncs.LoadSettings();
689 }
690
698 private void DPadLeftLabel_MouseDoubleClick(object sender, MouseEventArgs e)
699 {
700 FunctionForm form = new FunctionForm(ControllerFuncs.DPadLeft, "DPadLeftButton");
701 if (form.ShowDialog() != DialogResult.OK)
702 return;
703 ControllerFuncs.DPadLeft = form.Func;
704 Settings.Default.DPadLeft = ControllerFuncs.DPadLeft.Serialize();
705 Settings.Default.Save();
706 ControllerFuncs.LoadSettings();
707 }
708
716 private void shoulderLeftLabel_MouseDoubleClick(object sender, MouseEventArgs e)
717 {
718 FunctionForm form = new FunctionForm(ControllerFuncs.LShoulder, "ShoulderLeftButton");
719 if (form.ShowDialog() != DialogResult.OK)
720 return;
721 ControllerFuncs.LShoulder = form.Func;
722 Settings.Default.LShoulder = ControllerFuncs.LShoulder.Serialize();
723 Settings.Default.Save();
724 ControllerFuncs.LoadSettings();
725 }
726
733 private void shoulderRightLabel_MouseDoubleClick(object sender, MouseEventArgs e)
734 {
735 FunctionForm form = new FunctionForm(ControllerFuncs.RShoulder, "ShoulderRightButton");
736 if (form.ShowDialog() != DialogResult.OK)
737 return;
738 ControllerFuncs.RShoulder = form.Func;
739 Settings.Default.RShoulder = ControllerFuncs.RShoulder.Serialize();
740 Settings.Default.Save();
741 ControllerFuncs.LoadSettings();
742 }
749
750 private void r3PressedLabel_MouseDoubleClick(object sender, MouseEventArgs e)
751 {
752 FunctionForm form = new FunctionForm(ControllerFuncs.R3, "R3");
753 if (form.ShowDialog() != DialogResult.OK)
754 return;
755 ControllerFuncs.R3 = form.Func;
756 Settings.Default.Right3 = ControllerFuncs.R3.Serialize();
757 Settings.Default.Save();
758 ControllerFuncs.LoadSettings();
759 }
760
768 private void l3PressedLabel_MouseDoubleClick(object sender, MouseEventArgs e)
769 {
770 FunctionForm form = new FunctionForm(ControllerFuncs.L3, "L3");
771 if (form.ShowDialog() != DialogResult.OK)
772 return;
773 Settings.Default.Left3 = ControllerFuncs.L3.Serialize();
774 Settings.Default.Save();
775 ControllerFuncs.LoadSettings();
776 }
777
778 #endregion
779
787 private void openFileToolStripMenuItem_Click(object sender, EventArgs e)
788 {
789 if (storedImageBox.SelectedItem == null)
790 return;
791 BioImage s = (BioImage)storedImageBox.SelectedItem;
792 if (s.Filename == "")
793 return;
794 else
795 Process.Start(s.Filename);
796 }
797
804 private void openProfileBut_Click(object sender, EventArgs e)
805 {
806 openProfileFileDialog.InitialDirectory = Application.StartupPath + "\\Profiles";
807 if (openProfileFileDialog.ShowDialog() != DialogResult.OK)
808 return;
809 CurrentProfile = new Profile(openProfileFileDialog.FileName);
810 CurrentProfile.Load();
811 profilesBox.Items.Add(CurrentProfile);
812 int index = 0;
813 foreach (Profile item in profilesBox.Items)
814 {
815 if (item.FilePath == CurrentProfile.FilePath)
816 {
817 profilesBox.SelectedIndex = index;
818 break;
819 }
820 index++;
821 }
822 }
823
831 private void profilesBox_SelectedIndexChanged(object sender, EventArgs e)
832 {
833 if (profilesBox.SelectedIndex == -1)
834 return;
835 if (profilesBox.Text == "Default" || profilesBox.SelectedItem.ToString() == "Default")
836 return;
837 CurrentProfile = (Profile)profilesBox.SelectedItem;
838 }
839
846 private void saveProfileBut_Click(object sender, EventArgs e)
847 {
848 saveFileDialog.InitialDirectory = Application.StartupPath + "\\Profiles\\";
849 if (profilesBox.Text != "")
850 saveFileDialog.FileName = profilesBox.Text;
851
852 if (profilesBox.SelectedItem != null)
853 if (profilesBox.SelectedItem.ToString() == "Default" || profilesBox.Text == "Default")
854 {
855 MessageBox.Show("You are saving the default profile, are you sure you want to do this?", "NOTICE!");
856 Settings.Default.Save();
857 return;
858 }
859 if (saveFileDialog.ShowDialog() != DialogResult.OK)
860 return;
861 CurrentProfile.Save(saveFileDialog.FileName);
862 }
863
864 private void clearSnapsBut_Click(object sender, EventArgs e)
865 {
866 storedImageBox.Items.Clear();
867 }
868
876 private void storedSnapBox_SelectedIndexChanged(object sender, EventArgs e)
877 {
878 if (storedImageBox.SelectedItem == null)
879 return;
880 BioImage s = (BioImage)storedImageBox.SelectedItem;
881 xCoordBox.Value = (decimal)s.Volume.Location.X;
882 yCoordBox.Value = (decimal)s.Volume.Location.Y;
883 zCoordBox.Value = (decimal)s.Volume.Location.Z;
884
885 }
886 private void goToLocBox_Click(object sender, EventArgs e)
887 {
888 Point3D p = new Point3D((double)xCoordBox.Value, (double)yCoordBox.Value, (double)zCoordBox.Value);
889 Microscope.SetPosition(p);
890 }
891 private void tabContextMenu_Opening(object sender, CancelEventArgs e)
892 {
893
894 }
901
902 private void borderToolStripMenuItem_Click(object sender, EventArgs e)
903 {
904 if (this.FormBorderStyle == FormBorderStyle.Sizable)
905 {
906 this.FormBorderStyle = FormBorderStyle.None;
907 borderToolStripMenuItem.Text = "Window Border Normal";
908 }
909 else
910 {
911 this.FormBorderStyle = FormBorderStyle.Sizable;
912 borderToolStripMenuItem.Text = "Window Border None";
913 }
914 }
915
916 private void hideToolStripMenuItem_Click(object sender, EventArgs e)
917 {
918 this.Hide();
919 }
920
921 private void closeToolStripMenuItem_Click(object sender, EventArgs e)
922 {
923 this.Close();
924 }
925
933 private void openInImageViewToolStripMenuItem_Click(object sender, EventArgs e)
934 {
935 if (storedImageBox.SelectedIndex == -1)
936 return;
937 BioImage s = (BioImage)storedImageBox.SelectedItem;
938 }
939
947 private void MainForm_KeyDown(object sender, KeyEventArgs e)
948 {
949 if (e.KeyCode == Keys.S && e.Control)
950 {
951 if (saveImageDialog.ShowDialog() != DialogResult.OK)
952 return;
953 //imageview.image.Save(saveImageDialog.FileName);
954 }
955 }
956
962 private void copyToolStripMenuItem1_Click(object sender, EventArgs e)
963 {
964 Clipboard.SetText(storedImageBox.SelectedItem.ToString());
965 }
966
972 private void copyToolStripMenuItem_Click(object sender, EventArgs e)
973 {
974 Clipboard.SetText(storedCoordsBox.SelectedItem.ToString());
975 }
976
981 private void dockToApp_CheckedChanged(object sender, EventArgs e)
982 {
983
984 }
985
990 private void topMostCheckBox_CheckedChanged(object sender, EventArgs e)
991 {
992 this.TopMost = topMostCheckBox.Checked;
993 }
994
1002 public void CheckGamepadButtons(Gamepad state, Gamepad prevState)
1003 {
1004 #region YBAX Keys
1005 if (ControllerFuncs.Y.State == Function.ButtonState.Released)
1006 {
1007 if (prevState.Buttons == GamepadButtonFlags.Y && state.Buttons != GamepadButtonFlags.Y)
1008 {
1010 prevState.Buttons = GamepadButtonFlags.None;
1011 YPressedLabel.Text = "Y: released";
1012 }
1013 else
1014 YPressedLabel.Text = "Y: not pressed";
1015 }
1016 else
1017 {
1018 if (state.Buttons == GamepadButtonFlags.Y)
1019 {
1021 prevState.Buttons = GamepadButtonFlags.None;
1022 YPressedLabel.Text = "Y: pressed";
1023 }
1024 else
1025 YPressedLabel.Text = "Y: not pressed";
1026 }
1027 if (ControllerFuncs.B.State == Function.ButtonState.Released)
1028 {
1029 if (prevState.Buttons == GamepadButtonFlags.B && state.Buttons != GamepadButtonFlags.B)
1030 {
1032 prevState.Buttons = GamepadButtonFlags.None;
1033 state.Buttons = GamepadButtonFlags.None;
1034 BPressedLabel.Text = "B: released";
1035 }
1036 else
1037 BPressedLabel.Text = "B: not pressed";
1038 }
1039 else
1040 {
1041 if (state.Buttons == GamepadButtonFlags.B)
1042 {
1044 prevState.Buttons = GamepadButtonFlags.None;
1045 BPressedLabel.Text = "B: pressed";
1046 }
1047 else
1048 BPressedLabel.Text = "B: not pressed";
1049 }
1050 if (ControllerFuncs.A.State == Function.ButtonState.Released)
1051 {
1052 if (prevState.Buttons == GamepadButtonFlags.A && state.Buttons != GamepadButtonFlags.A)
1053 {
1055 prevState.Buttons = GamepadButtonFlags.None;
1056 APressedLabel.Text = "A: released";
1057 }
1058 else
1059 APressedLabel.Text = "A: not pressed";
1060 }
1061 else
1062 {
1063 if (state.Buttons == GamepadButtonFlags.A)
1064 {
1066 prevState.Buttons = GamepadButtonFlags.None;
1067 APressedLabel.Text = "A: pressed";
1068 }
1069 else
1070 APressedLabel.Text = "A: not pressed";
1071 }
1072 if (ControllerFuncs.X.State == Function.ButtonState.Released)
1073 {
1074 if (prevState.Buttons == GamepadButtonFlags.X && state.Buttons != GamepadButtonFlags.X)
1075 {
1077 prevState.Buttons = GamepadButtonFlags.None;
1078 XPressedLabel.Text = "X: released";
1079 }
1080 else
1081 XPressedLabel.Text = "X: not pressed";
1082 }
1083 else
1084 {
1085 if (state.Buttons == GamepadButtonFlags.X)
1086 {
1088 prevState.Buttons = GamepadButtonFlags.None;
1089 XPressedLabel.Text = "X: pressed";
1090 }
1091 else
1092 XPressedLabel.Text = "X: not pressed";
1093 }
1094 #endregion
1095
1096 #region Back & Start Keys
1097 if (ControllerFuncs.Start.State == Function.ButtonState.Released)
1098 {
1099 if (prevState.Buttons == GamepadButtonFlags.Start && state.Buttons != GamepadButtonFlags.Start)
1100 {
1102 prevState.Buttons = GamepadButtonFlags.None;
1103 StartPressedLabel.Text = "Start: released";
1104 }
1105 else
1106 StartPressedLabel.Text = "Start: not pressed";
1107 }
1108 else
1109 {
1110 if (state.Buttons == GamepadButtonFlags.Start)
1111 {
1113 prevState.Buttons = GamepadButtonFlags.None;
1114 StartPressedLabel.Text = "Start: pressed";
1115 }
1116 else
1117 StartPressedLabel.Text = "Start: not pressed";
1118 }
1119 if (ControllerFuncs.Back.State == Function.ButtonState.Released)
1120 {
1121 if (prevState.Buttons == GamepadButtonFlags.Back && state.Buttons != GamepadButtonFlags.Back)
1122 {
1124 prevState.Buttons = GamepadButtonFlags.None;
1125 BackPressedLabel.Text = "Back: released";
1126 }
1127 else
1128 BackPressedLabel.Text = "Back: not pressed";
1129 }
1130 else
1131 {
1132 if (state.Buttons == GamepadButtonFlags.Back)
1133 {
1135 prevState.Buttons = GamepadButtonFlags.None;
1136 BackPressedLabel.Text = "Back: pressed";
1137 }
1138 else
1139 BackPressedLabel.Text = "Back: not pressed";
1140 }
1141 #endregion
1142
1143 #region Shoulders
1144 if (ControllerFuncs.RShoulder.State == Function.ButtonState.Released)
1145 {
1146 if (prevState.Buttons == GamepadButtonFlags.RightShoulder && state.Buttons != GamepadButtonFlags.RightShoulder)
1147 {
1149 prevState.Buttons = GamepadButtonFlags.None;
1150 shoulderRightLabel.Text = "Right: released";
1151 }
1152 else
1153 shoulderRightLabel.Text = "Right: not pressed";
1154 }
1155 else
1156 {
1157 if (state.Buttons == GamepadButtonFlags.RightShoulder)
1158 {
1160 prevState.Buttons = GamepadButtonFlags.None;
1161 shoulderRightLabel.Text = "Right: pressed";
1162 }
1163 else
1164 shoulderRightLabel.Text = "Right: not pressed";
1165 }
1166 if (ControllerFuncs.LShoulder.State == Function.ButtonState.Released)
1167 {
1168 if (prevState.Buttons == GamepadButtonFlags.LeftShoulder && state.Buttons != GamepadButtonFlags.LeftShoulder)
1169 {
1171 prevState.Buttons = GamepadButtonFlags.None;
1172 shoulderLeftLabel.Text = "Left: released";
1173 }
1174 else
1175 shoulderLeftLabel.Text = "Left: not pressed";
1176 }
1177 else
1178 {
1179 if (state.Buttons == GamepadButtonFlags.LeftShoulder)
1180 {
1182 prevState.Buttons = GamepadButtonFlags.None;
1183 shoulderLeftLabel.Text = "Left: pressed";
1184 }
1185 else
1186 shoulderLeftLabel.Text = "Left: not pressed";
1187 }
1188
1189 #endregion
1190
1191 #region L3 & R3
1192 if (ControllerFuncs.R3.State == Function.ButtonState.Released)
1193 {
1194 if (prevState.Buttons == GamepadButtonFlags.RightThumb && state.Buttons != GamepadButtonFlags.RightThumb)
1195 {
1197 prevState.Buttons = GamepadButtonFlags.None;
1198 r3PressedLabel.Text = "R3: released";
1199 }
1200 else
1201 r3PressedLabel.Text = "R3: not pressed";
1202 }
1203 else
1204 {
1205 if (state.Buttons == GamepadButtonFlags.RightThumb)
1206 {
1208 prevState.Buttons = GamepadButtonFlags.None;
1209 r3PressedLabel.Text = "R3: pressed";
1210 }
1211 else
1212 r3PressedLabel.Text = "R3: not pressed";
1213 }
1214
1215 if (ControllerFuncs.L3.State == Function.ButtonState.Released)
1216 {
1217 if (prevState.Buttons == GamepadButtonFlags.LeftThumb && state.Buttons != GamepadButtonFlags.LeftThumb)
1218 {
1220 prevState.Buttons = GamepadButtonFlags.None;
1221 l3PressedLabel.Text = "L3: released";
1222 }
1223 else
1224 l3PressedLabel.Text = "L3: not pressed";
1225 }
1226 else
1227 {
1228 if (state.Buttons == GamepadButtonFlags.LeftThumb)
1229 {
1231 prevState.Buttons = GamepadButtonFlags.None;
1232 l3PressedLabel.Text = "L3: pressed";
1233 }
1234 else
1235 l3PressedLabel.Text = "L3: not pressed";
1236 }
1237 #endregion
1238
1239 #region DPAD BUTTONS
1240 if (ControllerFuncs.DPadUp.State == Function.ButtonState.Released)
1241 {
1242 if (prevState.Buttons == GamepadButtonFlags.DPadUp && state.Buttons != GamepadButtonFlags.DPadUp)
1243 {
1245 prevState.Buttons = GamepadButtonFlags.None;
1246 DPadUpLabel.Text = "Up: released";
1247 }
1248 else
1249 DPadUpLabel.Text = "Up: not pressed";
1250 }
1251 else
1252 {
1253 if (state.Buttons == GamepadButtonFlags.DPadUp)
1254 {
1256 prevState.Buttons = GamepadButtonFlags.None;
1257 DPadUpLabel.Text = "Up: pressed";
1258 }
1259 else
1260 DPadUpLabel.Text = "Up: not pressed";
1261 }
1262
1263 if (ControllerFuncs.DPadRight.State == Function.ButtonState.Released)
1264 {
1265 if (prevState.Buttons == GamepadButtonFlags.DPadRight && state.Buttons != GamepadButtonFlags.DPadRight)
1266 {
1268 prevState.Buttons = GamepadButtonFlags.None;
1269 DPadRightLabel.Text = "Right: released";
1270 }
1271 else
1272 DPadRightLabel.Text = "Right: not pressed";
1273 }
1274 else
1275 {
1276 if (state.Buttons == GamepadButtonFlags.DPadRight)
1277 {
1279 prevState.Buttons = GamepadButtonFlags.None;
1280 DPadRightLabel.Text = "Right: pressed";
1281 }
1282 else
1283 DPadRightLabel.Text = "Right: not pressed";
1284 }
1285
1286 if (ControllerFuncs.DPadDown.State == Function.ButtonState.Released)
1287 {
1288 if (prevState.Buttons == GamepadButtonFlags.DPadDown && state.Buttons != GamepadButtonFlags.DPadDown)
1289 {
1291 prevState.Buttons = GamepadButtonFlags.None;
1292 DPadDownLabel.Text = "Down: released";
1293 }
1294 else
1295 DPadDownLabel.Text = "Down: not pressed";
1296 }
1297 else
1298 {
1299 if (state.Buttons == GamepadButtonFlags.DPadDown)
1300 {
1302 prevState.Buttons = GamepadButtonFlags.None;
1303 DPadDownLabel.Text = "Down: pressed";
1304 }
1305 else
1306 DPadDownLabel.Text = "Down: not pressed";
1307 }
1308
1309 if (ControllerFuncs.DPadLeft.State == Function.ButtonState.Released)
1310 {
1311 if (prevState.Buttons == GamepadButtonFlags.DPadLeft && state.Buttons != GamepadButtonFlags.DPadLeft)
1312 {
1314 prevState.Buttons = GamepadButtonFlags.None;
1315 DPadLeftLabel.Text = "Left: released";
1316 }
1317 else
1318 DPadLeftLabel.Text = "Left: not pressed";
1319 }
1320 else
1321 {
1322 if (state.Buttons == GamepadButtonFlags.DPadLeft)
1323 {
1325 prevState.Buttons = GamepadButtonFlags.None;
1326 DPadLeftLabel.Text = "Left: pressed";
1327 }
1328 else
1329 DPadLeftLabel.Text = "Left: not pressed";
1330 }
1331
1332 #endregion
1333
1334 }
1335
1336 public static InputSimulator input = new InputSimulator();
1337
1343 public object PerformFunction(Function f)
1344 {
1345 if (f.FuncType == Function.FunctionType.Key)
1346 {
1347 if(AppP!=null)
1348 if (AppP.HasExited)
1349 return null;
1350 if (AppP != null)
1351 AppP.WaitForInputIdle();
1352 if (AppP != null)
1353 Win32.SetForegroundWindow(apph);
1354 if (f.Modifier != VirtualKeyCode.NONAME)
1355 {
1356 input.Keyboard.ModifiedKeyStroke(f.Modifier, f.Key);
1357 }
1358 else
1359 {
1360 input.Keyboard.KeyPress(f.Key);
1361 }
1362 return null;
1363 }
1364 if (f.FuncType == Function.FunctionType.Objective)
1365 {
1366 Objectives.Objective obj = BioImager.Microscope.Objectives.GetObjective();
1367 Microscope.Objectives.SetPosition((int)f.Value);
1368 //We set locate exposure as the locate tab is the only one that updates lightpath automatically after objective change.
1369 //Automation.SetProperty("LocateExposure", obj.LocateExposure.ToString());
1370 LJoystickStageMoveAmountBox.Value = (decimal)obj.MoveAmountL;
1371 RJoystickStageMoveAmountBox.Value = (decimal)obj.MoveAmountR;
1372 triggerFocusBox.Value = (decimal)obj.FocusMoveAmount;
1373 return null;
1374 }
1375 if (f.FuncType == Function.FunctionType.StoreCoordinate)
1376 {
1377 StoreCoordinate();
1378 return null;
1379 }
1380 if (f.FuncType == Function.FunctionType.NextCoordinate)
1381 {
1382 //If stored coordinates selected index is -1 then nothing is selected.
1383 //so we can't go to next stored coordinate
1384 if (storedCoordsBox.SelectedIndex != -1)
1385 {
1386 //We go to the next stored coordinate
1387 if (storedCoordsBox.SelectedIndex + 1 < storedCoordsBox.Items.Count)
1388 {
1389 Point3D p = (Point3D)storedCoordsBox.Items[storedCoordsBox.SelectedIndex + 1];
1390 Microscope.SetPosition(p);
1391 storedCoordsBox.SelectedIndex = storedCoordsBox.SelectedIndex + 1;
1392 }
1393 if (storedCoordsBox.SelectedIndex == 0)
1394 {
1395 Point3D p = (Point3D)storedCoordsBox.Items[storedCoordsBox.SelectedIndex];
1396 Microscope.SetPosition(p);
1397 }
1398 }
1399 return null;
1400 }
1401 if (f.FuncType == Function.FunctionType.PreviousCoordinate)
1402 {
1403 //We go to the previous stored coordinate unless selected index is 0
1404 //in which case we go to coordinate of selected point.
1405
1406 //If stored coordinates selected index is -1 then nothing is selected.
1407 //so we can't go to next stored coordinate
1408 if (storedCoordsBox.SelectedIndex != -1)
1409 {
1410 if (storedCoordsBox.SelectedIndex == 0)
1411 {
1412 Point3D p = (Point3D)storedCoordsBox.Items[storedCoordsBox.SelectedIndex];
1413 Microscope.SetPosition(p);
1414 }
1415 if (storedCoordsBox.SelectedIndex > 0)
1416 {
1417 Point3D p = (Point3D)storedCoordsBox.Items[storedCoordsBox.SelectedIndex - 1];
1418 Microscope.SetPosition(p);
1419 storedCoordsBox.SelectedIndex = storedCoordsBox.SelectedIndex - 1;
1420 }
1421 }
1422 return null;
1423 }
1424 if (f.FuncType == Function.FunctionType.NextSnapCoordinate)
1425 {
1426 //If stored coordinates selected index is -1 then nothing is selected.
1427 //so we can't go to next stored coordinate
1428 if (storedImageBox.SelectedIndex != -1)
1429 {
1430 //We go to the next stored coordinate
1431 if (storedImageBox.SelectedIndex + 1 < storedImageBox.Items.Count)
1432 {
1433 Point3D p = (Point3D)storedImageBox.Items[storedImageBox.SelectedIndex + 1];
1434 Microscope.SetPosition(p);
1435 storedImageBox.SelectedIndex = storedImageBox.SelectedIndex + 1;
1436 }
1437 if (storedImageBox.SelectedIndex == 0)
1438 {
1439 Point3D p = (Point3D)storedImageBox.Items[storedImageBox.SelectedIndex];
1440 Microscope.SetPosition(p);
1441 }
1442 }
1443 return null;
1444 }
1445 if (f.FuncType == Function.FunctionType.PreviousSnapCoordinate)
1446 {
1447 //We go to the previous stored coordinate unless selected index is 0
1448 //in which case we go to coordinate of selected point.
1449
1450 //If stored coordinates selected index is -1 then nothing is selected.
1451 //so we can't go to next stored coordinate
1452 if (storedImageBox.SelectedIndex != -1)
1453 {
1454 if (storedImageBox.SelectedIndex == 0)
1455 {
1456 Point3D p = (Point3D)storedImageBox.Items[storedImageBox.SelectedIndex];
1457 Microscope.SetPosition(p);
1458 }
1459 if (storedImageBox.SelectedIndex > 0)
1460 {
1461 Point3D p = (Point3D)storedImageBox.Items[storedImageBox.SelectedIndex - 1];
1462 Microscope.SetPosition(p);
1463 //We stop the controller update timer so we can update the stored coordinates list it operates on safely
1464 storedImageBox.SelectedIndex = storedImageBox.SelectedIndex - 1;
1465 }
1466 }
1467 return null;
1468 }
1469 if (f.FuncType == Function.FunctionType.Script)
1470 {
1471 Scripting.RunScript(f.File);
1472 }
1473 if (f.FuncType == Function.FunctionType.ImageJ)
1474 {
1475 ImageJ.RunMacro(f.File, "");
1476 }
1477 if (f.FuncType.ToString() == "StageUp")
1478 {
1479 Microscope.MoveUp(f.Value);
1480 }
1481 else
1482 if (f.FuncType.ToString() == "StageRight")
1483 {
1484 Microscope.MoveRight(f.Value);
1485 }
1486 else
1487 if (f.FuncType.ToString() == "StageDown")
1488 {
1489 Microscope.MoveDown(f.Value);
1490 }
1491 else
1492 if (f.FuncType.ToString() == "StageLeft")
1493 {
1494 Microscope.MoveLeft(f.Value);
1495 }
1496 else
1497 if (f.FuncType.ToString() == "FocusUp")
1498 {
1499 Microscope.SetFocus(f.Value);
1500 }
1501 else
1502 if (f.FuncType.ToString() == "FocusDown")
1503 {
1504 Microscope.SetFocus(-f.Value);
1505 }
1506 else
1507 if (f.FuncType.ToString() == "StageFieldUp")
1508 {
1509 Microscope.MoveFieldUp();
1510 }
1511 else
1512 if (f.FuncType.ToString() == "StageFieldRight")
1513 {
1514 Microscope.MoveFieldRight();
1515 }
1516 else
1517 if (f.FuncType.ToString() == "StageFieldDown")
1518 {
1519 Microscope.MoveFieldDown();
1520 }
1521 else
1522 if (f.FuncType.ToString() == "StageFieldLeft")
1523 {
1524 Microscope.MoveFieldLeft();
1525 }
1526 else
1527 if (f.FuncType.ToString() == "TakeImage")
1528 {
1529 Microscope.TakeImage();
1530 }
1531 else
1532 if (f.FuncType.ToString() == "TakeImageStack")
1533 {
1534 Microscope.TakeImageStack();
1535 }
1536 else
1537 if (f.FuncType.ToString() == "RL")
1538 {
1539 Microscope.RLShutter.SetPosition((int)f.Value);
1540 }
1541 else
1542 if (f.FuncType.ToString() == "TL")
1543 {
1544 Microscope.TLShutter.SetPosition((int)f.Value);
1545 }
1546 if (f.FuncType == Function.FunctionType.Property)
1547 {
1548 if (f.Name.StartsWith("Get"))
1549 {
1550 Automation.Recording r = (Automation.Recording)Automation.Properties[Path.GetFileNameWithoutExtension(f.File)];
1551 return r.Get();
1552 }
1553 else if (f.Name.StartsWith("Set"))
1554 {
1555 Automation.Recording r = (Automation.Recording)Automation.Properties[Path.GetFileNameWithoutExtension(f.File)];
1556 r.Set(f.Value.ToString());
1557 }
1558
1559 }
1560 if (f.FuncType == Function.FunctionType.Recording)
1561 {
1562 Automation.Recording r = (Automation.Recording)Automation.Recordings[Path.GetFileNameWithoutExtension(f.File)];
1563 r.Run();
1564 }
1565 return null;
1566 }
1567
1568 /* It's a class that contains a bunch of static variables that are used to store the functions
1569 that are assigned to each button */
1570 public class ControllerFuncs
1571 {
1572 public static Function Y, B, A, X, DPadUp, DPadRight, DPadDown, DPadLeft, Start, Back, RShoulder, LShoulder, R3, L3;
1573 public static bool Initialized = false;
1574 public static void LoadSettings()
1575 {
1576 Y = Function.Parse(Settings.Default.Y.ToString());
1577 B = Function.Parse(Settings.Default.B.ToString());
1578 A = Function.Parse(Settings.Default.A.ToString());
1579 X = Function.Parse(Settings.Default.X.ToString());
1580 DPadUp = Function.Parse(Settings.Default.DPadUp.ToString());
1581 DPadRight = Function.Parse(Settings.Default.DPadRight.ToString());
1582 DPadDown = Function.Parse(Settings.Default.DPadDown.ToString());
1583 DPadLeft = Function.Parse(Settings.Default.DPadLeft.ToString());
1584 Start = Function.Parse(Settings.Default.Start.ToString());
1585 Back = Function.Parse(Settings.Default.Back.ToString());
1586 RShoulder = Function.Parse(Settings.Default.RShoulder.ToString());
1587 LShoulder = Function.Parse(Settings.Default.LShoulder.ToString());
1588 R3 = Function.Parse(Settings.Default.Right3.ToString());
1589 L3 = Function.Parse(Settings.Default.Left3.ToString());
1590 Initialized = true;
1591 if (Settings.Default.Y.ToString() == "")
1592 Initialized = false;
1593 }
1594 }
1595
1596 private void ImagingTab_Click(object sender, EventArgs e)
1597 {
1598 statusLabel.Text = Microscope.GetPosition().ToString();
1599 }
1600 }
1601
1602}
static void RunMacro(string file, string param)
Definition ImageJ.cs:115
void UpdateStatus()
Definition Imager.cs:247
static int DigitsInString(string str)
Definition Imager.cs:482
void CheckGamepadButtons(Gamepad state, Gamepad prevState)
Definition Imager.cs:1002
object PerformFunction(Function f)
Definition Imager.cs:1343
static void RunScript(string file)
Definition Scripting.cs:381