BioGTK  5.1.1
A .NET library & program for annotating, editing various microscopy imaging formats using Bioformats supported images.
Loading...
Searching...
No Matches
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>()
 

Constructor & Destructor Documentation

◆ Script() [1/2]

BioGTK.Scripting.Script.Script ( string  file,
string  scriptStr 
)
inline
205 {
206 name = System.IO.Path.GetFileName(file);
207 scriptString = scriptStr;
208 if (file.EndsWith(".txt") || file.EndsWith(".ijm"))
209 type = ScriptType.imagej;
210 }
ScriptType type
Definition Scripting.cs:202
string name
Definition Scripting.cs:191
string file
Definition Scripting.cs:192
string scriptString
Definition Scripting.cs:193
ScriptType
Definition Scripting.cs:421

◆ Script() [2/2]

BioGTK.Scripting.Script.Script ( string  file)
inline
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 ( )
inline

It creates a new thread and starts it.

312 {
313 if (!scripts.ContainsKey(name))
314 scripts.Add(name, this);
315 scriptName = this.name;
316 thread = new Thread(new ThreadStart(RunScript));
317 thread.Start();
318 }
Thread thread
Definition Scripting.cs:201
static Dictionary< string, Script > scripts
Definition Scripting.cs:183

◆ Run() [2/2]

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

It creates a new thread and starts it.

The thread is started by calling the RunScript function.

Parameters
ScriptThe script you want to run.
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)
inlinestatic

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.
276 {
277 try
278 {
279 string loader =
280 @"//css_reference " + System.Reflection.Assembly.GetExecutingAssembly().GetName().Name + @".dll
281 using System;
282 using Gtk;
283 using System.Threading;
284 using BioGTK;
285 using AForge;";
286 foreach (string s in usings)
287 {
288 loader += usings + Environment.NewLine;
289 }
290 loader += @"
291 public class Loader
292 {
293 public object Load()
294 {" +
295 st + @";
296 return true;
297 }
298 }";
299 dynamic script = CSScript.Evaluator.LoadCode(loader);
300 return script.Load();
301 }
302 catch (Exception e)
303 {
304 MessageDialog md = new MessageDialog(window,
305 DialogFlags.DestroyWithParent, MessageType.Info,
306 ButtonsType.Close, e.Message + ", " + e.Source);
307 return e;
308 }
309 }
dynamic script
Definition Scripting.cs:195
static List< string > usings
Definition Scripting.cs:199
static Window window
Definition Scripting.cs:177

◆ Stop()

void BioGTK.Scripting.Script.Stop ( )
inline

It stops the thread.

321 {
322 exit = true;
323 }
bool exit
Definition Scripting.cs:194

◆ ToString()

override string BioGTK.Scripting.Script.ToString ( )
inline

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.
329 {
330 if (thread != null)
331 {
332 return name.ToString() + ", " + thread.ThreadState.ToString();
333 }
334 else
335 return name.ToString();
336 }

Member Data Documentation

◆ done

bool BioGTK.Scripting.Script.done = false

◆ ex

Exception BioGTK.Scripting.Script.ex = null

◆ exit

bool BioGTK.Scripting.Script.exit = false

◆ file

string BioGTK.Scripting.Script.file

◆ name

string BioGTK.Scripting.Script.name

◆ obj

object BioGTK.Scripting.Script.obj

◆ output

string BioGTK.Scripting.Script.output = ""

◆ script

dynamic BioGTK.Scripting.Script.script

◆ scriptString

string BioGTK.Scripting.Script.scriptString

◆ thread

Thread BioGTK.Scripting.Script.thread

◆ type

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

◆ usings

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

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