BioImager  5.0.0
A .NET microscopy imaging application based on Bio library. Supports various microscopes by using imported libraries & GUI automation. Supports XInput game controllers to move stage, take images, run ImageJ macros on images or Bio C# scripts.
Loading...
Searching...
No Matches
BioImager.ChannelsTool Class Reference
Inheritance diagram for BioImager.ChannelsTool:

Public Member Functions

void UpdateItems ()
 It clears the listbox and then adds all the items in the Channels list to the listbox.
 
 ChannelsTool (List< Channel > Channels)
 
void RefreshHistogram ()
 

Protected Member Functions

override void Dispose (bool disposing)
 Clean up any resources being used.
 

Properties

List< Channel > Channels [get]
 
Channel SelectedChannel [get]
 
int SelectedSample [get, set]
 

Detailed Description

Definition at line 4 of file ChannelsTool.designer.cs.

Constructor & Destructor Documentation

◆ ChannelsTool()

BioImager.ChannelsTool.ChannelsTool ( List< Channel > Channels)

Definition at line 68 of file ChannelsTool.cs.

69 {
70 initializing = true;
71 InitializeComponent();
72 foreach (Channel item in Channels)
73 {
74 channelsBox.Items.Add(item);
75 }
76 MouseWheel += new System.Windows.Forms.MouseEventHandler(ChannelsTool_MouseWheel);
77
78 if (Channels.Count == 0)
79 {
80 channelsBox.Enabled = false;
81 sampleBox.Enabled = false;
82 statsPanel.Controls.Add(new Label
83 {
84 Dock = DockStyle.Fill,
85 Text = "No channel metadata is available for this image.",
86 TextAlign = ContentAlignment.MiddleCenter
87 });
88 initializing = false;
89 return;
90 }
91
92 channelsBox.SelectedIndex = 0;
93 Channel channel = Channels[0];
94 int sample = channel.range?.Length > 0 ? 0 : -1;
95 int defaultMax = channel.BitsPerPixel <= 8 ? byte.MaxValue : ushort.MaxValue;
96 int minimum = sample >= 0 ? channel.range[sample].Min : 0;
97 int maximum = sample >= 0 ? channel.range[sample].Max : defaultMax;
98 if (channel.stats?.Length > 0)
99 {
100 minimum = (int)channel.stats[0].StackMin;
101 maximum = (int)channel.stats[0].StackMax;
102 }
103 minBox.Value = Math.Clamp(minimum, (int)minBox.Minimum, (int)minBox.Maximum);
104 maxBox.Value = Math.Clamp(maximum, (int)maxBox.Minimum, (int)maxBox.Maximum);
105 hist = new HistogramControl(channel);
106 hist.GraphMax = Math.Max(1, (int)maxBox.Value);
107 maxGraphBox.Value = Math.Clamp(maxBox.Value, maxGraphBox.Minimum, maxGraphBox.Maximum);
108 statsPanel.Controls.Add(hist);
109 initializing = false;
110 Shown += async (_, _) => await EnsureHistogramAsync();
111 }
List< Channel > Channels

Member Function Documentation

◆ Dispose()

override void BioImager.ChannelsTool.Dispose ( bool disposing)
protected

Clean up any resources being used.

Parameters
disposingtrue if managed resources should be disposed; otherwise, false.

Definition at line 15 of file ChannelsTool.designer.cs.

16 {
17 if (disposing && (components != null))
18 {
19 components.Dispose();
20 }
21 base.Dispose(disposing);
22 }

◆ RefreshHistogram()

void BioImager.ChannelsTool.RefreshHistogram ( )

Definition at line 329 of file ChannelsTool.cs.

330 {
331 if (Visible)
332 _ = EnsureHistogramAsync();
333 }

◆ UpdateItems()

void BioImager.ChannelsTool.UpdateItems ( )

It clears the listbox and then adds all the items in the Channels list to the listbox.

Definition at line 53 of file ChannelsTool.cs.

54 {
55 int selectedIndex = channelsBox.SelectedIndex;
56 initializing = true;
57 channelsBox.Items.Clear();
58 foreach (Channel item in Channels)
59 {
60 channelsBox.Items.Add(item);
61 }
62 channelsBox.SelectedIndex = Channels.Count == 0
63 ? -1
64 : Math.Clamp(selectedIndex, 0, Channels.Count - 1);
65 initializing = false;
66 }

Property Documentation

◆ Channels

List<Channel> BioImager.ChannelsTool.Channels
get

Definition at line 21 of file ChannelsTool.cs.

22 {
23 get
24 {
25 return App.Channels;
26 }
27 }

◆ SelectedChannel

Channel BioImager.ChannelsTool.SelectedChannel
get

Definition at line 29 of file ChannelsTool.cs.

30 {
31 get
32 {
33 if (channelsBox.SelectedIndex != -1)
34 return Channels[channelsBox.SelectedIndex];
35 else
36 return Channels[0];
37 }
38 }

◆ SelectedSample

int BioImager.ChannelsTool.SelectedSample
getset

Definition at line 41 of file ChannelsTool.cs.

42 {
43 get
44 {
45 return (int)sampleBox.Value;
46 }
47 set
48 {
49 sampleBox.Value = (decimal)value;
50 }
51 }

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