4using System.ComponentModel;
10 public static InputSimulator
input =
new InputSimulator();
13 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
28 InitializeComponent();
35 InitializeComponent();
46 textBox.Text = func.
Script;
48 funcsBox.Items.Clear();
51 funcsBox.Items.Add(f);
54 nameBox.Text = func.
Name;
56 stateBox.Items.Clear();
59 stateBox.Items.Add(val);
61 stateBox.SelectedItem = func.
State;
65 keysBox.Items.Clear();
66 foreach (VirtualKeyCode val
in Enum.GetValues(typeof(VirtualKeyCode)))
68 keysBox.Items.Add(val);
70 keysBox.SelectedIndex = ind;
74 modifierBox.Items.Clear();
75 modifierBox.Items.Add(VirtualKeyCode.NONAME);
76 modifierBox.Items.Add(VirtualKeyCode.RCONTROL);
77 modifierBox.Items.Add(VirtualKeyCode.LCONTROL);
78 modifierBox.Items.Add(VirtualKeyCode.RSHIFT);
79 modifierBox.Items.Add(VirtualKeyCode.LSHIFT);
80 modifierBox.Items.Add(VirtualKeyCode.MENU);
81 modifierBox.Items.Add(VirtualKeyCode.RWIN);
82 modifierBox.Items.Add(VirtualKeyCode.LWIN);
83 modifierBox.SelectedItem = func.
Modifier;
85 valBox.Value = (decimal)func.
Value;
90 private void UpdateItems()
92 textBox.Text = func.
Script;
93 nameBox.Text = func.
Name;
94 stateBox.SelectedItem = func.
State;
95 keysBox.SelectedItem = func.
Key;
96 modifierBox.SelectedItem = func.
Modifier;
97 valBox.Value = (decimal)func.
Value;
99 imageJRadioBut.Checked =
true;
101 imageJRadioBut.Checked =
false;
109 private void keysBox_SelectedIndexChanged(
object sender, EventArgs e)
111 Func.Key = (VirtualKeyCode)keysBox.SelectedItem;
119 private void modifierBox_SelectedIndexChanged(
object sender, EventArgs e)
121 Func.Modifier = (VirtualKeyCode)modifierBox.SelectedItem;
129 private void stateBox_SelectedIndexChanged(
object sender, EventArgs e)
138 private void applyButton_Click(
object sender, EventArgs e)
140 func.Name = nameBox.Text;
141 this.DialogResult = DialogResult.OK;
153 func.MenuPath = func.
MenuPath.TrimEnd(
'/');
176 private void setMacroFileBut_Click(
object sender, EventArgs e)
178 if (openFileDialog.ShowDialog() != DialogResult.OK)
180 Func.File = openFileDialog.FileName;
189 private void setScriptFileBut_Click(
object sender, EventArgs e)
191 if (openFileDialog.ShowDialog() != DialogResult.OK)
193 Func.File = openFileDialog.FileName;
201 private void valBox_ValueChanged(
object sender, EventArgs e)
203 Func.Value = (double)valBox.Value;
210 private void performBut_Click(
object sender, EventArgs e)
212 MessageBox.Show(func.
PerformFunction(imageJRadioBut.Checked).ToString());
220 private void cancelBut_Click(
object sender, EventArgs e)
222 this.DialogResult = DialogResult.Cancel;
228 private void textBox_TextChanged(
object sender, EventArgs e)
230 func.Script = textBox.Text;
231 if (bioRadioBut.Checked)
241 private void bioRadioBut_CheckedChanged(
object sender, EventArgs e)
243 if (bioRadioBut.Checked)
251 private void imageJRadioBut_CheckedChanged(
object sender, EventArgs e)
253 if (imageJRadioBut.Checked)
261 private void menuPath_TextChanged(
object sender, EventArgs e)
263 func.MenuPath = menuPath.Text;
270 private void FunctionForm_Activated(
object sender, EventArgs e)
281 private void funcsBox_SelectedIndexChanged(
object sender, EventArgs e)
283 if (funcsBox.SelectedIndex == -1)
285 func = (
Function)funcsBox.SelectedItem;
293 private void FunctionForm_FormClosing(
object sender, FormClosingEventArgs e)
303 private void contextMenuPath_TextChanged(
object sender, EventArgs e)
305 func.ContextPath = contextMenuPath.Text;
311 public static Dictionary<string, Function>
Functions =
new Dictionary<string, Function>();
348 private VirtualKeyCode key;
362 private VirtualKeyCode modifier = VirtualKeyCode.NONAME;
385 functionType = value;
393 set { file = value; }
396 private string script;
399 get {
return script; }
418 private string menuPath;
430 private string contextPath;
455 private string microscope;
481 return JsonConvert.DeserializeObject<
Function>(s);
489 return JsonConvert.SerializeObject(
this);
492 public static InputSimulator
input =
new InputSimulator();
518 if (
Modifier != VirtualKeyCode.NONAME)
534 string st = Application.StartupPath +
"/Functions";
535 if (!Directory.Exists(st))
536 Directory.CreateDirectory(st);
537 string[] sts = Directory.GetFiles(st);
538 for (
int i = 0; i < sts.Length; i++)
540 string fs = System.IO.File.ReadAllText(sts[i]);
553 if (!Directory.Exists(st +
"/Functions"))
555 Directory.CreateDirectory(st +
"/Functions");
559 System.IO.File.WriteAllText(st +
"/Functions/" + f.
Name +
".func", f.
Serialize());
System.Windows.Forms.Application Application
static void AddMenu(string menu)
static void AddContextMenu(string menu)
static bool useBioformats
static Dictionary< string, Function > Functions
override string ToString()
static InputSimulator input
static Function Parse(string s)
object PerformFunction(bool imagej)
void Save()
It saves all the functions in the Functions dictionary to a file.
ImageView control for image stacks, pyramidal and whole-slide-images.
static BioImage SelectedImage
static void RunString(string st)