diff --git a/App.config b/App.config index 8e15646..38d3b4a 100644 --- a/App.config +++ b/App.config @@ -1,6 +1,30 @@ - + + + +
+ + - + - \ No newline at end of file + + + + 1 + + + False + + + True + + + True + + + True + + + + diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs index 7c4e923..7b89b9c 100644 --- a/Properties/AssemblyInfo.cs +++ b/Properties/AssemblyInfo.cs @@ -6,7 +6,7 @@ // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("Digital Color Meter")] -[assembly: AssemblyDescription("Released under the MIT License")] +[assembly: AssemblyDescription("See color information about the pixel your mouse is hovering over. Released under the MIT License.")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("Digital Color Meter")] diff --git a/Properties/Resources.Designer.cs b/Properties/Resources.Designer.cs index c292828..4f8938a 100644 --- a/Properties/Resources.Designer.cs +++ b/Properties/Resources.Designer.cs @@ -1,17 +1,17 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:4.0.30319.34014 +// Runtime Version:4.0.30319.42000 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. // //------------------------------------------------------------------------------ -namespace dcm.Properties -{ - - +namespace dcm.Properties { + using System; + + /// /// A strongly-typed resource class, for looking up localized strings, etc. /// @@ -19,51 +19,43 @@ namespace dcm.Properties // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class Resources - { - + internal class Resources { + private static global::System.Resources.ResourceManager resourceMan; - + private static global::System.Globalization.CultureInfo resourceCulture; - + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Resources() - { + internal Resources() { } - + /// /// Returns the cached ResourceManager instance used by this class. /// [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager - { - get - { - if ((resourceMan == null)) - { + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("dcm.Properties.Resources", typeof(Resources).Assembly); resourceMan = temp; } return resourceMan; } } - + /// /// Overrides the current thread's CurrentUICulture property for all /// resource lookups using this strongly typed resource class. /// [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture - { - get - { + internal static global::System.Globalization.CultureInfo Culture { + get { return resourceCulture; } - set - { + set { resourceCulture = value; } } diff --git a/Properties/Settings.Designer.cs b/Properties/Settings.Designer.cs index ec44a69..774093a 100644 --- a/Properties/Settings.Designer.cs +++ b/Properties/Settings.Designer.cs @@ -1,30 +1,86 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:4.0.30319.34014 +// Runtime Version:4.0.30319.42000 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. // //------------------------------------------------------------------------------ -namespace dcm.Properties -{ - - +namespace dcm.Properties { + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] - internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase - { - + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.8.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); - - public static Settings Default - { - get - { + + public static Settings Default { + get { return defaultInstance; } } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("1")] + public int UpdateSpeedValue { + get { + return ((int)(this["UpdateSpeedValue"])); + } + set { + this["UpdateSpeedValue"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("False")] + public bool SaveColorRGBChecked { + get { + return ((bool)(this["SaveColorRGBChecked"])); + } + set { + this["SaveColorRGBChecked"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("True")] + public bool SaveColorHEXChecked { + get { + return ((bool)(this["SaveColorHEXChecked"])); + } + set { + this["SaveColorHEXChecked"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("True")] + public bool CopyColorListRGBChecked { + get { + return ((bool)(this["CopyColorListRGBChecked"])); + } + set { + this["CopyColorListRGBChecked"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("True")] + public bool CopyColorListHEXChecked { + get { + return ((bool)(this["CopyColorListHEXChecked"])); + } + set { + this["CopyColorListHEXChecked"] = value; + } + } } } diff --git a/Properties/Settings.settings b/Properties/Settings.settings index 3964565..db0b225 100644 --- a/Properties/Settings.settings +++ b/Properties/Settings.settings @@ -1,7 +1,21 @@  - - - - - - + + + + + 1 + + + False + + + True + + + True + + + True + + + \ No newline at end of file diff --git a/README.md b/README.md index 2b06b64..5a49834 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ Move your mouse about and get a zoomed preview and see the exact RGB color of the pixel underneath the current mouse position. -Press SPACE to store the current color in the list where you can right-click and copy from later. +Press SPACE to store the current color in the list where you can right-click or use the menu bar to copy from later -![Screenshot of Digital Color Meter](https://raw.githubusercontent.com/nagilum/dcm/master/screenshot.png) +![Screenshot of Digital Color Meter](https://github.com/user-attachments/assets/503e2bb4-8880-42ff-aa20-c0a1963ccb0b) -[Download binary](https://github.com/nagilum/dcm/releases/tag/v1.2) +[Download](https://github.com/nagilum/dcm/releases/) diff --git a/dcm.csproj b/dcm.csproj index a4e1592..8aa02a4 100644 --- a/dcm.csproj +++ b/dcm.csproj @@ -9,8 +9,9 @@ Properties dcm dcm - v4.5 + v4.8 512 + AnyCPU @@ -66,6 +67,7 @@ True Resources.resx + True SettingsSingleFileGenerator diff --git a/fmMain.Designer.cs b/fmMain.Designer.cs index ef09c3e..fc27547 100644 --- a/fmMain.Designer.cs +++ b/fmMain.Designer.cs @@ -43,13 +43,12 @@ private void InitializeComponent() this.chColor = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.chRGB = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.chHEX = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.cmColorsPopup = new System.Windows.Forms.ContextMenuStrip(this.components); - this.miCopyHEX = new System.Windows.Forms.ToolStripMenuItem(); - this.miCopyRGB = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); - this.miCopyR = new System.Windows.Forms.ToolStripMenuItem(); - this.miCopyG = new System.Windows.Forms.ToolStripMenuItem(); - this.miCopyB = new System.Windows.Forms.ToolStripMenuItem(); + this.copyValueContextMenuStrip = new System.Windows.Forms.ContextMenuStrip(this.components); + this.copyHexToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.copyRGBValueToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.copyRValueToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.copyGValueToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.copyBValueToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.ilColors = new System.Windows.Forms.ImageList(this.components); this.lbInfo = new System.Windows.Forms.Label(); this.rbRGB = new System.Windows.Forms.RadioButton(); @@ -57,15 +56,28 @@ private void InitializeComponent() this.label4 = new System.Windows.Forms.Label(); this.cbRGB = new System.Windows.Forms.CheckBox(); this.cbHEX = new System.Windows.Forms.CheckBox(); + this.copyValueMenuStrip = new System.Windows.Forms.MenuStrip(); + this.copyToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.copyRGBToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.copyRGBToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); + this.copyRedValueToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.copyGreenValueToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.copyBlueValueToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.lblUpdateSpeed = new System.Windows.Forms.Label(); + this.tbrUpdateSpeed = new System.Windows.Forms.TrackBar(); + this.lblSlow = new System.Windows.Forms.Label(); + this.lblFast = new System.Windows.Forms.Label(); ((System.ComponentModel.ISupportInitialize)(this.pbArea)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pbColor)).BeginInit(); - this.cmColorsPopup.SuspendLayout(); + this.copyValueContextMenuStrip.SuspendLayout(); + this.copyValueMenuStrip.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.tbrUpdateSpeed)).BeginInit(); this.SuspendLayout(); // // pbArea // this.pbArea.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.pbArea.Location = new System.Drawing.Point(12, 12); + this.pbArea.Location = new System.Drawing.Point(12, 29); this.pbArea.Name = "pbArea"; this.pbArea.Size = new System.Drawing.Size(132, 132); this.pbArea.TabIndex = 0; @@ -74,7 +86,7 @@ private void InitializeComponent() // pbColor // this.pbColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.pbColor.Location = new System.Drawing.Point(12, 150); + this.pbColor.Location = new System.Drawing.Point(12, 167); this.pbColor.Name = "pbColor"; this.pbColor.Size = new System.Drawing.Size(46, 62); this.pbColor.TabIndex = 1; @@ -83,7 +95,7 @@ private void InitializeComponent() // label1 // this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(64, 153); + this.label1.Location = new System.Drawing.Point(64, 170); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(15, 13); this.label1.TabIndex = 2; @@ -92,7 +104,7 @@ private void InitializeComponent() // label2 // this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(64, 174); + this.label2.Location = new System.Drawing.Point(64, 191); this.label2.Name = "label2"; this.label2.Size = new System.Drawing.Size(15, 13); this.label2.TabIndex = 3; @@ -101,7 +113,7 @@ private void InitializeComponent() // label3 // this.label3.AutoSize = true; - this.label3.Location = new System.Drawing.Point(64, 195); + this.label3.Location = new System.Drawing.Point(64, 212); this.label3.Name = "label3"; this.label3.Size = new System.Drawing.Size(14, 13); this.label3.TabIndex = 4; @@ -110,11 +122,12 @@ private void InitializeComponent() // trRefresh // this.trRefresh.Enabled = true; + this.trRefresh.Interval = 50; this.trRefresh.Tick += new System.EventHandler(this.trRefresh_Tick); // // tbRed // - this.tbRed.Location = new System.Drawing.Point(85, 150); + this.tbRed.Location = new System.Drawing.Point(85, 167); this.tbRed.Name = "tbRed"; this.tbRed.ReadOnly = true; this.tbRed.Size = new System.Drawing.Size(59, 20); @@ -122,7 +135,7 @@ private void InitializeComponent() // // tbGreen // - this.tbGreen.Location = new System.Drawing.Point(85, 171); + this.tbGreen.Location = new System.Drawing.Point(85, 188); this.tbGreen.Name = "tbGreen"; this.tbGreen.ReadOnly = true; this.tbGreen.Size = new System.Drawing.Size(59, 20); @@ -130,7 +143,7 @@ private void InitializeComponent() // // tbBlue // - this.tbBlue.Location = new System.Drawing.Point(85, 192); + this.tbBlue.Location = new System.Drawing.Point(85, 209); this.tbBlue.Name = "tbBlue"; this.tbBlue.ReadOnly = true; this.tbBlue.Size = new System.Drawing.Size(59, 20); @@ -144,10 +157,11 @@ private void InitializeComponent() this.chColor, this.chRGB, this.chHEX}); - this.lvColors.ContextMenuStrip = this.cmColorsPopup; + this.lvColors.ContextMenuStrip = this.copyValueContextMenuStrip; this.lvColors.FullRowSelect = true; + this.lvColors.HideSelection = false; this.lvColors.LargeImageList = this.ilColors; - this.lvColors.Location = new System.Drawing.Point(150, 12); + this.lvColors.Location = new System.Drawing.Point(150, 29); this.lvColors.Name = "lvColors"; this.lvColors.Size = new System.Drawing.Size(254, 200); this.lvColors.SmallImageList = this.ilColors; @@ -170,57 +184,51 @@ private void InitializeComponent() this.chHEX.Text = "HEX"; this.chHEX.Width = 80; // - // cmColorsPopup + // copyValueContextMenuStrip // - this.cmColorsPopup.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.miCopyHEX, - this.miCopyRGB, - this.toolStripSeparator1, - this.miCopyR, - this.miCopyG, - this.miCopyB}); - this.cmColorsPopup.Name = "cmColorsPopup"; - this.cmColorsPopup.Size = new System.Drawing.Size(137, 120); + this.copyValueContextMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.copyHexToolStripMenuItem, + this.copyRGBValueToolStripMenuItem, + this.copyRValueToolStripMenuItem, + this.copyGValueToolStripMenuItem, + this.copyBValueToolStripMenuItem}); + this.copyValueContextMenuStrip.Name = "contextMenuStrip1"; + this.copyValueContextMenuStrip.Size = new System.Drawing.Size(159, 114); // - // miCopyHEX + // copyHexToolStripMenuItem // - this.miCopyHEX.Name = "miCopyHEX"; - this.miCopyHEX.Size = new System.Drawing.Size(136, 22); - this.miCopyHEX.Text = "Copy HEX"; - this.miCopyHEX.Click += new System.EventHandler(this.miCopyHEX_Click); + this.copyHexToolStripMenuItem.Name = "copyHexToolStripMenuItem"; + this.copyHexToolStripMenuItem.Size = new System.Drawing.Size(158, 22); + this.copyHexToolStripMenuItem.Text = "Copy Hex Value"; + this.copyHexToolStripMenuItem.Click += new System.EventHandler(this.miCopyHEX_Click); // - // miCopyRGB + // copyRGBValueToolStripMenuItem // - this.miCopyRGB.Name = "miCopyRGB"; - this.miCopyRGB.Size = new System.Drawing.Size(136, 22); - this.miCopyRGB.Text = "Copy RGB"; - this.miCopyRGB.Click += new System.EventHandler(this.miCopyRGB_Click); + this.copyRGBValueToolStripMenuItem.Name = "copyRGBValueToolStripMenuItem"; + this.copyRGBValueToolStripMenuItem.Size = new System.Drawing.Size(158, 22); + this.copyRGBValueToolStripMenuItem.Text = "Copy RGB Value"; + this.copyRGBValueToolStripMenuItem.Click += new System.EventHandler(this.miCopyRGB_Click); // - // toolStripSeparator1 + // copyRValueToolStripMenuItem // - this.toolStripSeparator1.Name = "toolStripSeparator1"; - this.toolStripSeparator1.Size = new System.Drawing.Size(133, 6); + this.copyRValueToolStripMenuItem.Name = "copyRValueToolStripMenuItem"; + this.copyRValueToolStripMenuItem.Size = new System.Drawing.Size(158, 22); + this.copyRValueToolStripMenuItem.Text = "Copy R Value"; + this.copyRValueToolStripMenuItem.Click += new System.EventHandler(this.miCopyR_Click); // - // miCopyR + // copyGValueToolStripMenuItem // - this.miCopyR.Name = "miCopyR"; - this.miCopyR.Size = new System.Drawing.Size(136, 22); - this.miCopyR.Text = "Copy Red"; - this.miCopyR.Click += new System.EventHandler(this.miCopyR_Click); + this.copyGValueToolStripMenuItem.Name = "copyGValueToolStripMenuItem"; + this.copyGValueToolStripMenuItem.Size = new System.Drawing.Size(158, 22); + this.copyGValueToolStripMenuItem.Text = "Copy G Value"; + this.copyGValueToolStripMenuItem.Click += new System.EventHandler(this.miCopyG_Click); // - // miCopyG + // copyBValueToolStripMenuItem // - this.miCopyG.Name = "miCopyG"; - this.miCopyG.Size = new System.Drawing.Size(136, 22); - this.miCopyG.Text = "Copy Green"; - this.miCopyG.Click += new System.EventHandler(this.miCopyG_Click); - // - // miCopyB - // - this.miCopyB.Name = "miCopyB"; - this.miCopyB.Size = new System.Drawing.Size(136, 22); - this.miCopyB.Text = "Copy Blue"; - this.miCopyB.Click += new System.EventHandler(this.miCopyB_Click); + this.copyBValueToolStripMenuItem.Name = "copyBValueToolStripMenuItem"; + this.copyBValueToolStripMenuItem.Size = new System.Drawing.Size(158, 22); + this.copyBValueToolStripMenuItem.Text = "Copy B Value"; + this.copyBValueToolStripMenuItem.Click += new System.EventHandler(this.miCopyB_Click); // // ilColors // @@ -230,7 +238,7 @@ private void InitializeComponent() // // lbInfo // - this.lbInfo.Location = new System.Drawing.Point(147, 215); + this.lbInfo.Location = new System.Drawing.Point(147, 236); this.lbInfo.Name = "lbInfo"; this.lbInfo.Size = new System.Drawing.Size(257, 31); this.lbInfo.TabIndex = 12; @@ -239,28 +247,30 @@ private void InitializeComponent() // rbRGB // this.rbRGB.AutoSize = true; - this.rbRGB.Location = new System.Drawing.Point(236, 227); + this.rbRGB.Location = new System.Drawing.Point(236, 248); this.rbRGB.Name = "rbRGB"; this.rbRGB.Size = new System.Drawing.Size(48, 17); this.rbRGB.TabIndex = 13; this.rbRGB.Text = "RGB"; this.rbRGB.UseVisualStyleBackColor = true; + this.rbRGB.CheckedChanged += new System.EventHandler(this.rbRGB_CheckedChanged); // // rbHEX // this.rbHEX.AutoSize = true; this.rbHEX.Checked = true; - this.rbHEX.Location = new System.Drawing.Point(290, 227); + this.rbHEX.Location = new System.Drawing.Point(290, 248); this.rbHEX.Name = "rbHEX"; this.rbHEX.Size = new System.Drawing.Size(47, 17); this.rbHEX.TabIndex = 14; this.rbHEX.TabStop = true; this.rbHEX.Text = "HEX"; this.rbHEX.UseVisualStyleBackColor = true; + this.rbHEX.CheckedChanged += new System.EventHandler(this.rbHEX_CheckedChanged); // // label4 // - this.label4.Location = new System.Drawing.Point(147, 251); + this.label4.Location = new System.Drawing.Point(147, 269); this.label4.Name = "label4"; this.label4.Size = new System.Drawing.Size(257, 31); this.label4.TabIndex = 15; @@ -271,30 +281,134 @@ private void InitializeComponent() this.cbRGB.AutoSize = true; this.cbRGB.Checked = true; this.cbRGB.CheckState = System.Windows.Forms.CheckState.Checked; - this.cbRGB.Location = new System.Drawing.Point(236, 264); + this.cbRGB.Location = new System.Drawing.Point(236, 284); this.cbRGB.Name = "cbRGB"; this.cbRGB.Size = new System.Drawing.Size(49, 17); this.cbRGB.TabIndex = 16; this.cbRGB.Text = "RGB"; this.cbRGB.UseVisualStyleBackColor = true; + this.cbRGB.CheckedChanged += new System.EventHandler(this.cbRGB_CheckedChanged); // // cbHEX // this.cbHEX.AutoSize = true; this.cbHEX.Checked = true; this.cbHEX.CheckState = System.Windows.Forms.CheckState.Checked; - this.cbHEX.Location = new System.Drawing.Point(290, 264); + this.cbHEX.Location = new System.Drawing.Point(290, 284); this.cbHEX.Name = "cbHEX"; this.cbHEX.Size = new System.Drawing.Size(48, 17); this.cbHEX.TabIndex = 17; this.cbHEX.Text = "HEX"; this.cbHEX.UseVisualStyleBackColor = true; + this.cbHEX.CheckedChanged += new System.EventHandler(this.cbHEX_CheckedChanged); + // + // copyValueMenuStrip + // + this.copyValueMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.copyToolStripMenuItem}); + this.copyValueMenuStrip.Location = new System.Drawing.Point(0, 0); + this.copyValueMenuStrip.Name = "copyValueMenuStrip"; + this.copyValueMenuStrip.Size = new System.Drawing.Size(416, 24); + this.copyValueMenuStrip.TabIndex = 18; + this.copyValueMenuStrip.Text = "menuStrip1"; + // + // copyToolStripMenuItem + // + this.copyToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.copyRGBToolStripMenuItem, + this.copyRGBToolStripMenuItem1, + this.copyRedValueToolStripMenuItem, + this.copyGreenValueToolStripMenuItem, + this.copyBlueValueToolStripMenuItem}); + this.copyToolStripMenuItem.Name = "copyToolStripMenuItem"; + this.copyToolStripMenuItem.Size = new System.Drawing.Size(47, 20); + this.copyToolStripMenuItem.Text = "Copy"; + // + // copyRGBToolStripMenuItem + // + this.copyRGBToolStripMenuItem.Name = "copyRGBToolStripMenuItem"; + this.copyRGBToolStripMenuItem.Size = new System.Drawing.Size(127, 22); + this.copyRGBToolStripMenuItem.Text = "Hex Value"; + this.copyRGBToolStripMenuItem.Click += new System.EventHandler(this.miCopyHEX_Click); + // + // copyRGBToolStripMenuItem1 + // + this.copyRGBToolStripMenuItem1.Name = "copyRGBToolStripMenuItem1"; + this.copyRGBToolStripMenuItem1.Size = new System.Drawing.Size(127, 22); + this.copyRGBToolStripMenuItem1.Text = "RGB Value"; + this.copyRGBToolStripMenuItem1.Click += new System.EventHandler(this.miCopyRGB_Click); + // + // copyRedValueToolStripMenuItem + // + this.copyRedValueToolStripMenuItem.Name = "copyRedValueToolStripMenuItem"; + this.copyRedValueToolStripMenuItem.Size = new System.Drawing.Size(127, 22); + this.copyRedValueToolStripMenuItem.Text = "R Value"; + this.copyRedValueToolStripMenuItem.Click += new System.EventHandler(this.miCopyR_Click); + // + // copyGreenValueToolStripMenuItem + // + this.copyGreenValueToolStripMenuItem.Name = "copyGreenValueToolStripMenuItem"; + this.copyGreenValueToolStripMenuItem.Size = new System.Drawing.Size(127, 22); + this.copyGreenValueToolStripMenuItem.Text = "G Value"; + this.copyGreenValueToolStripMenuItem.Click += new System.EventHandler(this.miCopyG_Click); + // + // copyBlueValueToolStripMenuItem + // + this.copyBlueValueToolStripMenuItem.Name = "copyBlueValueToolStripMenuItem"; + this.copyBlueValueToolStripMenuItem.Size = new System.Drawing.Size(127, 22); + this.copyBlueValueToolStripMenuItem.Text = "B Value"; + this.copyBlueValueToolStripMenuItem.Click += new System.EventHandler(this.miCopyB_Click); + // + // lblUpdateSpeed + // + this.lblUpdateSpeed.AutoSize = true; + this.lblUpdateSpeed.Location = new System.Drawing.Point(38, 237); + this.lblUpdateSpeed.Name = "lblUpdateSpeed"; + this.lblUpdateSpeed.Size = new System.Drawing.Size(76, 13); + this.lblUpdateSpeed.TabIndex = 19; + this.lblUpdateSpeed.Text = "Update Speed"; + // + // tbrUpdateSpeed + // + this.tbrUpdateSpeed.LargeChange = 10; + this.tbrUpdateSpeed.Location = new System.Drawing.Point(23, 255); + this.tbrUpdateSpeed.Maximum = 99; + this.tbrUpdateSpeed.Minimum = 1; + this.tbrUpdateSpeed.Name = "tbrUpdateSpeed"; + this.tbrUpdateSpeed.Size = new System.Drawing.Size(104, 45); + this.tbrUpdateSpeed.TabIndex = 20; + this.tbrUpdateSpeed.TickFrequency = 10; + this.tbrUpdateSpeed.Value = 1; + this.tbrUpdateSpeed.Scroll += new System.EventHandler(this.tbrUpdateSpeed_Scroll); + // + // lblSlow + // + this.lblSlow.AutoSize = true; + this.lblSlow.Location = new System.Drawing.Point(22, 284); + this.lblSlow.Name = "lblSlow"; + this.lblSlow.Size = new System.Drawing.Size(30, 13); + this.lblSlow.TabIndex = 21; + this.lblSlow.Text = "Slow"; + // + // lblFast + // + this.lblFast.AutoSize = true; + this.lblFast.Location = new System.Drawing.Point(100, 284); + this.lblFast.Name = "lblFast"; + this.lblFast.Size = new System.Drawing.Size(27, 13); + this.lblFast.TabIndex = 22; + this.lblFast.Text = "Fast"; // // fmMain // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(416, 292); + this.ClientSize = new System.Drawing.Size(416, 305); + this.Controls.Add(this.lblFast); + this.Controls.Add(this.lblSlow); + this.Controls.Add(this.tbrUpdateSpeed); + this.Controls.Add(this.lblUpdateSpeed); + this.Controls.Add(this.copyValueMenuStrip); this.Controls.Add(this.cbHEX); this.Controls.Add(this.cbRGB); this.Controls.Add(this.label4); @@ -312,13 +426,18 @@ private void InitializeComponent() this.Controls.Add(this.pbArea); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); + this.MainMenuStrip = this.copyValueMenuStrip; this.MaximizeBox = false; this.Name = "fmMain"; this.Text = "Digital Color Meter"; + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.fmMain_FormClosing); this.Load += new System.EventHandler(this.fmMain_Load); ((System.ComponentModel.ISupportInitialize)(this.pbArea)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.pbColor)).EndInit(); - this.cmColorsPopup.ResumeLayout(false); + this.copyValueContextMenuStrip.ResumeLayout(false); + this.copyValueMenuStrip.ResumeLayout(false); + this.copyValueMenuStrip.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.tbrUpdateSpeed)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); @@ -339,19 +458,29 @@ private void InitializeComponent() private System.Windows.Forms.ColumnHeader chColor; private System.Windows.Forms.ColumnHeader chRGB; private System.Windows.Forms.Label lbInfo; - private System.Windows.Forms.ContextMenuStrip cmColorsPopup; - private System.Windows.Forms.ToolStripMenuItem miCopyRGB; - private System.Windows.Forms.ToolStripMenuItem miCopyR; - private System.Windows.Forms.ToolStripMenuItem miCopyG; - private System.Windows.Forms.ToolStripMenuItem miCopyB; private System.Windows.Forms.ImageList ilColors; private System.Windows.Forms.RadioButton rbRGB; private System.Windows.Forms.RadioButton rbHEX; private System.Windows.Forms.ColumnHeader chHEX; - private System.Windows.Forms.ToolStripMenuItem miCopyHEX; - private System.Windows.Forms.ToolStripSeparator toolStripSeparator1; private System.Windows.Forms.Label label4; private System.Windows.Forms.CheckBox cbRGB; private System.Windows.Forms.CheckBox cbHEX; + private System.Windows.Forms.MenuStrip copyValueMenuStrip; + private System.Windows.Forms.ToolStripMenuItem copyToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem copyRGBToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem copyRGBToolStripMenuItem1; + private System.Windows.Forms.ToolStripMenuItem copyRedValueToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem copyBlueValueToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem copyGreenValueToolStripMenuItem; + private System.Windows.Forms.Label lblUpdateSpeed; + private System.Windows.Forms.TrackBar tbrUpdateSpeed; + private System.Windows.Forms.Label lblSlow; + private System.Windows.Forms.Label lblFast; + private System.Windows.Forms.ContextMenuStrip copyValueContextMenuStrip; + private System.Windows.Forms.ToolStripMenuItem copyHexToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem copyRGBValueToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem copyRValueToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem copyGValueToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem copyBValueToolStripMenuItem; } } \ No newline at end of file diff --git a/fmMain.cs b/fmMain.cs index 07804da..c2b97de 100644 --- a/fmMain.cs +++ b/fmMain.cs @@ -25,6 +25,9 @@ public struct POINT { [DllImport("gdi32.dll")] public static extern uint GetPixel(IntPtr hdc, int nXPos, int nYPos); + readonly Bitmap output = new Bitmap(133, 133, PixelFormat.Format32bppArgb); + Color color; + public fmMain() { InitializeComponent(); } @@ -33,28 +36,39 @@ public fmMain() { /// Form load and initialization. /// private void fmMain_Load(object sender, EventArgs e) { - this.KeyDown += fmMain_KeyDown; - this.lvColors.KeyDown += fmMain_KeyDown; - this.tbRed.KeyDown += fmMain_KeyDown; - this.tbGreen.KeyDown += fmMain_KeyDown; - this.tbBlue.KeyDown += fmMain_KeyDown; - this.rbRGB.KeyDown += fmMain_KeyDown; - this.rbHEX.KeyDown += fmMain_KeyDown; - this.cbRGB.KeyDown += fmMain_KeyDown; - this.cbHEX.KeyDown += fmMain_KeyDown; + tbrUpdateSpeed.Value = Properties.Settings.Default.UpdateSpeedValue; + rbRGB.Checked = Properties.Settings.Default.SaveColorRGBChecked; + rbHEX.Checked = Properties.Settings.Default.SaveColorHEXChecked; + cbRGB.Checked = Properties.Settings.Default.CopyColorListRGBChecked; + cbHEX.Checked = Properties.Settings.Default.CopyColorListHEXChecked; + trRefresh.Interval = 100 - tbrUpdateSpeed.Value; + + KeyDown += fmMain_KeyDown; + lvColors.KeyDown += fmMain_KeyDown; + tbRed.KeyDown += fmMain_KeyDown; + tbGreen.KeyDown += fmMain_KeyDown; + tbBlue.KeyDown += fmMain_KeyDown; + rbRGB.KeyDown += fmMain_KeyDown; + rbHEX.KeyDown += fmMain_KeyDown; + cbRGB.KeyDown += fmMain_KeyDown; + cbHEX.KeyDown += fmMain_KeyDown; + } + + /// + /// Form closing + /// + private void fmMain_FormClosing(object sender, FormClosingEventArgs e) + { + Properties.Settings.Default.Save(); } /// /// Key shortcut handler. /// private void fmMain_KeyDown(object sender, KeyEventArgs e) { - int r; - int g; - int b; - - int.TryParse(this.tbRed.Text, out r); - int.TryParse(this.tbGreen.Text, out g); - int.TryParse(this.tbBlue.Text, out b); + int.TryParse(tbRed.Text, out int r); + int.TryParse(tbGreen.Text, out int g); + int.TryParse(tbBlue.Text, out int b); var rgb = r + "," + @@ -76,28 +90,32 @@ private void fmMain_KeyDown(object sender, KeyEventArgs e) { hex }); - var bitmap = new Bitmap(16, 16); - var gfx = Graphics.FromImage(bitmap); - var brush = new SolidBrush(Color.FromArgb(r, g, b)); + using (Bitmap bitmap = new Bitmap(16, 16)) + { + using (Graphics gfx = Graphics.FromImage(bitmap)) + { + var brush = new SolidBrush(Color.FromArgb(r, g, b)); - gfx.FillRectangle( - brush, - 0, 0, - 15, 15); + gfx.FillRectangle( + brush, + 0, 0, + 15, 15); - this.ilColors.Images.Add(bitmap); - item.ImageIndex = this.ilColors.Images.Count - 1; + ilColors.Images.Add(bitmap); + item.ImageIndex = ilColors.Images.Count - 1; - this.lvColors.Items.Add(item); + lvColors.Items.Add(item); + } + } } // Copy the RGB value to clipboard directly. else if (e.Control && e.KeyCode == Keys.C) { - if (this.rbRGB.Checked) { + if (rbRGB.Checked) { Clipboard.SetText(rgb); } - else if (this.rbHEX.Checked) { + else if (rbHEX.Checked) { Clipboard.SetText(hex); } } @@ -106,17 +124,17 @@ private void fmMain_KeyDown(object sender, KeyEventArgs e) { e.KeyCode == Keys.L) { var list = string.Empty; - foreach (ListViewItem item in this.lvColors.Items) { - if (this.cbRGB.Checked) { + foreach (ListViewItem item in lvColors.Items) { + if (cbRGB.Checked) { list += item.SubItems[1].Text; } - if (this.cbRGB.Checked && - this.cbHEX.Checked) { + if (cbRGB.Checked && + cbHEX.Checked) { list += "\t"; } - if (this.cbHEX.Checked) { + if (cbHEX.Checked) { list += item.SubItems[2].Text; } @@ -131,90 +149,97 @@ private void fmMain_KeyDown(object sender, KeyEventArgs e) { /// Refreshes the zoomed in area. /// private void refreshArea() { - POINT mousePos; - GetCursorPos(out mousePos); - - var snapshot = new Bitmap(33, 33, PixelFormat.Format32bppArgb); - var output = new Bitmap(133, 133); - var gfx = Graphics.FromImage(snapshot); - var rx = 0; - - gfx.CopyFromScreen( - mousePos.X - 16, - mousePos.Y - 16, - 0, - 0, - new Size(33, 33), - CopyPixelOperation.SourceCopy); - - for (var x = 0; x < 33; x++) { - var ry = 0; - - for (var y = 0; y < 33; y++) { - var color = snapshot.GetPixel(x, y); - - for (var rxs = rx; rxs < (rx + 5); rxs++) { - for (var rys = ry; rys < (ry + 5); rys++) { - output.SetPixel(rxs, rys, color); + GetCursorPos(out POINT mousePos); + + using (Bitmap snapshot = new Bitmap(33, 33, PixelFormat.Format32bppArgb)) + { + using (Graphics gfx = Graphics.FromImage(snapshot)) + { + var rx = 0; + + gfx.CopyFromScreen( + mousePos.X - 16, + mousePos.Y - 16, + 0, + 0, + new Size(33, 33), + CopyPixelOperation.SourceCopy); + + for (var x = 0; x < 33; x++) + { + var ry = 0; + + for (var y = 0; y < 33; y++) + { + color = snapshot.GetPixel(x, y); + + for (var rxs = rx; rxs < (rx + 5); rxs++) + { + for (var rys = ry; rys < (ry + 5); rys++) + { + output.SetPixel(rxs, rys, color); + } + } + + ry += 4; } - } - ry += 4; - } + rx += 4; + } - rx += 4; - } + // Black square in the center of the aperture + for (var c = 63; c < 70; c++) + { + output.SetPixel(c, 63, Color.Black); + output.SetPixel(c, 69, Color.Black); - for (var c = 63; c < 70; c++) { - output.SetPixel(c, 63, Color.Black); - output.SetPixel(c, 69, Color.Black); + output.SetPixel(63, c, Color.Black); + output.SetPixel(69, c, Color.Black); + } - output.SetPixel(63, c, Color.Black); - output.SetPixel(69, c, Color.Black); + pbArea.Image = output; + } } - - this.pbArea.Image = output; } /// /// Refresh the single color block and RGB values. /// private void refreshSinglePixel() { - POINT mousePos; - GetCursorPos(out mousePos); + GetCursorPos(out POINT mousePos); var hdc = GetDC(IntPtr.Zero); var pixel = GetPixel(hdc, mousePos.X, mousePos.Y); ReleaseDC(IntPtr.Zero, hdc); - var color = Color.FromArgb( + color = Color.FromArgb( (int) (pixel & 0x000000FF), (int) (pixel & 0x0000FF00) >> 8, (int) (pixel & 0x00FF0000) >> 16); - this.pbColor.BackColor = color; + pbColor.BackColor = color; - this.tbRed.Text = color.R.ToString(CultureInfo.InvariantCulture); - this.tbGreen.Text = color.G.ToString(CultureInfo.InvariantCulture); - this.tbBlue.Text = color.B.ToString(CultureInfo.InvariantCulture); + tbRed.Text = color.R.ToString(CultureInfo.InvariantCulture); + tbGreen.Text = color.G.ToString(CultureInfo.InvariantCulture); + tbBlue.Text = color.B.ToString(CultureInfo.InvariantCulture); } /// /// Refresh ticker which forces the UI to update the color under the mouse pointer. /// private void trRefresh_Tick(object sender, EventArgs e) { - this.refreshArea(); - this.refreshSinglePixel(); + refreshArea(); + refreshSinglePixel(); } /// /// Copies the HEX value of the selected color to clipboard. /// private void miCopyHEX_Click(object sender, EventArgs e) { - if (this.lvColors.SelectedItems.Count > 0) { + if (lvColors.SelectedItems.Count > 0) { Clipboard.SetText( - this.lvColors.SelectedItems[0].SubItems[2].Text); + lvColors.SelectedItems[0].SubItems[2].Text); } } @@ -222,9 +247,9 @@ private void miCopyHEX_Click(object sender, EventArgs e) { /// Copies the RGB value of the selected color to clipboard. /// private void miCopyRGB_Click(object sender, EventArgs e) { - if (this.lvColors.SelectedItems.Count > 0) { + if (lvColors.SelectedItems.Count > 0) { Clipboard.SetText( - this.lvColors.SelectedItems[0].SubItems[1].Text); + lvColors.SelectedItems[0].SubItems[1].Text); } } @@ -232,11 +257,11 @@ private void miCopyRGB_Click(object sender, EventArgs e) { /// Copies the red RGB value of the selected color to clipboard. /// private void miCopyR_Click(object sender, EventArgs e) { - if (this.lvColors.SelectedItems.Count <= 0) { + if (lvColors.SelectedItems.Count <= 0) { return; } - var colors = this.lvColors.SelectedItems[0].SubItems[1].Text.Split(','); + var colors = lvColors.SelectedItems[0].SubItems[1].Text.Split(','); Clipboard.SetText(colors[0]); } @@ -244,11 +269,11 @@ private void miCopyR_Click(object sender, EventArgs e) { /// Copies the green RGB value of the selected color to clipboard. /// private void miCopyG_Click(object sender, EventArgs e) { - if (this.lvColors.SelectedItems.Count <= 0) { + if (lvColors.SelectedItems.Count <= 0) { return; } - var colors = this.lvColors.SelectedItems[0].SubItems[1].Text.Split(','); + var colors = lvColors.SelectedItems[0].SubItems[1].Text.Split(','); Clipboard.SetText(colors[1]); } @@ -256,12 +281,40 @@ private void miCopyG_Click(object sender, EventArgs e) { /// Copies the blue RGB value of the selected color to clipboard. /// private void miCopyB_Click(object sender, EventArgs e) { - if (this.lvColors.SelectedItems.Count <= 0) { + if (lvColors.SelectedItems.Count <= 0) { return; } - var colors = this.lvColors.SelectedItems[0].SubItems[1].Text.Split(','); + var colors = lvColors.SelectedItems[0].SubItems[1].Text.Split(','); Clipboard.SetText(colors[2]); } + + private void tbrUpdateSpeed_Scroll(object sender, EventArgs e) + { + Properties.Settings.Default.UpdateSpeedValue = tbrUpdateSpeed.Value; + trRefresh.Interval = 100 - Properties.Settings.Default.UpdateSpeedValue; + } + + private void rbRGB_CheckedChanged(object sender, EventArgs e) + { + Properties.Settings.Default.SaveColorRGBChecked = rbRGB.Checked; + Properties.Settings.Default.SaveColorHEXChecked = !rbRGB.Checked; + } + + private void rbHEX_CheckedChanged(object sender, EventArgs e) + { + Properties.Settings.Default.SaveColorRGBChecked = !rbHEX.Checked; + Properties.Settings.Default.SaveColorHEXChecked = rbHEX.Checked; + } + + private void cbRGB_CheckedChanged(object sender, EventArgs e) + { + Properties.Settings.Default.CopyColorListRGBChecked = cbRGB.Checked; + } + + private void cbHEX_CheckedChanged(object sender, EventArgs e) + { + Properties.Settings.Default.CopyColorListHEXChecked = cbHEX.Checked; + } } } \ No newline at end of file diff --git a/fmMain.resx b/fmMain.resx index 7bfaf81..2840aa7 100644 --- a/fmMain.resx +++ b/fmMain.resx @@ -120,11 +120,14 @@ 17, 17 - - 118, 17 + + 357, 18 - 256, 17 + 108, 16 + + + 194, 18