mirror of
https://github.com/greenshot/greenshot.git
synced 2025-03-12 05:25:25 -07:00
Added a color picker, a modified Patch #3487158. Still needs some additional checks, if all resources are correctly freed etc.
git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@1654 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
parent
0f65452e6c
commit
63f71138cf
162
Greenshot/Controls/Dropper.cs
Normal file
162
Greenshot/Controls/Dropper.cs
Normal file
@ -0,0 +1,162 @@
|
||||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2012 Thomas Braun, Jens Klingen, Robin Krom
|
||||
*
|
||||
* For more information see: http://getgreenshot.org/
|
||||
* The Greenshot project is hosted on Sourceforge: http://sourceforge.net/projects/greenshot/
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 1 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using Greenshot.Plugin;
|
||||
using Greenshot.Forms;
|
||||
using System.Drawing;
|
||||
using GreenshotPlugin.UnmanagedHelpers;
|
||||
|
||||
namespace Greenshot.Controls {
|
||||
/// <summary>
|
||||
/// This code was supplied by Hi-Coder as a patch for Greenshot
|
||||
/// Needed some modifications to be stable.
|
||||
/// </summary>
|
||||
public class Dropper : Label, IMessageFilter, IDisposable {
|
||||
private Zoomer zoomer;
|
||||
private bool dragging;
|
||||
private Cursor _cursor;
|
||||
private Bitmap _image;
|
||||
private const int VK_ESC = 27;
|
||||
|
||||
public event EventHandler<DropperUsedArgs> DropperUsed;
|
||||
|
||||
public Dropper() {
|
||||
BorderStyle = BorderStyle.FixedSingle;
|
||||
dragging = false;
|
||||
_image = (Bitmap)new System.ComponentModel.ComponentResourceManager(typeof(ColorDialog)).GetObject("dropper.Image");
|
||||
_cursor = CreateCursor((Bitmap)_image, 0, 15);
|
||||
zoomer = new Zoomer();
|
||||
zoomer.Visible = false;
|
||||
Application.AddMessageFilter(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
~Dropper() {
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
// The bulk of the clean-up code is implemented in Dispose(bool)
|
||||
|
||||
/**
|
||||
* This Dispose is called from the Dispose and the Destructor.
|
||||
* When disposing==true all non-managed resources should be freed too!
|
||||
*/
|
||||
protected override void Dispose(bool disposing) {
|
||||
base.Dispose();
|
||||
if (disposing) {
|
||||
if (_cursor != null) {
|
||||
_cursor.Dispose();
|
||||
}
|
||||
if (zoomer != null) {
|
||||
zoomer.Dispose();
|
||||
}
|
||||
}
|
||||
zoomer = null;
|
||||
_cursor = null;
|
||||
}
|
||||
|
||||
protected override void OnMouseDown(MouseEventArgs e) {
|
||||
if (e.Button == MouseButtons.Left) {
|
||||
User32.SetCapture(this.Handle);
|
||||
zoomer.setHotSpot(PointToScreen(new Point(e.X, e.Y)));
|
||||
}
|
||||
base.OnMouseDown(e);
|
||||
}
|
||||
|
||||
protected override void OnMouseUp(MouseEventArgs e) {
|
||||
if (e.Button == MouseButtons.Left) {
|
||||
//Release Capture should consume MouseUp when canceled with the escape key
|
||||
User32.ReleaseCapture();
|
||||
DropperUsed(this, new DropperUsedArgs(zoomer.color));
|
||||
}
|
||||
base.OnMouseUp(e);
|
||||
}
|
||||
|
||||
protected override void OnMouseMove(MouseEventArgs e) {
|
||||
if (dragging) {
|
||||
//display the form on the right side of the cursor by default;
|
||||
Point zp = PointToScreen(new Point(e.X, e.Y));
|
||||
zoomer.setHotSpot(zp);
|
||||
}
|
||||
base.OnMouseMove(e);
|
||||
}
|
||||
|
||||
private Cursor CreateCursor(Bitmap bitmap, int x, int y) {
|
||||
IntPtr iconHandle = bitmap.GetHicon();
|
||||
IntPtr icon;
|
||||
IconInfo iconInfo = new IconInfo();
|
||||
User32.GetIconInfo(iconHandle, out iconInfo);
|
||||
iconInfo.xHotspot = 0;
|
||||
iconInfo.yHotspot = 15;
|
||||
iconInfo.fIcon = false;
|
||||
icon = User32.CreateIconIndirect(ref iconInfo);
|
||||
Cursor returnCursor = new Cursor(icon);
|
||||
//User32.DestroyIcon(icon);
|
||||
User32.DestroyIcon(iconHandle);
|
||||
return returnCursor;
|
||||
}
|
||||
|
||||
protected override void OnMouseCaptureChanged(EventArgs e) {
|
||||
if (this.Capture) {
|
||||
dragging = true;
|
||||
Image = null;
|
||||
Cursor c = _cursor;
|
||||
Cursor = c;
|
||||
zoomer.Visible = true;
|
||||
} else {
|
||||
dragging = false;
|
||||
|
||||
Image = _image;
|
||||
Cursor = Cursors.Arrow;
|
||||
zoomer.Visible = false;
|
||||
}
|
||||
base.OnMouseCaptureChanged(e);
|
||||
}
|
||||
|
||||
#region IMessageFilter Members
|
||||
|
||||
public bool PreFilterMessage(ref Message m) {
|
||||
if (dragging) {
|
||||
if (m.Msg == (int)WindowsMessages.WM_CHAR) {
|
||||
if ((int)m.WParam == VK_ESC) {
|
||||
User32.ReleaseCapture();
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
public class DropperUsedArgs : EventArgs {
|
||||
public Color color;
|
||||
|
||||
public DropperUsedArgs(Color c) {
|
||||
color = c;
|
||||
}
|
||||
}
|
||||
}
|
20
Greenshot/Forms/ColorDialog.Designer.cs
generated
20
Greenshot/Forms/ColorDialog.Designer.cs
generated
@ -46,6 +46,7 @@ namespace Greenshot {
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ColorDialog));
|
||||
this.btnTransparent = new System.Windows.Forms.Button();
|
||||
this.colorPanel = new System.Windows.Forms.Panel();
|
||||
this.labelHtmlColor = new System.Windows.Forms.Label();
|
||||
@ -60,6 +61,7 @@ namespace Greenshot {
|
||||
this.textBoxAlpha = new System.Windows.Forms.TextBox();
|
||||
this.labelAlpha = new System.Windows.Forms.Label();
|
||||
this.btnApply = new System.Windows.Forms.Button();
|
||||
this.dropper = new Greenshot.Controls.Dropper();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// btnTransparent
|
||||
@ -77,9 +79,9 @@ namespace Greenshot {
|
||||
// colorPanel
|
||||
//
|
||||
this.colorPanel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
this.colorPanel.Location = new System.Drawing.Point(210, 31);
|
||||
this.colorPanel.Location = new System.Drawing.Point(213, 30);
|
||||
this.colorPanel.Name = "colorPanel";
|
||||
this.colorPanel.Size = new System.Drawing.Size(78, 23);
|
||||
this.colorPanel.Size = new System.Drawing.Size(33, 23);
|
||||
this.colorPanel.TabIndex = 1;
|
||||
//
|
||||
// labelHtmlColor
|
||||
@ -206,11 +208,23 @@ namespace Greenshot {
|
||||
this.btnApply.UseVisualStyleBackColor = false;
|
||||
this.btnApply.Click += new System.EventHandler(this.BtnApplyClick);
|
||||
//
|
||||
// dropper
|
||||
//
|
||||
this.dropper.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
this.dropper.Cursor = System.Windows.Forms.Cursors.Arrow;
|
||||
this.dropper.Image = ((System.Drawing.Image)(resources.GetObject("dropper.Image")));
|
||||
this.dropper.Location = new System.Drawing.Point(255, 30);
|
||||
this.dropper.Name = "dropper";
|
||||
this.dropper.Size = new System.Drawing.Size(33, 23);
|
||||
this.dropper.TabIndex = 13;
|
||||
this.dropper.DropperUsed += new System.EventHandler<Greenshot.Controls.DropperUsedArgs>(this.dropperUsed);
|
||||
//
|
||||
// ColorDialog
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
|
||||
this.ClientSize = new System.Drawing.Size(292, 218);
|
||||
this.Controls.Add(this.dropper);
|
||||
this.Controls.Add(this.btnApply);
|
||||
this.Controls.Add(this.textBoxAlpha);
|
||||
this.Controls.Add(this.labelAlpha);
|
||||
@ -235,6 +249,7 @@ namespace Greenshot {
|
||||
this.Text = "TestProject";
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
private System.Windows.Forms.Label labelRed;
|
||||
private System.Windows.Forms.Label labelGreen;
|
||||
@ -250,6 +265,7 @@ namespace Greenshot {
|
||||
private System.Windows.Forms.TextBox textBoxBlue;
|
||||
private System.Windows.Forms.Panel colorPanel;
|
||||
private System.Windows.Forms.Button btnTransparent;
|
||||
private Greenshot.Controls.Dropper dropper;
|
||||
|
||||
|
||||
|
||||
|
@ -234,5 +234,9 @@ namespace Greenshot {
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private void dropperUsed(object sender, Greenshot.Controls.DropperUsedArgs e) {
|
||||
this.Color = e.color;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
135
Greenshot/Forms/ColorDialog.resx
Normal file
135
Greenshot/Forms/ColorDialog.resx
Normal file
@ -0,0 +1,135 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<assembly alias="System.Drawing" name="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
|
||||
<data name="dropper.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>
|
||||
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
|
||||
YQUAAAAZdEVYdFNvZnR3YXJlAEFkb2JlIEltYWdlUmVhZHlxyWU8AAABqklEQVQ4T6WTvUtCURiH34Mi
|
||||
Koo6CKI45HUT/4CgDwz8oMVFXLyGIVpDjTYkuDsoF6RPmtJKkIgKipYsCIoQihYXKxSCICjaGoTTe6R7
|
||||
uflBgcOPwz3wPL/3HM4FSikMkw6sVCphHPNCSE9auPf8kydCJuqEHNYIOakSMsXYjiClUPSFmVAUiHBb
|
||||
EOh7KkWPAC4lQb9mcY8J5HAzGKSP4TDdBrj+SzCGkkqTkHk2NmuWw+sAfklQBYDunAPUaLlMG4Qc9INX
|
||||
kZEERa8Xdvx+2A0EpJR8Pv4UJe1CoaeZwb8E2WwWcrkcCILQST6fd2YymeRS6SG9j5JGKEQ3AW7XAJZF
|
||||
eKBAhN8+v+p7V61jJimi5AMvbgVXDIiRjiBO0A2f3b9uud3u5IzRyOMEDA4MFKCES6fTCbGZwS6XK2G3
|
||||
250RvR42ZM09E/A8D/F4PCaHOY6LWSwWzmq1wp8Cj8fjiMzOLbAzs2YEeZPJ5DCbzfAvgc1mi7L20Unv
|
||||
ok6ni2q12hGDwQCDBEV8nRWMdIkajWZapVLFMZxarQb8hn6CMkI3mDvMhVwwzO/8DbWQqn7YBXReAAAA
|
||||
AElFTkSuQmCC
|
||||
</value>
|
||||
</data>
|
||||
</root>
|
188
Greenshot/Forms/Zoomer.Designer.cs
generated
Normal file
188
Greenshot/Forms/Zoomer.Designer.cs
generated
Normal file
@ -0,0 +1,188 @@
|
||||
namespace Greenshot.Forms
|
||||
{
|
||||
partial class Zoomer
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.panel1 = new System.Windows.Forms.Panel();
|
||||
this.html = new System.Windows.Forms.Label();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.preview = new System.Windows.Forms.Label();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this.red = new System.Windows.Forms.Label();
|
||||
this.green = new System.Windows.Forms.Label();
|
||||
this.label4 = new System.Windows.Forms.Label();
|
||||
this.blue = new System.Windows.Forms.Label();
|
||||
this.label6 = new System.Windows.Forms.Label();
|
||||
this.alpha = new System.Windows.Forms.Label();
|
||||
this.label5 = new System.Windows.Forms.Label();
|
||||
this.panel1.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// panel1
|
||||
//
|
||||
this.panel1.BackColor = System.Drawing.SystemColors.Info;
|
||||
this.panel1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
this.panel1.Controls.Add(this.alpha);
|
||||
this.panel1.Controls.Add(this.label5);
|
||||
this.panel1.Controls.Add(this.blue);
|
||||
this.panel1.Controls.Add(this.label6);
|
||||
this.panel1.Controls.Add(this.green);
|
||||
this.panel1.Controls.Add(this.label4);
|
||||
this.panel1.Controls.Add(this.red);
|
||||
this.panel1.Controls.Add(this.label2);
|
||||
this.panel1.Controls.Add(this.html);
|
||||
this.panel1.Controls.Add(this.label1);
|
||||
this.panel1.Controls.Add(this.preview);
|
||||
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(100, 100);
|
||||
this.panel1.TabIndex = 0;
|
||||
//
|
||||
// html
|
||||
//
|
||||
this.html.Location = new System.Drawing.Point(40, 18);
|
||||
this.html.Name = "html";
|
||||
this.html.Size = new System.Drawing.Size(59, 19);
|
||||
this.html.TabIndex = 2;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(40, 5);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(37, 13);
|
||||
this.label1.TabIndex = 1;
|
||||
this.label1.Text = "HTML";
|
||||
//
|
||||
// preview
|
||||
//
|
||||
this.preview.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
this.preview.Location = new System.Drawing.Point(5, 5);
|
||||
this.preview.Name = "preview";
|
||||
this.preview.Size = new System.Drawing.Size(32, 32);
|
||||
this.preview.TabIndex = 0;
|
||||
//
|
||||
// label2
|
||||
//
|
||||
this.label2.AutoSize = true;
|
||||
this.label2.Location = new System.Drawing.Point(2, 37);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(33, 13);
|
||||
this.label2.TabIndex = 3;
|
||||
this.label2.Text = "Red: ";
|
||||
//
|
||||
// red
|
||||
//
|
||||
this.red.Location = new System.Drawing.Point(43, 37);
|
||||
this.red.Name = "red";
|
||||
this.red.Size = new System.Drawing.Size(55, 13);
|
||||
this.red.TabIndex = 4;
|
||||
//
|
||||
// green
|
||||
//
|
||||
this.green.Location = new System.Drawing.Point(43, 50);
|
||||
this.green.Name = "green";
|
||||
this.green.Size = new System.Drawing.Size(55, 13);
|
||||
this.green.TabIndex = 6;
|
||||
//
|
||||
// label4
|
||||
//
|
||||
this.label4.AutoSize = true;
|
||||
this.label4.Location = new System.Drawing.Point(2, 50);
|
||||
this.label4.Name = "label4";
|
||||
this.label4.Size = new System.Drawing.Size(42, 13);
|
||||
this.label4.TabIndex = 5;
|
||||
this.label4.Text = "Green: ";
|
||||
//
|
||||
// blue
|
||||
//
|
||||
this.blue.Location = new System.Drawing.Point(43, 63);
|
||||
this.blue.Name = "blue";
|
||||
this.blue.Size = new System.Drawing.Size(55, 13);
|
||||
this.blue.TabIndex = 8;
|
||||
//
|
||||
// label6
|
||||
//
|
||||
this.label6.AutoSize = true;
|
||||
this.label6.Location = new System.Drawing.Point(2, 63);
|
||||
this.label6.Name = "label6";
|
||||
this.label6.Size = new System.Drawing.Size(34, 13);
|
||||
this.label6.TabIndex = 7;
|
||||
this.label6.Text = "Blue: ";
|
||||
//
|
||||
// alpha
|
||||
//
|
||||
this.alpha.Location = new System.Drawing.Point(43, 76);
|
||||
this.alpha.Name = "alpha";
|
||||
this.alpha.Size = new System.Drawing.Size(55, 13);
|
||||
this.alpha.TabIndex = 10;
|
||||
//
|
||||
// label5
|
||||
//
|
||||
this.label5.AutoSize = true;
|
||||
this.label5.Location = new System.Drawing.Point(2, 76);
|
||||
this.label5.Name = "label5";
|
||||
this.label5.Size = new System.Drawing.Size(40, 13);
|
||||
this.label5.TabIndex = 9;
|
||||
this.label5.Text = "Alpha: ";
|
||||
//
|
||||
// Zoomer
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(100, 100);
|
||||
this.Controls.Add(this.panel1);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
|
||||
this.Name = "Zoomer";
|
||||
this.ShowIcon = false;
|
||||
this.ShowInTaskbar = false;
|
||||
this.Text = "Zoomer";
|
||||
this.TopMost = true;
|
||||
this.panel1.ResumeLayout(false);
|
||||
this.panel1.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Panel panel1;
|
||||
private System.Windows.Forms.Label html;
|
||||
private System.Windows.Forms.Label label1;
|
||||
private System.Windows.Forms.Label preview;
|
||||
private System.Windows.Forms.Label alpha;
|
||||
private System.Windows.Forms.Label label5;
|
||||
private System.Windows.Forms.Label blue;
|
||||
private System.Windows.Forms.Label label6;
|
||||
private System.Windows.Forms.Label green;
|
||||
private System.Windows.Forms.Label label4;
|
||||
private System.Windows.Forms.Label red;
|
||||
private System.Windows.Forms.Label label2;
|
||||
}
|
||||
}
|
93
Greenshot/Forms/Zoomer.cs
Normal file
93
Greenshot/Forms/Zoomer.cs
Normal file
@ -0,0 +1,93 @@
|
||||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2012 Thomas Braun, Jens Klingen, Robin Krom
|
||||
*
|
||||
* For more information see: http://getgreenshot.org/
|
||||
* The Greenshot project is hosted on Sourceforge: http://sourceforge.net/projects/greenshot/
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 1 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using System.Drawing;
|
||||
using GreenshotPlugin.UnmanagedHelpers;
|
||||
|
||||
namespace Greenshot.Forms {
|
||||
/// <summary>
|
||||
/// This code was supplied by Hi-Coder as a patch for Greenshot
|
||||
/// Needed some modifications to be stable.
|
||||
/// </summary>
|
||||
public partial class Zoomer : Form {
|
||||
public Color color {
|
||||
get {
|
||||
return preview.BackColor;
|
||||
}
|
||||
}
|
||||
|
||||
public Zoomer() {
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public void setHotSpot(int x, int y) {
|
||||
Color c = GetPixelColor(x, y);
|
||||
preview.BackColor = c;
|
||||
html.Text = "#" + c.Name.Substring(2).ToUpper();
|
||||
red.Text = "" + c.R;
|
||||
blue.Text = "" + c.B;
|
||||
green.Text = "" + c.G;
|
||||
alpha.Text = "" + c.A;
|
||||
|
||||
Size cs = Cursor.Current.Size;
|
||||
Point hs = Cursor.Current.HotSpot;
|
||||
|
||||
Point zp = new Point(x, y);
|
||||
zp.X += cs.Width + 2 - hs.X;
|
||||
zp.Y -= hs.Y;
|
||||
|
||||
if (zp.X < 0) {
|
||||
zp.X = 0;
|
||||
} else if (zp.X + Width > Screen.PrimaryScreen.Bounds.Width) {
|
||||
zp.X = x - Width - 2 - hs.X;
|
||||
}
|
||||
|
||||
if (zp.Y < 0) {
|
||||
zp.Y = 0;
|
||||
} else if (zp.Y + Height > Screen.PrimaryScreen.Bounds.Height) {
|
||||
zp.Y = Screen.PrimaryScreen.Bounds.Height - Height;
|
||||
}
|
||||
|
||||
Location = zp;
|
||||
}
|
||||
|
||||
public void setHotSpot(Point screenCoordinates) {
|
||||
setHotSpot(screenCoordinates.X, screenCoordinates.Y);
|
||||
}
|
||||
|
||||
static private Color GetPixelColor(int x, int y) {
|
||||
IntPtr hdc = User32.GetDC(IntPtr.Zero);
|
||||
try {
|
||||
uint pixel = GDI32.GetPixel(hdc, x, y);
|
||||
Color color = Color.FromArgb(255, (int)(pixel & 0xFF), (int)(pixel & 0xFF00) >> 8, (int)(pixel & 0xFF0000) >> 16);
|
||||
return color;
|
||||
} catch (Exception) {
|
||||
return Color.Empty;
|
||||
} finally {
|
||||
if (hdc != IntPtr.Zero) {
|
||||
User32.ReleaseDC(IntPtr.Zero, hdc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -67,6 +67,7 @@
|
||||
<Compile Include="Controls\ToolStripNumericUpDown.cs" />
|
||||
<Compile Include="Controls\ToolStripEx.cs" />
|
||||
<Compile Include="Controls\MenuStripEx.cs" />
|
||||
<Compile Include="Controls\Dropper.cs" />
|
||||
<Compile Include="Destinations\ClipboardDestination.cs" />
|
||||
<Compile Include="Destinations\EditorDestination.cs" />
|
||||
<Compile Include="Destinations\EmailDestination.cs" />
|
||||
@ -153,6 +154,10 @@
|
||||
<Compile Include="Forms\BugReportForm.Designer.cs">
|
||||
<DependentUpon>BugReportForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Forms\Zoomer.cs" />
|
||||
<Compile Include="Forms\Zoomer.Designer.cs">
|
||||
<DependentUpon>Zoomer.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Helpers\AviHelper.cs" />
|
||||
<Compile Include="Helpers\CaptureHelper.cs" />
|
||||
<Compile Include="Helpers\ClipboardHelper.cs" />
|
||||
@ -217,6 +222,9 @@
|
||||
<Compile Include="Helpers\StartupHelper.cs" />
|
||||
<Compile Include="Helpers\ToolStripItemEndisabler.cs" />
|
||||
<Compile Include="GreenshotMain.cs" />
|
||||
<EmbeddedResource Include="Forms\ColorDialog.resx">
|
||||
<DependentUpon>ColorDialog.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Forms\ImageEditorForm.resx">
|
||||
<DependentUpon>ImageEditorForm.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
|
BIN
Greenshot/icons/pipette.png
Normal file
BIN
Greenshot/icons/pipette.png
Normal file
Binary file not shown.
After ![]() (image error) Size: 543 B |
@ -43,6 +43,8 @@ namespace GreenshotPlugin.UnmanagedHelpers {
|
||||
public static extern IntPtr CreateRectRgn(int nLeftRect, int nTopRect, int nRightRect, int nBottomRect);
|
||||
[DllImport("gdi32", SetLastError=true)]
|
||||
public static extern int GetClipBox(IntPtr hdc, out RECT lprc);
|
||||
[DllImport("gdi32", SetLastError = true)]
|
||||
public static extern uint GetPixel(IntPtr hdc, int nXPos, int nYPos);
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
|
@ -453,6 +453,21 @@ namespace GreenshotPlugin.UnmanagedHelpers {
|
||||
|
||||
[DllImport("user32", SetLastError = true)]
|
||||
public static extern bool DrawIcon(IntPtr hDC, int X, int Y, IntPtr hIcon);
|
||||
|
||||
[DllImport("user32", SetLastError = true)]
|
||||
public static extern IntPtr SetCapture(IntPtr hWnd);
|
||||
|
||||
[DllImport("user32", SetLastError = true)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
public static extern bool ReleaseCapture();
|
||||
|
||||
[DllImport("user32", SetLastError = true)]
|
||||
public static extern int GetSystemMetrics(SystemMetric index);
|
||||
|
||||
[DllImport("user32", SetLastError = true)]
|
||||
public static extern IntPtr CreateIconIndirect(ref IconInfo icon);
|
||||
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user