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
ColorTool.cs
Go to the documentation of this file.
1using System;
2using System.Collections.Generic;
3using System.ComponentModel;
4using System.Data;
5using System.Drawing;
6using System.Linq;
7using System.Text;
8using System.Threading.Tasks;
9using System.Windows.Forms;
10using AForge;
11namespace BioImager
12{
13 public partial class ColorTool : Form
14 {
15 private ColorS color = new ColorS(65535, 65535, 65535);
16 private int bitsPerPixel = 16;
17 /* A property. */
18 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
19 public ColorS Color
20 {
21 get
22 {
23 return color;
24 }
25 set
26 {
27 color = value;
28 }
29 }
30
32 public void UpdateGUI()
33 {
34 color = new ColorS((ushort)redBox.Value, (ushort)greenBox.Value, (ushort)blueBox.Value);
35 colorPanel.BackColor = System.Drawing.Color.FromArgb((int)(((float)color.R / (float)ushort.MaxValue) * 255),(int)(((float)color.G / (float)ushort.MaxValue) * 255),(int)(((float)color.B / (float)ushort.MaxValue) * 255));
36 if (rBar.Value != redBox.Value)
37 redBox.Value = rBar.Value;
38 if (gBar.Value != greenBox.Value)
39 greenBox.Value = gBar.Value;
40 if (bBar.Value != blueBox.Value)
41 blueBox.Value = bBar.Value;
42 }
43 /* A constructor. */
44 public ColorTool()
45 {
46 InitializeComponent();
47 UpdateGUI();
48 }
49 /* A constructor. */
50 public ColorTool(ColorS col, int bitPerPixel)
51 {
52 InitializeComponent();
53 this.bitsPerPixel = bitPerPixel;
54 if(bitsPerPixel == 8)
55 {
56 rBar.Maximum = 255;
57 gBar.Maximum = 255;
58 bBar.Maximum = 255;
59 redBox.Maximum = 255;
60 greenBox.Maximum = 255;
61 blueBox.Maximum = 255;
62 }
63 if (rBar.Maximum <= col.R)
64 rBar.Value = rBar.Maximum;
65 if (gBar.Maximum <= col.G)
66 gBar.Value = gBar.Maximum;
67 if (bBar.Maximum <= col.B)
68 bBar.Value = bBar.Maximum;
69 UpdateGUI();
70 }
71
72 private void redBox_ValueChanged(object sender, EventArgs e)
73 {
74 UpdateGUI();
75 }
76
77 private void greenBox_ValueChanged(object sender, EventArgs e)
78 {
79 UpdateGUI();
80 }
81
82 private void blueBox_ValueChanged(object sender, EventArgs e)
83 {
84 UpdateGUI();
85 }
86
87 private void rEnbaled_CheckedChanged(object sender, EventArgs e)
88 {
89 Tools.rEnabled = rEnbaled.Checked;
90 }
91
92 private void gEnabled_CheckedChanged(object sender, EventArgs e)
93 {
94 Tools.gEnabled = gEnabled.Checked;
95 }
96
97 private void bEnabled_CheckedChanged(object sender, EventArgs e)
98 {
99 Tools.bEnabled = bEnabled.Checked;
100 }
101
102 private void applyButton_Click(object sender, EventArgs e)
103 {
104 DialogResult = DialogResult.OK;
105 Close();
106 }
107
108 private void cancelBut_Click(object sender, EventArgs e)
109 {
110 DialogResult = DialogResult.Cancel;
111 Close();
112 }
113
114 private void rBar_Scroll(object sender, EventArgs e)
115 {
116 UpdateGUI();
117 }
118
119 private void gBar_Scroll(object sender, EventArgs e)
120 {
121 UpdateGUI();
122 }
123
124 private void bBar_Scroll(object sender, EventArgs e)
125 {
126 UpdateGUI();
127 }
128 }
129}
AForge.Color Color
ColorTool(ColorS col, int bitPerPixel)
Definition ColorTool.cs:50
void UpdateGUI()
It updates the GUI.
Definition ColorTool.cs:32