2using System.Collections.Generic;
3using System.ComponentModel;
5using System.Drawing.Imaging;
9using System.Threading.Tasks;
10using System.Runtime.InteropServices;
11using System.Windows.Forms;
12using System.Diagnostics;
13using System.Globalization;
14using System.Threading;
17using System.Configuration;
18using BioImager.Properties;
24 public partial class Imager : Form
26 private static Process AppP =
null;
28 private System.Drawing.Point mainWinDefLocation =
new System.Drawing.Point(1473, 509);
51 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
56 return (uint)imagesPerSliceBox.Value;
60 imagesPerSliceBox.Value = (decimal)value;
63 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
68 return (uint)sliceIncrementBox.Value;
72 sliceIncrementBox.Value = (decimal)value;
75 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
80 return (uint)slicesPerSlideBox.Value;
84 slicesPerSlideBox.Value = (decimal)value;
96 public void Save(
string path)
98 List<string> sts =
new List<string>();
99 foreach (SettingsProperty currentProperty
in Settings.Default.Properties)
101 string s = currentProperty.Name +
"=" +
Settings.Default[currentProperty.Name].ToString();
104 File.WriteAllLines(path, sts.ToArray());
110 if (path !=
"Default")
119 string[] sts = File.ReadAllLines(
FilePath);
120 foreach (
string s
in sts)
122 string[] ss = s.Split(
'=');
123 if (
Settings.Default[ss[0]].GetType() == typeof(
double))
125 Settings.Default[ss[0]] =
double.Parse(ss[1]);
128 if (
Settings.Default[ss[0]].GetType() == typeof(
string))
144 InitializeComponent();
147 topMostCheckBox.Checked =
false;
148 dockToApp.Checked =
false;
150 Stopwatch timer =
new Stopwatch();
152 TimeSpan st1 = timer.Elapsed;
154 if (
Settings.Default.AppPath !=
"" && !
Settings.Default.AppPath.Contains(
"ImageJ"))
160 MessageBox.Show(
"Error!",
"Imaging appplication not found. Please locate the executable.");
162 if (openExeFileDialog.ShowDialog() != DialogResult.OK)
164 Settings.Default.AppPath = openExeFileDialog.FileName;
166 string pn = Path.GetFileNameWithoutExtension(
AppPath);
167 Process[] prs = Process.GetProcessesByName(pn);
174 apph = AppP.MainWindowHandle;
178 AppP.WaitForInputIdle();
186 for (UserIndex i = UserIndex.One; i <= UserIndex.Four; i++)
199 controllerJoystickUpdate.Start();
201 controllerButtonUpdate.Start();
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)
210 profilesBox.Items.Add(p);
213 if (
Settings.Default.PreviousProfile !=
"Default")
218 foreach (
Profile item
in profilesBox.Items)
222 profilesBox.SelectedIndex = index;
228 this.TopMost = topMostCheckBox.Checked;
230 if (dockToApp.Checked && !Properties.Settings.Default.PycroManager)
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);
254 Point3D point =
new Point3D(p.X, p.Y, f);
255 statusLabel.Text =
"Stage: " + p.X +
" , " + p.Y +
" Focus: " + f;
258 int dif = StoredImages.Count - storedImageBox.Items.Count;
259 for (
int i = 0; i < dif; i++)
261 int index = (StoredImages.Count - 1) + dif;
270 storedCoordsBox.Items.Add(p3);
271 storedCoordsBox.SelectedIndex = storedCoordsBox.Items.Count - 1;
275 private void MainForm_FormClosing(
object sender, FormClosingEventArgs e)
286 private void deadzoneBox_ValueChanged(
object sender, EventArgs e)
291 private void storedCoordsBox_SelectedIndexChanged(
object sender, EventArgs e)
293 Point3D p = (Point3D)storedCoordsBox.SelectedItem;
294 xCoordBox.Value = (decimal)p.X;
295 yCoordBox.Value = (decimal)p.Y;
296 zCoordBox.Value = (decimal)p.Z;
299 private void addCoordBut_Click(
object sender, EventArgs e)
304 private void goToToolStripMenuItem_Click(
object sender, EventArgs e)
306 if (storedImageBox.SelectedIndex == -1)
309 Microscope.SetPosition(s.Volume.Location);
312 private void deleteToolStripMenuItem_Click(
object sender, EventArgs e)
314 if (storedImageBox.SelectedIndex == -1)
316 storedImageBox.Items.RemoveAt(storedImageBox.SelectedIndex);
317 storedImageBox.SelectedIndex = storedImageBox.Items.Count - 1;
320 private void clearBut_Click(
object sender, EventArgs e)
323 storedCoordsBox.Items.Clear();
326 private void clearToolStripMenuItem_Click(
object sender, EventArgs e)
328 storedImageBox.Items.Clear();
331 private void clearToolStripMenuItem1_Click(
object sender, EventArgs e)
333 storedCoordsBox.Items.Clear();
336 private void goToToolStripMenuItem1_Click(
object sender, EventArgs e)
338 Point3D p = (Point3D)storedCoordsBox.SelectedItem;
339 Microscope.SetPosition(p);
348 private void deleteToolStripMenuItem1_Click(
object sender, EventArgs e)
350 if (storedCoordsBox.SelectedIndex == -1)
352 storedCoordsBox.Items.RemoveAt(storedCoordsBox.SelectedIndex);
353 storedCoordsBox.SelectedIndex = storedCoordsBox.Items.Count - 1;
362 private void controllerJoystickUpdate_Tick(
object sender, EventArgs e)
383 double curpos = Microscope.GetFocus();
384 Microscope.SetFocus((((
double)triggerFocusBox.Value) *
rightTrigger) + curpos);
389 double curpos = Microscope.GetFocus();
390 Microscope.SetFocus((-1 * (((
double)triggerFocusBox.Value) *
leftTrigger)) + curpos);
396 double maxVal = ushort.MaxValue / 2;
397 double minVal = maxVal * -1;
399 Microscope.MoveRight((((
float)
gamepad.LeftThumbX) / maxVal) * (
float)LJoystickStageMoveAmountBox.Value);
401 Microscope.MoveLeft((((
float)
gamepad.LeftThumbX) / minVal) * (
float)LJoystickStageMoveAmountBox.Value);
403 Microscope.MoveUp((((
float)
gamepad.LeftThumbY) / maxVal) * (
float)LJoystickStageMoveAmountBox.Value);
405 Microscope.MoveDown((((
float)
gamepad.LeftThumbY) / minVal) * (
float)LJoystickStageMoveAmountBox.Value);
409 Microscope.MoveRight(((
float)
gamepad.RightThumbX / maxVal) * (
float)RJoystickStageMoveAmountBox.Value);
411 Microscope.MoveLeft((((
float)
gamepad.RightThumbX) / minVal) * (
float)RJoystickStageMoveAmountBox.Value);
413 Microscope.MoveUp((((
float)
gamepad.RightThumbY) / maxVal) * (
float)RJoystickStageMoveAmountBox.Value);
415 Microscope.MoveDown((((
float)
gamepad.RightThumbY) / minVal) * (
float)RJoystickStageMoveAmountBox.Value);
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");
425 if (storedCoordsBox.Items.Count > 0 && storedCoordsBox.SelectedIndex != -1)
427 Point3D p0 = (Point3D)storedCoordsBox.Items[storedCoordsBox.Items.Count - 1];
428 Point3D p1 = Microscope.GetPosition();
429 lastCoordDistanceLabel.Text = Point3D.Distance(p0, p1).ToString();
431 Point3D pp0 = (Point3D)storedCoordsBox.Items[storedCoordsBox.SelectedIndex];
432 Point3D pp1 = Microscope.GetPosition();
433 lastSelectedCoordsLabel.Text = Point3D.Distance(pp0, pp1).ToString();
436 if (storedImageBox.Items.Count > 0 && storedImageBox.SelectedIndex != -1)
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();
444 Point3D pp0 = ss.Volume.Location;
445 Point3D pp1 = Microscope.GetPosition();
446 lastSelectedSnapDistanceLabel.Text = Point3D.Distance(pp0, pp1).ToString();
458 private void controllerButtonUpdate_Tick(
object sender, EventArgs e)
485 for (
int i = 0; i < str.Length; i++)
487 if ((str[i] >=
'0') && (str[i] <=
'9'))
499 private void statusTimer_Tick(
object sender, EventArgs e)
502 if (dockToApp.Checked && !Properties.Settings.Default.PycroManager && !Properties.Settings.Default.PMicroscope)
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);
510 string s = Win32.GetActiveWindowTitle();
511 if(Microscope.initialized)
512 statusLabel.Text = Microscope.GetPosition().ToString();
514 if (s.Contains(
Settings.Default.AppName))
516 if (dockToApp.Checked)
520 if (!s.Contains(
"Imager"))
522 if (dockToApp.Checked)
529 #region Labels Double Clicked
539 private void YPressedLabel_MouseDoubleClick(
object sender, MouseEventArgs e)
541 FunctionForm form =
new FunctionForm(ControllerFuncs.Y,
"YButton");
542 if (form.ShowDialog() != DialogResult.OK)
544 ControllerFuncs.Y = form.Func;
545 Settings.Default.Y = ControllerFuncs.Y.Serialize();
547 ControllerFuncs.LoadSettings();
557 private void BPressedLabel_MouseDoubleClick(
object sender, MouseEventArgs e)
559 FunctionForm form =
new FunctionForm(ControllerFuncs.B,
"BButton");
560 if (form.ShowDialog() != DialogResult.OK)
562 ControllerFuncs.B = form.Func;
563 Settings.Default.B = ControllerFuncs.B.Serialize();
565 ControllerFuncs.LoadSettings();
575 private void APressedLabel_MouseDoubleClick(
object sender, MouseEventArgs e)
577 FunctionForm form =
new FunctionForm(ControllerFuncs.A,
"AButton");
578 if (form.ShowDialog() != DialogResult.OK)
580 ControllerFuncs.A = form.Func;
581 Settings.Default.A = ControllerFuncs.A.Serialize();
583 ControllerFuncs.LoadSettings();
593 private void XPressedLabel_MouseDoubleClick(
object sender, MouseEventArgs e)
595 FunctionForm form =
new FunctionForm(ControllerFuncs.X,
"XButton");
596 if (form.ShowDialog() != DialogResult.OK)
598 ControllerFuncs.X = form.Func;
599 Settings.Default.X = ControllerFuncs.X.Serialize();
601 ControllerFuncs.LoadSettings();
610 private void BackPressedLabel_MouseDoubleClick(
object sender, MouseEventArgs e)
612 FunctionForm form =
new FunctionForm(ControllerFuncs.Back,
"BackButton");
613 if (form.ShowDialog() != DialogResult.OK)
615 ControllerFuncs.Back = form.Func;
616 Settings.Default.Back = ControllerFuncs.Back.Serialize();
618 ControllerFuncs.LoadSettings();
627 private void StartPressedLabel_MouseDoubleClick(
object sender, MouseEventArgs e)
629 FunctionForm form =
new FunctionForm(ControllerFuncs.Start,
"StartButton");
630 if (form.ShowDialog() != DialogResult.OK)
632 Settings.Default.Start = ControllerFuncs.Start.Serialize();
634 ControllerFuncs.LoadSettings();
644 private void DPadUpLabel_MouseDoubleClick(
object sender, MouseEventArgs e)
646 FunctionForm form =
new FunctionForm(ControllerFuncs.DPadUp,
"DPadUpButton");
647 if (form.ShowDialog() != DialogResult.OK)
649 ControllerFuncs.DPadUp = form.Func;
650 Settings.Default.DPadUp = ControllerFuncs.DPadUp.Serialize();
652 ControllerFuncs.LoadSettings();
662 private void DPadRightLabel_MouseDoubleClick(
object sender, MouseEventArgs e)
664 FunctionForm form =
new FunctionForm(ControllerFuncs.DPadRight,
"DPadRightButton");
665 if (form.ShowDialog() != DialogResult.OK)
667 ControllerFuncs.DPadRight = form.Func;
668 Settings.Default.DPadRight = ControllerFuncs.DPadRight.Serialize();
670 ControllerFuncs.LoadSettings();
680 private void DPadDownLabel_MouseDoubleClick(
object sender, MouseEventArgs e)
682 FunctionForm form =
new FunctionForm(ControllerFuncs.DPadDown,
"DPadDownButton");
683 if (form.ShowDialog() != DialogResult.OK)
685 ControllerFuncs.DPadDown = form.Func;
686 Settings.Default.DPadDown = ControllerFuncs.DPadDown.Serialize();
688 ControllerFuncs.LoadSettings();
698 private void DPadLeftLabel_MouseDoubleClick(
object sender, MouseEventArgs e)
700 FunctionForm form =
new FunctionForm(ControllerFuncs.DPadLeft,
"DPadLeftButton");
701 if (form.ShowDialog() != DialogResult.OK)
703 ControllerFuncs.DPadLeft = form.Func;
704 Settings.Default.DPadLeft = ControllerFuncs.DPadLeft.Serialize();
706 ControllerFuncs.LoadSettings();
716 private void shoulderLeftLabel_MouseDoubleClick(
object sender, MouseEventArgs e)
718 FunctionForm form =
new FunctionForm(ControllerFuncs.LShoulder,
"ShoulderLeftButton");
719 if (form.ShowDialog() != DialogResult.OK)
721 ControllerFuncs.LShoulder = form.Func;
722 Settings.Default.LShoulder = ControllerFuncs.LShoulder.Serialize();
724 ControllerFuncs.LoadSettings();
733 private void shoulderRightLabel_MouseDoubleClick(
object sender, MouseEventArgs e)
735 FunctionForm form =
new FunctionForm(ControllerFuncs.RShoulder,
"ShoulderRightButton");
736 if (form.ShowDialog() != DialogResult.OK)
738 ControllerFuncs.RShoulder = form.Func;
739 Settings.Default.RShoulder = ControllerFuncs.RShoulder.Serialize();
741 ControllerFuncs.LoadSettings();
750 private void r3PressedLabel_MouseDoubleClick(
object sender, MouseEventArgs e)
752 FunctionForm form =
new FunctionForm(ControllerFuncs.R3,
"R3");
753 if (form.ShowDialog() != DialogResult.OK)
755 ControllerFuncs.R3 = form.Func;
756 Settings.Default.Right3 = ControllerFuncs.R3.Serialize();
758 ControllerFuncs.LoadSettings();
768 private void l3PressedLabel_MouseDoubleClick(
object sender, MouseEventArgs e)
770 FunctionForm form =
new FunctionForm(ControllerFuncs.L3,
"L3");
771 if (form.ShowDialog() != DialogResult.OK)
773 Settings.Default.Left3 = ControllerFuncs.L3.Serialize();
775 ControllerFuncs.LoadSettings();
787 private void openFileToolStripMenuItem_Click(
object sender, EventArgs e)
789 if (storedImageBox.SelectedItem ==
null)
792 if (s.Filename ==
"")
795 Process.Start(s.Filename);
804 private void openProfileBut_Click(
object sender, EventArgs e)
806 openProfileFileDialog.InitialDirectory = Application.StartupPath +
"\\Profiles";
807 if (openProfileFileDialog.ShowDialog() != DialogResult.OK)
813 foreach (Profile item
in profilesBox.Items)
817 profilesBox.SelectedIndex = index;
831 private void profilesBox_SelectedIndexChanged(
object sender, EventArgs e)
833 if (profilesBox.SelectedIndex == -1)
835 if (profilesBox.Text ==
"Default" || profilesBox.SelectedItem.ToString() ==
"Default")
846 private void saveProfileBut_Click(
object sender, EventArgs e)
848 saveFileDialog.InitialDirectory = Application.StartupPath +
"\\Profiles\\";
849 if (profilesBox.Text !=
"")
850 saveFileDialog.FileName = profilesBox.Text;
852 if (profilesBox.SelectedItem !=
null)
853 if (profilesBox.SelectedItem.ToString() ==
"Default" || profilesBox.Text ==
"Default")
855 MessageBox.Show(
"You are saving the default profile, are you sure you want to do this?",
"NOTICE!");
859 if (saveFileDialog.ShowDialog() != DialogResult.OK)
864 private void clearSnapsBut_Click(
object sender, EventArgs e)
866 storedImageBox.Items.Clear();
876 private void storedSnapBox_SelectedIndexChanged(
object sender, EventArgs e)
878 if (storedImageBox.SelectedItem ==
null)
881 xCoordBox.Value = (decimal)s.Volume.Location.X;
882 yCoordBox.Value = (decimal)s.Volume.Location.Y;
883 zCoordBox.Value = (decimal)s.Volume.Location.Z;
886 private void goToLocBox_Click(
object sender, EventArgs e)
888 Point3D p =
new Point3D((
double)xCoordBox.Value, (
double)yCoordBox.Value, (
double)zCoordBox.Value);
889 Microscope.SetPosition(p);
891 private void tabContextMenu_Opening(
object sender, CancelEventArgs e)
902 private void borderToolStripMenuItem_Click(
object sender, EventArgs e)
904 if (this.FormBorderStyle == FormBorderStyle.Sizable)
906 this.FormBorderStyle = FormBorderStyle.None;
907 borderToolStripMenuItem.Text =
"Window Border Normal";
911 this.FormBorderStyle = FormBorderStyle.Sizable;
912 borderToolStripMenuItem.Text =
"Window Border None";
916 private void hideToolStripMenuItem_Click(
object sender, EventArgs e)
921 private void closeToolStripMenuItem_Click(
object sender, EventArgs e)
933 private void openInImageViewToolStripMenuItem_Click(
object sender, EventArgs e)
935 if (storedImageBox.SelectedIndex == -1)
947 private void MainForm_KeyDown(
object sender, KeyEventArgs e)
949 if (e.KeyCode ==
Keys.S && e.Control)
951 if (saveImageDialog.ShowDialog() != DialogResult.OK)
962 private void copyToolStripMenuItem1_Click(
object sender, EventArgs e)
964 Clipboard.SetText(storedImageBox.SelectedItem.ToString());
972 private void copyToolStripMenuItem_Click(
object sender, EventArgs e)
974 Clipboard.SetText(storedCoordsBox.SelectedItem.ToString());
981 private void dockToApp_CheckedChanged(
object sender, EventArgs e)
990 private void topMostCheckBox_CheckedChanged(
object sender, EventArgs e)
992 this.TopMost = topMostCheckBox.Checked;
1007 if (
prevState.Buttons == GamepadButtonFlags.Y && state.Buttons != GamepadButtonFlags.Y)
1010 prevState.Buttons = GamepadButtonFlags.None;
1011 YPressedLabel.Text =
"Y: released";
1014 YPressedLabel.Text =
"Y: not pressed";
1018 if (state.Buttons == GamepadButtonFlags.Y)
1021 prevState.Buttons = GamepadButtonFlags.None;
1022 YPressedLabel.Text =
"Y: pressed";
1025 YPressedLabel.Text =
"Y: not pressed";
1029 if (
prevState.Buttons == GamepadButtonFlags.B && state.Buttons != GamepadButtonFlags.B)
1032 prevState.Buttons = GamepadButtonFlags.None;
1033 state.Buttons = GamepadButtonFlags.None;
1034 BPressedLabel.Text =
"B: released";
1037 BPressedLabel.Text =
"B: not pressed";
1041 if (state.Buttons == GamepadButtonFlags.B)
1044 prevState.Buttons = GamepadButtonFlags.None;
1045 BPressedLabel.Text =
"B: pressed";
1048 BPressedLabel.Text =
"B: not pressed";
1052 if (
prevState.Buttons == GamepadButtonFlags.A && state.Buttons != GamepadButtonFlags.A)
1055 prevState.Buttons = GamepadButtonFlags.None;
1056 APressedLabel.Text =
"A: released";
1059 APressedLabel.Text =
"A: not pressed";
1063 if (state.Buttons == GamepadButtonFlags.A)
1066 prevState.Buttons = GamepadButtonFlags.None;
1067 APressedLabel.Text =
"A: pressed";
1070 APressedLabel.Text =
"A: not pressed";
1074 if (
prevState.Buttons == GamepadButtonFlags.X && state.Buttons != GamepadButtonFlags.X)
1077 prevState.Buttons = GamepadButtonFlags.None;
1078 XPressedLabel.Text =
"X: released";
1081 XPressedLabel.Text =
"X: not pressed";
1085 if (state.Buttons == GamepadButtonFlags.X)
1088 prevState.Buttons = GamepadButtonFlags.None;
1089 XPressedLabel.Text =
"X: pressed";
1092 XPressedLabel.Text =
"X: not pressed";
1096 #region Back & Start Keys
1099 if (
prevState.Buttons == GamepadButtonFlags.Start && state.Buttons != GamepadButtonFlags.Start)
1102 prevState.Buttons = GamepadButtonFlags.None;
1103 StartPressedLabel.Text =
"Start: released";
1106 StartPressedLabel.Text =
"Start: not pressed";
1110 if (state.Buttons == GamepadButtonFlags.Start)
1113 prevState.Buttons = GamepadButtonFlags.None;
1114 StartPressedLabel.Text =
"Start: pressed";
1117 StartPressedLabel.Text =
"Start: not pressed";
1121 if (
prevState.Buttons == GamepadButtonFlags.Back && state.Buttons != GamepadButtonFlags.Back)
1124 prevState.Buttons = GamepadButtonFlags.None;
1125 BackPressedLabel.Text =
"Back: released";
1128 BackPressedLabel.Text =
"Back: not pressed";
1132 if (state.Buttons == GamepadButtonFlags.Back)
1135 prevState.Buttons = GamepadButtonFlags.None;
1136 BackPressedLabel.Text =
"Back: pressed";
1139 BackPressedLabel.Text =
"Back: not pressed";
1146 if (
prevState.Buttons == GamepadButtonFlags.RightShoulder && state.Buttons != GamepadButtonFlags.RightShoulder)
1149 prevState.Buttons = GamepadButtonFlags.None;
1150 shoulderRightLabel.Text =
"Right: released";
1153 shoulderRightLabel.Text =
"Right: not pressed";
1157 if (state.Buttons == GamepadButtonFlags.RightShoulder)
1160 prevState.Buttons = GamepadButtonFlags.None;
1161 shoulderRightLabel.Text =
"Right: pressed";
1164 shoulderRightLabel.Text =
"Right: not pressed";
1168 if (
prevState.Buttons == GamepadButtonFlags.LeftShoulder && state.Buttons != GamepadButtonFlags.LeftShoulder)
1171 prevState.Buttons = GamepadButtonFlags.None;
1172 shoulderLeftLabel.Text =
"Left: released";
1175 shoulderLeftLabel.Text =
"Left: not pressed";
1179 if (state.Buttons == GamepadButtonFlags.LeftShoulder)
1182 prevState.Buttons = GamepadButtonFlags.None;
1183 shoulderLeftLabel.Text =
"Left: pressed";
1186 shoulderLeftLabel.Text =
"Left: not pressed";
1194 if (
prevState.Buttons == GamepadButtonFlags.RightThumb && state.Buttons != GamepadButtonFlags.RightThumb)
1197 prevState.Buttons = GamepadButtonFlags.None;
1198 r3PressedLabel.Text =
"R3: released";
1201 r3PressedLabel.Text =
"R3: not pressed";
1205 if (state.Buttons == GamepadButtonFlags.RightThumb)
1208 prevState.Buttons = GamepadButtonFlags.None;
1209 r3PressedLabel.Text =
"R3: pressed";
1212 r3PressedLabel.Text =
"R3: not pressed";
1217 if (
prevState.Buttons == GamepadButtonFlags.LeftThumb && state.Buttons != GamepadButtonFlags.LeftThumb)
1220 prevState.Buttons = GamepadButtonFlags.None;
1221 l3PressedLabel.Text =
"L3: released";
1224 l3PressedLabel.Text =
"L3: not pressed";
1228 if (state.Buttons == GamepadButtonFlags.LeftThumb)
1231 prevState.Buttons = GamepadButtonFlags.None;
1232 l3PressedLabel.Text =
"L3: pressed";
1235 l3PressedLabel.Text =
"L3: not pressed";
1239 #region DPAD BUTTONS
1242 if (
prevState.Buttons == GamepadButtonFlags.DPadUp && state.Buttons != GamepadButtonFlags.DPadUp)
1245 prevState.Buttons = GamepadButtonFlags.None;
1246 DPadUpLabel.Text =
"Up: released";
1249 DPadUpLabel.Text =
"Up: not pressed";
1253 if (state.Buttons == GamepadButtonFlags.DPadUp)
1256 prevState.Buttons = GamepadButtonFlags.None;
1257 DPadUpLabel.Text =
"Up: pressed";
1260 DPadUpLabel.Text =
"Up: not pressed";
1265 if (
prevState.Buttons == GamepadButtonFlags.DPadRight && state.Buttons != GamepadButtonFlags.DPadRight)
1268 prevState.Buttons = GamepadButtonFlags.None;
1269 DPadRightLabel.Text =
"Right: released";
1272 DPadRightLabel.Text =
"Right: not pressed";
1276 if (state.Buttons == GamepadButtonFlags.DPadRight)
1279 prevState.Buttons = GamepadButtonFlags.None;
1280 DPadRightLabel.Text =
"Right: pressed";
1283 DPadRightLabel.Text =
"Right: not pressed";
1288 if (
prevState.Buttons == GamepadButtonFlags.DPadDown && state.Buttons != GamepadButtonFlags.DPadDown)
1291 prevState.Buttons = GamepadButtonFlags.None;
1292 DPadDownLabel.Text =
"Down: released";
1295 DPadDownLabel.Text =
"Down: not pressed";
1299 if (state.Buttons == GamepadButtonFlags.DPadDown)
1302 prevState.Buttons = GamepadButtonFlags.None;
1303 DPadDownLabel.Text =
"Down: pressed";
1306 DPadDownLabel.Text =
"Down: not pressed";
1311 if (
prevState.Buttons == GamepadButtonFlags.DPadLeft && state.Buttons != GamepadButtonFlags.DPadLeft)
1314 prevState.Buttons = GamepadButtonFlags.None;
1315 DPadLeftLabel.Text =
"Left: released";
1318 DPadLeftLabel.Text =
"Left: not pressed";
1322 if (state.Buttons == GamepadButtonFlags.DPadLeft)
1325 prevState.Buttons = GamepadButtonFlags.None;
1326 DPadLeftLabel.Text =
"Left: pressed";
1329 DPadLeftLabel.Text =
"Left: not pressed";
1336 public static InputSimulator
input =
new InputSimulator();
1351 AppP.WaitForInputIdle();
1354 if (f.
Modifier != VirtualKeyCode.NONAME)
1370 LJoystickStageMoveAmountBox.Value = (decimal)obj.
MoveAmountL;
1371 RJoystickStageMoveAmountBox.Value = (decimal)obj.
MoveAmountR;
1384 if (storedCoordsBox.SelectedIndex != -1)
1387 if (storedCoordsBox.SelectedIndex + 1 < storedCoordsBox.Items.Count)
1389 Point3D p = (Point3D)storedCoordsBox.Items[storedCoordsBox.SelectedIndex + 1];
1391 storedCoordsBox.SelectedIndex = storedCoordsBox.SelectedIndex + 1;
1393 if (storedCoordsBox.SelectedIndex == 0)
1395 Point3D p = (Point3D)storedCoordsBox.Items[storedCoordsBox.SelectedIndex];
1408 if (storedCoordsBox.SelectedIndex != -1)
1410 if (storedCoordsBox.SelectedIndex == 0)
1412 Point3D p = (Point3D)storedCoordsBox.Items[storedCoordsBox.SelectedIndex];
1415 if (storedCoordsBox.SelectedIndex > 0)
1417 Point3D p = (Point3D)storedCoordsBox.Items[storedCoordsBox.SelectedIndex - 1];
1419 storedCoordsBox.SelectedIndex = storedCoordsBox.SelectedIndex - 1;
1428 if (storedImageBox.SelectedIndex != -1)
1431 if (storedImageBox.SelectedIndex + 1 < storedImageBox.Items.Count)
1433 Point3D p = (Point3D)storedImageBox.Items[storedImageBox.SelectedIndex + 1];
1435 storedImageBox.SelectedIndex = storedImageBox.SelectedIndex + 1;
1437 if (storedImageBox.SelectedIndex == 0)
1439 Point3D p = (Point3D)storedImageBox.Items[storedImageBox.SelectedIndex];
1452 if (storedImageBox.SelectedIndex != -1)
1454 if (storedImageBox.SelectedIndex == 0)
1456 Point3D p = (Point3D)storedImageBox.Items[storedImageBox.SelectedIndex];
1459 if (storedImageBox.SelectedIndex > 0)
1461 Point3D p = (Point3D)storedImageBox.Items[storedImageBox.SelectedIndex - 1];
1464 storedImageBox.SelectedIndex = storedImageBox.SelectedIndex - 1;
1477 if (f.
FuncType.ToString() ==
"StageUp")
1482 if (f.
FuncType.ToString() ==
"StageRight")
1487 if (f.
FuncType.ToString() ==
"StageDown")
1492 if (f.
FuncType.ToString() ==
"StageLeft")
1497 if (f.
FuncType.ToString() ==
"FocusUp")
1502 if (f.
FuncType.ToString() ==
"FocusDown")
1507 if (f.
FuncType.ToString() ==
"StageFieldUp")
1512 if (f.
FuncType.ToString() ==
"StageFieldRight")
1517 if (f.
FuncType.ToString() ==
"StageFieldDown")
1522 if (f.
FuncType.ToString() ==
"StageFieldLeft")
1527 if (f.
FuncType.ToString() ==
"TakeImage")
1532 if (f.
FuncType.ToString() ==
"TakeImageStack")
1548 if (f.
Name.StartsWith(
"Get"))
1553 else if (f.
Name.StartsWith(
"Set"))
1572 public static Function Y,
B,
A,
X,
DPadUp,
DPadRight,
DPadDown,
DPadLeft,
Start,
Back,
RShoulder,
LShoulder,
R3,
L3;
1591 if (
Settings.Default.Y.ToString() ==
"")
1596 private void ImagingTab_Click(
object sender, EventArgs e)
System.Windows.Forms.Keys Keys
System.Windows.Forms.Application Application
BioImager.Properties.Settings Settings
static Dictionary< string, Recording > Recordings
static Dictionary< string, Recording > Properties
static Function Parse(string s)
static void RunMacro(string file, string param)
PointD Origin
A property of the class PointD. */.
static Function RShoulder
static Function DPadRight
static void LoadSettings()
static Function LShoulder
override string ToString()
static InputSimulator input
static List< BioImage > StoredImages
static int DigitsInString(string str)
Gamepad previousGamepadState
void CheckGamepadButtons(Gamepad state, Gamepad prevState)
object PerformFunction(Function f)
static Objectives Objectives
static void MoveFieldUp()
Move the field up by the height of the view.
static void SetPosition(Point3D p)
static void MoveRight(double d)
static RLShutter RLShutter
static Point3D GetPosition()
static void MoveFieldDown()
Move the field down by one unit.
static BioImage TakeImage()
static void SetFocus(double d)
static void MoveDown(double d)
static void MoveFieldRight()
Move the field right by the width of the view.
static void MoveLeft(double d)
static TLShutter TLShutter
static BioImage TakeImageStack()
static void MoveFieldLeft()
Move the field left by the width of the viewport.
static void MoveUp(double d)
void SetPosition(int index)
static void RunScript(string file)
static bool SetForegroundWindow(IntPtr hWnd)
static bool GetWindowRect(IntPtr hwnd, ref Rect rectangle)