BioImager  3.9.1
A .NET microscopy imaging library. Supports various microscopes by using imported libraries & GUI automation. Supported libraries include PriorĀ® & ZeissĀ® & all devices supported by Micromanager 2.0 and python-microscope.
Loading...
Searching...
No Matches
BioImager.Function Class Reference

Public Types

enum  FunctionType
 
enum  ButtonState
 

Public Member Functions

override string ToString ()
 
string Serialize ()
 
object PerformFunction (bool imagej)
 
void Save ()
 It saves all the functions in the Functions dictionary to a file. More...
 

Static Public Member Functions

static Function Parse (string s)
 
static void Initialize ()
 

Static Public Attributes

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

Properties

ButtonState State [get, set]
 
VirtualKeyCode Key [get, set]
 
VirtualKeyCode 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]
 

Detailed Description

Definition at line 397 of file FunctionForm.cs.

Member Enumeration Documentation

◆ ButtonState

enum BioImager.Function.ButtonState

Definition at line 431 of file FunctionForm.cs.

432 {
433 Pressed,
434 Released
435 }

◆ FunctionType

enum BioImager.Function.FunctionType

Definition at line 401 of file FunctionForm.cs.

402 {
403 Key,
404 StageUp,
405 StageRight,
406 StageDown,
407 StageLeft,
408 FocusUp,
409 FocusDown,
410 StageFieldUp,
411 StageFieldRight,
412 StageFieldDown,
413 StageFieldLeft,
414 TakeImage,
415 TakeImageStack,
416 RL,
417 TL,
418 Objective,
419 StoreCoordinate,
420 NextCoordinate,
421 PreviousCoordinate,
422 NextSnapCoordinate,
423 PreviousSnapCoordinate,
424 Recording,
425 Property,
426 ImageJ,
427 Script,
428 None
429 }

Member Function Documentation

◆ Initialize()

static void BioImager.Function.Initialize ( )
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 718 of file FunctionForm.cs.

719 {
720 string st = Application.StartupPath + "/Functions";
721 if (!Directory.Exists(st))
722 Directory.CreateDirectory(st);
723 string[] sts = Directory.GetFiles(st);
724 for (int i = 0; i < sts.Length; i++)
725 {
726 string fs = System.IO.File.ReadAllText(sts[i]);
727 Function f = Function.Parse(fs);
728 if(!Functions.ContainsKey(f.Name))
729 Functions.Add(f.Name, f);
730 App.AddMenu(f.MenuPath, f);
731 App.AddContextMenu(f.ContextPath, f);
732 }
733 }

References BioImager.App.AddContextMenu(), and BioImager.App.AddMenu().

◆ Parse()

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

Definition at line 561 of file FunctionForm.cs.

562 {
563 if (s == "")
564 return new Function();
565 try
566 {
567 return JsonConvert.DeserializeObject<Function>(s);
568 }
569 catch (Exception)
570 {
571 return new Function();
572 }
573 }

◆ PerformFunction()

object BioImager.Function.PerformFunction ( bool  imagej)

It runs a function based on the type of function it is

Parameters
imagejboolean
Returns
The return value is the object that is being returned.

Definition at line 586 of file FunctionForm.cs.

587 {
588 if(FuncType == FunctionType.Key && Script!="")
589 if(imagej)
590 {
591 FuncType = FunctionType.ImageJ;
592 }
593 else
594 FuncType = FunctionType.Script;
595 if (FuncType == Function.FunctionType.Script)
596 {
597 Scripting.RunString(script);
598 }
599 if (FuncType == Function.FunctionType.ImageJ)
600 {
601 ImageJ.RunOnImage(script, false, BioConsole.onTab, BioConsole.useBioformats, BioConsole.newTab);
602 }
603 if (FuncType == Function.FunctionType.Property)
604 {
605 if (Name.StartsWith("Get"))
606 {
607 Automation.Recording r = (Automation.Recording)Automation.Properties[System.IO.Path.GetFileNameWithoutExtension(File)];
608 return r.Get();
609 }
610 else if (Name.StartsWith("Set"))
611 {
612 Automation.Recording r = (Automation.Recording)Automation.Properties[System.IO.Path.GetFileNameWithoutExtension(File)];
613 r.Set(Value.ToString());
614 }
615
616 }
617 if (FuncType == Function.FunctionType.Key)
618 {
619 if (Modifier != VirtualKeyCode.NONAME)
620 {
621 input.Keyboard.ModifiedKeyStroke(Modifier, Key);
622 }
623 else
624 {
625 input.Keyboard.KeyPress(Key);
626 }
627 return null;
628 }
629 if (FuncType == Function.FunctionType.Recording)
630 {
631 Automation.Recording r = (Automation.Recording)Automation.Recordings[System.IO.Path.GetFileNameWithoutExtension(File)];
632 r.Run();
633 }
634 if (FuncType == Function.FunctionType.Objective)
635 {
636 App.imager.PerformFunction(this);
637 }
638 if (FuncType == Function.FunctionType.StoreCoordinate)
639 {
640 App.imager.PerformFunction(this);
641 }
642 if (FuncType == Function.FunctionType.NextCoordinate)
643 {
644 App.imager.PerformFunction(this);
645 }
646 if (FuncType == Function.FunctionType.PreviousCoordinate)
647 {
648 App.imager.PerformFunction(this);
649 }
650 if (FuncType == Function.FunctionType.NextSnapCoordinate)
651 {
652 App.imager.PerformFunction(this);
653 }
654 if (FuncType == Function.FunctionType.PreviousSnapCoordinate)
655 {
656 App.imager.PerformFunction(this);
657 }
658 if (FuncType == Function.FunctionType.StageUp)
659 {
660 Microscope.MoveUp(Value);
661 }
662 if (FuncType == Function.FunctionType.StageRight)
663 {
664 Microscope.MoveRight(Value);
665 }
666 if (FuncType == Function.FunctionType.StageDown)
667 {
668 Microscope.MoveDown(Value);
669 }
670 if (FuncType == Function.FunctionType.StageLeft)
671 {
672 Microscope.MoveLeft(Value);
673 }
674 if (FuncType == Function.FunctionType.FocusUp)
675 {
676 Microscope.SetFocus(Value);
677 }
678 if (FuncType == Function.FunctionType.FocusDown)
679 {
680 Microscope.SetFocus(-Value);
681 }
682 if (FuncType == Function.FunctionType.StageFieldUp)
683 {
684 Microscope.MoveFieldUp();
685 }
686 if (FuncType == Function.FunctionType.StageFieldRight)
687 {
688 Microscope.MoveFieldRight();
689 }
690 if (FuncType == Function.FunctionType.StageFieldDown)
691 {
692 Microscope.MoveFieldDown();
693 }
694 if (FuncType == Function.FunctionType.StageFieldLeft)
695 {
696 Microscope.MoveFieldLeft();
697 }
698 if (FuncType == Function.FunctionType.TakeImage)
699 {
700 Microscope.TakeImage();
701 }
702 if (FuncType == Function.FunctionType.TakeImageStack)
703 {
704 Microscope.TakeImageStack();
705 }
706 if (FuncType == Function.FunctionType.RL)
707 {
708 Microscope.RLShutter.SetPosition((int)Value);
709 }
710 if (FuncType == Function.FunctionType.TL)
711 {
712 Microscope.TLShutter.SetPosition((int)Value);
713 }
714 return null;
715 }

References BioImager.Imager.PerformFunction(), BioImager.ImageJ.RunOnImage(), and BioImager.Scripting.RunString().

◆ Save()

void BioImager.Function.Save ( )

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

Definition at line 735 of file FunctionForm.cs.

736 {
737 string st = Application.StartupPath;
738
739 if(!Directory.Exists(st + "/Functions"))
740 {
741 Directory.CreateDirectory(st + "/Functions");
742 }
743 foreach (Function f in Functions.Values)
744 {
745 System.IO.File.WriteAllText(st + "/Functions/" + f.Name + ".func",f.Serialize());
746 }
747 }

◆ Serialize()

string BioImager.Function.Serialize ( )

Definition at line 575 of file FunctionForm.cs.

576 {
577 return JsonConvert.SerializeObject(this);
578 }

◆ ToString()

override string BioImager.Function.ToString ( )

Definition at line 557 of file FunctionForm.cs.

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

Member Data Documentation

◆ Functions

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

Definition at line 399 of file FunctionForm.cs.

◆ input

InputSimulator BioImager.Function.input = new InputSimulator()
static

Definition at line 580 of file FunctionForm.cs.

Property Documentation

◆ ContextPath

string BioImager.Function.ContextPath
getset

Definition at line 533 of file FunctionForm.cs.

534 {
535 get
536 {
537 return menuPath;
538 }
539 set
540 {
541 menuPath = value;
542 }
543 }

◆ File

string BioImager.Function.File
getset

Definition at line 492 of file FunctionForm.cs.

493 {
494 get { return file; }
495 set { file = value; }
496 }

◆ FuncType

FunctionType BioImager.Function.FuncType
getset

Definition at line 479 of file FunctionForm.cs.

480 {
481 get
482 {
483 return functionType;
484 }
485 set
486 {
487 functionType = value;
488 }
489 }

◆ Key

VirtualKeyCode BioImager.Function.Key
getset

Definition at line 453 of file FunctionForm.cs.

454 {
455 get
456 {
457 return key;
458 }
459 set
460 {
461 key = value;
462 }
463 }

◆ MenuPath

string BioImager.Function.MenuPath
getset

Definition at line 521 of file FunctionForm.cs.

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

◆ Modifier

VirtualKeyCode BioImager.Function.Modifier
getset

Definition at line 466 of file FunctionForm.cs.

467 {
468 get
469 {
470 return modifier;
471 }
472 set
473 {
474 modifier = value;
475 }
476 }

◆ Name

string BioImager.Function.Name
getset

Definition at line 509 of file FunctionForm.cs.

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

◆ Script

string BioImager.Function.Script
getset

Definition at line 499 of file FunctionForm.cs.

500 {
501 get { return script; }
502 set
503 {
504 script = value;
505 }
506 }

◆ State

ButtonState BioImager.Function.State
getset

Definition at line 439 of file FunctionForm.cs.

440 {
441 get
442 {
443 return buttonState;
444 }
445 set
446 {
447 buttonState = value;
448 }
449 }

◆ Value

double BioImager.Function.Value
getset

Definition at line 546 of file FunctionForm.cs.

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

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