BioCore  5.0.0
A Windows .NET microscopy library and application for viewing, editing, and annotating images.
Loading...
Searching...
No Matches
BioCore.Function Class Reference

Public Types

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

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.
 

Static Public Member Functions

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

Static Public Attributes

static Dictionary< string, Function > Functions = 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]
 
string Microscope [get, set]
 

Detailed Description

Definition at line 309 of file FunctionForm.cs.

Member Enumeration Documentation

◆ ButtonState

Enumerator
Pressed 
Released 

Definition at line 329 of file FunctionForm.cs.

◆ FunctionType

Enumerator
Key 
Microscope 
Objective 
StoreCoordinate 
NextCoordinate 
PreviousCoordinate 
NextSnapCoordinate 
PreviousSnapCoordinate 
Recording 
Property 
ImageJ 
Script 
None 

Definition at line 313 of file FunctionForm.cs.

Member Function Documentation

◆ Initialize()

static void BioCore.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 532 of file FunctionForm.cs.

533 {
534 string st = Application.StartupPath + "/Functions";
535 if (!Directory.Exists(st))
536 Directory.CreateDirectory(st);
537 string[] sts = Directory.GetFiles(st);
538 for (int i = 0; i < sts.Length; i++)
539 {
540 string fs = System.IO.File.ReadAllText(sts[i]);
541 Function f = Function.Parse(fs);
542 if (!Functions.ContainsKey(f.Name))
543 Functions.Add(f.Name, f);
544 App.AddMenu(f.MenuPath, f);
546 }
547 }
static void AddMenu(string menu)
Definition App.cs:207
static void AddContextMenu(string menu)
Definition App.cs:215
static Dictionary< string, Function > Functions
static Function Parse(string s)

◆ Parse()

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

It takes a string, and if it's empty, it returns a new Function object. Otherwise, it returns a new Function object that is the deserialized version of the string

Parameters
sThe string to parse
Returns
A function object.

Definition at line 477 of file FunctionForm.cs.

478 {
479 if (s == "")
480 return new Function();
481 return JsonConvert.DeserializeObject<Function>(s);
482 }

◆ PerformFunction()

object BioCore.Function.PerformFunction ( bool imagej)

It runs a script or a keystroke

Parameters
imagejboolean, whether to run the script as an ImageJ script or a C# script
Returns
The return value is the result of the function.

Definition at line 498 of file FunctionForm.cs.

499 {
500 if (FuncType == FunctionType.Key && Script != "")
501 if (imagej)
502 {
503 FuncType = FunctionType.ImageJ;
504 }
505 else
506 FuncType = FunctionType.Script;
507 if (FuncType == Function.FunctionType.Script)
508 {
509 Scripting.RunString(script);
510 }
511 if (FuncType == Function.FunctionType.ImageJ)
512 {
514 }
515
516 if (FuncType == Function.FunctionType.Key)
517 {
518 if (Modifier != VirtualKeyCode.NONAME)
519 {
520 input.Keyboard.ModifiedKeyStroke(Modifier, Key);
521 }
522 else
523 {
524 input.Keyboard.KeyPress(Key);
525 }
526 return null;
527 }
528 return null;
529 }
static bool newTab
Definition BioConsole.cs:23
static bool useBioformats
Definition BioConsole.cs:21
static bool onTab
Definition BioConsole.cs:20
static InputSimulator input
FunctionType FuncType
VirtualKeyCode Modifier
ImageView control for image stacks, pyramidal and whole-slide-images.
static BioImage SelectedImage
Definition ImageView.cs:306
static void RunString(string st)
Definition Scripting.cs:417

◆ Save()

void BioCore.Function.Save ( )

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

Definition at line 549 of file FunctionForm.cs.

550 {
551 string st = Application.StartupPath;
552
553 if (!Directory.Exists(st + "/Functions"))
554 {
555 Directory.CreateDirectory(st + "/Functions");
556 }
557 foreach (Function f in Functions.Values)
558 {
559 System.IO.File.WriteAllText(st + "/Functions/" + f.Name + ".func", f.Serialize());
560 }
561 }
System.Windows.Forms.Application Application
Definition ImageView.cs:14

◆ Serialize()

string BioCore.Function.Serialize ( )

"Serialize" is a function that takes an object and returns a string

Returns
The object is being serialized into a JSON string.

Definition at line 487 of file FunctionForm.cs.

488 {
489 return JsonConvert.SerializeObject(this);
490 }

◆ ToString()

override string BioCore.Function.ToString ( )

Definition at line 467 of file FunctionForm.cs.

468 {
469 return name + ", " + MenuPath;
470 }

Member Data Documentation

◆ Functions

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

Definition at line 311 of file FunctionForm.cs.

◆ input

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

Definition at line 492 of file FunctionForm.cs.

Property Documentation

◆ ContextPath

string BioCore.Function.ContextPath
getset

Definition at line 431 of file FunctionForm.cs.

432 {
433 get
434 {
435 return contextPath;
436 }
437 set
438 {
439 contextPath = value;
440 }
441 }

◆ File

string BioCore.Function.File
getset

Definition at line 390 of file FunctionForm.cs.

391 {
392 get { return file; }
393 set { file = value; }
394 }

◆ FuncType

FunctionType BioCore.Function.FuncType
getset

Definition at line 377 of file FunctionForm.cs.

378 {
379 get
380 {
381 return functionType;
382 }
383 set
384 {
385 functionType = value;
386 }
387 }

◆ Key

VirtualKeyCode BioCore.Function.Key
getset

Definition at line 349 of file FunctionForm.cs.

350 {
351 get
352 {
353 return key;
354 }
355 set
356 {
357 key = value;
359 }
360 }

◆ MenuPath

string BioCore.Function.MenuPath
getset

Definition at line 419 of file FunctionForm.cs.

420 {
421 get
422 {
423 return menuPath;
424 }
425 set
426 {
427 menuPath = value;
428 }
429 }

◆ Microscope

string BioCore.Function.Microscope
getset

Definition at line 456 of file FunctionForm.cs.

457 {
458 get
459 {
460 return microscope;
461 }
462 set
463 {
464 microscope = value;
465 }
466 }

◆ Modifier

VirtualKeyCode BioCore.Function.Modifier
getset

Definition at line 363 of file FunctionForm.cs.

364 {
365 get
366 {
367 return modifier;
368 }
369 set
370 {
372 modifier = value;
373 }
374 }

◆ Name

string BioCore.Function.Name
getset

Definition at line 407 of file FunctionForm.cs.

408 {
409 get
410 {
411 return name;
412 }
413 set
414 {
415 name = value;
416 }
417 }

◆ Script

string BioCore.Function.Script
getset

Definition at line 397 of file FunctionForm.cs.

398 {
399 get { return script; }
400 set
401 {
402 script = value;
403 }
404 }

◆ State

ButtonState BioCore.Function.State
getset

Definition at line 336 of file FunctionForm.cs.

337 {
338 get
339 {
340 return buttonState;
341 }
342 set
343 {
344 buttonState = value;
345 }
346 }

◆ Value

double BioCore.Function.Value
getset

Definition at line 444 of file FunctionForm.cs.

445 {
446 get
447 {
448 return val;
449 }
450 set
451 {
452 val = value;
453 }
454 }

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