diff --git a/exhibit.sln b/exhibit.sln new file mode 100644 index 0000000..fc822f1 --- /dev/null +++ b/exhibit.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.23107.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "exhibit", "exhibit\exhibit.csproj", "{FF947855-D5E9-4484-832F-27B3B34297B6}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {FF947855-D5E9-4484-832F-27B3B34297B6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FF947855-D5E9-4484-832F-27B3B34297B6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FF947855-D5E9-4484-832F-27B3B34297B6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FF947855-D5E9-4484-832F-27B3B34297B6}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/exhibit/Form1.Designer.cs b/exhibit/Form1.Designer.cs index a7a9287..6920a63 100644 --- a/exhibit/Form1.Designer.cs +++ b/exhibit/Form1.Designer.cs @@ -30,64 +30,56 @@ private void InitializeComponent() { this.components = new System.ComponentModel.Container(); this.panel1 = new System.Windows.Forms.Panel(); - this.pictureBox1 = new System.Windows.Forms.PictureBox(); - this.label1 = new System.Windows.Forms.Label(); - this.textBox1 = new System.Windows.Forms.TextBox(); this.button1 = new System.Windows.Forms.Button(); + this.textBox1 = new System.Windows.Forms.TextBox(); + this.label1 = new System.Windows.Forms.Label(); this.MouseMoveTimer = new System.Windows.Forms.Timer(this.components); this.panel1.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); this.SuspendLayout(); // // panel1 // + this.panel1.AutoSize = true; + this.panel1.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; this.panel1.Controls.Add(this.button1); this.panel1.Controls.Add(this.textBox1); this.panel1.Controls.Add(this.label1); - this.panel1.Dock = System.Windows.Forms.DockStyle.Top; + this.panel1.Dock = System.Windows.Forms.DockStyle.Fill; this.panel1.Location = new System.Drawing.Point(0, 0); this.panel1.Name = "panel1"; - this.panel1.Size = new System.Drawing.Size(843, 54); + this.panel1.Size = new System.Drawing.Size(455, 43); this.panel1.TabIndex = 0; // - // pictureBox1 - // - this.pictureBox1.Dock = System.Windows.Forms.DockStyle.Fill; - this.pictureBox1.Location = new System.Drawing.Point(0, 0); - this.pictureBox1.Name = "pictureBox1"; - this.pictureBox1.Size = new System.Drawing.Size(843, 469); - this.pictureBox1.TabIndex = 1; - this.pictureBox1.TabStop = false; - // - // label1 + // button1 // - this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(12, 16); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(66, 13); - this.label1.TabIndex = 0; - this.label1.Text = "This color is:"; + this.button1.Dock = System.Windows.Forms.DockStyle.Right; + this.button1.Font = new System.Drawing.Font("Lucida Fax", 20.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.button1.Location = new System.Drawing.Point(310, 0); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(145, 43); + this.button1.TabIndex = 2; + this.button1.Text = "Exhibit!"; + this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.button1_Click); // // textBox1 // this.textBox1.Enabled = false; - this.textBox1.Location = new System.Drawing.Point(84, 9); + this.textBox1.Location = new System.Drawing.Point(84, 13); + this.textBox1.Multiline = true; this.textBox1.Name = "textBox1"; - this.textBox1.Size = new System.Drawing.Size(100, 20); + this.textBox1.Size = new System.Drawing.Size(180, 20); this.textBox1.TabIndex = 1; this.textBox1.Text = "#Color"; // - // button1 + // label1 // - this.button1.Dock = System.Windows.Forms.DockStyle.Right; - this.button1.Font = new System.Drawing.Font("Lucida Fax", 20.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.button1.Location = new System.Drawing.Point(698, 0); - this.button1.Name = "button1"; - this.button1.Size = new System.Drawing.Size(145, 54); - this.button1.TabIndex = 2; - this.button1.Text = "Exhibit!"; - this.button1.UseVisualStyleBackColor = true; - this.button1.Click += new System.EventHandler(this.button1_Click); + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(12, 16); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(66, 13); + this.label1.TabIndex = 0; + this.label1.Text = "This color is:"; // // MouseMoveTimer // @@ -97,25 +89,23 @@ private void InitializeComponent() // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(843, 469); + this.ClientSize = new System.Drawing.Size(455, 43); this.ControlBox = false; this.Controls.Add(this.panel1); - this.Controls.Add(this.pictureBox1); this.Cursor = System.Windows.Forms.Cursors.Default; this.Name = "frmMain"; this.Text = "Form1"; this.Load += new System.EventHandler(this.frmMain_Load); this.panel1.ResumeLayout(false); this.panel1.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); this.ResumeLayout(false); + this.PerformLayout(); } #endregion private System.Windows.Forms.Panel panel1; - private System.Windows.Forms.PictureBox pictureBox1; private System.Windows.Forms.TextBox textBox1; private System.Windows.Forms.Label label1; private System.Windows.Forms.Button button1; diff --git a/exhibit/Form1.cs b/exhibit/Form1.cs index 9a2a7ef..79d4e28 100644 --- a/exhibit/Form1.cs +++ b/exhibit/Form1.cs @@ -17,8 +17,8 @@ namespace exhibit { public partial class frmMain : Form { - private bool mouseMoveTimer = false; + Bitmap screenPixel = new Bitmap(1, 1, PixelFormat.Format32bppArgb); [DllImport("user32.dll")] @@ -47,10 +47,7 @@ public Color GetColorAt(Point location) return screenPixel.GetPixel(0, 0); } - private void MouseMoveTimer_Tick(object sender, EventArgs e) - { - - } + private void frmMain_Load(object sender, EventArgs e) { @@ -61,13 +58,20 @@ private void button1_Click(object sender, EventArgs e) if (!mouseMoveTimer) { MouseMoveTimer.Start(); + mouseMoveTimer = true; } else { MouseMoveTimer.Stop(); + mouseMoveTimer = false; } } + private static string HexConverter(Color c) + { + return String.Format("{0:X6}", c.ToArgb() & 0x00FFFFFF); + + } private void MouseMoveTimer_Tick_1(object sender, EventArgs e) { @@ -75,12 +79,272 @@ private void MouseMoveTimer_Tick_1(object sender, EventArgs e) GetCursorPos(ref cursor); var c = GetColorAt(cursor); - this.BackColor = c; + + textBox1.Text = NameOfColorHSV(c); + + } + #region RGB + /* + Using RGB wasn't the best idea since there was some sort of mix-up between color values. Also, + The arangment of the colors was very important to be in an ascending order to make sure that + The values are accurate. + */ + private string NameOfColorRGB(Color c) + { + //This will check the RGB values of the color and will determine the name of the color. + //All colors are based on the values from workwithcolor.com page [Check link bellow]. + //http://www.workwithcolor.com/orange-brown-color-hue-range-01.htm + + //The result that will be returned. + string colorName = null; + + //Pink-Red + if ((c.R <= 255 && c.R >= 101) && (c.G <= 193 && c.G >= 0) && (c.B <= 204 && c.B >= 11)) + { + colorName = "Pink-Red (" + c.R + "," + c.G + "," + c.B + ")"; + + } + //Pink + else if ((c.R <= 255 && c.R >= 86) && (c.G <= 209 && c.G >= 0) && (c.B <= 220 && c.B >= 25)) + { + colorName = "Pink (" + c.R + "," + c.G + "," + c.B + ")"; + + } + //Magenta-Pink + else if ((c.R <= 255 && c.R >= 97) && (c.G <= 240 && c.G >= 0) && (c.B <= 245 && c.B >= 81)) + { + colorName = "Magenta-Pink (" + c.R + "," + c.G + "," + c.B + ")"; + + } + //Magenta + else if ((c.R <= 255 && c.R >= 93) && (c.G <= 159 && c.G >= 0) && (c.B <= 255 && c.B >= 84)) + { + colorName = "Magenta (" + c.R + "," + c.G + "," + c.B + ")"; + + } + //Blue-Magenta + else if ((c.R <= 191 && c.R >= 105) && (c.G <= 148 && c.G >= 0) && (c.B <= 255 && c.B >= 150)) + { + colorName = "Blue-Magenta (" + c.R + "," + c.G + "," + c.B + ")"; + + } + //Blue + else if ((c.R <= 248 && c.R >= 0) && (c.G <= 248 && c.G >= 0) && (c.B <= 255 && c.B >= 102)) + { + colorName = "Blue (" + c.R + "," + c.G + "," + c.B + ")"; + + } + //Cyan-Blue + else if ((c.R <= 240 && c.R >= 0) && (c.G <= 248 && c.G >= 33) && (c.B <= 255 && c.B >= 71)) + { + colorName = "Cyan-Blue (" + c.R + "," + c.G + "," + c.B + ")"; + + } + //Cyan + else if ((c.R <= 231 && c.R >= 0) && (c.G <= 255 && c.G >= 79) && (c.B <= 255 && c.B >= 79)) + { + colorName = "Cyan (" + c.R + "," + c.G + "," + c.B + ")"; + + } + //Green-Cyan + else if ((c.R <= 178 && c.R >= 0) && (c.G <= 255 && c.G >= 36) && (c.B <= 212 && c.B >= 32)) + { + colorName = "Green-Cyan (" + c.R + "," + c.G + "," + c.B + ")"; + + } + //Green + else if ((c.R <= 178 && c.R >= 0) && (c.G <= 255 && c.G >= 72) && (c.B <= 175 && c.B >= 0)) + { + colorName = "Green (" + c.R + "," + c.G + "," + c.B + ")"; + + } + //Yellow-Green + else if ((c.R <= 223 && c.R >= 75) && (c.G <= 255 && c.G >= 83) && (c.B <= 130 && c.B >= 0)) + { + colorName = "Yellow-Green (" + c.R + "," + c.G + "," + c.B + ")"; + + } + //Yellow + else if ((c.R <= 255 && c.R >= 181) && (c.G <= 255 && c.G >= 166) && (c.B <= 240 && c.B >= 0)) + { + colorName = "Yellow (" + c.R + "," + c.G + "," + c.B + ")"; + + } + //Orange-Yellow + + else if ((c.R <= 255 && c.R >= 145) && (c.G <= 248 && c.G >= 113) && (c.B <= 226 && c.B >= 0)) + { + colorName = "Orange-Yellow (" + c.R + "," + c.G + "," + c.B + ")"; + + } + //Orange & Brown + else if ((c.R <= 255 && c.R >= 61) && (c.G <= 245 && c.G >= 43) && (c.B <= 238 && c.B >= 0)) + { + colorName = "Orange & Brown (" + c.R + "," + c.G + "," + c.B + ")"; + + } + //Red-Orange + else if ((c.R <= 255 && c.R >= 109) && (c.G <= 153 && c.G >= 51) && (c.B <= 123 && c.B >= 0)) + { + colorName = "Red-Orange (" + c.R + "," + c.G + "," + c.B + ")"; + + } + //Red + else if ((c.R <= 255 && c.R >= 50) && (c.G <= 250 && c.G >= 0) && (c.B <= 250 && c.B >= 0)) + { + colorName = "Red (" + c.R + "," + c.G + "," + c.B + ")"; + } + //Uknown - Color can't be found [DEBUG] + else + { + colorName = "Unkown (" + c.R + "," + c.G + "," + c.B + ")"; + + } + - if (c.R == c.G && c.G < 64 && c.B > 128) + return colorName; + } + #endregion + #region HSV + /* + Using HSV was better, and the right way in my opinion, find the values of colors in a less + complicated way. + */ + private string NameOfColorHSV(Color c) + { + //Determines the name of the color based on it's HSV value. + string colorName = null; + + int max = Math.Max(c.R, Math.Max(c.G, c.B)); + int min = Math.Min(c.R, Math.Min(c.G, c.B)); + + var Hue = Math.Round(c.GetHue(), 2); + var Saturation = ((max == 0) ? 0 : 1d - (1d * min / max)) * 100; + Saturation = Math.Round(Saturation, 2); + var Value = Math.Round(((max / 255d) * 100), 2); + + //The HSV model distributes colors in a 360(DEGREE) circle where all the colors are distributed + //into a 60(DEGREE) slices. Value and saturation determine the brightness and + + //White + if (Value == 100 && Saturation < 5) + { + colorName = "White (" + Hue + "," + Saturation + "," + Value + ")"; + + } + else if (Value == 0 && Saturation < 95) + { + colorName = "Black (" + Hue + "," + Saturation + "," + Value + ")"; + + } + //Pink-Red + else if (Hue >= 346 && Hue <= 355) + { + colorName = "Pink-Red (" + Hue + "," + Saturation + "," + Value + ")"; + + } + //Pink + else if (Hue >= 331 && Hue <= 345) + { + colorName = "Pink (" + Hue + "," + Saturation + "," + Value + ")"; + + } + //Magenta-Pink + else if (Hue >= 321 && Hue <= 330) + { + colorName = "Magenta-Pink (" + Hue + "," + Saturation + "," + Value + ")"; + + } + //Magenta + else if (Hue >= 281 && Hue <= 320) + { + colorName = "Magenta (" + Hue + "," + Saturation + "," + Value + ")"; + + } + //Blue-Magenta + else if (Hue >= 241 && Hue <= 280) + { + colorName = "Blue-Magenta (" + Hue + "," + Saturation + "," + Value + ")"; + + } + //Blue + else if (Hue >= 221 && Hue <= 240) + { + colorName = "Blue (" + Hue + "," + Saturation + "," + Value + ")"; + + } + //Cyan-Blue + else if (Hue >= 201 && Hue <= 220) + { + colorName = "Cyan-Blue (" + Hue + "," + Saturation + "," + Value + ")"; + + } + //Cyan + else if (Hue >= 170 && Hue <= 200) { - MessageBox.Show("Blue"); + colorName = "Cyan (" + Hue + "," + Saturation + "," + Value + ")"; + + } + //Green-Cyan + else if (Hue >= 141 && Hue <= 169) + { + colorName = "Green-Cyan (" + Hue + "," + Saturation + "," + Value + ")"; + + } + //Green + else if (Hue >= 81 && Hue <= 140) + { + colorName = "Green (" + Hue + "," + Saturation + "," + Value + ")"; + + } + //Yellow-Green + else if (Hue >= 61 && Hue <= 80) + { + colorName = "Yellow-Green (" + Hue + "," + Saturation + "," + Value + ")"; + + } + //Yellow + else if (Hue >= 51 && Hue <= 60) + { + colorName = "Yellow (" + Hue + "," + Saturation + "," + Value + ")"; + + } + //Orange-Yellow + + else if (Hue >= 41 && Hue <= 50) + { + colorName = "Orange-Yellow (" + Hue + "," + Saturation + "," + Value + ")"; + } + //Orange & Brown + else if (Hue >= 21 && Hue <= 40) + { + colorName = "Orange & Brown (" + Hue + "," + Saturation + "," + Value + ")"; + + } + //Red-Orange + else if (Hue >= 11 && Hue <= 20) + { + colorName = "Red-Orange (" + Hue + "," + Saturation + "," + Value + ")"; + + } + //Red + else if (Hue >= 355 || Hue <= 10) + { + colorName = "Red (" + Hue + "," + Saturation + "," + Value + ")"; + } + //Uknown - Color can't be found [DEBUG] + else + { + colorName = "Unkown (" + Hue + "," + Saturation + "," + Value + ")"; + + } + + + + return colorName; } + #endregion + } } diff --git a/exhibit/Form1.resx b/exhibit/Form1.resx index 50e5be9..0e0ded0 100644 --- a/exhibit/Form1.resx +++ b/exhibit/Form1.resx @@ -117,12 +117,6 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - True - - - True - 17, 17