mirror of
https://github.com/greenshot/greenshot
synced 2025-07-15 09:33:46 -07:00
Fixed update issue with Dropper/Zoomer, now called Pipette and I will rename the zoomer.
git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@1657 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
parent
c1330fb88c
commit
1116ff8a25
8 changed files with 70 additions and 72 deletions
|
@ -32,29 +32,29 @@ namespace Greenshot.Controls {
|
||||||
/// This code was supplied by Hi-Coder as a patch for Greenshot
|
/// This code was supplied by Hi-Coder as a patch for Greenshot
|
||||||
/// Needed some modifications to be stable.
|
/// Needed some modifications to be stable.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class Dropper : Label, IMessageFilter, IDisposable {
|
public class Pipette : Label, IMessageFilter, IDisposable {
|
||||||
private Zoomer zoomer;
|
private Zoomer zoomer;
|
||||||
private bool dragging;
|
private bool dragging;
|
||||||
private Cursor _cursor;
|
private Cursor _cursor;
|
||||||
private Bitmap _image;
|
private Bitmap _image;
|
||||||
private const int VK_ESC = 27;
|
private const int VK_ESC = 27;
|
||||||
|
|
||||||
public event EventHandler<DropperUsedArgs> DropperUsed;
|
public event EventHandler<PipetteUsedArgs> PipetteUsed;
|
||||||
|
|
||||||
public Dropper() {
|
public Pipette() {
|
||||||
BorderStyle = BorderStyle.FixedSingle;
|
BorderStyle = BorderStyle.FixedSingle;
|
||||||
dragging = false;
|
dragging = false;
|
||||||
_image = (Bitmap)new System.ComponentModel.ComponentResourceManager(typeof(ColorDialog)).GetObject("dropper.Image");
|
_image = (Bitmap)new System.ComponentModel.ComponentResourceManager(typeof(ColorDialog)).GetObject("pipette.Image");
|
||||||
|
Image = _image;
|
||||||
_cursor = CreateCursor((Bitmap)_image, 0, 15);
|
_cursor = CreateCursor((Bitmap)_image, 0, 15);
|
||||||
zoomer = new Zoomer();
|
zoomer = new Zoomer();
|
||||||
zoomer.Visible = false;
|
|
||||||
Application.AddMessageFilter(this);
|
Application.AddMessageFilter(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Destructor
|
* Destructor
|
||||||
*/
|
*/
|
||||||
~Dropper() {
|
~Pipette() {
|
||||||
Dispose(false);
|
Dispose(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,7 +90,7 @@ namespace Greenshot.Controls {
|
||||||
if (e.Button == MouseButtons.Left) {
|
if (e.Button == MouseButtons.Left) {
|
||||||
//Release Capture should consume MouseUp when canceled with the escape key
|
//Release Capture should consume MouseUp when canceled with the escape key
|
||||||
User32.ReleaseCapture();
|
User32.ReleaseCapture();
|
||||||
DropperUsed(this, new DropperUsedArgs(zoomer.color));
|
PipetteUsed(this, new PipetteUsedArgs(zoomer.color));
|
||||||
}
|
}
|
||||||
base.OnMouseUp(e);
|
base.OnMouseUp(e);
|
||||||
}
|
}
|
||||||
|
@ -128,11 +128,11 @@ namespace Greenshot.Controls {
|
||||||
zoomer.Visible = true;
|
zoomer.Visible = true;
|
||||||
} else {
|
} else {
|
||||||
dragging = false;
|
dragging = false;
|
||||||
|
|
||||||
Image = _image;
|
Image = _image;
|
||||||
Cursor = Cursors.Arrow;
|
Cursor = Cursors.Arrow;
|
||||||
zoomer.Visible = false;
|
zoomer.Visible = false;
|
||||||
}
|
}
|
||||||
|
Update();
|
||||||
base.OnMouseCaptureChanged(e);
|
base.OnMouseCaptureChanged(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -152,10 +152,10 @@ namespace Greenshot.Controls {
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
||||||
public class DropperUsedArgs : EventArgs {
|
public class PipetteUsedArgs : EventArgs {
|
||||||
public Color color;
|
public Color color;
|
||||||
|
|
||||||
public DropperUsedArgs(Color c) {
|
public PipetteUsedArgs(Color c) {
|
||||||
color = c;
|
color = c;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -557,12 +557,12 @@ namespace Greenshot.Drawing {
|
||||||
switch (effect) {
|
switch (effect) {
|
||||||
case Effects.Shadow:
|
case Effects.Shadow:
|
||||||
offset = new Point(6, 6);
|
offset = new Point(6, 6);
|
||||||
newImage = ImageHelper.CreateShadow((Bitmap)Image, 1f, 7, offset, PixelFormat.Format24bppRgb); //Image.PixelFormat);
|
newImage = ImageHelper.CreateShadow((Bitmap)Image, 1f, 7, offset, PixelFormat.Format32bppRgb); //Image.PixelFormat);
|
||||||
break;
|
break;
|
||||||
case Effects.TornEdge:
|
case Effects.TornEdge:
|
||||||
offset = new Point(5, 5);
|
offset = new Point(5, 5);
|
||||||
using (Bitmap tmpImage = ImageHelper.CreateTornEdge((Bitmap)Image)) {
|
using (Bitmap tmpImage = ImageHelper.CreateTornEdge((Bitmap)Image)) {
|
||||||
newImage = ImageHelper.CreateShadow(tmpImage, 1f, 6, offset, PixelFormat.Format24bppRgb); //Image.PixelFormat);
|
newImage = ImageHelper.CreateShadow(tmpImage, 1f, 6, offset, PixelFormat.Format32bppRgb); //Image.PixelFormat);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Effects.Border:
|
case Effects.Border:
|
||||||
|
|
25
Greenshot/Forms/ColorDialog.Designer.cs
generated
25
Greenshot/Forms/ColorDialog.Designer.cs
generated
|
@ -47,6 +47,7 @@ namespace Greenshot {
|
||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ColorDialog));
|
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ColorDialog));
|
||||||
|
this.SuspendLayout();
|
||||||
this.btnTransparent = new System.Windows.Forms.Button();
|
this.btnTransparent = new System.Windows.Forms.Button();
|
||||||
this.colorPanel = new System.Windows.Forms.Panel();
|
this.colorPanel = new System.Windows.Forms.Panel();
|
||||||
this.labelHtmlColor = new System.Windows.Forms.Label();
|
this.labelHtmlColor = new System.Windows.Forms.Label();
|
||||||
|
@ -61,8 +62,7 @@ namespace Greenshot {
|
||||||
this.textBoxAlpha = new System.Windows.Forms.TextBox();
|
this.textBoxAlpha = new System.Windows.Forms.TextBox();
|
||||||
this.labelAlpha = new System.Windows.Forms.Label();
|
this.labelAlpha = new System.Windows.Forms.Label();
|
||||||
this.btnApply = new System.Windows.Forms.Button();
|
this.btnApply = new System.Windows.Forms.Button();
|
||||||
this.dropper = new Greenshot.Controls.Dropper();
|
this.pipette = new Greenshot.Controls.Pipette();
|
||||||
this.SuspendLayout();
|
|
||||||
//
|
//
|
||||||
// btnTransparent
|
// btnTransparent
|
||||||
//
|
//
|
||||||
|
@ -208,23 +208,22 @@ namespace Greenshot {
|
||||||
this.btnApply.UseVisualStyleBackColor = false;
|
this.btnApply.UseVisualStyleBackColor = false;
|
||||||
this.btnApply.Click += new System.EventHandler(this.BtnApplyClick);
|
this.btnApply.Click += new System.EventHandler(this.BtnApplyClick);
|
||||||
//
|
//
|
||||||
// dropper
|
// pipette
|
||||||
//
|
//
|
||||||
this.dropper.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
this.pipette.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||||
this.dropper.Cursor = System.Windows.Forms.Cursors.Arrow;
|
this.pipette.Cursor = System.Windows.Forms.Cursors.Arrow;
|
||||||
this.dropper.Image = ((System.Drawing.Image)(resources.GetObject("dropper.Image")));
|
this.pipette.Location = new System.Drawing.Point(255, 30);
|
||||||
this.dropper.Location = new System.Drawing.Point(255, 30);
|
this.pipette.Name = "pipette";
|
||||||
this.dropper.Name = "dropper";
|
this.pipette.Size = new System.Drawing.Size(33, 23);
|
||||||
this.dropper.Size = new System.Drawing.Size(33, 23);
|
this.pipette.TabIndex = 13;
|
||||||
this.dropper.TabIndex = 13;
|
this.pipette.PipetteUsed += new System.EventHandler<Greenshot.Controls.PipetteUsedArgs>(this.pipetteUsed);
|
||||||
this.dropper.DropperUsed += new System.EventHandler<Greenshot.Controls.DropperUsedArgs>(this.dropperUsed);
|
|
||||||
//
|
//
|
||||||
// ColorDialog
|
// ColorDialog
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
|
||||||
this.ClientSize = new System.Drawing.Size(292, 218);
|
this.ClientSize = new System.Drawing.Size(292, 218);
|
||||||
this.Controls.Add(this.dropper);
|
this.Controls.Add(this.pipette);
|
||||||
this.Controls.Add(this.btnApply);
|
this.Controls.Add(this.btnApply);
|
||||||
this.Controls.Add(this.textBoxAlpha);
|
this.Controls.Add(this.textBoxAlpha);
|
||||||
this.Controls.Add(this.labelAlpha);
|
this.Controls.Add(this.labelAlpha);
|
||||||
|
@ -265,7 +264,7 @@ namespace Greenshot {
|
||||||
private System.Windows.Forms.TextBox textBoxBlue;
|
private System.Windows.Forms.TextBox textBoxBlue;
|
||||||
private System.Windows.Forms.Panel colorPanel;
|
private System.Windows.Forms.Panel colorPanel;
|
||||||
private System.Windows.Forms.Button btnTransparent;
|
private System.Windows.Forms.Button btnTransparent;
|
||||||
private Greenshot.Controls.Dropper dropper;
|
private Greenshot.Controls.Pipette pipette;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -235,7 +235,7 @@ namespace Greenshot {
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
private void dropperUsed(object sender, Greenshot.Controls.DropperUsedArgs e) {
|
private void pipetteUsed(object sender, Greenshot.Controls.PipetteUsedArgs e) {
|
||||||
this.Color = e.color;
|
this.Color = e.color;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -118,7 +118,7 @@
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
</resheader>
|
</resheader>
|
||||||
<assembly alias="System.Drawing" name="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
|
<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">
|
<data name="pipette.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
<value>
|
<value>
|
||||||
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
|
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
|
||||||
YQUAAAAZdEVYdFNvZnR3YXJlAEFkb2JlIEltYWdlUmVhZHlxyWU8AAABqklEQVQ4T6WTvUtCURiH34Mi
|
YQUAAAAZdEVYdFNvZnR3YXJlAEFkb2JlIEltYWdlUmVhZHlxyWU8AAABqklEQVQ4T6WTvUtCURiH34Mi
|
||||||
|
|
54
Greenshot/Forms/Zoomer.Designer.cs
generated
54
Greenshot/Forms/Zoomer.Designer.cs
generated
|
@ -43,27 +43,6 @@ namespace Greenshot.Forms
|
||||||
this.panel1.SuspendLayout();
|
this.panel1.SuspendLayout();
|
||||||
this.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
|
// html
|
||||||
//
|
//
|
||||||
this.html.Location = new System.Drawing.Point(40, 18);
|
this.html.Location = new System.Drawing.Point(40, 18);
|
||||||
|
@ -151,9 +130,32 @@ namespace Greenshot.Forms
|
||||||
this.label5.Size = new System.Drawing.Size(40, 13);
|
this.label5.Size = new System.Drawing.Size(40, 13);
|
||||||
this.label5.TabIndex = 9;
|
this.label5.TabIndex = 9;
|
||||||
this.label5.Text = "Alpha: ";
|
this.label5.Text = "Alpha: ";
|
||||||
//
|
//
|
||||||
|
// 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;
|
||||||
|
//
|
||||||
// Zoomer
|
// Zoomer
|
||||||
//
|
//
|
||||||
|
this.Visible = false;
|
||||||
|
this.Location = new System.Drawing.Point(-10000,-10000);
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.ClientSize = new System.Drawing.Size(100, 100);
|
this.ClientSize = new System.Drawing.Size(100, 100);
|
||||||
|
@ -164,10 +166,8 @@ namespace Greenshot.Forms
|
||||||
this.ShowInTaskbar = false;
|
this.ShowInTaskbar = false;
|
||||||
this.Text = "Zoomer";
|
this.Text = "Zoomer";
|
||||||
this.TopMost = true;
|
this.TopMost = true;
|
||||||
this.panel1.ResumeLayout(false);
|
this.panel1.ResumeLayout(true);
|
||||||
this.panel1.PerformLayout();
|
this.ResumeLayout(true);
|
||||||
this.ResumeLayout(false);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
|
@ -42,39 +42,38 @@ namespace Greenshot.Forms {
|
||||||
public void setHotSpot(int x, int y) {
|
public void setHotSpot(int x, int y) {
|
||||||
Color c = GetPixelColor(x, y);
|
Color c = GetPixelColor(x, y);
|
||||||
preview.BackColor = c;
|
preview.BackColor = c;
|
||||||
html.Text = "#" + c.Name.Substring(2).ToUpper();
|
html.Text = "#" + c.Name.Substring(2).ToUpper();
|
||||||
red.Text = "" + c.R;
|
red.Text = "" + c.R;
|
||||||
blue.Text = "" + c.B;
|
blue.Text = "" + c.B;
|
||||||
green.Text = "" + c.G;
|
green.Text = "" + c.G;
|
||||||
alpha.Text = "" + c.A;
|
alpha.Text = "" + c.A;
|
||||||
|
|
||||||
Size cs = Cursor.Current.Size;
|
Size cursorSize = Cursor.Current.Size;
|
||||||
Point hs = Cursor.Current.HotSpot;
|
Point hotspot = Cursor.Current.HotSpot;
|
||||||
|
|
||||||
Point zp = new Point(x, y);
|
Point zoomerLocation = new Point(x, y);
|
||||||
zp.X += cs.Width + 5 - hs.X;
|
zoomerLocation.X += cursorSize.Width + 5 - hotspot.X;
|
||||||
zp.Y += cs.Height + 5 - hs.Y;
|
zoomerLocation.Y += cursorSize.Height + 5 - hotspot.Y;
|
||||||
|
|
||||||
foreach (Screen screen in Screen.AllScreens) {
|
foreach (Screen screen in Screen.AllScreens) {
|
||||||
Rectangle screenRectangle = screen.Bounds;
|
Rectangle screenRectangle = screen.Bounds;
|
||||||
if (screen.Bounds.Contains(x, y)) {
|
if (screen.Bounds.Contains(x, y)) {
|
||||||
if (zp.X < screenRectangle.X) {
|
if (zoomerLocation.X < screenRectangle.X) {
|
||||||
zp.X = screenRectangle.X;
|
zoomerLocation.X = screenRectangle.X;
|
||||||
} else if (zp.X + Width > screenRectangle.X + screenRectangle.Width) {
|
} else if (zoomerLocation.X + Width > screenRectangle.X + screenRectangle.Width) {
|
||||||
zp.X = x - Width - 5 - hs.X;
|
zoomerLocation.X = x - Width - 5 - hotspot.X;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (zp.Y < screenRectangle.Y) {
|
if (zoomerLocation.Y < screenRectangle.Y) {
|
||||||
zp.Y = screenRectangle.Y;
|
zoomerLocation.Y = screenRectangle.Y;
|
||||||
} else if (zp.Y + Height > screenRectangle.Y + screenRectangle.Height) {
|
} else if (zoomerLocation.Y + Height > screenRectangle.Y + screenRectangle.Height) {
|
||||||
zp.Y = y - Height - 5 - hs.Y;
|
zoomerLocation.Y = y - Height - 5 - hotspot.Y;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Location = zoomerLocation;
|
||||||
Location = zp;
|
Update();
|
||||||
Invalidate();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setHotSpot(Point screenCoordinates) {
|
public void setHotSpot(Point screenCoordinates) {
|
||||||
|
|
|
@ -67,7 +67,7 @@
|
||||||
<Compile Include="Controls\ToolStripNumericUpDown.cs" />
|
<Compile Include="Controls\ToolStripNumericUpDown.cs" />
|
||||||
<Compile Include="Controls\ToolStripEx.cs" />
|
<Compile Include="Controls\ToolStripEx.cs" />
|
||||||
<Compile Include="Controls\MenuStripEx.cs" />
|
<Compile Include="Controls\MenuStripEx.cs" />
|
||||||
<Compile Include="Controls\Dropper.cs" />
|
<Compile Include="Controls\Pipette.cs" />
|
||||||
<Compile Include="Destinations\ClipboardDestination.cs" />
|
<Compile Include="Destinations\ClipboardDestination.cs" />
|
||||||
<Compile Include="Destinations\EditorDestination.cs" />
|
<Compile Include="Destinations\EditorDestination.cs" />
|
||||||
<Compile Include="Destinations\EmailDestination.cs" />
|
<Compile Include="Destinations\EmailDestination.cs" />
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue