BioCore  5.0.0
A Windows .NET microscopy library and application for viewing, editing, and annotating images.
Loading...
Searching...
No Matches
BioCore.ChannelsTool Class Reference
Inheritance diagram for BioCore.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()

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

Definition at line 63 of file ChannelsTool.cs.

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

Member Function Documentation

◆ Dispose()

override void BioCore.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 BioCore.ChannelsTool.RefreshHistogram ( )

Definition at line 322 of file ChannelsTool.cs.

323 {
324 if (Visible)
325 _ = EnsureHistogramAsync();
326 }

◆ UpdateItems()

void BioCore.ChannelsTool.UpdateItems ( )

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

Definition at line 48 of file ChannelsTool.cs.

49 {
50 int selectedIndex = channelsBox.SelectedIndex;
51 initializing = true;
52 channelsBox.Items.Clear();
53 foreach (Channel item in Channels)
54 {
55 channelsBox.Items.Add(item);
56 }
57 channelsBox.SelectedIndex = Channels.Count == 0
58 ? -1
59 : Math.Clamp(selectedIndex, 0, Channels.Count - 1);
60 initializing = false;
61 }

Property Documentation

◆ Channels

List<Channel> BioCore.ChannelsTool.Channels
get

Definition at line 16 of file ChannelsTool.cs.

17 {
18 get
19 {
20 return App.Channels;
21 }
22 }

◆ SelectedChannel

Channel BioCore.ChannelsTool.SelectedChannel
get

Definition at line 24 of file ChannelsTool.cs.

25 {
26 get
27 {
28 if (channelsBox.SelectedIndex != -1)
29 return Channels[channelsBox.SelectedIndex];
30 else
31 return Channels[0];
32 }
33 }

◆ SelectedSample

int BioCore.ChannelsTool.SelectedSample
getset

Definition at line 36 of file ChannelsTool.cs.

37 {
38 get
39 {
40 return (int)sampleBox.Value;
41 }
42 set
43 {
44 sampleBox.Value = (decimal)value;
45 }
46 }

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