BioGTK  6.5.0
A .NET library & program for annotating, editing various microscopy imaging formats using Bioformats supported images. Including whole slide, pyramidal, and series.
Loading...
Searching...
No Matches
BioGTK.Function Class Reference

Public Types

enum  FunctionType {
  Key , Microscope , Objective , StoreCoordinate ,
  NextCoordinate , PreviousCoordinate , NextSnapCoordinate , PreviousSnapCoordinate ,
  Recording , Property , ImageJ , Script ,
  None
}
 
enum  ButtonState { Pressed = 0 , Released = 1 }
 

Public Member Functions

override string ToString ()
 
string Serialize ()
 
object PerformFunction (bool imagej)
 
void Save ()
 It saves the function to a file.
 

Static Public Member Functions

static Function Parse (string s)
 
static void InitializeMainMenu ()
 
static void InitializeContextMenu ()
 
static void SaveAll ()
 It saves all the functions in the Functions dictionary to a file.
 

Static Public Attributes

static Dictionary< string, FunctionFunctions = new Dictionary<string, Function>()
 

Properties

ButtonState State [get, set]
 
Gdk.Key Key [get, set]
 
Gdk.ModifierType Modifier [get, set]
 
FunctionType FuncType [get, set]
 
string File [get, set]
 
string Script [get, set]
 
string Name [get, set]
 
string MenuPath [get, set]
 
string ContextPath [get, set]
 
double Value [get, set]
 
string Microscope [get, set]
 

Detailed Description

Definition at line 398 of file Functions.cs.

Member Enumeration Documentation

◆ ButtonState

enum BioGTK.Function.ButtonState

Definition at line 419 of file Functions.cs.

420 {
421 Pressed = 0,
422 Released = 1,
423 }

◆ FunctionType

enum BioGTK.Function.FunctionType

Definition at line 402 of file Functions.cs.

403 {
404 Key,
405 Microscope,
406 Objective,
407 StoreCoordinate,
408 NextCoordinate,
409 PreviousCoordinate,
410 NextSnapCoordinate,
411 PreviousSnapCoordinate,
412 Recording,
413 Property,
414 ImageJ,
415 Script,
416 None
417 }

Member Function Documentation

◆ InitializeContextMenu()

static void BioGTK.Function.InitializeContextMenu ( )
static

It reads all the files in the Functions folder, parses them into Function objects, and adds them to the Functions dictionary

Definition at line 628 of file Functions.cs.

629 {
630 string st = System.IO.Path.GetDirectoryName(Environment.ProcessPath) + "/Functions";
631 if (!Directory.Exists(st))
632 Directory.CreateDirectory(st);
633 string[] sts = Directory.GetFiles(st);
634 for (int i = 0; i < sts.Length; i++)
635 {
636 string fs = System.IO.File.ReadAllText(sts[i]);
637 Function f = Function.Parse(fs);
638 if (!Functions.ContainsKey(f.Name))
639 Functions.Add(f.Name, f);
640 App.AddContextMenu(f.ContextPath);
641 }
642 }

◆ InitializeMainMenu()

static void BioGTK.Function.InitializeMainMenu ( )
static

It reads all the files in the Functions folder, parses them into Function objects, and adds them to the Functions dictionary

Definition at line 611 of file Functions.cs.

612 {
613 string st = System.IO.Path.GetDirectoryName(Environment.ProcessPath) + "/Functions";
614 if (!Directory.Exists(st))
615 Directory.CreateDirectory(st);
616 string[] sts = Directory.GetFiles(st);
617 for (int i = 0; i < sts.Length; i++)
618 {
619 string fs = System.IO.File.ReadAllText(sts[i]);
620 Function f = Function.Parse(fs);
621 if (!Functions.ContainsKey(f.Name))
622 Functions.Add(f.Name, f);
623 App.AddMenu(f.MenuPath);
624 }
625 }

◆ Parse()

static Function BioGTK.Function.Parse ( string s)
static

It converts a string to a function.

Parameters
sThe string to parse
Returns
A function object.

Definition at line 567 of file Functions.cs.

568 {
569 if (s == "")
570 return new Function();
571 return JsonConvert.DeserializeObject<Function>(s);
572 }

◆ PerformFunction()

object BioGTK.Function.PerformFunction ( bool imagej)

If the function type is a key, and the script is not empty, then if the imagej flag is true, set the function type to imagej, otherwise set the function type to script. If the function type is a script, run the script. If the function type is imagej, run the script on the image

Parameters
imagejboolean, whether to run the function as an ImageJ macro or not
Returns
The return value is the result of the function.

Definition at line 589 of file Functions.cs.

590 {
591 if (FuncType == FunctionType.Key && Script != "")
592 if (imagej)
593 {
594 FuncType = FunctionType.ImageJ;
595 }
596 else
597 FuncType = FunctionType.Script;
598 if (FuncType == Function.FunctionType.Script)
599 {
600 return Scripting.RunString(script);
601 }
602 if (FuncType == Function.FunctionType.ImageJ)
603 {
604 Fiji.RunOnImage(ImageView.SelectedImage,script, false, BioConsole.onTab, BioConsole.useBioformats, BioConsole.resultInNewTab);
605 }
606 return null;
607 }

◆ Save()

void BioGTK.Function.Save ( )

It saves the function to a file.

Definition at line 658 of file Functions.cs.

659 {
660 string st = System.IO.Path.GetDirectoryName(Environment.ProcessPath);
661 if (!Directory.Exists(st + "/Functions"))
662 {
663 Directory.CreateDirectory(st + "/Functions");
664 }
665 System.IO.File.WriteAllText(st + "/Functions/" + Name + ".func", Serialize());
666 }
string Serialize()
Definition Functions.cs:577

◆ SaveAll()

static void BioGTK.Function.SaveAll ( )
static

It saves all the functions in the Functions dictionary to a file.

Definition at line 644 of file Functions.cs.

645 {
646 string st = System.IO.Path.GetDirectoryName(Environment.ProcessPath);
647
648 if (!Directory.Exists(st + "/Functions"))
649 {
650 Directory.CreateDirectory(st + "/Functions");
651 }
652 foreach (Function f in Functions.Values)
653 {
654 System.IO.File.WriteAllText(st + "/Functions/" + f.Name + ".func", f.Serialize());
655 }
656 }

◆ Serialize()

string BioGTK.Function.Serialize ( )

It takes the current object and converts it to a JSON string.

Returns
The object is being serialized into a JSON string.

Definition at line 577 of file Functions.cs.

578 {
579 return JsonConvert.SerializeObject(this);
580 }

◆ ToString()

override string BioGTK.Function.ToString ( )

Definition at line 558 of file Functions.cs.

559 {
560 return name + ", " + MenuPath;
561 }

Member Data Documentation

◆ Functions

Dictionary<string, Function> BioGTK.Function.Functions = new Dictionary<string, Function>()
static

Definition at line 400 of file Functions.cs.

Property Documentation

◆ ContextPath

string BioGTK.Function.ContextPath
getset

Definition at line 522 of file Functions.cs.

523 {
524 get
525 {
526 return contextPath;
527 }
528 set
529 {
530 contextPath = value;
531 }
532 }

◆ File

string BioGTK.Function.File
getset

Definition at line 481 of file Functions.cs.

482 {
483 get { return file; }
484 set { file = value; }
485 }

◆ FuncType

FunctionType BioGTK.Function.FuncType
getset

Definition at line 468 of file Functions.cs.

469 {
470 get
471 {
472 return functionType;
473 }
474 set
475 {
476 functionType = value;
477 }
478 }

◆ Key

Gdk.Key BioGTK.Function.Key
getset

Definition at line 440 of file Functions.cs.

441 {
442 get
443 {
444 return key;
445 }
446 set
447 {
448 key = value;
449 FuncType = FunctionType.Key;
450 }
451 }

◆ MenuPath

string BioGTK.Function.MenuPath
getset

Definition at line 510 of file Functions.cs.

511 {
512 get
513 {
514 return menuPath;
515 }
516 set
517 {
518 menuPath = value;
519 }
520 }

◆ Microscope

string BioGTK.Function.Microscope
getset

Definition at line 547 of file Functions.cs.

548 {
549 get
550 {
551 return microscope;
552 }
553 set
554 {
555 microscope = value;
556 }
557 }

◆ Modifier

Gdk.ModifierType BioGTK.Function.Modifier
getset

Definition at line 454 of file Functions.cs.

455 {
456 get
457 {
458 return modifier;
459 }
460 set
461 {
462 FuncType = FunctionType.Key;
463 modifier = value;
464 }
465 }

◆ Name

string BioGTK.Function.Name
getset

Definition at line 498 of file Functions.cs.

499 {
500 get
501 {
502 return name;
503 }
504 set
505 {
506 name = value;
507 }
508 }

◆ Script

string BioGTK.Function.Script
getset

Definition at line 488 of file Functions.cs.

489 {
490 get { return script; }
491 set
492 {
493 script = value;
494 }
495 }

◆ State

ButtonState BioGTK.Function.State
getset

Definition at line 427 of file Functions.cs.

428 {
429 get
430 {
431 return buttonState;
432 }
433 set
434 {
435 buttonState = value;
436 }
437 }

◆ Value

double BioGTK.Function.Value
getset

Definition at line 535 of file Functions.cs.

536 {
537 get
538 {
539 return val;
540 }
541 set
542 {
543 val = value;
544 }
545 }

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