15 private Builder _builder;
16 private string pred =
"";
17 private List<string> preds =
new List<string>();
18 public static bool onTab =
false;
19 public static bool useBioformats =
true;
20 public static bool headless =
false;
21 public static bool resultInNewTab =
false;
23#pragma warning disable 649
25 private Label predLabel;
27 private Button imagejBut;
29 private Button runBut;
31 private TextView textBox;
33 private TextView consoleBox;
35 private CheckButton headlessBox;
37 private CheckButton bioformatsBox;
39 private CheckButton resultsBox;
41 private CheckButton selRadioBut;
43 private CheckButton tabRadioBut;
44#pragma warning restore 649
48 #region Constructors / Destructors
54 Builder builder =
new Builder(
new FileStream(System.IO.Path.GetDirectoryName(Environment.ProcessPath) +
"/" +
"Glade/BioConsole.glade", FileMode.Open));
55 return new BioConsole(builder, builder.GetObject(
"console").Handle);
61 protected BioConsole(Builder builder, IntPtr handle) : base(handle)
64 builder.Autoconnect(
this);
66 App.ApplyStyles(
this);
76 runBut.Clicked += RunBut_Clicked;
77 imagejBut.Clicked += ImagejBut_Clicked;
78 headlessBox.Clicked += HeadlessBox_Clicked;
79 resultsBox.Clicked += ResultsBox_Clicked;
80 selRadioBut.Clicked += SelRadioBox_Clicked;
81 tabRadioBut.Clicked += TabRadioBox_Clicked;
82 consoleBox.Buffer.Changed += Buffer_Changed;
83 consoleBox.KeyPressEvent += Console_KeyPressEvent;
86 private int Measure(
string s)
89 using (var layout =
new Pango.Layout(predLabel.PangoContext))
93 layout.FontDescription = FontDescription.FromString(
"Sans 12");
96 layout.GetPixelSize(out width, out height);
102 string chs =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
103 private void Buffer_Changed(
object sender, EventArgs e)
105 if (consoleBox.Buffer.CharCount == 0)
112 pred = pred.Replace(
"\t",
"").Replace(
"\r",
"").Replace(
"\n",
"");
113 if (pred.Contains(
' '))
114 pred = consoleBox.Buffer.Text.Remove(0,consoleBox.Buffer.Text.LastIndexOf(
' '));
116 pred = consoleBox.Buffer.Text.Replace(
"\t",
"").Replace(
"\r",
"").Replace(
"\n",
"");
121 foreach (Char cs
in pred)
124 foreach (Char c
in chs)
137 pred = pred.Remove(0, ind+1);
142 foreach(var cs
in Fiji.Macro.Commands)
144 if (cs.Value.Name.StartsWith(pred))
145 preds.Add(cs.Value.Name);
147 foreach (var cs
in Fiji.Macro.Functions)
149 if (cs.Value[0].Name.StartsWith(pred))
150 preds.Add(cs.Value[0].Name);
153 foreach(var item
in preds)
155 if (this.AllocatedWidth > Measure(predLabel.Text))
157 predLabel.Text += item +
", ";
161 if(consoleBox.Buffer.Text.EndsWith(
'\t'))
163 string s = consoleBox.Buffer.Text.TrimEnd(
'\t');
165 consoleBox.Buffer.Text = s.Remove(s.Length - pred.Length, pred.Length) + preds[0];
174 private void ResultsBox_Clicked(
object sender, EventArgs e)
176 resultInNewTab = resultsBox.Active;
186 private void Console_KeyPressEvent(
object o, KeyPressEventArgs args)
188 if (args.Event.Key == Gdk.Key.w)
191 string[] s = consoleBox.Buffer.Text.Split(Environment.NewLine);
192 textBox.Buffer.Text = s[s.Length - 1 - line];
194 if (args.Event.Key == Gdk.Key.s)
197 string[] s = consoleBox.Buffer.Text.Split(Environment.NewLine);
198 textBox.Buffer.Text = s[s.Length - 1 - line];
206 private void TabRadioBox_Clicked(
object sender, EventArgs e)
208 onTab = tabRadioBut.Active;
209 selRadioBut.Active = !onTab;
216 private void SelRadioBox_Clicked(
object sender, EventArgs e)
218 onTab = !selRadioBut.Active;
219 tabRadioBut.Active = onTab;
221 private void HeadlessBox_Clicked(
object sender, EventArgs e)
223 headless = headlessBox.Active;
233 private void ImagejBut_Clicked(
object sender, EventArgs e)
237 Fiji.RunOnImage(
ImageView.SelectedImage, consoleBox.Buffer.Text, headless, onTab, useBioformats, resultsBox.Active);
238 textBox.Buffer.Text += textBox.Buffer.Text + Environment.NewLine;
239 consoleBox.Buffer.Text =
"";
246 private void RunBut_Clicked(
object sender, EventArgs e)
249 textBox.Buffer.Text += textBox.Buffer.Text + Environment.NewLine + o.ToString() + Environment.NewLine;
250 consoleBox.Buffer.Text =
"";