BioGTK  6.0.0
A .NET library & program for annotating, editing various microscopy imaging formats using Bioformats supported images. Including whole slide, pyramidal, and series.
All Classes Namespaces Functions
BioGTK.Scripting.Script Class Reference

Public Member Functions

 Script (string file, string scriptStr)
 
 Script (string file)
 
void Run ()
 It creates a new thread and starts it.
 
void Stop ()
 It stops the thread.
 
override string ToString ()
 

Static Public Member Functions

static void Run (Script rn)
 
static object RunString (string st)
 

Public Attributes

string name
 
string file
 
string scriptString
 
bool exit = false
 
dynamic script
 
object obj
 
string output = ""
 
bool done = false
 
Exception ex = null
 
Thread thread
 
ScriptType type = ScriptType.script
 

Static Public Attributes

static List< string > usings = new List<string>()
 

Detailed Description

Definition at line 189 of file Scripting.cs.

Constructor & Destructor Documentation

◆ Script() [1/2]

BioGTK.Scripting.Script.Script ( string file,
string scriptStr )

Definition at line 204 of file Scripting.cs.

205 {
206 name = System.IO.Path.GetFileName(file);
207 scriptString = scriptStr;
208 if (file.EndsWith(".txt") || file.EndsWith(".ijm"))
209 type = ScriptType.imagej;
210 }

◆ Script() [2/2]

BioGTK.Scripting.Script.Script ( string file)

Definition at line 213 of file Scripting.cs.

214 {
215 name = System.IO.Path.GetFileName(file);
216 scriptString = File.ReadAllText(file);
217 this.file = file;
218 if (file.EndsWith(".txt") || file.EndsWith(".ijm"))
219 type = ScriptType.imagej;
220 }

Member Function Documentation

◆ Run() [1/2]

void BioGTK.Scripting.Script.Run ( )

It creates a new thread and starts it.

Definition at line 314 of file Scripting.cs.

315 {
316 if (!scripts.ContainsKey(name))
317 scripts.Add(name, this);
318 scriptName = this.name;
319 thread = new Thread(new ThreadStart(RunScript));
320 thread.Start();
321 }

◆ Run() [2/2]

static void BioGTK.Scripting.Script.Run ( Script rn)
static

It creates a new thread and starts it.

The thread is started by calling the RunScript function.

Parameters
ScriptThe script you want to run.

Definition at line 225 of file Scripting.cs.

226 {
227 scriptName = rn.name;
228 Thread t = new Thread(new ThreadStart(RunScript));
229 t.Start();
230 }

◆ RunString()

static object BioGTK.Scripting.Script.RunString ( string st)
static

It takes a string, adds using statements, wraps it in a class, and then runs it.

Parameters
stThe string to be executed
Returns
The return value of the last statement in the script.

Definition at line 278 of file Scripting.cs.

279 {
280 try
281 {
282 string loader =
283 @"//css_reference " + System.Reflection.Assembly.GetExecutingAssembly().GetName().Name + @".dll
284 using System;
285 using Gtk;
286 using System.Threading;
287 using BioGTK;
288 using AForge;";
289 foreach (string s in usings)
290 {
291 loader += usings + Environment.NewLine;
292 }
293 loader += @"
294 public class Loader
295 {
296 public object Load()
297 {" +
298 st + @";
299 return true;
300 }
301 }";
302 dynamic script = CSScript.Evaluator.LoadCode(loader);
303 return script.Load();
304 }
305 catch (Exception e)
306 {
307 MessageDialog md = new MessageDialog(window,
308 DialogFlags.DestroyWithParent, MessageType.Info,
309 ButtonsType.Close, e.Message + ", " + e.Source);
310 return e;
311 }
312 }

◆ Stop()

void BioGTK.Scripting.Script.Stop ( )

It stops the thread.

Definition at line 323 of file Scripting.cs.

324 {
325 exit = true;
326 }

◆ ToString()

override string BioGTK.Scripting.Script.ToString ( )

If the thread is not null, return the name and the thread state. Otherwise, return the name

Returns
The name of the thread and the state of the thread.

Definition at line 331 of file Scripting.cs.

332 {
333 if (thread != null)
334 {
335 return name.ToString() + ", " + thread.ThreadState.ToString();
336 }
337 else
338 return name.ToString();
339 }

Member Data Documentation

◆ done

bool BioGTK.Scripting.Script.done = false

Definition at line 198 of file Scripting.cs.

◆ ex

Exception BioGTK.Scripting.Script.ex = null

Definition at line 200 of file Scripting.cs.

◆ exit

bool BioGTK.Scripting.Script.exit = false

Definition at line 194 of file Scripting.cs.

◆ file

string BioGTK.Scripting.Script.file

Definition at line 192 of file Scripting.cs.

◆ name

string BioGTK.Scripting.Script.name

Definition at line 191 of file Scripting.cs.

◆ obj

object BioGTK.Scripting.Script.obj

Definition at line 196 of file Scripting.cs.

◆ output

string BioGTK.Scripting.Script.output = ""

Definition at line 197 of file Scripting.cs.

◆ script

dynamic BioGTK.Scripting.Script.script

Definition at line 195 of file Scripting.cs.

◆ scriptString

string BioGTK.Scripting.Script.scriptString

Definition at line 193 of file Scripting.cs.

◆ thread

Thread BioGTK.Scripting.Script.thread

Definition at line 201 of file Scripting.cs.

◆ type

ScriptType BioGTK.Scripting.Script.type = ScriptType.script

Definition at line 202 of file Scripting.cs.

◆ usings

List<string> BioGTK.Scripting.Script.usings = new List<string>()
static

Definition at line 199 of file Scripting.cs.


The documentation for this class was generated from the following file: